index.tsx 50 KB

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