detail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  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. :cellClassName="cellClassNameFn"
  28. >
  29. </LjVxeTable>
  30. </template>
  31. <template #tabNavRight="scope" v-if="orderStatus">
  32. <div class="flx-center flx-end flx-1 ml-24" v-if="scope.active == 'mattressYW'">
  33. <LjHeaderMenu group-cls="flx-start" :action="qdActionYW"></LjHeaderMenu>
  34. </div>
  35. <div class="flx-center flx-end flx-1 ml-24" v-else-if="scope.active == 'mattressQD'">
  36. <LjHeaderMenu group-cls="flx-start" :action="qdAction"></LjHeaderMenu>
  37. </div>
  38. </template>
  39. <template #mattressQD>
  40. <LjFoldLayout ref="LjFoldLayoutRef" v-bind="layoutSetting">
  41. <template #left>
  42. <LjVxeTable
  43. ref="YwTableRef"
  44. row-key="key"
  45. table-cls="h-full"
  46. :data="mattressYWList"
  47. :columns="columns_yw_qd"
  48. :dwname="DwnameEnum.mattressInterfaceYw"
  49. :request-auto="false"
  50. :table-props="tableProps_mx"
  51. :tool-button="[]"
  52. :auto-load-layout="false"
  53. collapseButtons
  54. >
  55. </LjVxeTable>
  56. </template>
  57. <div class="main-box flx-col">
  58. <LjVxeTable
  59. ref="QdTableRef"
  60. row-key="key"
  61. table-cls="h-full"
  62. :data="mattressQDList"
  63. :columns="columns_qd"
  64. :dwname="DwnameEnum.mattressInterfaceQd"
  65. :request-auto="false"
  66. :table-props="tableProps_qd"
  67. :tool-button="['setting']"
  68. collapseButtons
  69. @setMergeCells="resetMergeCellsQd"
  70. @row-dragend="autoRowDragend"
  71. >
  72. </LjVxeTable>
  73. </div>
  74. </LjFoldLayout>
  75. </template>
  76. </LjDetail>
  77. <LjDialog ref="LjDialogQdRowAdd" class="is-selector" :style="{ padding: 0 }" width="480px">
  78. <template #header>
  79. <div class="flx-1">
  80. <span class="text-h5-b">产品清单新增</span>
  81. </div>
  82. </template>
  83. <!-- <div class="flx-1 h-full">
  84. <LjHeaderMenu :action="qdDefaultAction" />
  85. {{ interIndex }}
  86. <el-form :model="qdFormParam" label-width="80px">
  87. <el-form-item label="项目">
  88. <el-select v-model="qdFormParam.itemname" placeholder="请选择部门">
  89. <el-option v-for="(col, index) in itemnameEnum" :key="index" :label="col.label" :value="col.value"></el-option>
  90. </el-select>
  91. <el-autocomplete
  92. v-model="qdFormParam.itemname"
  93. :fetch-suggestions="querySearch"
  94. :trigger-on-focus="false"
  95. clearable
  96. class="inline-input w-50"
  97. placeholder="Please Input"
  98. @select="handleSelect"
  99. />
  100. </el-form-item>
  101. <el-form-item label="二级项目">
  102. <el-select v-model="qdFormParam.bj_pzname">
  103. <el-option v-for="(col, index) in itemnameEnum" :key="index" :label="col.label" :value="col.value"></el-option>
  104. </el-select>
  105. </el-form-item>
  106. <el-form-item label="明细项目">
  107. <el-select v-model="qdFormParam.bj_pzname_mx">
  108. <el-option v-for="(col, index) in itemnameEnum" :key="index" :label="col.label" :value="col.value"></el-option>
  109. </el-select>
  110. </el-form-item>
  111. 核价系统物料名称
  112. </el-form>
  113. </div> -->
  114. </LjDialog>
  115. <MattressDialog ref="MattressDialogRef" v-bind="MattressDialogProps" />
  116. <MtrldefErpDialog ref="MtrldefErpDialogRef" v-bind="MtrldefErpDialogProps" />
  117. <!-- <SetSubspecsDialog ref=SetSubspecsDialogRef" /> -->
  118. </template>
  119. <script setup lang="tsx" name="mattressInterfaceDetail">
  120. import { ref, watch, reactive, inject, onMounted, computed, nextTick, onBeforeMount } from "vue";
  121. import { DwnameEnum } from "@/enums/dwnameEnum";
  122. import LjDetail from "@/components/LjDetail/index.vue";
  123. import { DetailProp } from "@/components/LjDetail/interface";
  124. import { useI18n } from "vue-i18n";
  125. import { useRoute, useRouter } from "vue-router";
  126. import { useHooks } from "./hooks/index";
  127. import { useAuthButtons } from "@/hooks/useAuthButtons";
  128. import { CommonDynamicSelect, GetERPWrkGrpList, GetERPWrkGrpList2 } from "@/api/modules/common";
  129. import { SaveMattressInterface, GetResetWiptype, UpdateL1Basicinfo } from "@/api/modules/quote";
  130. import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
  131. import mittBus from "@/utils/mittBus";
  132. import { MittEnum } from "@/enums/mittEnum";
  133. import MattressDialog from "@/views/system/selector/mattress/index.vue";
  134. import MtrldefErpDialog from "@/views/system/selector/mtrldefErp/index.vue";
  135. import { formatToDate } from "@/utils/dateUtil";
  136. import LjFoldLayout from "@/components/LjFoldLayout/index.vue";
  137. import { detailAction } from "@/components/LjDetail/interface";
  138. import { transformTreeData, autoMergeCells, isFilterPrice } from "@/utils/index";
  139. import LjDialog from "@/components/LjDialog/index.vue";
  140. // import dialog from "@/utils/dialog";
  141. // import SetSubspecsDialog from "./components/setSubspecs.vue";
  142. interface detailProp {
  143. /**
  144. * @argument any 页面数据
  145. */
  146. data?: any;
  147. /**
  148. * @argument string 请求数据的api ==> 非必传
  149. */
  150. requestApi?: (params: any) => Promise<any>;
  151. /**
  152. * @argument any 基础信息,表格展示数据
  153. */
  154. // columns?: any;
  155. /**
  156. * @description 是否可编辑
  157. */
  158. status: "edit" | "new" | string;
  159. enum?: any;
  160. }
  161. const props = withDefaults(defineProps<detailProp>(), {});
  162. const { t } = useI18n();
  163. const route = useRoute();
  164. const router = useRouter();
  165. const {
  166. VxeTableMxRef,
  167. YwTableRef,
  168. QdTableRef,
  169. orderStatus,
  170. LjDetailRef,
  171. columns_detail,
  172. columns_yw,
  173. columns_yw_qd,
  174. columns_qd,
  175. mainData,
  176. editType,
  177. mattressYWList,
  178. mattressQDList,
  179. MattressDialogRef,
  180. MattressDialogProps,
  181. MtrldefErpDialogRef,
  182. MtrldefErpDialogProps,
  183. tableProps_mx,
  184. tableProps_qd,
  185. workgrpEnum,
  186. workgrpEnum2,
  187. configureTypeEnum,
  188. RetriveMattressInterface,
  189. RefreshMattressInterfaceList,
  190. RefreshMattressInterfaceQdList,
  191. fModelChoseMattress,
  192. toExcel,
  193. toCreateMtrl,
  194. toCreateORDelMtrlPf,
  195. // toUpdateL1Planprice,
  196. YWAudit,
  197. JSAudit,
  198. JS2Audit,
  199. resetMergeCellsQd,
  200. resetMergeCells,
  201. funcAddRowQd,
  202. funcCmpCC,
  203. dynamicRef
  204. } = useHooks(t);
  205. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  206. const initParams = ref({ mattressid: 0 as Number });
  207. const layoutSetting = reactive({});
  208. const SetSubspecsDialogRef = ref();
  209. const detailProps = reactive<DetailProp>({
  210. dwname: DwnameEnum.mattressInterfaceDetail,
  211. columns: columns_detail,
  212. basicDefault: {},
  213. header: {
  214. foldright: {
  215. width: 80
  216. },
  217. fieldNames: {
  218. code: "sptcode",
  219. codeLabel: t("table.u_spt.sptcode") + ":",
  220. name: "name"
  221. }
  222. },
  223. mould: [
  224. {
  225. id: "mattressYW",
  226. type: "table",
  227. label: "产品配置"
  228. },
  229. {
  230. id: "mattressQD",
  231. type: "table",
  232. label: "产品清单"
  233. }
  234. ]
  235. });
  236. const tabRemove: Function = inject("tabRemove") as Function;
  237. const loadingStatus = reactive({
  238. save: false,
  239. synchsL1: false
  240. });
  241. const cellClassNameFn = (data: any, editable) => {
  242. let { column, row } = data;
  243. if (editable) {
  244. if (column.field == "bj_pzname") {
  245. if (
  246. (["垫层", "辅料"].includes(row.itemname) && row.bj_pzname.indexOf("说明") == -1) ||
  247. [
  248. "边带",
  249. "面层裥棉图案",
  250. "底层裥棉图案",
  251. "大侧裥棉图案",
  252. "小侧1裥棉图案",
  253. "小侧2裥棉图案",
  254. "小侧3裥棉图案",
  255. "拉手刺绣及其他工艺项目所有"
  256. ].includes(row.bj_pzname)
  257. ) {
  258. return "vxecol-danger";
  259. }
  260. }
  261. }
  262. return null;
  263. };
  264. const moveData = async (refName: string, index: number, nextIndex: number) => {
  265. const $table = dynamicRef(refName).element;
  266. // const $table = QdTableRef.value.element;
  267. let { visibleData } = $table.getTableData();
  268. const curRecords = $table?.getCurrentRecord();
  269. let prevRow = visibleData[nextIndex];
  270. visibleData[nextIndex] = visibleData[index];
  271. visibleData[index] = prevRow;
  272. visibleData.map((o, idx) => {
  273. o.printid = idx + 1;
  274. return o;
  275. });
  276. $table.reloadData(visibleData);
  277. await $table.setCurrentRow(curRecords);
  278. if (refName == "VxeTableMxRef") {
  279. resetMergeCells(() => {
  280. setTimeout(() => {
  281. $table.scrollToRow(curRecords);
  282. }, 0);
  283. });
  284. } else if (refName == "QdTableRef") {
  285. resetMergeCellsQd(() => {
  286. setTimeout(() => {
  287. $table.scrollToRow(curRecords);
  288. }, 0);
  289. });
  290. }
  291. };
  292. const toMove = async (refName: string, action: number) => {
  293. // const $table = QdTableRef.value.element;
  294. const $table = dynamicRef(refName).element;
  295. let curRecords = $table?.getCurrentRecord();
  296. let visibleData = $table.getTableData().visibleData;
  297. if (!curRecords) {
  298. ElMessage.warning("请先选择要移动的行");
  299. return;
  300. }
  301. let curIdx = visibleData.findIndex(t => t === curRecords);
  302. console.log("curIdx :>> ", curIdx);
  303. if (action == 1) {
  304. // 上移
  305. if (curIdx == 0) {
  306. ElMessage.warning("已经是第一条了");
  307. return;
  308. }
  309. moveData(refName, curIdx, curIdx - 1);
  310. } else if (action == -1) {
  311. // 下移
  312. if (curIdx == visibleData.length - 1) {
  313. ElMessage.warning("已经是最后一条了");
  314. return;
  315. }
  316. moveData(refName, curIdx, curIdx + 1);
  317. }
  318. };
  319. const qdActionYW: detailAction[] = [
  320. // buttonDefault({
  321. // label: "增行",
  322. // clickFunc: () => {
  323. // interIndex.value = -1;
  324. // LjDialogQdRowAdd.value.show();
  325. // }
  326. // }),
  327. // buttonDefault({
  328. // label: "插行",
  329. // divider: true,
  330. // clickFunc: () => {
  331. // const $table = QdTableRef.value.element;
  332. // const curRecords = $table?.getCurrentRecord();
  333. // if (curRecords) {
  334. // interIndex.value = $table.getRowIndex(curRecords);
  335. // }
  336. // LjDialogQdRowAdd.value.show();
  337. // }
  338. // }),
  339. buttonDefault({
  340. label: "上移",
  341. clickFunc: () => toMove("VxeTableMxRef", 1)
  342. }),
  343. buttonDefault({
  344. label: "下移",
  345. clickFunc: () => toMove("VxeTableMxRef", -1),
  346. divider: true
  347. })
  348. ];
  349. const qdAction: detailAction[] = [
  350. buttonDefault({
  351. label: "增行",
  352. clickFunc: () => {
  353. interIndex.value = -1;
  354. LjDialogQdRowAdd.value.show();
  355. }
  356. }),
  357. buttonDefault({
  358. label: "插行",
  359. clickFunc: () => {
  360. const $table = QdTableRef.value.element;
  361. const curRecords = $table?.getCurrentRecord();
  362. if (curRecords) {
  363. interIndex.value = $table.getRowIndex(curRecords);
  364. }
  365. LjDialogQdRowAdd.value.show();
  366. }
  367. }),
  368. // buttonDefault({
  369. // label: "删行",
  370. // divider: true,
  371. // clickFunc: () => {
  372. // ElMessageBox.prompt(`是否确定删除当前行?`, "提示", {
  373. // confirmButtonText: "确定",
  374. // cancelButtonText: "取消"
  375. // })
  376. // .then(({ value }) => {})
  377. // .catch(() => {
  378. // // ElMessage.warning("已经取消审批流程操作!");
  379. // });
  380. // }
  381. // }),
  382. buttonDefault({
  383. label: "上移",
  384. clickFunc: () => toMove("QdTableRef", 1)
  385. }),
  386. buttonDefault({
  387. label: "下移",
  388. clickFunc: () => toMove("QdTableRef", -1),
  389. divider: true
  390. }),
  391. buttonDefault({
  392. label: "清单增加默认项目",
  393. limited: () => {
  394. return !orderStatus.value;
  395. },
  396. clickFunc: () => funcAddRowQd()
  397. }),
  398. buttonDefault({
  399. label: "辅助计算生产尺寸",
  400. divider: true,
  401. limited: () => {
  402. return !orderStatus.value;
  403. },
  404. clickFunc: () => funcCmpCC()
  405. }),
  406. buttonDefault({
  407. label: "批量设置",
  408. clickFunc: async () => {
  409. let _cur = QdTableRef.value.currentEditCell;
  410. if (!["wrkgrpid", "wrkgrpid2", "actual_useqty"].includes(_cur.field)) {
  411. return ElMessage.warning("此列暂不支持批量设置(仅支持实际用量、工组)");
  412. }
  413. // return mattressQDList.value.length == 0;
  414. // nextTick(() => {
  415. const $table = QdTableRef.value.element;
  416. const { visibleData } = $table.getTableData();
  417. let _data = [];
  418. if (visibleData) {
  419. let _val = visibleData[_cur.rowIndex];
  420. _data = visibleData.map((o, idx) => {
  421. if (o.actual_useqty > 0 && idx > _cur.rowIndex) {
  422. o[_cur.field] = _val[_cur.field];
  423. if (_cur.field == "wrkgrpid1") {
  424. o.wrkgrpcode1 = _val.wrkgrpcode1;
  425. } else if (_cur.field == "wrkgrpid2") {
  426. o.wrkgrpcode2 = _val.wrkgrpcode2;
  427. }
  428. }
  429. if (_cur.field == "actual_useqty") {
  430. if (o.useqty > 0 && idx > _cur.rowIndex) {
  431. o[_cur.field] = _val[_cur.field];
  432. }
  433. }
  434. return o;
  435. });
  436. await $table.reloadData(_data);
  437. resetMergeCellsQd();
  438. ElMessage.success("批设成功(有实际用量的数据行)");
  439. }
  440. }
  441. })
  442. ];
  443. const orderDefaultAction = [
  444. buttonDefault({
  445. label: t("common.cancelText"),
  446. icon: "iconchevron-left",
  447. limited: () => {
  448. return !orderStatus.value;
  449. },
  450. clickFunc: item => {
  451. // router.replace(
  452. // `/erpapi/mattressInterface/detail?id=${LjDetailRef.value?._mainData.mattressid}&code=${LjDetailRef.value?._mainData.mattresscode}`
  453. // );
  454. const _cur = mainData.value[0];
  455. router.push({
  456. name: "mattressInterfaceDetail",
  457. params: {
  458. id: _cur.mattressid
  459. },
  460. query: {
  461. code: _cur.mattresscode
  462. },
  463. replace: true
  464. });
  465. }
  466. }),
  467. buttonDefault({
  468. label: t("common.saveText"),
  469. loading: () => loadingStatus.save,
  470. limited: () => !orderStatus.value,
  471. clickFunc: async item => {
  472. try {
  473. await LjDetailRef.value.toValidateForm();
  474. let $tableYW = VxeTableMxRef.value.element;
  475. let { visibleData } = $tableYW.getTableData();
  476. visibleData.map(o => {
  477. console.log("tableYW visibleData o :>> ", o);
  478. if (
  479. (["垫层", "辅料"].includes(o.itemname) && o.bj_pzname.indexOf("说明") == -1) ||
  480. [
  481. "边带",
  482. "面层裥棉图案",
  483. "底层裥棉图案",
  484. "大侧裥棉图案",
  485. "小侧1裥棉图案",
  486. "小侧2裥棉图案",
  487. "小侧3裥棉图案",
  488. "拉手刺绣及其他工艺项目所有"
  489. ].includes(o.bj_pzname)
  490. ) {
  491. if (o.bj_namemx == "") {
  492. VxeTableMxRef.value.scrollTo(o, "bj_namemx");
  493. throw new Error("产品配置:【" + o.bj_pzname + "】的明细是必填项,请输入/选择");
  494. }
  495. }
  496. return o;
  497. });
  498. ElMessageBox.confirm("是否确定要保存吗?", "询问", {
  499. confirmButtonText: "是",
  500. cancelButtonText: "否",
  501. type: "warning"
  502. }).then(async () => {
  503. loadingStatus.save = true;
  504. try {
  505. // const { visibleData } = QdTableRef.value.element.getTableData();
  506. // console.log(" mattressQDList.value :>> ", mattressQDList.value);
  507. // console.log("QdTableRef visibleData :>> ", visibleData);
  508. const res = await SaveMattressInterface({
  509. mattress: LjDetailRef.value?._mainData,
  510. interfaceList: mattressYWList.value,
  511. qdList: mattressQDList.value
  512. })
  513. .then(res => {
  514. ElNotification({
  515. title: "温馨提示",
  516. message: t("sys.api.sueccessToSave"),
  517. type: "success"
  518. });
  519. // tabRemove(route.fullPath);
  520. // router.replace(
  521. // `/erpapi/mattressInterface/detail?id=${LjDetailRef.value?._mainData.mattressid}&code=${LjDetailRef.value?._mainData.mattresscode}`
  522. // );
  523. const _cur = LjDetailRef.value?._mainData;
  524. router.push({
  525. name: "mattressInterfaceDetail",
  526. params: {
  527. id: _cur.mattressid
  528. },
  529. query: {
  530. code: _cur.mattresscode
  531. },
  532. replace: true
  533. });
  534. // LjDetailRef.value.refresh();
  535. loadingStatus.save = false;
  536. })
  537. .catch(error => {
  538. console.log("error !! :>> ", error);
  539. loadingStatus.save = false;
  540. });
  541. } catch (error) {
  542. loadingStatus.save = false;
  543. ElMessage.error(t("sys.api.operationFailed"));
  544. }
  545. });
  546. } catch (error) {
  547. console.log("errorerrorerrorerror :>> ", typeof error, error);
  548. if (error.hasOwnProperty("message")) {
  549. ElMessage.error(error.message);
  550. } else {
  551. for (const key in error) {
  552. if (Object.prototype.hasOwnProperty.call(error, key)) {
  553. const element = error[key];
  554. ElMessage.error(element[0].message);
  555. }
  556. }
  557. }
  558. return false;
  559. }
  560. }
  561. }),
  562. [
  563. buttonDefault({
  564. label: "刷新带出配置",
  565. limited: () => {
  566. return !orderStatus.value || editType.value == 3;
  567. },
  568. clickFunc: item => {
  569. RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 1, LjDetailRef.value?._mainData.erp_configcodetype);
  570. }
  571. }),
  572. buttonDefault({
  573. label: "复制配置",
  574. limited: () => {
  575. return !orderStatus.value || editType.value == 3;
  576. },
  577. clickFunc: item => {
  578. fModelChoseMattress().then((res: any) => {
  579. RefreshMattressInterfaceList(res.mattressid, 1);
  580. });
  581. }
  582. }),
  583. buttonDefault({
  584. label: "重新生成配置项目",
  585. limited: () => {
  586. return !orderStatus.value || editType.value != 1;
  587. },
  588. disabledTextCallBack: (data: any) => {
  589. if (data.yw_flag == 1) {
  590. return "已业务补充审核,无法操作";
  591. }
  592. return "";
  593. },
  594. clickFunc: item => {
  595. RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 0, LjDetailRef.value?._mainData.erp_configcodetype);
  596. }
  597. })
  598. ],
  599. [
  600. buttonDefault({
  601. label: "刷新清单",
  602. limited: () => {
  603. return !orderStatus.value;
  604. },
  605. clickFunc: item => {
  606. RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 1);
  607. }
  608. }),
  609. buttonDefault({
  610. label: "复制清单",
  611. limited: () => {
  612. return !orderStatus.value;
  613. },
  614. clickFunc: item => {
  615. fModelChoseMattress().then((res: any) => {
  616. RefreshMattressInterfaceQdList(res.mattressid, 1, 0);
  617. });
  618. }
  619. }),
  620. buttonDefault({
  621. label: "重新生成清单",
  622. limited: () => {
  623. return !orderStatus.value;
  624. },
  625. clickFunc: item => {
  626. RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 0);
  627. }
  628. })
  629. ],
  630. [
  631. buttonDefault({
  632. label: "增行",
  633. limited: () => {
  634. return !orderStatus.value;
  635. },
  636. clickFunc: item => {}
  637. }),
  638. buttonDefault({
  639. label: "插行",
  640. limited: () => {
  641. return !orderStatus.value;
  642. },
  643. clickFunc: item => {},
  644. divider: true
  645. }),
  646. buttonDefault({
  647. label: "上移",
  648. limited: () => {
  649. return !orderStatus.value;
  650. },
  651. clickFunc: item => {}
  652. }),
  653. buttonDefault({
  654. label: "下移",
  655. limited: () => {
  656. return !orderStatus.value;
  657. },
  658. clickFunc: item => {},
  659. divider: true
  660. }),
  661. buttonDefault({
  662. label: "清单增加默认项目",
  663. limited: () => {
  664. return !orderStatus.value;
  665. },
  666. clickFunc: () => funcAddRowQd()
  667. }),
  668. buttonDefault({
  669. label: "辅助计算生产尺寸",
  670. limited: () => {
  671. return !orderStatus.value;
  672. },
  673. clickFunc: () => funcCmpCC()
  674. })
  675. ],
  676. buttonDefault({
  677. label: "重置半成品归属列数据",
  678. limited: () => {
  679. return !orderStatus.value;
  680. },
  681. clickFunc: async () => {
  682. const $table = QdTableRef.value.element;
  683. if ($table) {
  684. const { visibleData } = $table.getTableData();
  685. let res = await GetResetWiptype({ qdList: visibleData });
  686. let arr = visibleData.map(o => {
  687. let _itm = res.qdList.find(itm => itm.printid == o.printid);
  688. if (_itm) {
  689. o.wip_type = _itm.wip_type;
  690. !o.wrkgrpcode2 && (o.wrkgrpcode2 = _itm.o.wrkgrpcode2);
  691. }
  692. return o;
  693. });
  694. $table.reloadData(arr);
  695. resetMergeCellsQd();
  696. }
  697. }
  698. }),
  699. [
  700. buttonDefault({
  701. label: "业务补充",
  702. power: 79,
  703. limited: () => {
  704. return !!orderStatus.value || LjDetailRef.value?._mainData.xd_flag == 1;
  705. },
  706. disabledTextCallBack: (data: any) => {
  707. if (data.yw_flag == 1) {
  708. return "已业务补充审核,无法修改";
  709. }
  710. return "";
  711. },
  712. clickFunc: item => {
  713. routeToEdit(1);
  714. }
  715. }),
  716. buttonDefault({
  717. label: "业务审核",
  718. power: 80,
  719. limited: () => {
  720. return !!orderStatus.value;
  721. },
  722. clickFunc: item => {
  723. const curRecords = [LjDetailRef.value?._mainData];
  724. YWAudit(1, curRecords, () => {
  725. LjDetailRef.value.refresh();
  726. });
  727. }
  728. }),
  729. buttonDefault({
  730. label: "业务撤审",
  731. power: 81,
  732. limited: () => {
  733. return !!orderStatus.value;
  734. },
  735. clickFunc: item => {
  736. const curRecords = [LjDetailRef.value?._mainData];
  737. YWAudit(0, curRecords, () => {
  738. LjDetailRef.value.refresh();
  739. });
  740. }
  741. })
  742. ],
  743. [
  744. buttonDefault({
  745. label: "产品补充",
  746. power: 82,
  747. limited: () => {
  748. return !!orderStatus.value;
  749. },
  750. disabledTextCallBack: (data: any) => {
  751. if (data.js1_flag == 1) {
  752. return "已产品补充审核,无法修改";
  753. }
  754. return "";
  755. },
  756. clickFunc: item => {
  757. routeToEdit(2);
  758. }
  759. }),
  760. buttonDefault({
  761. label: "产品补充审核",
  762. power: 83,
  763. limited: () => {
  764. return !!orderStatus.value;
  765. },
  766. clickFunc: item => {
  767. const curRecords = [LjDetailRef.value?._mainData];
  768. JSAudit(1, curRecords, () => {
  769. LjDetailRef.value.refresh();
  770. });
  771. }
  772. }),
  773. buttonDefault({
  774. label: "产品补充撤审",
  775. power: 84,
  776. limited: () => {
  777. return !!orderStatus.value;
  778. },
  779. clickFunc: item => {
  780. const curRecords = [LjDetailRef.value?._mainData];
  781. JSAudit(0, curRecords, () => {
  782. LjDetailRef.value.refresh();
  783. });
  784. }
  785. })
  786. ],
  787. [
  788. buttonDefault({
  789. label: "清单补充",
  790. power: 85,
  791. limited: () => {
  792. return !!orderStatus.value;
  793. },
  794. disabledTextCallBack: (data: any) => {
  795. if (data.js2_flag == 1) {
  796. return "已清单补充审核,无法修改";
  797. }
  798. return "";
  799. },
  800. clickFunc: item => {
  801. routeToEdit(3);
  802. }
  803. }),
  804. buttonDefault({
  805. label: "清单补充审核",
  806. power: 86,
  807. limited: () => {
  808. return !!orderStatus.value;
  809. },
  810. clickFunc: item => {
  811. const curRecords = [LjDetailRef.value?._mainData];
  812. JS2Audit(1, curRecords, () => {
  813. LjDetailRef.value.refresh();
  814. });
  815. }
  816. }),
  817. buttonDefault({
  818. label: "清单补充撤审",
  819. power: 87,
  820. limited: () => {
  821. return !!orderStatus.value;
  822. },
  823. clickFunc: item => {
  824. const curRecords = [LjDetailRef.value?._mainData];
  825. JS2Audit(0, curRecords, () => {
  826. LjDetailRef.value.refresh();
  827. });
  828. }
  829. })
  830. ],
  831. buttonDefault({
  832. label: "覆盖配置到副规格产品",
  833. limited: () => {
  834. return !!orderStatus.value || LjDetailRef.value?._mainData.child_count == 0;
  835. },
  836. disabledTextCallBack: (data: any) => {
  837. if (data.child_count == 0) {
  838. return "没有副规格产品,无法操作";
  839. }
  840. return "";
  841. },
  842. clickFunc: item => {
  843. // dialog(SetSubspecsDialog, {
  844. // mattressid: initParams.value.mattressid
  845. // }).then((data: any) => {
  846. // console.log(data);
  847. // });
  848. alert("功能维护中!");
  849. // SetSubspecsDialogRef.value.show();
  850. }
  851. }),
  852. buttonDefault({
  853. label: "生成/更新物料",
  854. power: 88,
  855. limited: () => {
  856. return !!orderStatus.value;
  857. },
  858. clickFunc: item => {
  859. toCreateMtrl(1, [LjDetailRef.value?._mainData.mattressid]);
  860. }
  861. }),
  862. [
  863. buttonDefault({
  864. label: "生成金蝶清单",
  865. power: 90,
  866. disabledTextCallBack: (data: any) => {
  867. console.log("生成金蝶清单 disabledTextCallBack data", data);
  868. if (data.js2_flag == 0) {
  869. return "床垫清单未审核,无法生成金蝶清单";
  870. }
  871. return "";
  872. },
  873. limited: () => {
  874. return !!orderStatus.value;
  875. },
  876. clickFunc: item => {
  877. toCreateORDelMtrlPf(1, [LjDetailRef.value?._mainData.mattressid]);
  878. }
  879. })
  880. // buttonDefault({
  881. // label: "删除金蝶清单",
  882. // power: 91,
  883. // clickFunc: item => {
  884. // toCreateORDelMtrlPf(0, LjDetailRef.value?._mainData.mattressid);
  885. // }
  886. // })
  887. // buttonDefault({
  888. // label: "更新计划价",
  889. // power: 91,
  890. // limited: () => {
  891. // return !!orderStatus.value;
  892. // },
  893. // clickFunc: item => {
  894. // toUpdateL1Planprice(LjDetailRef.value?._mainData.mattressid);
  895. // }
  896. // })
  897. ],
  898. buttonDefault({
  899. label: "同步L1资料",
  900. // limited: () => {
  901. // return !orderStatus.value;
  902. // },
  903. loading: () => loadingStatus.synchsL1,
  904. clickFunc: async () => {
  905. try {
  906. loadingStatus.synchsL1 = true;
  907. let res = await UpdateL1Basicinfo();
  908. if (res) {
  909. ElNotification({
  910. title: "同步成功",
  911. message: `物料:${res.mtrlnum}个 <br/>工组:${res.wkgnum}个 <br/>物料类别:${res.mtrltypenum}个`,
  912. dangerouslyUseHTMLString: true,
  913. type: "warning"
  914. });
  915. }
  916. loadingStatus.synchsL1 = false;
  917. } catch (error) {
  918. loadingStatus.synchsL1 = false;
  919. console.error(error);
  920. }
  921. }
  922. }),
  923. buttonDefault({
  924. label: t("common.back"),
  925. clickFunc: item => {
  926. router.push(`/erpapi/mattressInterface`);
  927. }
  928. })
  929. ];
  930. const routeToEdit = (type: any) => {
  931. console.log("routeToEdit mainData :>> ", mainData, route.fullPath);
  932. const _cur = mainData.value[0];
  933. // router.replace(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
  934. router.push({
  935. name: "mattressInterfaceEditYw",
  936. params: {
  937. id: _cur.mattressid
  938. },
  939. query: {
  940. code: _cur.mattresscode,
  941. type: type
  942. },
  943. replace: true
  944. });
  945. };
  946. /**
  947. * @description 页面数据加载完成
  948. */
  949. const funcAfterMound = async () => {
  950. console.log("onMounted detail sale start!!!! :>> ", orderStatus.value);
  951. if (!orderStatus.value) {
  952. // 详情页
  953. // gotoSummy(8000);
  954. } else {
  955. // 新增/编辑
  956. tableProps_mx.value.editConfig.enabled = true;
  957. tableProps_qd.value.editConfig.enabled = true;
  958. // tableProps_mx_yw.value.editConfig.enabled = true;
  959. // tableProps_mx_qd.value.editConfig.enabled = true;
  960. }
  961. console.log("onMounted detail sale start!!!! :>> ", tableProps_mx.value.editConfig);
  962. console.log("onMounted detail sale start LjDetailRef.value.mainData :>> ", LjDetailRef.value);
  963. if (orderStatus.value != "new") {
  964. }
  965. };
  966. onBeforeMount(() => {
  967. if (route.params?.id) {
  968. // 刷新数据
  969. initParams.value.mattressid = Number(route.params?.id);
  970. editType.value = Number(route.query?.type);
  971. }
  972. });
  973. onMounted(async () => {
  974. console.log("route onMounted:>> ", route);
  975. console.log("route onMounted:>> ", route.params);
  976. console.log("route onMounted:>> ", route.params.id);
  977. const result = await GetERPWrkGrpList();
  978. if (result.workgroupList) {
  979. workgrpEnum.value = result.workgroupList.map(item => {
  980. return {
  981. label: item.wrkGrpName,
  982. value: item.wrkGrpid,
  983. code: item.wrkgrpcode
  984. };
  985. });
  986. // columns_qd.value = columns_qd.value.map(item => {
  987. // if (item.field == "wrkgrpid") {
  988. // item.editRender.options = workgrpEnum.value;
  989. // }
  990. // return item;
  991. // });
  992. }
  993. const result2 = await GetERPWrkGrpList2();
  994. workgrpEnum2.value = result2.datatable ?? [];
  995. if (route.params?.id) {
  996. // 刷新数据
  997. // initParams.value.mattressid = Number(route.params?.id);
  998. // editType.value = Number(route.query?.type);
  999. console.log("detail onMounted initParams.value :>> ", initParams.value);
  1000. console.log("领用工组领用工组领用工组领用工组 columns_qd.value :>> ", columns_qd.value);
  1001. await RetriveMattressInterface(initParams.value.mattressid.valueOf());
  1002. }
  1003. });
  1004. /** 发现4.11~4.13版本reloadData加载超慢放弃使用 */
  1005. const autoRowDragend = async data => {
  1006. const $table = QdTableRef.value.element;
  1007. $table.clearMergeCells();
  1008. // setTimeout(() => {
  1009. nextTick(() => {
  1010. console.time("autoRowDragend");
  1011. console.log("autoRowDragend data :>> ", data);
  1012. console.log(`拖拽完成,被拖拽行:${data.oldRow.itemname} 目标行:${data.newRow.itemname} 目标位置:${data.dragPos}`);
  1013. // resetMergeCellsQd();
  1014. // console.time("autoRowDragend getTableData");
  1015. // const { visibleData } = $table.getTableData();
  1016. // console.timeEnd("autoRowDragend getTableData");
  1017. // console.time("autoRowDragend arr");
  1018. // let arr = visibleData.map((o, idx) => {
  1019. // o.printid = idx + 1;
  1020. // return o;
  1021. // });
  1022. // console.timeEnd("autoRowDragend arr");
  1023. // console.time("autoRowDragend reloadData");
  1024. // await $table.reloadData(arr);
  1025. // console.timeEnd("autoRowDragend reloadData");
  1026. console.time("autoRowDragend autoMergeCells");
  1027. let mergeCells = autoMergeCells($table, ["itemname", "bj_pzname", "bj_pzname_mx_mx"]);
  1028. console.timeEnd("autoRowDragend autoMergeCells");
  1029. console.time("autoRowDragend setMergeCells");
  1030. $table.setMergeCells(mergeCells);
  1031. console.timeEnd("autoRowDragend setMergeCells");
  1032. console.timeEnd("autoRowDragend");
  1033. });
  1034. // }, 1000);
  1035. };
  1036. const LjDialogQdRowAdd = ref();
  1037. const interIndex = ref(0);
  1038. const qdFormParam = ref({
  1039. itemname: "",
  1040. bj_pzname: "",
  1041. bj_pzname_mx: "",
  1042. u_mtrl_price_mtrlname: ""
  1043. });
  1044. const qdDefaultAction = [
  1045. buttonDefault({
  1046. label: t("common.cancelText"),
  1047. icon: "iconchevron-left",
  1048. clickFunc: item => {
  1049. LjDialogQdRowAdd.value.hide();
  1050. }
  1051. }),
  1052. buttonDefault({
  1053. label: t("common.okText"),
  1054. clickFunc: async item => {
  1055. LjDialogQdRowAdd.value.hide();
  1056. }
  1057. })
  1058. ];
  1059. const querySearch = (queryString: string, cb: any) => {
  1060. const results = queryString ? restaurants.value.filter(createFilter(queryString)) : restaurants.value;
  1061. // call callback function to return suggestions
  1062. cb(results);
  1063. };
  1064. </script>