index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div class="flx-col h-full">
  3. <div class="main-box">
  4. <LjFoldLayout ref="LjFoldLayoutRef" v-bind="layoutSetting" :dwname="dwname">
  5. <template #left>
  6. <div class="flx-col h-full card">
  7. <van-tabs v-model:active="initParams.arg_typeid" @click-tab="gMattressExtraTypeList">
  8. <van-tab title="特殊工艺" :name="1"></van-tab>
  9. <van-tab title="材料额外费用" :name="2"></van-tab>
  10. <template #nav-right v-if="CheckPower(130)">
  11. <div class="flx-center">
  12. <el-button :icon="Plus" circle ref="addBtnRef" @click="openTypePopover" />
  13. </div>
  14. </template>
  15. </van-tabs>
  16. <TreeFilter
  17. ref="LjTreeRef"
  18. id="extraid"
  19. wrapper-cls=""
  20. label="typename"
  21. :searchable="false"
  22. :expand-on-click-node="true"
  23. :data="extraTypeList"
  24. @change="changeTreeFilter"
  25. >
  26. <template #default="{ node }">
  27. <div class="flx-justify-between flx-1">
  28. <span class="title">{{ node.label }}</span>
  29. <el-space class="mr-4" v-if="node.data.extraid && CheckPower(130)">
  30. <el-button
  31. :ref="el => setDynamicRef(el, `buttonRefs_` + node.data.extraid)"
  32. :icon="EditPen"
  33. circle
  34. size="small"
  35. @click="handleEditType(node, `buttonRefs_` + node.data.extraid)"
  36. />
  37. <el-button
  38. :ref="el => setDynamicRef(el, `buttonRefs_del_` + node.data.extraid)"
  39. :icon="Delete"
  40. type="danger"
  41. plain
  42. circle
  43. size="small"
  44. @click="handleDeleteType(node, `buttonRefs_del_` + node.data.extraid)"
  45. />
  46. </el-space>
  47. </div>
  48. </template>
  49. </TreeFilter>
  50. </div>
  51. </template>
  52. <div class="main-box flx-col">
  53. <LjVxeTable
  54. ref="VxeTableRef"
  55. row-key="deptid"
  56. :columns="columns"
  57. :request-api="getData"
  58. :data-callback="dataCallback"
  59. :init-param="initParams"
  60. :dwname="dwname"
  61. :table-props="tableProps"
  62. :table-events="tableEvents"
  63. :tool-button="['export', 'refresh', 'setting', 'search', 'location']"
  64. :auto-load-layout="false"
  65. pagination
  66. >
  67. <template #tableHeader>
  68. <el-button-group class="mt-12">
  69. <el-button @click="handleOpenNewTable">{{ $t("common.add") }}</el-button>
  70. <el-button @click="fDelete">{{ $t("common.delText") }}</el-button>
  71. </el-button-group>
  72. </template>
  73. </LjVxeTable>
  74. </div>
  75. </LjFoldLayout>
  76. </div>
  77. </div>
  78. <LjPopover ref="LjPopoverRef" :title="popoverTitle" width="320">
  79. <template v-if="!ifdel">
  80. <!-- <p>{{ popoverTitle }}</p> -->
  81. <div class="mb-8">
  82. <el-input v-model="typeItem.typename" placeholder="请输入类型名称"></el-input>
  83. </div>
  84. <div class="mb-8">
  85. <span>录入类型: </span>
  86. <!-- <el-select v-model="typeItem.inputtype" style="width: 120px">
  87. <el-option label="仅可选择" :value="0"></el-option>
  88. <el-option label="选择且可录入" :value="1"></el-option>
  89. </el-select> -->
  90. <el-segmented v-model="typeItem.inputtype" :options="inputtypeOptions" size="small" />
  91. </div>
  92. <div style="display: flex; text-align: right; margin: 0">
  93. <el-button class="flx-1" size="small" type="primary" @click="gotoSaveType">保存</el-button>
  94. </div>
  95. </template>
  96. <template v-else>
  97. <p>如有单据选择此类型,将无法显示项目类型</p>
  98. <div style="display: flex; text-align: right; margin: 0">
  99. <el-button class="flx-1" size="small" type="danger" @click="gotoDelType">删除</el-button>
  100. </div>
  101. </template>
  102. </LjPopover>
  103. <LjDialog
  104. ref="LjDrawerRef"
  105. class="is-selector"
  106. v-bind="{
  107. ...drawerDefineProp
  108. }"
  109. :style="{ padding: 0 }"
  110. >
  111. <template #header>
  112. <div class="flx-1">
  113. <span class="text-h5-b">{{ deptname }}</span>
  114. </div>
  115. </template>
  116. <div class="flx-1 h-full">
  117. <LjHeaderMenu :data="mainData" :action="orderEditAction" />
  118. <Detail class="flx-1" :data="mainData" :status="orderStatus" :enum="enumMap" />
  119. </div>
  120. </LjDialog>
  121. </template>
  122. <script setup lang="ts" name="baseinfo_mattress_extralist">
  123. import { ref, onMounted, provide, computed, unref, reactive } from "vue";
  124. import { getMattressExtraList, SaveMattressExtraType, DeleteMattressExtraType } from "@/api/modules/basicinfo";
  125. import { ColumnProps } from "@/components/LjVxeTable/interface";
  126. import LjDrawer from "@/components/LjDrawer/index.vue";
  127. import Detail from "./detail.vue";
  128. import { useHooks } from "./hooks/index";
  129. import LjDialog from "@/components/LjDialog/index.vue";
  130. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  131. import { useI18n } from "vue-i18n";
  132. import { useAuthButtons } from "@/hooks/useAuthButtons";
  133. import { ALLOW_EDIT_STATE } from "@/config/index";
  134. import { cloneDeep } from "lodash-es";
  135. import { CommonDynamicSelect } from "@/api/modules/common";
  136. import { Select, Plus, EditPen, Delete } from "@element-plus/icons-vue";
  137. import { ElNotification, ClickOutside as vClickOutside } from "element-plus";
  138. import { DwnameEnum } from "@/enums/dwnameEnum";
  139. import LjPopover from "@/components/LjPopover/index.vue";
  140. import { useDynameicRef } from "@/hooks/useDynameicRef";
  141. import TreeFilter from "@/components/TreeFilter/index.vue";
  142. const dwname = "web_extra_costs";
  143. const mainData = ref({});
  144. const layoutSetting = {
  145. dwname: dwname,
  146. right: {
  147. hidden: true
  148. }
  149. };
  150. const tableProps = {
  151. height: "auto",
  152. editConfig: { trigger: "click", mode: "cell" }
  153. // rowClassName: rowClsNameFunc
  154. // exportConfig: {
  155. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  156. // }
  157. };
  158. const inputtypeOptions = [
  159. {
  160. label: "仅可选择",
  161. value: 0
  162. },
  163. {
  164. label: "选择且可录入",
  165. value: 1
  166. },
  167. {
  168. label: "不可修改",
  169. value: 2
  170. }
  171. ];
  172. const { t } = useI18n();
  173. const { VxeTableRef, LjDetailRef, columns, fSave, fDelete } = useHooks(t);
  174. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  175. const { dynamicRefs, setDynamicRef } = useDynameicRef();
  176. const initParams = ref<any>({ arg_typeid: 1 });
  177. const orderStatus = ref("");
  178. const deptname = ref("");
  179. const enumMap = ref(new Map());
  180. const extraTypeList = ref<any>([]);
  181. const LjPopoverRef = ref();
  182. const LjTreeRef = ref();
  183. const addBtnRef = ref();
  184. const ifdel = ref(false);
  185. const buttonRefs = ref();
  186. const type_visible = ref(false);
  187. const type_name = ref("");
  188. const typeItem = ref<any>({
  189. extraid: 0,
  190. typename: "",
  191. typeid: 0,
  192. inputtype: 0
  193. });
  194. const popoverTitle = computed(() => {
  195. if (ifdel.value) {
  196. return "删除" + (initParams.value.arg_typeid === 1 ? "特殊工艺类型" : "材料额外费用类型");
  197. }
  198. return (
  199. (typeItem.value.extraid === 0 ? "新增" : "修改") + (initParams.value.arg_typeid === 1 ? "特殊工艺类型" : "材料额外费用类型")
  200. );
  201. });
  202. const openTypePopover = (refName: string) => {
  203. ifdel.value = false;
  204. typeItem.value.extraid = 0;
  205. typeItem.value.typeid = initParams.value.arg_typeid;
  206. typeItem.value.typename = "";
  207. typeItem.value.inputtype = 0;
  208. LjPopoverRef.value.show(addBtnRef.value);
  209. };
  210. const gotoSaveType = async () => {
  211. if (!typeItem.value.typename.trim()) {
  212. ElMessage.warning("请输入类型名称");
  213. return false;
  214. }
  215. typeItem.value.typeid = initParams.value.arg_typeid;
  216. typeItem.value.typename = typeItem.value.typename.trim();
  217. let res = await SaveMattressExtraType({ data: typeItem.value });
  218. if (res.ErrMsg) {
  219. ElNotification({
  220. title: "保存失败",
  221. message: res.ErrMsg,
  222. type: "error"
  223. });
  224. return false;
  225. } else {
  226. ElNotification({
  227. title: "温馨提示",
  228. message: "保存成功!",
  229. type: "success"
  230. });
  231. gMattressExtraTypeList();
  232. LjPopoverRef.value.close();
  233. }
  234. type_visible.value = false;
  235. };
  236. const handleEditType = (node: any, refName: string) => {
  237. ifdel.value = false;
  238. console.log("handleEditType :>> ", node);
  239. console.log("handleEditType dynamicRefs.value[refName]:>> ", dynamicRefs.value[refName]);
  240. typeItem.value.extraid = node.data.extraid;
  241. typeItem.value.typeid = initParams.value.arg_typeid;
  242. typeItem.value.typename = node.data.typename;
  243. typeItem.value.inputtype = node.data.inputtype;
  244. LjPopoverRef.value.show(dynamicRefs.value[refName]);
  245. };
  246. const gotoDelType = async () => {
  247. typeItem.value.typeid = initParams.value.arg_typeid;
  248. let res = await DeleteMattressExtraType({ list: [typeItem.value] });
  249. if (res.ErrMsg) {
  250. ElNotification({
  251. title: "删除失败",
  252. message: res.ErrMsg,
  253. type: "error"
  254. });
  255. return false;
  256. } else {
  257. ElNotification({
  258. title: "温馨提示",
  259. message: "删除成功!",
  260. type: "success"
  261. });
  262. gMattressExtraTypeList();
  263. LjPopoverRef.value.close();
  264. }
  265. };
  266. const handleDeleteType = (node: any, refName: string) => {
  267. ifdel.value = true;
  268. console.log("handleDeleteType :>> ", node);
  269. typeItem.value.extraid = node.data.extraid;
  270. typeItem.value.typeid = initParams.value.arg_typeid;
  271. LjPopoverRef.value.show(dynamicRefs.value[refName]);
  272. };
  273. const orderDefaultAction = [
  274. buttonDefault({
  275. label: t("common.cancelText"),
  276. icon: "iconchevron-left"
  277. }),
  278. buttonNew({
  279. label: t("common.saveText"),
  280. icon: "iconsave-01",
  281. clickFunc: item => {
  282. // fSaveDept({ dept: LjDetailRef.value?.infoParam }).then(() => {
  283. // LjDrawerRef.value.hide();
  284. // });
  285. }
  286. })
  287. ];
  288. const orderEditAction = [
  289. buttonNew({
  290. label: t("common.saveText"),
  291. icon: "iconsave-01",
  292. clickFunc: item => {
  293. let save_data = LjDetailRef.value?._mainData;
  294. save_data.inuse = Number(save_data.inuse);
  295. save_data.ifinit = Number(save_data.ifinit);
  296. fSave({ data: save_data }).then(() => {
  297. LjDrawerRef.value.hide();
  298. });
  299. }
  300. }),
  301. buttonDefault({
  302. label: t("common.delText"),
  303. clickFunc: item => {
  304. let save_data = LjDetailRef.value?._mainData;
  305. fDelete({ list: [save_data] }).then(() => {
  306. LjDrawerRef.value.hide();
  307. });
  308. }
  309. })
  310. ];
  311. const gMattressExtraTypeList = async () => {
  312. // console.log("getData_subSpecs getData params :>> ", params);
  313. let newParams: any = {};
  314. // params.pageNum && (newParams.pageindex = params.pageNum);
  315. // params.pageSize && (newParams.pagesize = params.pageSize);
  316. // delete params.pageNum;
  317. // delete params.pageSize;
  318. newParams.queryParams = {
  319. arg_typeid: initParams.value.arg_typeid
  320. };
  321. // console.log("params :>> ", params);
  322. newParams.dsname = "_Mapper_mattressextra";
  323. let res = await CommonDynamicSelect(newParams, DwnameEnum.mattressExtraType);
  324. extraTypeList.value = res.datatable;
  325. // let enumArr = res.datatable.map((item: any) => {
  326. // return {
  327. // label: item.typename,
  328. // value: item.extraid
  329. // };
  330. // });
  331. // enumMap.value.set("extraid", enumArr);
  332. };
  333. const changeTreeFilter = (val: number) => {
  334. console.log("changeTreeFilter val :>> ", val);
  335. initParams.value.arg_extraid = val?.extraid ?? 0;
  336. };
  337. /*
  338. * @description 抽屉默认属性
  339. */
  340. const drawerDefineProp = {
  341. draggable: true,
  342. overflow: true,
  343. width: "40%"
  344. // modalClass: "lj-file-dialog"
  345. };
  346. const getData = (params: any) => {
  347. // return getMattressExtraList(params);
  348. let newParams: any = {};
  349. newParams.dsname = "web_mattress_extralist";
  350. newParams.queryparams = params;
  351. params.pageNum && (newParams.pageindex = params.pageNum);
  352. params.pageSize && (newParams.pagesize = params.pageSize);
  353. delete params.pageNum;
  354. delete params.pageSize;
  355. return CommonDynamicSelect(newParams, "web_mattress_extra");
  356. };
  357. const dataCallback = (data: any) => {
  358. console.log("dataCallback data:>> ", data);
  359. data.tableinfo?.columns.map((item: any) => {
  360. // if (item?.field === "inputtype") {
  361. // let enumArr = item.enum.filter(item => item.value !== 0);
  362. // enumMap.value.set(item.field, enumArr);
  363. // } else
  364. if (item?.enum) {
  365. enumMap.value.set(item.field, item.enum);
  366. }
  367. });
  368. return {
  369. list: data.datatable,
  370. tableinfo: data.tableinfo,
  371. total: data.totalcnt,
  372. pageNum: data.pageindex,
  373. pageSize: data.pagesize
  374. };
  375. };
  376. const LjDrawerRef = ref();
  377. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  378. // 弹窗
  379. mainData.value = cloneDeep(row);
  380. deptname.value = row.deptname;
  381. orderStatus.value = "edit";
  382. LjDrawerRef.value.show();
  383. };
  384. const handleOpenNewTable = () => {
  385. mainData.value = {
  386. extraid: initParams.value.arg_extraid,
  387. extramxid: 0,
  388. typeid: initParams.value.arg_typeid,
  389. inputtype: 1
  390. };
  391. console.log(Number(initParams.value.arg_typeid) == 1);
  392. // typename.value = "";
  393. deptname.value = "新增" + (Number(initParams.value.arg_typeid) == 1 ? "特殊工艺" : "额外费用");
  394. orderStatus.value = "new";
  395. LjDrawerRef.value.show();
  396. };
  397. // 返回绑定的事件
  398. const tableEvents = {
  399. "cell-dblclick": handleDBlClickTable
  400. // "cell-click": handleClickTable
  401. };
  402. onMounted(() => {
  403. gMattressExtraTypeList();
  404. });
  405. </script>
  406. <style lang="scss">
  407. .el-tree-node.is-current {
  408. .el-tree-node__content {
  409. .title {
  410. color: var(--lj-color-background);
  411. }
  412. }
  413. }
  414. </style>