detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <template>
  2. <LjDetail
  3. name="mattressInterfaceDetail"
  4. ref="LjDetailRef"
  5. v-bind="detailProps"
  6. :data="mainData"
  7. v-model:order-status="orderStatus"
  8. :action="orderDefaultAction"
  9. @after-mounted="funcAfterMound"
  10. :if-layout-editable="false"
  11. :search-col="{ xs: 3, sm: 3, md: 3, lg: 3, xl: 3 }"
  12. :basic-group-col="{ xs: 3, sm: 3, md: 3, lg: 3, xl: 3 }"
  13. >
  14. <template #mattressYW>
  15. <LjVxeTable
  16. ref="VxeTableMxRef"
  17. row-key="key"
  18. table-cls=""
  19. :data="mattressYWList"
  20. :columns="columns_yw"
  21. :dwname="DwnameEnum.mattressInterfaceYw"
  22. :request-auto="false"
  23. :table-props="tableProps_mx"
  24. :tool-button="[]"
  25. :auto-load-layout="false"
  26. collapseButtons
  27. >
  28. </LjVxeTable>
  29. </template>
  30. <template #tabNavRight v-if="orderStatus">
  31. <div class="flx-center flx-end flx-1">
  32. <LjHeaderMenu group-cls="flx-end" :action="qdAction"></LjHeaderMenu>
  33. </div>
  34. </template>
  35. <template #mattressQD>
  36. <LjFoldLayout ref="LjFoldLayoutRef" v-bind="layoutSetting">
  37. <template #left>
  38. <LjVxeTable
  39. ref="YwTableRef"
  40. row-key="key"
  41. table-cls="h-full"
  42. :data="mattressYWList"
  43. :columns="columns_yw_qd"
  44. :dwname="DwnameEnum.mattressInterfaceYw"
  45. :request-auto="false"
  46. :table-props="tableProps_mx"
  47. :tool-button="[]"
  48. :auto-load-layout="false"
  49. collapseButtons
  50. >
  51. </LjVxeTable>
  52. </template>
  53. <div class="main-box flx-col">
  54. <LjVxeTable
  55. ref="QdTableRef"
  56. row-key="key"
  57. table-cls="h-full"
  58. :data="mattressQDList"
  59. :columns="columns_qd"
  60. :dwname="DwnameEnum.mattressInterfaceQd"
  61. :request-auto="false"
  62. :table-props="tableProps_mx"
  63. :tool-button="[]"
  64. :auto-load-layout="false"
  65. collapseButtons
  66. >
  67. </LjVxeTable>
  68. </div>
  69. </LjFoldLayout>
  70. </template>
  71. </LjDetail>
  72. <MattressDialog ref="MattressDialogRef" v-bind="MattressDialogProps" />
  73. <MtrldefErpDialog ref="MtrldefErpDialogRef" v-bind="MtrldefErpDialogProps" />
  74. </template>
  75. <script setup lang="tsx" name="mattressInterfaceDetail">
  76. import { ref, watch, reactive, inject, onMounted, computed, nextTick, onBeforeMount } from "vue";
  77. import { DwnameEnum } from "@/enums/dwnameEnum";
  78. import LjDetail from "@/components/LjDetail/index.vue";
  79. import { DetailProp } from "@/components/LjDetail/interface";
  80. import { useI18n } from "vue-i18n";
  81. import { useRoute, useRouter } from "vue-router";
  82. import { useHooks } from "./hooks/index";
  83. import { useAuthButtons } from "@/hooks/useAuthButtons";
  84. import { CommonDynamicSelect, GetERPWrkGrpList, GetERPWrkGrpList2 } from "@/api/modules/common";
  85. import { SaveMattressInterface } from "@/api/modules/quote";
  86. import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
  87. import mittBus from "@/utils/mittBus";
  88. import { MittEnum } from "@/enums/mittEnum";
  89. import MattressDialog from "@/views/system/selector/mattress/index.vue";
  90. import MtrldefErpDialog from "@/views/system/selector/mtrldefErp/index.vue";
  91. import { formatToDate } from "@/utils/dateUtil";
  92. import LjFoldLayout from "@/components/LjFoldLayout/index.vue";
  93. interface detailProp {
  94. /**
  95. * @argument any 页面数据
  96. */
  97. data?: any;
  98. /**
  99. * @argument string 请求数据的api ==> 非必传
  100. */
  101. requestApi?: (params: any) => Promise<any>;
  102. /**
  103. * @argument any 基础信息,表格展示数据
  104. */
  105. // columns?: any;
  106. /**
  107. * @description 是否可编辑
  108. */
  109. status: "edit" | "new" | string;
  110. enum?: any;
  111. }
  112. const props = withDefaults(defineProps<detailProp>(), {});
  113. const { t } = useI18n();
  114. const route = useRoute();
  115. const router = useRouter();
  116. const {
  117. VxeTableMxRef,
  118. YwTableRef,
  119. QdTableRef,
  120. orderStatus,
  121. LjDetailRef,
  122. columns_detail,
  123. columns_yw,
  124. columns_yw_qd,
  125. columns_qd,
  126. mainData,
  127. editType,
  128. mattressYWList,
  129. mattressQDList,
  130. MattressDialogRef,
  131. MattressDialogProps,
  132. MtrldefErpDialogRef,
  133. MtrldefErpDialogProps,
  134. tableProps_mx,
  135. workgrpEnum,
  136. workgrpEnum2,
  137. configureTypeEnum,
  138. RetriveMattressInterface,
  139. RefreshMattressInterfaceList,
  140. RefreshMattressInterfaceQdList,
  141. fModelChoseMattress,
  142. toExcel,
  143. toCreateMtrl,
  144. toCreateORDelMtrlPf,
  145. // toUpdateL1Planprice,
  146. YWAudit,
  147. JSAudit,
  148. JS2Audit,
  149. resetMergeCellsQd
  150. } = useHooks(t);
  151. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  152. const initParams = ref({ mattressid: 0 as Number });
  153. const layoutSetting = reactive({});
  154. const detailProps = reactive<DetailProp>({
  155. dwname: DwnameEnum.mattressInterfaceDetail,
  156. columns: columns_detail,
  157. basicDefault: {},
  158. header: {
  159. foldright: {
  160. width: 80
  161. },
  162. fieldNames: {
  163. code: "sptcode",
  164. codeLabel: t("table.u_spt.sptcode") + ":",
  165. name: "name"
  166. }
  167. },
  168. mould: [
  169. {
  170. id: "mattressYW",
  171. type: "table",
  172. label: "产品配置"
  173. },
  174. {
  175. id: "mattressQD",
  176. type: "table",
  177. label: "产品清单"
  178. }
  179. ]
  180. });
  181. const tabRemove: Function = inject("tabRemove") as Function;
  182. const loadingStatus = reactive({
  183. save: false
  184. });
  185. const qdAction = [
  186. buttonDefault({
  187. label: "批量设置",
  188. clickFunc: () => {
  189. let _cur = QdTableRef.value.currentEditCell;
  190. if (!["wrkgrpid", "wrkgrpid2", "actual_useqty"].includes(_cur.field)) {
  191. return ElMessage.warning("此列暂不支持批量设置(仅支持实际用量、工组)");
  192. }
  193. // return mattressQDList.value.length == 0;
  194. // nextTick(() => {
  195. const $table = QdTableRef.value.element;
  196. const { visibleData } = $table.getTableData();
  197. let _data = [];
  198. if (visibleData) {
  199. let _val = visibleData[_cur.rowIndex];
  200. _data = visibleData.map((o, idx) => {
  201. if (o.actual_useqty > 0 && idx > _cur.rowIndex) {
  202. o[_cur.field] = _val[_cur.field];
  203. if (_cur.field == "wrkgrpid1") {
  204. o.wrkgrpcode1 = _val.wrkgrpcode1;
  205. } else if (_cur.field == "wrkgrpid2") {
  206. o.wrkgrpcode2 = _val.wrkgrpcode2;
  207. }
  208. }
  209. if (_cur.field == "actual_useqty") {
  210. if (o.useqty > 0 && idx > _cur.rowIndex) {
  211. o[_cur.field] = _val[_cur.field];
  212. }
  213. }
  214. return o;
  215. });
  216. $table.reloadData(_data);
  217. resetMergeCellsQd();
  218. ElMessage.success("批设成功(有实际用量的数据行)");
  219. }
  220. }
  221. })
  222. ];
  223. const orderDefaultAction = [
  224. buttonDefault({
  225. label: t("common.cancelText"),
  226. icon: "iconchevron-left",
  227. limited: () => {
  228. return !orderStatus.value;
  229. },
  230. clickFunc: item => {
  231. // router.replace(
  232. // `/erpapi/mattressInterface/detail?id=${LjDetailRef.value?._mainData.mattressid}&code=${LjDetailRef.value?._mainData.mattresscode}`
  233. // );
  234. const _cur = mainData.value[0];
  235. router.push({
  236. name: "mattressInterfaceDetail",
  237. params: {
  238. id: _cur.mattressid
  239. },
  240. query: {
  241. code: _cur.mattresscode
  242. },
  243. replace: true
  244. });
  245. }
  246. }),
  247. buttonDefault({
  248. label: t("common.saveText"),
  249. loading: () => loadingStatus.save,
  250. limited: () => !orderStatus.value,
  251. clickFunc: async item => {
  252. try {
  253. await LjDetailRef.value.toValidateForm();
  254. ElMessageBox.confirm("是否确定要保存吗?", "询问", {
  255. confirmButtonText: "是",
  256. cancelButtonText: "否",
  257. type: "warning"
  258. }).then(async () => {
  259. loadingStatus.save = true;
  260. try {
  261. // const { visibleData } = QdTableRef.value.element.getTableData();
  262. // console.log(" mattressQDList.value :>> ", mattressQDList.value);
  263. // console.log("QdTableRef visibleData :>> ", visibleData);
  264. const res = await SaveMattressInterface({
  265. mattress: LjDetailRef.value?._mainData,
  266. interfaceList: mattressYWList.value,
  267. qdList: mattressQDList.value
  268. })
  269. .then(res => {
  270. ElNotification({
  271. title: "温馨提示",
  272. message: t("sys.api.sueccessToSave"),
  273. type: "success"
  274. });
  275. // tabRemove(route.fullPath);
  276. // router.replace(
  277. // `/erpapi/mattressInterface/detail?id=${LjDetailRef.value?._mainData.mattressid}&code=${LjDetailRef.value?._mainData.mattresscode}`
  278. // );
  279. // const _cur = LjDetailRef.value?._mainData;
  280. // router.push({
  281. // name: "mattressInterfaceDetail",
  282. // params: {
  283. // id: _cur.mattressid
  284. // },
  285. // query: {
  286. // code: _cur.mattresscode
  287. // },
  288. // replace: true
  289. // });
  290. // LjDetailRef.value.refresh();
  291. loadingStatus.save = false;
  292. })
  293. .catch(error => {
  294. console.log("error !! :>> ", error);
  295. loadingStatus.save = false;
  296. });
  297. } catch (error) {
  298. loadingStatus.save = false;
  299. ElMessage.error(t("sys.api.operationFailed"));
  300. }
  301. });
  302. } catch (error) {
  303. for (const key in error) {
  304. if (Object.prototype.hasOwnProperty.call(error, key)) {
  305. const element = error[key];
  306. ElMessage.error(element[0].message);
  307. }
  308. }
  309. return false;
  310. }
  311. }
  312. }),
  313. [
  314. buttonDefault({
  315. label: "刷新带出配置",
  316. limited: () => {
  317. return !orderStatus.value || editType.value == 3;
  318. },
  319. clickFunc: item => {
  320. RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 1, LjDetailRef.value?._mainData.erp_configcodetype);
  321. }
  322. }),
  323. buttonDefault({
  324. label: "复制配置",
  325. limited: () => {
  326. return !orderStatus.value || editType.value == 3;
  327. },
  328. clickFunc: item => {
  329. fModelChoseMattress().then((res: any) => {
  330. RefreshMattressInterfaceList(res.mattressid, 1);
  331. });
  332. }
  333. }),
  334. buttonDefault({
  335. label: "重新生成配置项目",
  336. limited: () => {
  337. return !orderStatus.value || editType.value != 1;
  338. },
  339. disabledTextCallBack: (data: any) => {
  340. if (data.yw_flag == 1) {
  341. return "已业务补充审核,无法操作";
  342. }
  343. return "";
  344. },
  345. clickFunc: item => {
  346. RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 0, LjDetailRef.value?._mainData.erp_configcodetype);
  347. }
  348. })
  349. ],
  350. [
  351. buttonDefault({
  352. label: "刷新清单",
  353. limited: () => {
  354. return !orderStatus.value;
  355. },
  356. clickFunc: item => {
  357. RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 1);
  358. }
  359. }),
  360. buttonDefault({
  361. label: "复制清单",
  362. limited: () => {
  363. return !orderStatus.value;
  364. },
  365. clickFunc: item => {
  366. fModelChoseMattress().then((res: any) => {
  367. RefreshMattressInterfaceQdList(res.mattressid, 1, 0);
  368. });
  369. }
  370. }),
  371. buttonDefault({
  372. label: "重新生成清单",
  373. limited: () => {
  374. return !orderStatus.value;
  375. },
  376. clickFunc: item => {
  377. RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 0);
  378. }
  379. })
  380. ],
  381. [
  382. buttonDefault({
  383. label: "业务补充",
  384. power: 79,
  385. limited: () => {
  386. return !!orderStatus.value || LjDetailRef.value?._mainData.xd_flag == 1;
  387. },
  388. disabledTextCallBack: (data: any) => {
  389. if (data.yw_flag == 1) {
  390. return "已业务补充审核,无法修改";
  391. }
  392. return "";
  393. },
  394. clickFunc: item => {
  395. routeToEdit(1);
  396. }
  397. }),
  398. buttonDefault({
  399. label: "业务审核",
  400. power: 80,
  401. limited: () => {
  402. return !!orderStatus.value;
  403. },
  404. clickFunc: item => {
  405. const curRecords = [LjDetailRef.value?._mainData];
  406. YWAudit(1, curRecords, () => {
  407. LjDetailRef.value.refresh();
  408. });
  409. }
  410. }),
  411. buttonDefault({
  412. label: "业务撤审",
  413. power: 81,
  414. limited: () => {
  415. return !!orderStatus.value;
  416. },
  417. clickFunc: item => {
  418. const curRecords = [LjDetailRef.value?._mainData];
  419. YWAudit(0, curRecords, () => {
  420. LjDetailRef.value.refresh();
  421. });
  422. }
  423. })
  424. ],
  425. [
  426. buttonDefault({
  427. label: "产品补充",
  428. power: 82,
  429. limited: () => {
  430. return !!orderStatus.value;
  431. },
  432. disabledTextCallBack: (data: any) => {
  433. if (data.js1_flag == 1) {
  434. return "已产品补充审核,无法修改";
  435. }
  436. return "";
  437. },
  438. clickFunc: item => {
  439. routeToEdit(2);
  440. }
  441. }),
  442. buttonDefault({
  443. label: "产品补充审核",
  444. power: 83,
  445. limited: () => {
  446. return !!orderStatus.value;
  447. },
  448. clickFunc: item => {
  449. const curRecords = [LjDetailRef.value?._mainData];
  450. JSAudit(1, curRecords, () => {
  451. LjDetailRef.value.refresh();
  452. });
  453. }
  454. }),
  455. buttonDefault({
  456. label: "产品补充撤审",
  457. power: 84,
  458. limited: () => {
  459. return !!orderStatus.value;
  460. },
  461. clickFunc: item => {
  462. const curRecords = [LjDetailRef.value?._mainData];
  463. JSAudit(0, curRecords, () => {
  464. LjDetailRef.value.refresh();
  465. });
  466. }
  467. })
  468. ],
  469. [
  470. buttonDefault({
  471. label: "清单补充",
  472. power: 85,
  473. limited: () => {
  474. return !!orderStatus.value;
  475. },
  476. disabledTextCallBack: (data: any) => {
  477. if (data.js2_flag == 1) {
  478. return "已清单补充审核,无法修改";
  479. }
  480. return "";
  481. },
  482. clickFunc: item => {
  483. routeToEdit(3);
  484. }
  485. }),
  486. buttonDefault({
  487. label: "清单补充审核",
  488. power: 86,
  489. limited: () => {
  490. return !!orderStatus.value;
  491. },
  492. clickFunc: item => {
  493. const curRecords = [LjDetailRef.value?._mainData];
  494. JS2Audit(1, curRecords, () => {
  495. LjDetailRef.value.refresh();
  496. });
  497. }
  498. }),
  499. buttonDefault({
  500. label: "清单补充撤审",
  501. power: 87,
  502. limited: () => {
  503. return !!orderStatus.value;
  504. },
  505. clickFunc: item => {
  506. const curRecords = [LjDetailRef.value?._mainData];
  507. JS2Audit(0, curRecords, () => {
  508. LjDetailRef.value.refresh();
  509. });
  510. }
  511. })
  512. ],
  513. buttonDefault({
  514. label: "生成/更新物料",
  515. power: 88,
  516. limited: () => {
  517. return !!orderStatus.value;
  518. },
  519. clickFunc: item => {
  520. toCreateMtrl(1, { list: [LjDetailRef.value?._mainData.mattressid] });
  521. }
  522. }),
  523. [
  524. buttonDefault({
  525. label: "生成金蝶清单",
  526. power: 90,
  527. disabledTextCallBack: (data: any) => {
  528. console.log("生成金蝶清单 disabledTextCallBack data", data);
  529. if (data.js2_flag == 0) {
  530. return "床垫清单未审核,无法生成金蝶清单";
  531. }
  532. return "";
  533. },
  534. limited: () => {
  535. return !!orderStatus.value;
  536. },
  537. clickFunc: item => {
  538. toCreateORDelMtrlPf(1, { list: [LjDetailRef.value?._mainData.mattressid] });
  539. }
  540. })
  541. // buttonDefault({
  542. // label: "删除金蝶清单",
  543. // power: 91,
  544. // clickFunc: item => {
  545. // toCreateORDelMtrlPf(0, LjDetailRef.value?._mainData.mattressid);
  546. // }
  547. // })
  548. // buttonDefault({
  549. // label: "更新计划价",
  550. // power: 91,
  551. // limited: () => {
  552. // return !!orderStatus.value;
  553. // },
  554. // clickFunc: item => {
  555. // toUpdateL1Planprice(LjDetailRef.value?._mainData.mattressid);
  556. // }
  557. // })
  558. ],
  559. buttonDefault({
  560. label: t("common.back"),
  561. clickFunc: item => {
  562. router.push(`/erpapi/mattressInterface`);
  563. }
  564. })
  565. ];
  566. const routeToEdit = (type: any) => {
  567. console.log("routeToEdit mainData :>> ", mainData, route.fullPath);
  568. const _cur = mainData.value[0];
  569. // router.replace(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
  570. router.push({
  571. name: "mattressInterfaceEditYw",
  572. params: {
  573. id: _cur.mattressid
  574. },
  575. query: {
  576. code: _cur.mattresscode,
  577. type: type
  578. },
  579. replace: true
  580. });
  581. };
  582. /**
  583. * @description 页面数据加载完成
  584. */
  585. const funcAfterMound = async () => {
  586. console.log("onMounted detail sale start!!!! :>> ");
  587. if (!orderStatus.value) {
  588. // 详情页
  589. // gotoSummy(8000);
  590. } else {
  591. // 新增/编辑
  592. tableProps_mx.value.editConfig.enabled = true;
  593. // tableProps_mx_yw.value.editConfig.enabled = true;
  594. // tableProps_mx_qd.value.editConfig.enabled = true;
  595. }
  596. console.log("onMounted detail sale start LjDetailRef.value.mainData :>> ", LjDetailRef.value);
  597. if (orderStatus.value != "new") {
  598. }
  599. };
  600. onBeforeMount(() => {
  601. if (route.params?.id) {
  602. // 刷新数据
  603. initParams.value.mattressid = Number(route.params?.id);
  604. editType.value = Number(route.query?.type);
  605. }
  606. });
  607. onMounted(async () => {
  608. console.log("route onMounted:>> ", route);
  609. console.log("route onMounted:>> ", route.params);
  610. console.log("route onMounted:>> ", route.params.id);
  611. const result = await GetERPWrkGrpList();
  612. if (result.workgroupList) {
  613. workgrpEnum.value = result.workgroupList.map(item => {
  614. return {
  615. label: item.wrkgrpname,
  616. value: item.wrkgrpid,
  617. code: item.wrkgrpcode
  618. };
  619. });
  620. // columns_qd.value = columns_qd.value.map(item => {
  621. // if (item.field == "wrkgrpid") {
  622. // item.editRender.options = workgrpEnum.value;
  623. // }
  624. // return item;
  625. // });
  626. }
  627. const result2 = await GetERPWrkGrpList2();
  628. workgrpEnum2.value = result2.datatable ?? [];
  629. if (route.params?.id) {
  630. // 刷新数据
  631. // initParams.value.mattressid = Number(route.params?.id);
  632. // editType.value = Number(route.query?.type);
  633. console.log("detail onMounted initParams.value :>> ", initParams.value);
  634. console.log("领用工组领用工组领用工组领用工组 columns_qd.value :>> ", columns_qd.value);
  635. await RetriveMattressInterface(initParams.value.mattressid.valueOf());
  636. }
  637. });
  638. </script>