index.tsx 68 KB

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