index.tsx 52 KB

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