index.tsx 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038
  1. import { ref, reactive, computed, toRefs, nextTick, inject } from "vue";
  2. import { Table } from "@/hooks/interface";
  3. import { ColumnProps } from "@/components/LjVxeTable/interface";
  4. import { ALLOW_EDIT_STATE } from "@/config/index";
  5. import { GetMattressInterfaceList, RefreshMattressInterface, RefreshMattressInterfaceQd } from "@/api/modules/quote";
  6. import { getConfigureTypeList, getConfigureCodeList, getConfigureCodeMxList } from "@/api/modules/basicinfo";
  7. import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
  8. import {
  9. CommonDynamicSelect,
  10. GetERPMtrldefList,
  11. GetERPWrkGrpList,
  12. GetERPMtrlTypeList,
  13. CreatMtrlPf,
  14. CreatPrdPf,
  15. DelMtrlPf
  16. } from "@/api/modules/common";
  17. import { transformTreeData, autoMergeCells, isFilterPrice } from "@/utils/index";
  18. import { floatSub, floatAdd, floatMul, floatDiv, formatFixedNumber } from "@/utils/index";
  19. import MtrldefErpSelect from "@/views/system/selector/mtrldefErp/select.vue";
  20. import CodemxSelect from "@/views/system/selector/codemx/select.vue";
  21. import { isFixedColumn } from "element-plus/es/components/table/src/util";
  22. import * as Exceljs from "exceljs";
  23. import { saveAs } from "file-saver";
  24. import { MattressYWAudit, MattressJSAudit, MattressJS2Audit } from "@/api/modules/quote";
  25. import { useRouter } from "vue-router";
  26. interface defaultState {
  27. initParams: any;
  28. /**
  29. * @description 单据当前状态
  30. */
  31. orderStatus: string;
  32. /**
  33. * @description 列表Ref
  34. */
  35. VxeTableRef: any;
  36. /**
  37. * @description 详情页Ref
  38. */
  39. LjDetailRef: any;
  40. mainData: any;
  41. mattressYWList: any[];
  42. mattressQDList: any[];
  43. /**
  44. * @description //1 业务补充 2--技术1 3--技术2
  45. */
  46. editType: number;
  47. MattressDialogRef: any;
  48. MattressDialogProps: any;
  49. MtrldefErpDialogRef: any;
  50. MtrldefErpDialogProps: any;
  51. workgrpEnum: any;
  52. workgrpEnum2: any;
  53. configureTypeEnum: any;
  54. VxeTableMxRef: any;
  55. YwTableRef: any;
  56. QdTableRef: any;
  57. }
  58. /**
  59. * @description 表格多选数据操作
  60. * @param {String} rowKey 当表格可以多选时,所指定的 id
  61. * */
  62. export const useHooks = (t?: any) => {
  63. const state = reactive<defaultState>({
  64. initParams: {},
  65. orderStatus: "",
  66. VxeTableRef: null,
  67. VxeTableMxRef: null,
  68. YwTableRef: null,
  69. QdTableRef: null,
  70. LjDetailRef: null,
  71. mainData: [],
  72. mattressYWList: [],
  73. mattressQDList: [],
  74. editType: 0,
  75. MattressDialogRef: null,
  76. MattressDialogProps: {},
  77. MtrldefErpDialogRef: null,
  78. MtrldefErpDialogProps: {},
  79. workgrpEnum: [],
  80. workgrpEnum2: [],
  81. configureTypeEnum: []
  82. });
  83. const toCreateORDelMtrlPf = (type: number, list: any) => {
  84. if (type === 1) {
  85. if (state.QdTableRef) {
  86. const $table = state.QdTableRef.element;
  87. if ($table) {
  88. $table.clearEdit();
  89. const { visibleData } = $table.getTableData();
  90. console.log("visibleData :>> ", visibleData);
  91. try {
  92. visibleData.map((o, idx) => {
  93. if (!o.erp_mtrlid && o.actual_useqty > 0) {
  94. state.QdTableRef.scrollTo(o, "erp_mtrlid");
  95. throw new Error(`第${idx + 1}行:产品补充未填入L1物料信息,请先选择L1物料修改`);
  96. }
  97. });
  98. } catch (error) {
  99. ElMessage.error(error.message);
  100. return false;
  101. }
  102. }
  103. }
  104. ElMessageBox.confirm(`是否确定要生成金蝶清单?`, "询问", {
  105. confirmButtonText: t("common.okText"),
  106. cancelButtonText: "否",
  107. type: "warning"
  108. })
  109. .then(() => {
  110. CreatPrdPf({ list }).then(() => {
  111. ElNotification({
  112. title: "金蝶清单",
  113. message: "生成成功!",
  114. type: "success"
  115. });
  116. });
  117. })
  118. .catch((e: TypeError) => {
  119. console.log("e :>> ", e);
  120. ElMessage({
  121. type: "info",
  122. message: "操作取消"
  123. });
  124. });
  125. } else {
  126. ElMessageBox.confirm(`是否确定要删除金蝶清单?`, "询问", {
  127. confirmButtonText: t("common.delText"),
  128. cancelButtonText: "否",
  129. type: "warning"
  130. })
  131. .then(() => {
  132. DelMtrlPf({ list }).then(() => {
  133. ElMessage.success("删除成功!");
  134. });
  135. })
  136. .catch((e: TypeError) => {
  137. console.log("e :>> ", e);
  138. ElMessage({
  139. type: "info",
  140. message: "操作取消"
  141. });
  142. });
  143. }
  144. };
  145. const toCreateMtrl = (type: number, list: any) => {
  146. ElMessageBox.confirm(`是否确定要生成/更新物料?`, "询问", {
  147. confirmButtonText: t("common.okText"),
  148. cancelButtonText: "否",
  149. type: "warning"
  150. })
  151. .then(() => {
  152. CreatMtrlPf({ list }).then(res => {
  153. console.log("toCreateMtrl, res :>> ", res);
  154. if (state.LjDetailRef) {
  155. state.LjDetailRef._mainData.erp_mtrlid = res.mattress.erp_mtrlid;
  156. state.LjDetailRef._mainData.creatmtrl_flag = res.mattress.creatmtrl_flag;
  157. state.LjDetailRef._mainData.erp_mtrlcode = res.mattress.erp_mtrlcode;
  158. }
  159. ElNotification({
  160. title: "物料",
  161. message: "生成/更新成功!",
  162. type: "success"
  163. });
  164. });
  165. })
  166. .catch((e: TypeError) => {
  167. ElMessage({
  168. type: "info",
  169. message: "操作取消"
  170. });
  171. });
  172. };
  173. // const toUpdateL1Planprice = (mattressid: number) => {
  174. // ElMessageBox.confirm(`是否确定要更新计划价?`, "询问", {
  175. // confirmButtonText: t("common.okText"),
  176. // cancelButtonText: "否",
  177. // type: "warning"
  178. // })
  179. // .then(() => {
  180. // CreatMtrlPf({ mattressid }).then(() => {
  181. // ElNotification({
  182. // title: "更新计划价",
  183. // message: "更新成功!",
  184. // type: "success"
  185. // });
  186. // });
  187. // })
  188. // .catch((e: TypeError) => {
  189. // console.log("e :>> ", e);
  190. // ElMessage({
  191. // type: "info",
  192. // message: "操作取消"
  193. // });
  194. // });
  195. // };
  196. const ywFlagChange = (value: any) => {
  197. console.log("value :>> ", value);
  198. // console.log("Lj :>> ", state.LjDetailRef._mainData);
  199. value = parseInt(value ?? 0);
  200. // handleSelMxData(value);
  201. // fChangeBedNetType(value);
  202. switch (value) {
  203. case 2: // 待业务审
  204. state.initParams.yw_flag = 0;
  205. state.initParams.js1_flag = 0;
  206. state.initParams.js2_flag = 0;
  207. state.initParams.creatmtrl_flag = 0;
  208. state.initParams.creatmtrlqd_flag = 0;
  209. break;
  210. case 3: //待产品补充审
  211. state.initParams.yw_flag = 1;
  212. state.initParams.js1_flag = 0;
  213. state.initParams.js2_flag = 0;
  214. state.initParams.creatmtrl_flag = 0;
  215. state.initParams.creatmtrlqd_flag = 0;
  216. break;
  217. case 4: //待清单补充审
  218. state.initParams.yw_flag = 1;
  219. state.initParams.js1_flag = 1;
  220. state.initParams.js2_flag = 0;
  221. state.initParams.creatmtrl_flag = -1;
  222. state.initParams.creatmtrlqd_flag = -1;
  223. break;
  224. case 5: //待生成erp产品
  225. state.initParams.yw_flag = 1;
  226. state.initParams.js1_flag = 1;
  227. state.initParams.js2_flag = 1;
  228. state.initParams.creatmtrl_flag = 1;
  229. state.initParams.creatmtrlqd_flag = -1;
  230. break;
  231. case 6: //待生成erp清单
  232. state.initParams.yw_flag = 1;
  233. state.initParams.js1_flag = 1;
  234. state.initParams.js2_flag = 1;
  235. state.initParams.creatmtrl_flag = 1;
  236. state.initParams.creatmtrlqd_flag = 0;
  237. break;
  238. default:
  239. state.initParams.yw_flag = -1;
  240. state.initParams.js1_flag = -1;
  241. state.initParams.js2_flag = -1;
  242. state.initParams.creatmtrl_flag = -1;
  243. state.initParams.creatmtrlqd_flag = -1;
  244. break;
  245. }
  246. };
  247. /**
  248. * @description 选择物料弹窗
  249. */
  250. const fModelChoseMtrlErp = (data: any, params: any) => {
  251. return new Promise((resolve, reject) => {
  252. // if (!ALLOW_EDIT_STATE.includes(status)) return;
  253. console.log("fModelChoseMtrl fModelChoseMtrl params :>> ", params);
  254. let _params = {
  255. keyword: "",
  256. ...params
  257. // arg_mtrltype: params.mtrltype,
  258. // arg_pricelistid: _pricelistid
  259. };
  260. state.MtrldefErpDialogProps = {
  261. onSubmit: (res: any) => {
  262. // submit
  263. console.log("openCustDialog res", res);
  264. nextTick(() => {
  265. // cb(data, res.value[0]);
  266. rModelSetMtrlErp(data, res.value[0]);
  267. resolve(1);
  268. });
  269. },
  270. onCancel: (error: any) => {
  271. // cancel 回调
  272. console.log("openCustDialog error", error);
  273. }
  274. };
  275. state.MtrldefErpDialogRef.show(_params);
  276. });
  277. };
  278. const rModelSetMtrlErp = (data: any, item: any) => {
  279. console.log("rModelSetMtrlErp item :>> ", item);
  280. if (item) {
  281. data.erp_mtrlid = item.mtrlid;
  282. data.erp_mtrlname = item.mtrlname;
  283. data.erp_mtrlmode = item.mtrlmode;
  284. data.erp_mtrlcode = item.mtrlcode;
  285. data.erp_unit = item.unit;
  286. data.erp_mtrlengname = item.zxmtrlmode;
  287. }
  288. };
  289. const rModelClearMtrlErp = (data: any, type: number) => {
  290. if (type == 1) {
  291. // 清空配置选项
  292. if (Number(data.erp_inputtype) != 2) {
  293. data.bj_namemx = "";
  294. }
  295. } else if (type == 2) {
  296. // 清空配置选项
  297. // if (Number(data.erp_inputtype) == 2) {
  298. data.erp_mtrlid = 0;
  299. data.erp_mtrlcode = "";
  300. data.erp_mtrlname = "";
  301. data.erp_mtrlmode = "";
  302. data.erp_unit = "";
  303. data.erp_mtrlengname = "";
  304. // }
  305. }
  306. };
  307. const rModelSetCodemx = (data: any, item: any, $table?: any) => {
  308. if (item) {
  309. data.bj_namemx = item.namemx;
  310. } else {
  311. data.bj_namemx = "";
  312. }
  313. // cb && cb();
  314. if ($table) {
  315. $table.clearEdit();
  316. nextTick(() => {
  317. $table.setActiveRow(data);
  318. });
  319. }
  320. };
  321. const rModelClearCodemx = (data: any, $table?: any) => {
  322. data.bj_namemx = "";
  323. if ($table) {
  324. $table.clearEdit();
  325. }
  326. };
  327. // 表格配置项
  328. const columns: ColumnProps<any>[] = [
  329. { type: "checkbox", width: 80, fixed: "left" },
  330. { title: "#", field: "pid", fixed: "left", width: 80 },
  331. {
  332. field: "yw_flag",
  333. title: "业务审核",
  334. search: {
  335. // el: "select",
  336. render: scope => {
  337. // let _keys = Object.keys(scope);
  338. // let _data = _keys.includes("row") ? scope.row : _keys.includes("searchParam") ? scope.searchParam : scope;
  339. return (
  340. <el-select v-model={scope.searchParam.status_flag} placeholder="全部" clearable onChange={ywFlagChange}>
  341. <el-option label="待业务审" value="2" />
  342. <el-option label="待产品补充审" value="3" />
  343. <el-option label="待清单补充审" value="4" />
  344. <el-option label="待生成erp产品" value="5" />
  345. <el-option label="待生成erp清单" value="6" />
  346. </el-select>
  347. );
  348. }
  349. }
  350. },
  351. {
  352. field: "js1_flag",
  353. title: "产品补充审核"
  354. },
  355. {
  356. field: "js2_flag",
  357. title: "清单补充审核"
  358. },
  359. {
  360. field: "creatmtrl_flag",
  361. title: "生成L1产品"
  362. },
  363. {
  364. field: "creatmtrlqd_flag",
  365. title: "生成L1清单"
  366. },
  367. {
  368. field: "erp_mtrlcode",
  369. title: "L1物料编码",
  370. search: {
  371. el: "input",
  372. key: "arg_search"
  373. }
  374. },
  375. {
  376. field: "deptid",
  377. title: "部门",
  378. search: {
  379. el: "select",
  380. key: "arg_deptid",
  381. props: {
  382. filterable: true,
  383. onChange: (value: any) => {
  384. state.initParams.arg_deptid = value;
  385. }
  386. },
  387. order: 1
  388. }
  389. },
  390. {
  391. field: "mattresscode",
  392. title: "报价唯一码"
  393. },
  394. {
  395. field: "mattressrelcode",
  396. title: "核价编码"
  397. },
  398. {
  399. field: "mattressname",
  400. title: "核价名称",
  401. treeNode: true,
  402. render: scope => {
  403. return !scope.row?.child_count && !scope.row?.parentid ? (
  404. scope.row?.mattressname
  405. ) : scope.row?.parentid ? (
  406. <>
  407. <el-tag type="warning" effect="light" disable-transitions size="small" class="mr-4">
  408. </el-tag>
  409. {scope.row?.mattressname}
  410. </>
  411. ) : (
  412. <>
  413. <el-tag type="primary" effect="light" disable-transitions size="small" class="mr-4">
  414. </el-tag>
  415. {scope.row?.mattressname}
  416. </>
  417. );
  418. }
  419. },
  420. {
  421. field: "mattresstypeid",
  422. title: "床垫类别"
  423. },
  424. {
  425. field: "mattress_width",
  426. title: "床垫宽/CM"
  427. },
  428. {
  429. field: "mattress_length",
  430. title: "床垫长/CM"
  431. },
  432. {
  433. field: "mattress_height",
  434. title: "床垫高/CM"
  435. },
  436. {
  437. field: "createby",
  438. title: "登记人"
  439. },
  440. {
  441. field: "createtime",
  442. title: "登记时间"
  443. },
  444. {
  445. field: "yw_auditingrep",
  446. title: "业务审核人"
  447. },
  448. {
  449. field: "yw_auditingdate",
  450. title: "业务审核时间"
  451. },
  452. {
  453. field: "js1_auditingrep",
  454. title: "产品补充审核人"
  455. },
  456. {
  457. field: "js1_auditingdate",
  458. title: "产品补充审核时间"
  459. },
  460. {
  461. field: "js2_auditingrep",
  462. title: "清单补充审核人"
  463. },
  464. {
  465. field: "js2_auditingdate",
  466. title: "清单补充审核时间"
  467. },
  468. {
  469. field: "creatmtrl_auditingrep",
  470. title: "生成L1产品人"
  471. },
  472. {
  473. field: "creatmtrl_auditingdate",
  474. title: "生成L1产品时间"
  475. },
  476. {
  477. field: "creatmtrlqd_auditingrep",
  478. title: "生成L1清单人"
  479. },
  480. {
  481. field: "creatmtrlqd_auditingdate",
  482. title: "生成L1清单时间"
  483. },
  484. {
  485. field: "dijia_cost",
  486. title: "底价"
  487. },
  488. {
  489. field: "yongjin",
  490. title: "佣金",
  491. render: (scope: any) => {
  492. let result = floatSub(floatDiv(scope.row.dijia_cost, floatSub(1, scope.row.commission - 1)), scope.row.dijia_cost);
  493. result = formatFixedNumber({ val: result });
  494. return result;
  495. }
  496. },
  497. {
  498. field: "taxrate",
  499. title: "税率"
  500. },
  501. {
  502. field: "fob",
  503. title: "FOB"
  504. },
  505. {
  506. field: "taxes",
  507. title: "税金"
  508. },
  509. {
  510. field: "erp_mtrlengname",
  511. title: "原物料编码"
  512. },
  513. {
  514. field: "erp_configcodetype",
  515. title: "ERP配置类型"
  516. }
  517. ];
  518. const columns_detail: ColumnProps<any>[] = [
  519. {
  520. field: "erp_mtrlcode",
  521. title: "系统物料编码",
  522. basicinfo: {
  523. el: "input",
  524. // props: {
  525. // clearable: true,
  526. // onClick: (scope: any) => {
  527. // console.log("columns_detail scope :>> ", scope);
  528. // // fModelChoseMtrl()
  529. // }
  530. // },
  531. // editable: ALLOW_EDIT_STATE,
  532. group: "单据信息",
  533. order: 1,
  534. span: 1
  535. }
  536. },
  537. {
  538. field: "erp_mtrlname",
  539. title: "系统物料名称",
  540. basicinfo: {
  541. el: "input",
  542. editable: ALLOW_EDIT_STATE,
  543. group: "单据信息",
  544. order: 4,
  545. span: 1
  546. }
  547. },
  548. {
  549. field: "erp_mtrlmode",
  550. title: "物料规格",
  551. basicinfo: {
  552. el: "input",
  553. editable: ALLOW_EDIT_STATE,
  554. group: "单据信息",
  555. order: 2,
  556. span: 1
  557. }
  558. },
  559. {
  560. field: "erp_mtrlunit",
  561. title: "物料单位",
  562. basicinfo: {
  563. el: "input",
  564. editable: ALLOW_EDIT_STATE,
  565. group: "单据信息",
  566. order: 5,
  567. span: 1,
  568. rules: [{ required: true, message: "物料单位不能为空" }]
  569. }
  570. },
  571. {
  572. field: "erp_mtrltypeid",
  573. title: "物料类别",
  574. basicinfo: {
  575. el: "tree-select",
  576. editable: ALLOW_EDIT_STATE,
  577. group: "单据信息",
  578. order: 3,
  579. span: 1,
  580. props: {
  581. filterable: true
  582. // onChange: ()=> {
  583. // },
  584. // renderContent: data => {
  585. // console.log("erp_mtrltypeid value data :>> ", data);
  586. // return <div>321</div>;
  587. // }
  588. }
  589. },
  590. enum: async () => {
  591. const data = await GetERPMtrlTypeList();
  592. console.log("GetERPMtrlTypeList data :>> ", data?.reList);
  593. return transformTreeData(data.reList);
  594. },
  595. fieldNames: {
  596. label: "mtrltype",
  597. value: "mtrltypeid",
  598. children: "children"
  599. }
  600. },
  601. {
  602. field: "erp_configcodetype",
  603. title: "配置类型",
  604. basicinfo: {
  605. el: "select",
  606. editable: ALLOW_EDIT_STATE,
  607. group: "单据信息",
  608. order: 6,
  609. span: 1
  610. },
  611. enum: async () => {
  612. const data = await getConfigureTypeList({});
  613. console.log("data configureTypeEnum:>> ", data);
  614. // let dataEnum = data.datatable.map(item => {
  615. // return {
  616. // label: item.configuretypename,
  617. // value: item.configuretypeid
  618. // };
  619. // });
  620. return data.datatable;
  621. },
  622. fieldNames: {
  623. label: "contfigtypename",
  624. value: "contfigtypeid"
  625. }
  626. },
  627. {
  628. field: "mattresscode",
  629. title: "图号(床垫唯一码)",
  630. basicinfo: {
  631. el: "input",
  632. editable: () => {
  633. return false;
  634. },
  635. group: "单据信息",
  636. order: 8,
  637. span: 1
  638. }
  639. },
  640. {
  641. field: "erp_mtrlengname",
  642. title: "旧床垫编码",
  643. basicinfo: {
  644. el: "input",
  645. editable: ALLOW_EDIT_STATE,
  646. group: "单据信息",
  647. order: 7,
  648. span: 1
  649. }
  650. },
  651. {
  652. field: "old_mtrlname",
  653. title: "旧物料名称",
  654. basicinfo: {
  655. el: "input",
  656. editable: ALLOW_EDIT_STATE,
  657. group: "单据信息",
  658. order: 9,
  659. span: 1
  660. }
  661. }
  662. ];
  663. const columns_yw: ColumnProps<any>[] = [
  664. {
  665. field: "printid",
  666. title: "排序",
  667. width: 80
  668. },
  669. {
  670. field: "itemname",
  671. title: "项目",
  672. width: 120
  673. },
  674. {
  675. field: "bj_pzname",
  676. title: "核价_配置名称"
  677. },
  678. {
  679. field: "erp_pzcode",
  680. title: "ERP配置编码",
  681. width: 100
  682. },
  683. {
  684. field: "erp_pzname",
  685. title: "ERP配置名称",
  686. width: 120
  687. },
  688. {
  689. field: "bj_inputtype",
  690. title: "录入类型",
  691. width: 80,
  692. enum: [
  693. {
  694. value: 0,
  695. label: "选择"
  696. },
  697. {
  698. value: 1,
  699. label: "录入"
  700. },
  701. {
  702. value: 2,
  703. label: "带出"
  704. }
  705. ],
  706. editRender: {
  707. name: "$select",
  708. options: [
  709. {
  710. value: 0,
  711. label: "选择"
  712. },
  713. {
  714. value: 1,
  715. label: "录入"
  716. },
  717. {
  718. value: 2,
  719. label: "带出"
  720. }
  721. ]
  722. }
  723. },
  724. {
  725. field: "bj_namemx",
  726. title: "明细名称",
  727. width: 280,
  728. editRender: {},
  729. editColRender: (scope: any) => {
  730. const { $table, column, row, status } = scope;
  731. // console.log("bj_namemx scope :>> ", scope);
  732. let params = {
  733. pzid: row.erp_pzid
  734. };
  735. if (row.bj_inputtype == 0) {
  736. return (
  737. <CodemxSelect
  738. value={scope.row.bj_namemx}
  739. {...params}
  740. clearable
  741. placeholder="请选择配置"
  742. onSelect={val => rModelSetCodemx(scope.row, val, $table)}
  743. onClear={() => rModelClearCodemx(scope.row, $table)}
  744. ></CodemxSelect>
  745. );
  746. } else if (row.bj_inputtype == 1) {
  747. return <el-input v-model={scope.row.bj_namemx} />;
  748. } else {
  749. return <span>{row.bj_namemx}</span>;
  750. }
  751. }
  752. },
  753. {
  754. field: "actual_size",
  755. title: "生产尺寸",
  756. limited: () => {
  757. return state.editType == 1;
  758. },
  759. editRender: {
  760. name: "$input"
  761. }
  762. },
  763. {
  764. field: "sb_craft",
  765. title: "锁边工艺",
  766. limited: () => {
  767. return state.editType == 1;
  768. },
  769. editRender: {
  770. name: "$input"
  771. }
  772. },
  773. {
  774. field: "actual_size_sb",
  775. title: "锁边后尺寸",
  776. limited: () => {
  777. return state.editType == 1;
  778. },
  779. editRender: {
  780. name: "$input"
  781. }
  782. },
  783. {
  784. field: "ss_rate",
  785. title: "收缩率",
  786. limited: () => {
  787. return state.editType == 1;
  788. },
  789. datatype: "number",
  790. editRender: {
  791. name: "$input"
  792. }
  793. },
  794. {
  795. field: "ls_rate",
  796. title: "拉伸率",
  797. limited: () => {
  798. return state.editType == 1;
  799. },
  800. datatype: "number",
  801. editRender: {
  802. name: "$input"
  803. }
  804. }
  805. ];
  806. const columns_yw_qd: ColumnProps<any>[] = [
  807. {
  808. field: "bj_pzname",
  809. title: "核价_配置名称"
  810. },
  811. {
  812. field: "bj_namemx",
  813. title: "明细名称"
  814. },
  815. {
  816. field: "actual_size",
  817. title: "生产尺寸",
  818. limited: () => {
  819. return state.editType == 1;
  820. }
  821. },
  822. {
  823. field: "printid",
  824. title: "排序",
  825. width: 80
  826. },
  827. {
  828. field: "erp_pzcode",
  829. title: "ERP配置编码"
  830. },
  831. {
  832. field: "erp_pzname",
  833. title: "ERP配置名称"
  834. },
  835. {
  836. field: "bj_inputtype",
  837. title: "录入类型",
  838. width: 80,
  839. enum: [
  840. {
  841. value: "0",
  842. label: "选择"
  843. },
  844. {
  845. value: "1",
  846. label: "录入"
  847. },
  848. {
  849. value: "2",
  850. label: "带出"
  851. }
  852. ]
  853. },
  854. {
  855. field: "itemname",
  856. title: "项目"
  857. },
  858. {
  859. field: "sb_craft",
  860. title: "锁边工艺",
  861. limited: () => {
  862. return state.editType == 1;
  863. }
  864. },
  865. {
  866. field: "actual_size_sb",
  867. title: "锁边后尺寸",
  868. limited: () => {
  869. return state.editType == 1;
  870. }
  871. },
  872. {
  873. field: "ss_rate",
  874. title: "收缩率",
  875. limited: () => {
  876. return state.editType == 1;
  877. },
  878. datatype: "number"
  879. },
  880. {
  881. field: "ls_rate",
  882. title: "拉伸率",
  883. limited: () => {
  884. return state.editType == 1;
  885. },
  886. datatype: "number"
  887. }
  888. ];
  889. const enumMap = inject("enumMap", ref(new Map()));
  890. const workgrpEnum = computed(() => {
  891. console.log('领用工组领用工组领用工组领用工组 enumMap.value.get("wrkgrpid") :>> ', enumMap.value.get("wrkgrpid"));
  892. return enumMap.value.get("wrkgrpid");
  893. });
  894. const columns_qd = ref<ColumnProps<any>[]>([
  895. {
  896. field: "printid",
  897. title: "排序",
  898. width: 80,
  899. fixed: "left"
  900. },
  901. {
  902. field: "itemname",
  903. title: "项目",
  904. width: 100,
  905. fixed: "left"
  906. },
  907. {
  908. field: "bj_pzname",
  909. title: "二级项目",
  910. fixed: "left",
  911. width: 120
  912. },
  913. {
  914. field: "bj_pzname_mx",
  915. title: "明细项目",
  916. width: 100,
  917. fixed: "left"
  918. },
  919. {
  920. field: "bj_pzname_mx_mx",
  921. title: "二级明细项目",
  922. fixed: "left"
  923. },
  924. {
  925. field: "erp_mtrlcode",
  926. title: "L1物料编码",
  927. // limited: () => {
  928. // return state.editType == 1 || state.editType == 2;
  929. // },
  930. // editRender: {
  931. // name: "$input"
  932. // }
  933. editRender: {
  934. // name: "$select"
  935. autoFocus: "input"
  936. },
  937. editColRender: (scope: any) => {
  938. // console.log("mtrlname hooks render scope :>> ", scope);
  939. // console.log("mtrlname hooks render LjDetailRef.value._mainData :>> ", state.LjDetailRef);
  940. const { $table, column, row, status } = scope;
  941. let field = column.field;
  942. let _label = column.title;
  943. // if (column?.format) {
  944. // _label = handleRowAccordingToProp(searchParam, field, column?.format);
  945. // }
  946. let params = {
  947. keyword: row.erp_mtrlcode
  948. };
  949. return (
  950. <MtrldefErpSelect
  951. value={row.erp_mtrlid}
  952. {...params}
  953. clearable
  954. placeholder={_label}
  955. onOpenModal={() => fModelChoseMtrlErp(row, params)}
  956. onSelect={val => rModelSetMtrlErp(row, val)}
  957. onClear={() => rModelClearMtrlErp(row, 2)}
  958. >
  959. {{
  960. label: () => row.erp_mtrlcode
  961. }}
  962. </MtrldefErpSelect>
  963. );
  964. }
  965. },
  966. {
  967. field: "dscrp",
  968. title: "备注",
  969. editRender: {
  970. name: "$input"
  971. }
  972. },
  973. {
  974. field: "mtrlengname",
  975. title: "自定义2",
  976. limited: () => {
  977. return state.editType == 1 || state.editType == 2;
  978. },
  979. editRender: {
  980. name: "$input"
  981. }
  982. },
  983. {
  984. field: "erp_mtrlname",
  985. title: "L1物料名称",
  986. limited: () => {
  987. return state.editType == 1 || state.editType == 2;
  988. }
  989. },
  990. {
  991. field: "ss_rate",
  992. title: "收缩率",
  993. datatype: "number",
  994. editRender: {
  995. name: "$input"
  996. }
  997. },
  998. {
  999. field: "erp_mtrlmode",
  1000. title: "L1物料规格",
  1001. limited: () => {
  1002. return state.editType == 1 || state.editType == 2;
  1003. }
  1004. },
  1005. {
  1006. field: "qd_actual_size",
  1007. title: "实际尺寸",
  1008. editRender: {
  1009. name: "$input"
  1010. }
  1011. },
  1012. {
  1013. field: "qd_pfgroupqty",
  1014. title: "条数",
  1015. width: 80,
  1016. editRender: {
  1017. name: "$input"
  1018. }
  1019. },
  1020. {
  1021. field: "ls_rate",
  1022. title: "拉伸率",
  1023. datatype: "number",
  1024. editRender: {
  1025. name: "$input"
  1026. }
  1027. },
  1028. {
  1029. field: "erp_unit",
  1030. title: "L1物料单位",
  1031. limited: () => {
  1032. return state.editType == 1 || state.editType == 2;
  1033. }
  1034. },
  1035. {
  1036. field: "sh_rate",
  1037. title: "损耗率",
  1038. datatype: "number",
  1039. editRender: {
  1040. name: "$input"
  1041. }
  1042. },
  1043. {
  1044. field: "useqty",
  1045. title: "参考用料量",
  1046. datatype: "number",
  1047. limited: () => {
  1048. return state.editType == 1 || state.editType == 2;
  1049. }
  1050. },
  1051. {
  1052. field: "actual_useqty",
  1053. title: "实际用量",
  1054. datatype: "number",
  1055. editRender: {
  1056. name: "$input"
  1057. },
  1058. limited: () => {
  1059. return state.editType == 1 || state.editType == 2;
  1060. }
  1061. },
  1062. {
  1063. field: "wrkgrpid",
  1064. title: "领用工组",
  1065. // enum: async () => {
  1066. // const data = await GetERPWrkGrpList();
  1067. // console.log("领用工组领用工组领用工组领用工组 data :>> ", data);
  1068. // return { data: data.workgroupList };
  1069. // },
  1070. // fieldNames: { label: "wrkgrpname", value: "wrkgrpid" },
  1071. // enum: async () => {
  1072. // console.log("领用工组领用工组领用工组领用工组 state.workgrpEnum :>> ", state.workgrpEnum);
  1073. // return { data: state.workgrpEnum };
  1074. // },
  1075. isFilterEnum: true,
  1076. editRender: {
  1077. // name: "$select"
  1078. autoFocus: "input"
  1079. },
  1080. editColRender: (scope: any) => {
  1081. // console.log("formulakind editColRender scope :>> ", scope);
  1082. return (
  1083. <el-select v-model={scope.row.wrkgrpid} filterable onChange={val => rModelSetWrkgrp1(val, scope.row)}>
  1084. {{
  1085. default: () => {
  1086. let rs = [];
  1087. if (state.workgrpEnum.length) {
  1088. state.workgrpEnum.map((t: any) => {
  1089. rs.push(<el-option label={`${t.code} - ${t.label}`} value={t.value} />);
  1090. });
  1091. }
  1092. return rs;
  1093. },
  1094. label: ({ label, value }) => label
  1095. }}
  1096. </el-select>
  1097. );
  1098. },
  1099. render: scope => {
  1100. let item = state.workgrpEnum.find(t => t.value == scope.row.wrkgrpid);
  1101. if (item) {
  1102. return item.label + " - " + item.code;
  1103. } else {
  1104. return "";
  1105. }
  1106. }
  1107. },
  1108. {
  1109. field: "wrkgrpid2",
  1110. title: "领用工组(新L1)",
  1111. // enum: async () => {
  1112. // const data = await GetERPWrkGrpList();
  1113. // console.log("领用工组领用工组领用工组领用工组 data :>> ", data);
  1114. // return { data: data.workgroupList };
  1115. // },
  1116. // fieldNames: { label: "wrkgrpname", value: "wrkgrpid" },
  1117. // enum: async () => {
  1118. // console.log("领用工组领用工组领用工组领用工组 state.workgrpEnum :>> ", state.workgrpEnum);
  1119. // return { data: state.workgrpEnum };
  1120. // },
  1121. isFilterEnum: true,
  1122. editRender: {
  1123. // name: "$select"
  1124. autoFocus: "input"
  1125. },
  1126. editColRender: (scope: any) => {
  1127. // console.log("formulakind editColRender scope :>> ", scope);
  1128. return (
  1129. <el-select v-model={scope.row.wrkgrpid2} filterable onChange={val => rModelSetWrkgrp2(val, scope.row)}>
  1130. {{
  1131. default: () => {
  1132. let rs = [];
  1133. if (state.workgrpEnum2.length) {
  1134. state.workgrpEnum2.map((t: any) => {
  1135. rs.push(<el-option label={`${t.code} - ${t.label}`} value={t.value} />);
  1136. });
  1137. }
  1138. return rs;
  1139. },
  1140. label: ({ label, value }) => label
  1141. }}
  1142. </el-select>
  1143. );
  1144. },
  1145. render: scope => {
  1146. let item = state.workgrpEnum2.find(t => t.value == scope.row.wrkgrpid2);
  1147. if (item) {
  1148. return item.label + " - " + item.code;
  1149. } else {
  1150. return "";
  1151. }
  1152. }
  1153. }
  1154. ]);
  1155. const rModelSetWrkgrp1 = (value: any, data: any) => {
  1156. let item = state.workgrpEnum.find(t => t.value == value);
  1157. if (item) {
  1158. data.wrkgrpcode1 = item.code;
  1159. }
  1160. };
  1161. const rModelSetWrkgrp2 = (value: any, data: any) => {
  1162. let item = state.workgrpEnum2.find(t => t.value == value);
  1163. if (item) {
  1164. data.wrkgrpcode2 = item.code;
  1165. }
  1166. };
  1167. // const columns_export = [
  1168. // {
  1169. // name: "行号",
  1170. // field: "pid",
  1171. // },
  1172. // {
  1173. // name: "层",
  1174. // field: "lp",
  1175. // },
  1176. // {
  1177. // name: "",
  1178. // field: "lp_tree",
  1179. // },
  1180. // {
  1181. // name: "序",
  1182. // field: "u_prdpf_printid",
  1183. // },
  1184. // {
  1185. // name: "工艺模板编码",
  1186. // field: "mb_mtrlcode",
  1187. // },
  1188. // {
  1189. // name: "物料编码",
  1190. // field: "u_mtrldef_mtrlcode",
  1191. // },
  1192. // {
  1193. // name: "来源",
  1194. // field: "u_mtrldef_mtrlorigin",
  1195. // },
  1196. // {
  1197. // name: "物料属性",
  1198. // field: "u_mtrldef_mtrlprp",
  1199. // },
  1200. // {
  1201. // name: "物料名称",
  1202. // field: "u_mtrldef_mtrlname",
  1203. // },
  1204. // {
  1205. // name: "物料规格",
  1206. // field: "u_mtrldef_mtrlmode",
  1207. // },
  1208. // {
  1209. // name: "库存 单位",
  1210. // field: "u_mtrldef_unit",
  1211. // },
  1212. // {
  1213. // name: "物料类别",
  1214. // field: "u_mtrldef_mtrltypeid",
  1215. // },
  1216. // {
  1217. // name: "弹簧数",
  1218. // field: "u_mtrldef_mtrlsectype",
  1219. // },
  1220. // {
  1221. // name: "旧编码",
  1222. // field: "u_mtrldef_zxmtrlmode",
  1223. // },
  1224. // {
  1225. // name: "旧产品名称",
  1226. // field: "u_mtrldef_usermtrlmode",
  1227. // },
  1228. // {
  1229. // name: "图号",
  1230. // field: "u_mtrldef_piccode",
  1231. // },
  1232. // {
  1233. // name: "排产属性",
  1234. // field: "u_mtrldef_ifselforder",
  1235. // },
  1236. // {
  1237. // name: "计划属性",
  1238. // field: "u_mtrldef_ordertype",
  1239. // },
  1240. // {
  1241. // name: "默认 制造分部",
  1242. // field: "u_mtrldef_scid",
  1243. // },
  1244. // {
  1245. // name: "默认 制造车间",
  1246. // field: "u_mtrldef_dftwrkgrpid",
  1247. // },
  1248. // {
  1249. // name: "板件属性",
  1250. // field: "u_mtrldef_bantype",
  1251. // },
  1252. // {
  1253. // name: "安装序号",
  1254. // field: "u_prdpf_azcode",
  1255. // },
  1256. // {
  1257. // name: "部件名称",
  1258. // field: "u_prdpf_pfgroup",
  1259. // },
  1260. // {
  1261. // name: "部件 数",
  1262. // field: "u_prdpf_pfgroupqty",
  1263. // },
  1264. // {
  1265. // name: "部件规格",
  1266. // field: "u_prdpf_pfgroupmode",
  1267. // },
  1268. // {
  1269. // name: "部件代号",
  1270. // field: "u_prdpf_promode",
  1271. // },
  1272. // {
  1273. // name: "开料规格",
  1274. // field: "u_prdpf_pfklmode",
  1275. // },
  1276. // {
  1277. // name: "领料组",
  1278. // field: "u_prdpf_wrkgrpid",
  1279. // },
  1280. // {
  1281. // name: "用料量",
  1282. // field: "u_prdpf_sonscale",
  1283. // },
  1284. // {
  1285. // name: "损耗率",
  1286. // field: "u_prdpf_sonloss",
  1287. // },
  1288. // {
  1289. // name: "损附加",
  1290. // field: "u_prdpf_sondecloss",
  1291. // },
  1292. // {
  1293. // name: "配置",
  1294. // field: "u_prdpf_status",
  1295. // },
  1296. // {
  1297. // name: "配置1",
  1298. // field: "u_prdpf_woodcode",
  1299. // },
  1300. // {
  1301. // name: "配置2",
  1302. // field: "u_prdpf_pcode",
  1303. // },
  1304. // {
  1305. // name: "生产 提前期(天)",
  1306. // field: "u_prdpf_sonahead",
  1307. // },
  1308. // {
  1309. // name: "清单",
  1310. // field: "u_prdpf_sonpfcode",
  1311. // },
  1312. // {
  1313. // name: "说明",
  1314. // field: "u_prdpf_dscrp",
  1315. // },
  1316. // {
  1317. // name: "发料用 损耗率",
  1318. // field: "u_prdpf_scllloss",
  1319. // },
  1320. // {
  1321. // name: "发料用 损耗附加",
  1322. // field: "u_prdpf_sclldecloss",
  1323. // },
  1324. // {
  1325. // name: "按配置 拆装",
  1326. // field: "u_prdpf_ifover",
  1327. // },
  1328. // {
  1329. // name: "拆装 运算配置",
  1330. // field: "u_prdpf_dipztype",
  1331. // },
  1332. // {
  1333. // name: "采购 参数",
  1334. // field: "u_prdpf_buyarg",
  1335. // },
  1336. // {
  1337. // name: "生产 保险期(天)",
  1338. // field: "u_mtrldef_orderdays",
  1339. // },
  1340. // {
  1341. // name: "采购 周期(天)",
  1342. // field: "u_mtrldef_buydays",
  1343. // },
  1344. // {
  1345. // name: "外协 周期(天)",
  1346. // field: "u_mtrldef_wfjgdays",
  1347. // },
  1348. // {
  1349. // name: "出仓类型",
  1350. // field: "u_mtrldef_outtype",
  1351. // },
  1352. // {
  1353. // name: "密度(kg/m³)",
  1354. // field: "u_mtrldef_midu",
  1355. // },
  1356. // {
  1357. // name: "物料备注",
  1358. // field: "u_mtrldef_dscrp",
  1359. // },
  1360. // {
  1361. // name: "单件体积(m³)",
  1362. // field: "cubage",
  1363. // },
  1364. // {
  1365. // name: "长度(mm)",
  1366. // field: "length",
  1367. // },
  1368. // {
  1369. // name: "宽度(mm)",
  1370. // field: "width",
  1371. // },
  1372. // {
  1373. // name: "工艺路线模板(双击选择)",
  1374. // field: "u_prdpf_modlename",
  1375. // },
  1376. // {
  1377. // name: "清单-纹理方向",
  1378. // field: "u_prdpf_wenli",
  1379. // },
  1380. // {
  1381. // name: "清单-封边信息",
  1382. // field: "u_prdpf_fengbian",
  1383. // },
  1384. // {
  1385. // name: "清单-排孔信息",
  1386. // field: "u_prdpf_paikong",
  1387. // },
  1388. // {
  1389. // name: "清单-锣机信息",
  1390. // field: "u_prdpf_luoji",
  1391. // },
  1392. // {
  1393. // name: "清单-喷油(吸塑)信",
  1394. // field: "u_prdpf_penyou",
  1395. // },
  1396. // {
  1397. // name: "包件",
  1398. // field: "u_mtrldef_ifpack",
  1399. // },
  1400. // {
  1401. // name: "物料-部件代号",
  1402. // field: "u_mtrldef_ban_promode",
  1403. // },
  1404. // {
  1405. // name: "物料-开料规格",
  1406. // field: "u_mtrldef_ban_pfklmode",
  1407. // },
  1408. // {
  1409. // name: "物料-纹理方向",
  1410. // field: "u_mtrldef_ban_wenli",
  1411. // },
  1412. // {
  1413. // name: "物料-封边信息",
  1414. // field: "u_mtrldef_ban_fengbian",
  1415. // },
  1416. // {
  1417. // name: "物料-排孔信息",
  1418. // field: "u_mtrldef_ban_paikong",
  1419. // },
  1420. // {
  1421. // name: "物料-锣机信息",
  1422. // field: "u_mtrldef_ban_luoji",
  1423. // },
  1424. // {
  1425. // name: "物料-喷油(吸塑)信息",
  1426. // field: "u_mtrldef_ban_penyou",
  1427. // },
  1428. // {
  1429. // name: "物料-工艺备注",
  1430. // field: "u_mtrldef_ban_gydscrp",
  1431. // },
  1432. // {
  1433. // name: "摆放方向",
  1434. // field: "u_mtrldef_ban_direction",
  1435. // },
  1436. // {
  1437. // name: "物料ID",
  1438. // field: "u_mtrldef_mtrlid",
  1439. // },
  1440. // {
  1441. // name: "虚拟进出",
  1442. // field: "u_mtrldef_xninoutflag",
  1443. // },
  1444. // {
  1445. // name: "产品选配值",
  1446. // field: "config_val",
  1447. // },
  1448. // {
  1449. // name: "当前物料开料规格",
  1450. // field: "u_mtrldef_pfklmode_son",
  1451. // },
  1452. // {
  1453. // name: "上级物料开料规格",
  1454. // field: "u_mtrldef_pfklmode_p",
  1455. // },
  1456. // ];
  1457. const tableProps_mx = ref<any>({
  1458. height: "auto",
  1459. align: "left",
  1460. // height: "",
  1461. minHeight: "300px",
  1462. editConfig: {
  1463. trigger: "click",
  1464. mode: "cell",
  1465. enabled: false,
  1466. // afterEditMethod: ({ row, rowIndex, column, columnIndex }) => {
  1467. // console.log("afterEditMethod :>> ", row);
  1468. // }
  1469. beforeEditMethod: ({ row, rowIndex, column, columnIndex }) => {
  1470. console.log("state.editType == 1 :>> ", state.editType, column.field);
  1471. if (state.editType == 1) {
  1472. if (["bj_inputtype"].includes(column.field)) {
  1473. return false;
  1474. }
  1475. }
  1476. return true;
  1477. }
  1478. },
  1479. showOverflow: false,
  1480. // exportConfig: {
  1481. // filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
  1482. // }
  1483. keyboardConfig: {
  1484. isEdit: true,
  1485. isArrow: true,
  1486. isEnter: true,
  1487. isTab: true,
  1488. isDel: true,
  1489. isBack: true,
  1490. isEsc: true,
  1491. editMethod({ $table, row, column }) {
  1492. // 先清空原先的值
  1493. row[column.field] = "";
  1494. // 再激活编辑状态并输入新值
  1495. $table.setEditCell(row, column);
  1496. }
  1497. },
  1498. mouseConfig: {
  1499. selected: true
  1500. }
  1501. });
  1502. const resetMergeCells = () => {
  1503. nextTick(() => {
  1504. const $table = state.YwTableRef.element;
  1505. const $table2 = state.VxeTableMxRef.element;
  1506. if ($table) {
  1507. let mergeCells = autoMergeCells($table, ["itemname"]);
  1508. $table.setMergeCells(mergeCells);
  1509. }
  1510. if ($table2) {
  1511. let mergeCells = autoMergeCells($table2, ["itemname"]);
  1512. $table2.setMergeCells(mergeCells);
  1513. // });
  1514. }
  1515. });
  1516. };
  1517. const resetMergeCellsQd = () => {
  1518. nextTick(() => {
  1519. const $table = state.QdTableRef.element;
  1520. if ($table) {
  1521. let mergeCells = autoMergeCells($table, ["itemname", "bj_pzname", "bj_pzname_mx_mx"]);
  1522. // console.log("autoMergeCells mergeCells :>> ", mergeCells);
  1523. $table.setMergeCells(mergeCells);
  1524. }
  1525. });
  1526. };
  1527. /**
  1528. * 获取产品配置,产品清单
  1529. * @param mattressid 床垫ID
  1530. */
  1531. const RetriveMattressInterface = async (mattressid: number) => {
  1532. let res = await GetMattressInterfaceList({ mattressid, isEdit: Number(state.orderStatus != "") });
  1533. state.mainData = [res.mattress];
  1534. state.mattressYWList = res.interfaceList;
  1535. state.mattressQDList = res.qdList;
  1536. resetMergeCells();
  1537. resetMergeCellsQd();
  1538. };
  1539. /**
  1540. * 获取产品配置,产品清单
  1541. * @param mattressid 床垫ID
  1542. */
  1543. const RefreshMattressInterfaceList = async (mattressid: number, isPz: number, configcodetype: number = 0) => {
  1544. let res = await RefreshMattressInterface({ mattressid, isPz, configcodetype });
  1545. state.mattressYWList = res.mxList;
  1546. resetMergeCells();
  1547. ElNotification({
  1548. title: "刷新成功",
  1549. type: "success"
  1550. });
  1551. };
  1552. /**
  1553. * 获取产品配置,产品清单
  1554. * @param mattressid 床垫ID
  1555. */
  1556. const RefreshMattressInterfaceQdList = async (mattressid: number, isPz: number, isCheck?: number) => {
  1557. isCheck = isCheck ?? 1;
  1558. let res = await RefreshMattressInterfaceQd({ mattressid, isPz, isCheck });
  1559. const interfaceMap = {};
  1560. state.mattressYWList.forEach(mb => {
  1561. interfaceMap[mb.bj_pzname] = mb;
  1562. });
  1563. // 遍历 qdList 并使用哈希表来查找和赋值
  1564. res.mxList.forEach(mx => {
  1565. const mb = interfaceMap[mx.bj_pzname];
  1566. if (mb) {
  1567. mx.bj_pzname_mx_mx = mb.bj_namemx;
  1568. if (mx.ss_rate === 0) {
  1569. mx.ss_rate = mb.ss_rate;
  1570. }
  1571. if (mx.ls_rate === 0) {
  1572. mx.ls_rate = mb.ls_rate;
  1573. }
  1574. }
  1575. });
  1576. state.mattressQDList = res.mxList;
  1577. resetMergeCellsQd();
  1578. ElNotification({
  1579. title: "刷新成功",
  1580. type: "success"
  1581. });
  1582. };
  1583. /**
  1584. * @description 弹窗模块:床垫选择
  1585. * @param data 当前数据
  1586. * @param status 当前订单状态
  1587. * @returns Promise
  1588. */
  1589. const fModelChoseMattress = (label?: string) => {
  1590. return new Promise((resolve, reject) => {
  1591. let _params = {
  1592. arg_deptid: state.mainData[0].deptid
  1593. };
  1594. state.MattressDialogProps = {
  1595. onSubmit: (res: any) => {
  1596. // submit
  1597. console.log("openCustDialog res", res);
  1598. nextTick(() => {
  1599. resolve(res.value[0]);
  1600. });
  1601. },
  1602. onCancel: (error: any) => {
  1603. // cancel 回调
  1604. console.log("openCustDialog error", error);
  1605. }
  1606. };
  1607. state.MattressDialogRef.show(_params, label);
  1608. });
  1609. };
  1610. const toExcel = (fileName: string) => {
  1611. // const { data, mxdata } = params;
  1612. const data = state.mattressQDList;
  1613. console.log("mainData :>> ", data);
  1614. let default_font = { size: 12, name: "宋体" };
  1615. let default_alignment: any = {
  1616. vertical: "middle", // 垂直居中
  1617. horizontal: "left", // 水平居左
  1618. wrapText: true // 自动换行
  1619. };
  1620. const workbook = new Exceljs.Workbook(); // 创建工作簿
  1621. const workST = workbook.addWorksheet("沙头工厂清单"); // 创建工作表(sheet1)
  1622. // 冻结前7行
  1623. workST.views = [{ state: "frozen", xSplit: 0, ySplit: 1 }];
  1624. // let _columns = columns_qd.map((itm: any) => {
  1625. // return {
  1626. // name: itm.label
  1627. // };
  1628. // });
  1629. // _columns.unshift({
  1630. // name: ""
  1631. // });
  1632. // _columns.unshift({
  1633. // name: "层"
  1634. // });
  1635. // let _rows = [];
  1636. // // 第一层
  1637. // let firstRow = [];
  1638. // firstRow.push(0);
  1639. // firstRow.push("--------------------");
  1640. // _columns.map((col: any) => {
  1641. // firstRow.push(col.);
  1642. // });
  1643. // _rows.push(firstRow);
  1644. // 第二层
  1645. // state.mattressQDList.map((itm: any) => {
  1646. // let _row = [];
  1647. // _row.push(1);
  1648. // _row.push("├--------------------");
  1649. // _columns.map((col: any) => {
  1650. // _row.push(itm[col.field]);
  1651. // });
  1652. // _rows.push(_row);
  1653. // });
  1654. // console.log('toExcel _rows :>> ', _rows);
  1655. // workST.addTable({
  1656. // name: "workSTTable",
  1657. // ref: "A1",
  1658. // headerRow: true,
  1659. // totalsRow: true,
  1660. // // style: {
  1661. // // theme: 'TableStyleDark3',
  1662. // // showRowStripes: true,
  1663. // // },
  1664. // columns: _columns,
  1665. // rows: _rows
  1666. // });
  1667. const worksLJ = workbook.addWorksheet("龙江总部清单"); // 创建工作表(sheet1)
  1668. // // // 设置整个工作表的背景颜色为白色
  1669. // // worksheet.eachRow(row => {
  1670. // // // row.eachCell(cell => {
  1671. // // // cell.fill = {
  1672. // // // type: "pattern",
  1673. // // // pattern: "solid",
  1674. // // // bgColor: { argb: "FFFFFFFF" } // 白色
  1675. // // // };
  1676. // // // });
  1677. // // row.eachCell({ includeEmpty: true }, function (cell, rowNumber) {
  1678. // // cell.fill = {
  1679. // // type: "pattern",
  1680. // // pattern: "solid",
  1681. // // bgColor: { argb: "FFFFFF" } // 白色
  1682. // // };
  1683. // // });
  1684. // // });
  1685. // // 宽度设置
  1686. // const ACol = worksheet.getColumn("A");
  1687. // ACol.width = 0.78;
  1688. // const BCol = worksheet.getColumn("B");
  1689. // BCol.width = 13.55;
  1690. // BCol.key = "label";
  1691. // BCol.style = {
  1692. // font: default_font,
  1693. // alignment: { ...default_alignment, vertical: "top" }
  1694. // };
  1695. // const CCol = worksheet.getColumn("C");
  1696. // CCol.width = 49.33;
  1697. // CCol.key = "dscrp";
  1698. // CCol.style = {
  1699. // font: default_font,
  1700. // alignment: default_alignment
  1701. // };
  1702. // const DCol = worksheet.getColumn("D");
  1703. // DCol.width = 5.69;
  1704. // DCol.key = "qty";
  1705. // DCol.style = {
  1706. // font: default_font,
  1707. // alignment: { ...default_alignment, horizontal: "center" }
  1708. // };
  1709. // const ECol = worksheet.getColumn("E");
  1710. // ECol.width = 10;
  1711. // ECol.key = "costamt";
  1712. // ECol.style = {
  1713. // font: default_font,
  1714. // alignment: { ...default_alignment, horizontal: "right" }
  1715. // };
  1716. // const FCol = worksheet.getColumn("F");
  1717. // FCol.width = 13;
  1718. // FCol.key = "useqty";
  1719. // FCol.style = {
  1720. // font: default_font,
  1721. // alignment: { ...default_alignment, horizontal: "right" }
  1722. // };
  1723. // const GCol = worksheet.getColumn("G");
  1724. // GCol.width = 12.48;
  1725. // GCol.key = "price";
  1726. // GCol.style = {
  1727. // font: default_font,
  1728. // alignment: { ...default_alignment, horizontal: "right" }
  1729. // };
  1730. // //======================================= 第一行 =================================
  1731. // // 合并A1到L1的单元格 (大标题)
  1732. // worksheet.mergeCells("B1:F1");
  1733. // const cellB1 = worksheet.getCell("B1");
  1734. // let foreign_cost = formatAmount(data?.foreign_cost);
  1735. // let currency = Number(data?.moneyrate) != 1 ? "美金" : "人民币";
  1736. // cellB1.value = `报价日期:${formatTime(data.createtime, "{y}-{m}-{d}", false)} 报价金额:${foreign_cost}${currency}报价清单`;
  1737. // // 设置第一行的单元格样式
  1738. // cellB1.font = { size: 15, bold: true, name: "宋体" };
  1739. // cellB1.alignment = default_alignment;
  1740. // worksheet.getRow(1).height = 26; // 设置行高
  1741. // //======================================= 第二行 =================================
  1742. // worksheet.mergeCells("B2:F2");
  1743. // const cellB2 = worksheet.getCell("B2");
  1744. // cellB2.value = `财务底价:${formatAmount(data.nottax_dept_cost)} 佣金点数:${formatAmount(
  1745. // data.commission
  1746. // )} 税率:${formatAmount(data.taxrate)} `;
  1747. // cellB2.font = default_font;
  1748. // cellB2.alignment = default_alignment;
  1749. // worksheet.getRow(2).height = 39;
  1750. // //======================================= 第三行 =================================
  1751. // worksheet.mergeCells("B3:F3");
  1752. // const cellB3 = worksheet.getCell("B3");
  1753. // cellB3.value = `额外点数:${formatAmount(data.other_rate)} 额外费用:${formatAmount(
  1754. // data.extras_cost
  1755. // )} 汇率:${formatAmount(data.moneyrate)} `;
  1756. // cellB3.font = default_font;
  1757. // cellB3.alignment = default_alignment;
  1758. // worksheet.getRow(3).height = 18;
  1759. // //======================================= 第四行 =================================
  1760. // worksheet.mergeCells("B4:F4");
  1761. // const cellB4 = worksheet.getCell("B4");
  1762. // cellB4.value = `款式费用:${formatAmount(data.hrcost)} 边带费用:${formatAmount(
  1763. // data.biandaicost
  1764. // )} 总成本:${formatAmount(data.total_cost)} `;
  1765. // cellB4.font = default_font;
  1766. // cellB4.alignment = default_alignment;
  1767. // worksheet.getRow(4).height = 18;
  1768. // //======================================= 第五行 =================================
  1769. // worksheet.mergeCells("B5:F5");
  1770. // const cellB5 = worksheet.getCell("B5");
  1771. // cellB5.value = `工厂利润率${formatAmount(data.profitrate)} 工艺点数:${formatAmount(
  1772. // data.profitrate_point
  1773. // )} 不含税出厂价:${formatAmount(data.nottax_factory_cost)} `;
  1774. // cellB5.font = default_font;
  1775. // cellB5.alignment = default_alignment;
  1776. // worksheet.getRow(5).height = 18;
  1777. // //======================================= 第六行 =================================
  1778. // worksheet.mergeCells("B6:F6");
  1779. // const cellB6 = worksheet.getCell("B6");
  1780. // cellB6.value = `部门利润率:${formatAmount(data.dept_profitrate)} FOB费用:${formatAmount(
  1781. // data.fob
  1782. // )} 部门售价:${formatAmount(data.nottax_dept_cost)} `;
  1783. // cellB6.font = default_font;
  1784. // cellB6.alignment = default_alignment;
  1785. // worksheet.getRow(6).height = 18;
  1786. // //======================================= 第七行 =================================
  1787. // worksheet.mergeCells("B7:F7");
  1788. // const cellB7 = worksheet.getCell("B7");
  1789. // cellB7.value = `让利点数:${formatAmount(data.dept_profitrate_rangli)} 海绵款扣点:${formatAmount(data.haimian_point)} `;
  1790. // cellB7.font = default_font;
  1791. // cellB7.alignment = default_alignment;
  1792. // worksheet.getRow(7).height = 18;
  1793. // //======================================= 第八行 =================================
  1794. // // wf_retrieve_qingdan(params);
  1795. // const headerRows = worksheet.insertRow(
  1796. // 8,
  1797. // { label: "项目", dscrp: "内容", qty: "数量", costamt: "金额", useqty: "用量", price: "单价" },
  1798. // "n"
  1799. // );
  1800. // const insertedRows = worksheet.insertRows(9, state.tableData, "n");
  1801. // // const cellBSum = worksheet.getCell(`B${9 + state.tableData.length}`);
  1802. // // cellBSum.value = "材料合计:";
  1803. // // const cellESum = worksheet.getCell(`E${9 + state.tableData.length}`);
  1804. // // cellESum.value = getSummaries(state.tableData, "costamt");
  1805. // const footerRows = worksheet.insertRow(
  1806. // 9 + state.tableData.length,
  1807. // { label: "材料合计:", dscrp: "", qty: "", costamt: getSummaries(state.tableData, "costamt"), useqty: "", price: "" },
  1808. // "n"
  1809. // );
  1810. // // 设置单元格边框
  1811. // let default_border: any = {
  1812. // top: { style: "thin", color: { argb: "FF000000" } },
  1813. // left: { style: "thin", color: { argb: "FF000000" } },
  1814. // bottom: { style: "thin", color: { argb: "FF000000" } },
  1815. // right: { style: "thin", color: { argb: "FF000000" } }
  1816. // };
  1817. // headerRows.eachCell(cell => {
  1818. // cell.border = default_border;
  1819. // });
  1820. // footerRows.eachCell(cell => {
  1821. // cell.border = default_border;
  1822. // });
  1823. // insertedRows.map(row => {
  1824. // row.eachCell(cell => {
  1825. // cell.border = default_border;
  1826. // });
  1827. // });
  1828. // // label列内容相同时合并单元格
  1829. // let same = 0;
  1830. // state.tableData.map((t, i) => {
  1831. // // label列内容相同的时候,多行合并单元格
  1832. // if (i > 0 && t.label === state.tableData[i - 1].label) {
  1833. // same++;
  1834. // } else {
  1835. // if (same > 0) {
  1836. // worksheet.mergeCells(`B${9 + i - 1}:B${9 + i - 1 - same}`);
  1837. // }
  1838. // same = 0;
  1839. // }
  1840. // });
  1841. // 下载工作簿
  1842. workbook.xlsx.writeBuffer().then(buffer => {
  1843. saveAs(new Blob([buffer], { type: "application/octet-stream" }), fileName + state.mainData[0].erp_mtrlcode + ".xlsx");
  1844. });
  1845. };
  1846. const YWAudit = (type: any, curRecords: any, cb?: any) => {
  1847. if (!curRecords.length) {
  1848. ElMessage.warning(t("business.tips.mattress.records"));
  1849. return;
  1850. }
  1851. let list = curRecords.map((item: any) => {
  1852. return {
  1853. mattressid: Number(item.mattressid)
  1854. };
  1855. });
  1856. ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
  1857. confirmButtonText: t("common.okText"),
  1858. cancelButtonText: "否",
  1859. type: "warning"
  1860. })
  1861. .then(() => {
  1862. MattressYWAudit({ list, type }).then(() => {
  1863. ElMessage.success(`业务${type ? "审核" : "撤审"}成功!`);
  1864. cb && cb();
  1865. // vxeTableRef.value.refresh();
  1866. });
  1867. })
  1868. .catch((e: TypeError) => {
  1869. console.log("e :>> ", e);
  1870. ElMessage({
  1871. type: "info",
  1872. message: "操作取消"
  1873. });
  1874. });
  1875. };
  1876. const JSAudit = (type: any, curRecords: any, cb?: any) => {
  1877. if (!curRecords.length) {
  1878. ElMessage.warning(t("business.tips.mattress.records"));
  1879. return;
  1880. }
  1881. let list = curRecords.map((item: any) => {
  1882. return {
  1883. mattressid: Number(item.mattressid)
  1884. };
  1885. });
  1886. ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
  1887. confirmButtonText: t("common.okText"),
  1888. cancelButtonText: "否",
  1889. type: "warning"
  1890. })
  1891. .then(() => {
  1892. MattressJSAudit({ list, type }).then(() => {
  1893. ElMessage.success(`产品补充${type ? "审核" : "撤审"}成功!`);
  1894. cb && cb();
  1895. // vxeTableRef.value.refresh();
  1896. });
  1897. })
  1898. .catch((e: TypeError) => {
  1899. console.log("e :>> ", e);
  1900. ElMessage({
  1901. type: "info",
  1902. message: "操作取消"
  1903. });
  1904. });
  1905. };
  1906. const JS2Audit = (type: any, curRecords: any, cb?: any) => {
  1907. if (!curRecords.length) {
  1908. ElMessage.warning(t("business.tips.mattress.records"));
  1909. return;
  1910. }
  1911. let list = curRecords.map((item: any) => {
  1912. return {
  1913. mattressid: Number(item.mattressid)
  1914. };
  1915. });
  1916. ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
  1917. confirmButtonText: t("common.okText"),
  1918. cancelButtonText: "否",
  1919. type: "warning"
  1920. })
  1921. .then(() => {
  1922. MattressJS2Audit({ list, type }).then(() => {
  1923. ElMessage.success(`清单补充${type ? "审核" : "撤审"}成功!`);
  1924. cb && cb();
  1925. // vxeTableRef.value.refresh();
  1926. });
  1927. })
  1928. .catch((e: TypeError) => {
  1929. console.log("e :>> ", e);
  1930. ElMessage({
  1931. type: "info",
  1932. message: "操作取消"
  1933. });
  1934. });
  1935. };
  1936. return {
  1937. ...toRefs(state),
  1938. columns,
  1939. columns_detail,
  1940. columns_yw,
  1941. columns_yw_qd,
  1942. columns_qd,
  1943. tableProps_mx,
  1944. RetriveMattressInterface,
  1945. RefreshMattressInterfaceList,
  1946. RefreshMattressInterfaceQdList,
  1947. fModelChoseMattress,
  1948. toExcel,
  1949. toCreateMtrl,
  1950. toCreateORDelMtrlPf,
  1951. // toUpdateL1Planprice,
  1952. YWAudit,
  1953. JSAudit,
  1954. JS2Audit,
  1955. resetMergeCellsQd
  1956. };
  1957. };