index.tsx 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458
  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, sys_arry_formulatype } from "@/config/index";
  5. import { CommonDynamicSelect } from "@/api/modules/common";
  6. import { GetComputeBednet } from "@/api/modules/quote";
  7. import { useUserStore } from "@/stores/modules/user";
  8. import MtrldefSelect from "@/views/system/selector/mtrldef/select.vue";
  9. import SpringSelect from "@/views/system/selector/spring/select.vue";
  10. // import { handleRowAccordingToProp } from "@/utils";
  11. import { ElButton, ElMessage, ElPopconfirm, ElMessageBox, ElNotification } from "element-plus";
  12. import { Minus, Plus, InfoFilled } from "@element-plus/icons-vue";
  13. import { DwnameEnum } from "@/enums/dwnameEnum";
  14. import { isArray } from "@/utils/is";
  15. import { calculateFormula, formulaPartsFormula, floatAdd, floatMul, formatFixedNumber, formatIntNumber } from "@/utils/index";
  16. import { cloneDeep, defaultsDeep } from "lodash-es";
  17. import { TYPE, useToast, POSITION } from "vue-toastification";
  18. import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
  19. import ToastHistoryPrice from "@/components/ToastWidget/HistoryPrice/index.vue";
  20. import { numCheck } from "@/utils/rules/index";
  21. interface defaultState {
  22. /**
  23. * @description 单据当前状态
  24. */
  25. orderStatus: string;
  26. LjDetailRef: any;
  27. initParams: any;
  28. initParamsMx: any;
  29. initParamsMxSpring: any;
  30. bednetMxData: any;
  31. bednetMxSpringData: any;
  32. vxeTableMxRef: any;
  33. vxeTableMxSpringRef: any;
  34. MtrldefDialogRef: any;
  35. MtrldefDialogProps: any;
  36. SpringDialogRef: any;
  37. SpringDialogProps: any;
  38. currentArea: any;
  39. AreaList: any;
  40. bednetVarList: any;
  41. AllFormulaRef: any;
  42. }
  43. /**
  44. * @description 床网明细表-属性默认值
  45. */
  46. const dw_bednet_define_add_mx = {
  47. pid: 1,
  48. bednetmxid: 0,
  49. bednetid: 0,
  50. spring_qty_width: 0,
  51. spring_qty_length: 0,
  52. bednet_height: 0,
  53. wire_mtrlid: 0,
  54. springid: 0,
  55. springname: 0,
  56. if_part: 0,
  57. if_15strip: 0,
  58. if_pocket_around: 0,
  59. pocket_around_springid: 0,
  60. pocket_around_springname: 0,
  61. pocket_around_row: 0,
  62. pocket_around_wire_price: 0,
  63. pocket_around_spring_cost: 0,
  64. pocket_around_fabrics_cost: 0,
  65. if_hard_around: 0,
  66. hard_around_springid: 0,
  67. hard_around_springname: 0,
  68. hard_around_row: 0,
  69. hard_around_wire_price: 0,
  70. hard_around_mtrl_cost: 0,
  71. hard_around_hr_cost: 0,
  72. fabrics1_mtrlid: 0,
  73. fabrics1_price: 0,
  74. fabrics1_mtrl_cost: 0,
  75. fabrics2_mtrlid: 0,
  76. fabrics2_price: 0,
  77. fabrics2_mtrl_cost: 0,
  78. if_side_iron: 0,
  79. side_iron_qty: 0,
  80. side_iron_mtrl_cost: 0,
  81. side_iron_hr_cost: 0,
  82. pocket_around_spring_cost_replace_formula: "",
  83. pocket_around_fabrics_cost_replace_formula: "",
  84. hard_around_mtrl_cost_replace_formula: "",
  85. hard_around_hr_cost_replace_formula: "",
  86. fabrics1_mtrl_cost_replace_formula: "",
  87. fabrics2_mtrl_cost_replace_formula: "",
  88. side_iron_mtrl_cost_replace_formula: "",
  89. side_iron_hr_cost_replace_formula: "",
  90. cnail_mtrl_cost_replace_formula: "",
  91. cnail_mtrl_cost: 0,
  92. cnail_hr_cost_replace_formula: "",
  93. cnail_hr_cost: 0,
  94. glue_mtrl_cost_replace_formula: "",
  95. glue_mtrl_cost: 0,
  96. spring_mtrl_cost: 0,
  97. spring_hr_cost: 0,
  98. spring_mtrl_cost_replace_formula: "",
  99. spring_hr_cost_replace_formula: "",
  100. spring_weight_replace_formula: ""
  101. };
  102. const dw_bednet_mx_spring = {
  103. bednetmx_partid: 0,
  104. bednetmxid: 0,
  105. springid: 0,
  106. springname: "",
  107. spring_qty_width: 0,
  108. spring_qty_length: 0,
  109. fabrics1_mtrl_cost: 0
  110. };
  111. const ifsaleout_default = {
  112. commission: 1.05,
  113. other_rate: 1.05,
  114. taxrate: 1.07,
  115. moneyrate: 6.7
  116. };
  117. export const useHooks = (t?: any) => {
  118. const state = reactive<defaultState>({
  119. orderStatus: "",
  120. LjDetailRef: null,
  121. vxeTableMxRef: null,
  122. vxeTableMxSpringRef: null,
  123. initParams: {},
  124. initParamsMx: {},
  125. initParamsMxSpring: {},
  126. bednetMxData: [],
  127. bednetMxSpringData: [],
  128. MtrldefDialogRef: null,
  129. MtrldefDialogProps: {},
  130. SpringDialogRef: null,
  131. SpringDialogProps: {},
  132. currentArea: null,
  133. AreaList: [],
  134. bednetVarList: [],
  135. AllFormulaRef: null
  136. });
  137. state.orderStatus = inject("orderStatus", "");
  138. const { userInfo } = useUserStore();
  139. const rModelSetFabrics2_mtrlid = (data: any) => {
  140. data.sponge_tc_mtrlid = 0;
  141. data.mtrl_sponge_tc_name = "";
  142. data.sponge_tc_thickness = 0;
  143. data.sponge_tc_height = 0;
  144. };
  145. /**
  146. * @description 填充海绵
  147. */
  148. const rModelSetSpring = (data: any, item: any) => {
  149. console.log("rModelSetSpring data, item :>> ", data, item);
  150. if (item) {
  151. data.springid = item.springid;
  152. data.springname = item.name;
  153. }
  154. };
  155. const rModelClearSpring = (data: any) => {
  156. data.springid = 0;
  157. data.springname = "";
  158. };
  159. /**
  160. * @description 弹窗模块:选择弹簧
  161. * @param data 当前数据
  162. * @param status 当前订单状态
  163. * @returns Promise
  164. */
  165. const fModelChoseSpring = (data: any, params: any, cb: any) => {
  166. return new Promise((resolve, reject) => {
  167. // if (!ALLOW_EDIT_STATE.includes(status)) return;
  168. let _params = {
  169. arg_search: params
  170. };
  171. state.SpringDialogProps = {
  172. onSubmit: (res: any) => {
  173. // submit
  174. console.log("openCustDialog res", res);
  175. nextTick(() => {
  176. cb(data, res.value[0]);
  177. resolve(1);
  178. });
  179. },
  180. onCancel: (error: any) => {
  181. // cancel 回调
  182. console.log("openCustDialog error", error);
  183. }
  184. };
  185. state.SpringDialogRef.show(_params);
  186. });
  187. };
  188. const rModelSetMtrlFelt = (data: any, item: any) => {
  189. if (item) {
  190. data.felt_mtrlid = item.mtrlid;
  191. data.felt_price = item.pricelistprice;
  192. data.mtrl_felt_name = item.mtrlname;
  193. data.felt_qty = 1;
  194. }
  195. };
  196. const rModelClearMtrlFelt = (data: any) => {
  197. data.felt_mtrlid = 0;
  198. data.felt_price = 0;
  199. data.mtrl_felt_name = "";
  200. data.felt_qty = 0;
  201. data.felt_dscrp = "";
  202. };
  203. const rModelSetMtrlFeltX = (data: any, item: any) => {
  204. if (item) {
  205. data.felt_x_mtrlid = item.mtrlid;
  206. data.mtrl_felt_x_name = item.mtrlname;
  207. data.felt_x_qty = 1;
  208. }
  209. };
  210. const rModelClearMtrlFeltX = (data: any) => {
  211. data.felt_x_mtrlid = 0;
  212. data.mtrl_felt_x_name = "";
  213. data.felt_x_qty = 0;
  214. };
  215. /**
  216. * @description 封边
  217. */
  218. const rModelSetMtrlEdge = (data: any, item: any) => {
  219. if (item) {
  220. data.edge_mtrlid = item.mtrlid;
  221. data.edge_price = item.pricelistprice;
  222. data.mtrl_edge_name = item.mtrlname;
  223. }
  224. };
  225. const rModelClearMtrlEdge = (data: any) => {
  226. data.edge_mtrlid = 0;
  227. data.edge_price = 0;
  228. data.mtrl_edge_name = "";
  229. data.edge_height = 0;
  230. };
  231. /**
  232. * @description 填充海绵
  233. */
  234. const rModelSetMtrlSpongeTc = (data: any, item: any) => {
  235. if (item) {
  236. data.sponge_tc_mtrlid = item.mtrlid;
  237. data.mtrl_sponge_tc_name = item.mtrlname;
  238. }
  239. };
  240. const rModelClearMtrlSpongeTc = (data: any) => {
  241. data.sponge_tc_mtrlid = 0;
  242. data.mtrl_sponge_tc_name = "";
  243. data.sponge_tc_thickness = 0;
  244. data.sponge_tc_height = 0;
  245. };
  246. const rModelSetMtrlFabrisc1 = (data: any, item: any) => {
  247. if (item) {
  248. data.fabrics1_mtrlid = item.mtrlid;
  249. data.fabrics1_price = item.pricelistprice;
  250. }
  251. };
  252. const rModelClearMtrlFabrisc1 = (data: any) => {
  253. data.fabrics1_mtrlid = 0;
  254. data.fabrics1_price = 0;
  255. };
  256. const rModelSetMtrlFabrisc2 = (data: any, item: any) => {
  257. if (item) {
  258. data.fabrics2_mtrlid = item.mtrlid;
  259. data.fabrics2_price = item.pricelistprice;
  260. }
  261. };
  262. const rModelClearMtrlFabrisc2 = (data: any) => {
  263. data.fabrics2_mtrlid = 0;
  264. data.fabrics2_price = 0;
  265. };
  266. const rModelSetHardAroundSpring = (data: any, item: any) => {
  267. if (item) {
  268. data.hard_around_springid = item.springid;
  269. data.hard_around_springname = item.name;
  270. }
  271. };
  272. const rModelClearHardAroundSpring = (data: any) => {
  273. data.hard_around_springid = 0;
  274. data.hard_around_springname = "";
  275. };
  276. const getPriceid = () => {
  277. let _deptid = state.LjDetailRef?._mainData?.deptid ?? 0;
  278. if (!_deptid) {
  279. ElMessage.warning("请先选择部门");
  280. state.LjDetailRef?.baseformRef.element.validateField("deptid");
  281. return 0;
  282. }
  283. let deptEnum = state.LjDetailRef.enumMap.get("deptid");
  284. let _pricelistid = 0;
  285. console.log("deptEnum :>> ", deptEnum);
  286. if (deptEnum) {
  287. let depItem = deptEnum.find((item: any) => item.value == _deptid);
  288. console.log("depItem :>> ", depItem);
  289. if (depItem) {
  290. _pricelistid = Number(depItem.pricelistid);
  291. }
  292. }
  293. return _pricelistid;
  294. };
  295. /**
  296. * @description 弹窗模块:选择物料
  297. * @param data 当前数据
  298. * @param status 当前订单状态
  299. * @returns Promise
  300. */
  301. const fModelChoseMtrl = (data: any, params: any, cb: any) => {
  302. return new Promise((resolve, reject) => {
  303. let _pricelistid = getPriceid();
  304. if (!_pricelistid) return false;
  305. // if (!ALLOW_EDIT_STATE.includes(status)) return;
  306. console.log("fModelChoseMtrl fModelChoseMtrl params :>> ", params);
  307. let _params = {
  308. keyword: "",
  309. arg_mtrltype: params.mtrltype,
  310. arg_pricelistid: _pricelistid
  311. };
  312. state.MtrldefDialogProps = {
  313. onSubmit: (res: any) => {
  314. // submit
  315. console.log("openCustDialog res", res);
  316. nextTick(() => {
  317. cb(data, res.value[0]);
  318. resolve(1);
  319. });
  320. },
  321. onCancel: (error: any) => {
  322. // cancel 回调
  323. console.log("openCustDialog error", error);
  324. }
  325. };
  326. state.MtrldefDialogRef.show(_params);
  327. });
  328. };
  329. /**
  330. * @description 数据赋值:包边海绵
  331. * @param data 当前数据
  332. * @param item 当前选择的数据
  333. */
  334. const rModelSetMtrlSponge = (data: any, item: any) => {
  335. console.log("rModelSetMtrlSponge data :>> ", data);
  336. console.log("rModelSetMtrlSponge item :>> ", item);
  337. if (item) {
  338. data.sponge_mtrlid = item.mtrlid;
  339. data.sponge_price = item.pricelistprice;
  340. data.mtrl_sponge_name = item.mtrlname;
  341. }
  342. console.log("rModelSetMtrlSponge after data :>> ", data);
  343. };
  344. const rModelClearMtrlSponge = (data: any) => {
  345. console.log("rModelClearMtrlSponge data :>> ", data);
  346. data.sponge_mtrlid = 0;
  347. data.sponge_price = 0;
  348. data.mtrl_sponge_name = "";
  349. data.sponge_thickness = 0;
  350. data.sponge_height = 0;
  351. };
  352. const wf_hide_dw2 = (bednetData: any, columns: any) => {
  353. let hFields = [];
  354. console.log('bednetData.typename != "袋装网" :>> ', bednetData.typename, bednetData.typename != "袋装网");
  355. // if (bednetData.typename != "袋装网") {
  356. if (Number(bednetData.bednettypeid) != 11) {
  357. hFields.push("if_part");
  358. // 圆网和拉丝网 没有 入袋无纺布和底面无纺布
  359. hFields.push("fabrics1_mtrlid");
  360. hFields.push("fabrics2_mtrlid");
  361. }
  362. //四周加硬
  363. if (Number(bednetData.if_hard_around) == 0) {
  364. hFields.push("if_hard_around");
  365. hFields.push("hard_around_wire_price");
  366. hFields.push("hard_around_mtrl_cost");
  367. hFields.push("hard_around_hr_cost");
  368. hFields.push("hard_around_springid");
  369. hFields.push("hard_around_row");
  370. }
  371. //四周口袋
  372. if (Number(bednetData.if_pocket_around) == 0) {
  373. hFields.push("pocket_around_springname");
  374. hFields.push("pocket_around_springid");
  375. hFields.push("pocket_around_row");
  376. hFields.push("pocket_around_wire_price");
  377. hFields.push("pocket_around_spring_cost");
  378. hFields.push("pocket_around_fabrics_cost");
  379. hFields.push("if_pocket_around");
  380. }
  381. // 边铁?
  382. if (Number(bednetData.if_side_iron) == 0) {
  383. hFields.push("if_side_iron");
  384. hFields.push("side_iron_qty");
  385. hFields.push("side_iron_mtrl_cost");
  386. hFields.push("side_iron_hr_cost");
  387. }
  388. return columns.map(t => {
  389. if (hFields.includes(t.field)) {
  390. return {
  391. ...t,
  392. limited: true
  393. };
  394. }
  395. return t;
  396. });
  397. };
  398. /**
  399. * @description 重载床网明细和多区明细,返回多区明细数据
  400. * @param bednetData
  401. * @returns
  402. */
  403. const reload_dw2 = async (bednetData: any, cb?: any) => {
  404. state.bednetMxData = [];
  405. state.bednetMxSpringData = [];
  406. let res = await getDataMxAdd(state.initParamsMx);
  407. console.log("getDataMxAdd res :>> ", res);
  408. let result = dataCallback(res);
  409. columnsMx.value = wf_hide_dw2(bednetData, result.tableinfo.columns).map(item => {
  410. let _default = columnsMx_default.value.find(t => t.field == item.field);
  411. if (_default) {
  412. item = defaultsDeep(item, _default);
  413. }
  414. return item;
  415. });
  416. console.log("reset columnsMx.value :>> ", columnsMx.value, result);
  417. // cb && cb(result);
  418. let res2 = await getDataMxSpring(state.initParamsMx);
  419. let result2 = dataCallback(res2);
  420. // columnsMxSpring.value = result.tableinfo.columns;
  421. columnsMxSpring.value = result2.tableinfo.columns.map(item => {
  422. let _default = columnsMxSpring_default.value.find(t => t.field == item.field);
  423. if (_default) {
  424. item = defaultsDeep(item, _default);
  425. }
  426. return item;
  427. });
  428. console.log("reload_dw2 columnsMxSpring.value :>> ", columnsMxSpring.value, result);
  429. cb && cb({ mx: result, spring: result2 });
  430. };
  431. /**
  432. * @description 变更床垫分类时,重载明细数据 dw_1 itemchange
  433. * @author w_mattress_add dw_1 itemchange
  434. */
  435. const wf_b_bednet_type_ch = async (val: any) => {
  436. console.log("wf_b_bednet_type_ch state.LjDetailRef._mainData val:>> ", val, state.LjDetailRef, state.orderStatus);
  437. const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
  438. // let mainData = state.orderStatus == "new" ? initParam : _mainData;
  439. console.log("mainData :>> ", _mainData);
  440. if (!Number(_mainData.deptid)) {
  441. ElMessage.warning("请先选择部门");
  442. console.log("baseformRef.element :>> ", baseformRef.element);
  443. baseformRef.element.validateField("deptid");
  444. _mainData.bednettypeid = "";
  445. return;
  446. }
  447. let _params = {
  448. dsname: "_Mapper_bednet_type_define",
  449. queryparams: {
  450. arg_bednettypeid: Number(val)
  451. }
  452. };
  453. let res = await CommonDynamicSelect(_params);
  454. let rBednetType: any = {};
  455. if (res?.datatable?.length > 0) {
  456. rBednetType = res?.datatable[0];
  457. }
  458. _mainData.bednettypeid = rBednetType.bednettypeid;
  459. _mainData.snake_wire_diameter = rBednetType.snake_wire_diameter;
  460. _mainData.snake_wire_mtrl_formula = rBednetType.snake_wire_mtrl_formula;
  461. _mainData.pocket_around_spring_formula = rBednetType.pocket_around_spring_formula;
  462. _mainData.pocket_around_fabrics_formula = rBednetType.pocket_around_fabrics_formula;
  463. _mainData.hard_around_mtrl_formula = rBednetType.hard_around_mtrl_formula;
  464. _mainData.hard_around_hr_formula = rBednetType.hard_around_hr_formula;
  465. _mainData.glue_mtrl_formula = rBednetType.glue_mtrl_formula;
  466. _mainData.if_side_iron = rBednetType.if_side_iron;
  467. _mainData.side_iron_mtrl_formula = rBednetType.side_iron_mtrl_formula;
  468. _mainData.side_iron_hr_formula = rBednetType.side_iron_hr_formula;
  469. _mainData.cnail_mtrl_formula = rBednetType.cnail_mtrl_formula;
  470. _mainData.cnail_hr_formula = rBednetType.cnail_hr_formula;
  471. _mainData.if_sponge_drilling = rBednetType.if_sponge_drilling;
  472. _mainData.sponge_mtrl_formula = rBednetType.sponge_mtrl_formula;
  473. _mainData.sponge_hr_formula = rBednetType.sponge_hr_formula;
  474. _mainData.edge_mtrl_formula = rBednetType.edge_mtrl_formula;
  475. _mainData.edge_hr_formula = rBednetType.edge_hr_formula;
  476. _mainData.fork_mtrl_formula = rBednetType.fork_mtrl_formula;
  477. _mainData.fork_hr_formula = rBednetType.fork_hr_formula;
  478. _mainData.if_rsorwa = rBednetType.if_rsorwa;
  479. _mainData.rsorwa_mtrl_formula = rBednetType.rsorwa_mtrl_formula;
  480. _mainData.rsorwa_hr_formula = rBednetType.rsorwa_hr_formula;
  481. _mainData.sponge_drilling_hr_formula = rBednetType.sponge_drilling_hr_formula;
  482. _mainData.spring_mtrl_formula = rBednetType.spring_mtrl_formula;
  483. _mainData.spring_hr_formula = rBednetType.spring_hr_formula;
  484. _mainData.fabrics1_mtrl_formula = rBednetType.fabrics1_mtrl_formula;
  485. _mainData.fabrics2_mtrl_formula = rBednetType.fabrics2_mtrl_formula;
  486. _mainData.felt_mtrl_formula = rBednetType.felt_mtrl_formula;
  487. _mainData.felt_hr_formula = rBednetType.felt_hr_formula;
  488. _mainData.packet_mtrl_formula = rBednetType.packet_mtrl_formula;
  489. _mainData.packet_hr_formula = rBednetType.packet_hr_formula;
  490. _mainData.sponge_mtrl_tc_formula = rBednetType.sponge_mtrl_tc_formula;
  491. _mainData.spring_weight_formula = rBednetType.spring_weight_formula;
  492. _mainData.side_iron_weight_formula = rBednetType.side_iron_weight_formula;
  493. _mainData.hard_around_weight_formula = rBednetType.hard_around_weight_formula;
  494. _mainData.fabrics1_weight_formula = rBednetType.fabrics1_weight_formula;
  495. _mainData.fabrics2_weight_formula = rBednetType.fabrics2_weight_formula;
  496. _mainData.felt_weight_formula = rBednetType.felt_weight_formula;
  497. _mainData.cnail_weight_formula = rBednetType.cnail_weight_formula;
  498. _mainData.sponge_weight_formula = rBednetType.sponge_weight_formula;
  499. _mainData.sponge_weight_tc_formula = rBednetType.sponge_weight_tc_formula;
  500. _mainData.edge_weight_formula = rBednetType.edge_weight_formula;
  501. _mainData.fork_weight_formula = rBednetType.fork_weight_formula;
  502. reload_dw2(rBednetType, () => {
  503. state.bednetMxData = [cloneDeep(dw_bednet_define_add_mx)];
  504. });
  505. nextTick(() => {
  506. console.log("wf_b_bednet_type_ch state.vxeTableMxRef :>> ", state.vxeTableMxRef);
  507. state.vxeTableMxRef && state.vxeTableMxRef.refresh();
  508. });
  509. };
  510. const getData = (params: any) => {
  511. console.log("getData params :>> ", params);
  512. let newParams: any = {};
  513. params.pageNum && (newParams.pageindex = params.pageNum);
  514. params.pageSize && (newParams.pagesize = params.pageSize);
  515. delete params.pageNum;
  516. delete params.pageSize;
  517. newParams.queryParams = params;
  518. console.log("params :>> ", params);
  519. newParams.dsname = "web_bednet_define";
  520. return CommonDynamicSelect(newParams, DwnameEnum.bednetQuote);
  521. // return [];
  522. };
  523. /**
  524. * @description 获取明细数据
  525. * @param params
  526. * @returns
  527. */
  528. const getDataMx = (params: any) => {
  529. console.log("getData beatad params :>> ", params);
  530. let newParams: any = {};
  531. params.pageNum && (newParams.pageindex = params.pageNum);
  532. params.pageSize && (newParams.pagesize = params.pageSize);
  533. delete params.pageNum;
  534. delete params.pageSize;
  535. newParams.queryParams = params;
  536. console.log("params :>> ", params);
  537. newParams.dsname = "web_bednet_mx";
  538. return CommonDynamicSelect(newParams, DwnameEnum.bednetQuoteMx);
  539. };
  540. /**
  541. * @description 获取弹簧明细
  542. * @param params
  543. * @returns
  544. */
  545. const getDataMxSpring = (params: any) => {
  546. console.log("getData params :>> ", params);
  547. let newParams: any = {};
  548. params.pageNum && (newParams.pageindex = params.pageNum);
  549. params.pageSize && (newParams.pagesize = params.pageSize);
  550. delete params.pageNum;
  551. delete params.pageSize;
  552. newParams.queryParams = params;
  553. console.log("params :>> ", params);
  554. newParams.dsname = "web_bednet_mx_spring";
  555. return CommonDynamicSelect(newParams, DwnameEnum.bednetQuoteMxSpring);
  556. };
  557. const getDataMxAdd = async (params: any) => {
  558. console.log("getData params :>> ", params);
  559. let newParams: any = {};
  560. params.pageNum && (newParams.pageindex = params.pageNum);
  561. params.pageSize && (newParams.pagesize = params.pageSize);
  562. delete params.pageNum;
  563. delete params.pageSize;
  564. newParams.queryParams = params;
  565. console.log("params :>> ", params);
  566. newParams.dsname = "web_bednet_mx_add";
  567. return await CommonDynamicSelect(newParams, DwnameEnum.bednetQuoteMx);
  568. };
  569. const dataCallback = (data: any) => {
  570. return {
  571. list: data.datatable,
  572. tableinfo: data.tableinfo,
  573. total: data.totalcnt,
  574. pageNum: data.pageindex,
  575. pageSize: data.pagesize
  576. };
  577. };
  578. const handleBlur = (value: any, data: any, field: string) => {
  579. //保留小数点和-号
  580. value = (value + "").replace(/[^-\d.]/g, "");
  581. console.log(value);
  582. // 保留整数部分
  583. value = value == "" ? 0 : parseInt(value, 10).toString();
  584. data[field] = value;
  585. };
  586. const columns: ColumnProps<any>[] = [
  587. { type: "checkbox", width: 50, fixed: "left" },
  588. { title: "#", field: "pid", fixed: "left", width: 80 },
  589. {
  590. title: "审核",
  591. field: "flag",
  592. basicinfo: {
  593. props: {
  594. trueValue: "1",
  595. falseValue: "0"
  596. }
  597. }
  598. },
  599. {
  600. field: "deptid",
  601. title: "部门",
  602. search: {
  603. el: "select",
  604. key: "arg_deptid",
  605. props: {
  606. filterable: true
  607. },
  608. order: 1
  609. },
  610. basicinfo: {
  611. el: "select",
  612. editable: ALLOW_EDIT_STATE,
  613. rules: [{ required: true, message: "请先选择部门", trigger: "change" }],
  614. props: {
  615. filterable: true,
  616. clearable: false
  617. },
  618. order: 1,
  619. group: "单据信息"
  620. }
  621. },
  622. {
  623. title: "床网编码",
  624. field: "bednetcode",
  625. table: "u_bednet_define"
  626. },
  627. {
  628. title: "床网名称",
  629. field: "bednetname",
  630. table: "u_bednet_define",
  631. search: {
  632. el: "input",
  633. titleKey: "keyword",
  634. key: "arg_search",
  635. props: {
  636. filterable: true
  637. },
  638. order: 2
  639. },
  640. basicinfo: {
  641. el: "input",
  642. editable: ALLOW_EDIT_STATE
  643. }
  644. },
  645. {
  646. title: "部门售价",
  647. field: "dept_cost"
  648. },
  649. {
  650. title: "外币价",
  651. field: "foreign_cost"
  652. },
  653. {
  654. title: "床网类别",
  655. field: "bednettypeid",
  656. basicinfo: {
  657. el: "select",
  658. editable: ALLOW_EDIT_STATE,
  659. rules: [{ required: true, message: "请先选择床网类别", trigger: "change" }],
  660. props: {
  661. clearable: false,
  662. filterable: true,
  663. onChange: val => wf_b_bednet_type_ch(val)
  664. }
  665. }
  666. },
  667. {
  668. title: "床垫宽/CM",
  669. field: "mattress_width",
  670. basicinfo: {
  671. el: "input",
  672. editable: ALLOW_EDIT_STATE,
  673. rules: [{ validator: numCheck, trigger: "blur" }]
  674. }
  675. },
  676. {
  677. title: "床垫长/CM",
  678. field: "mattress_length",
  679. basicinfo: {
  680. el: "input",
  681. editable: ALLOW_EDIT_STATE,
  682. rules: [{ validator: numCheck, trigger: "blur" }]
  683. }
  684. },
  685. {
  686. title: "床垫高/CM",
  687. field: "mattress_height",
  688. basicinfo: {
  689. el: "input",
  690. editable: ALLOW_EDIT_STATE,
  691. rules: [{ validator: numCheck, trigger: "blur" }]
  692. }
  693. },
  694. {
  695. title: "双网?",
  696. field: "if_doublenet"
  697. },
  698. {
  699. title: "双簧?",
  700. field: "if_doublespring",
  701. basicinfo: {
  702. labelHidden: true,
  703. render: (scope: any) => {
  704. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  705. return (
  706. <>
  707. <el-checkbox
  708. v-model={scope.searchParam.if_doublespring}
  709. disabled={_disabled}
  710. true-value="1"
  711. false-value="0"
  712. label="双簧"
  713. class="mr-8"
  714. />
  715. <el-checkbox
  716. v-model={scope.searchParam.if_rsorwa}
  717. disabled={_disabled}
  718. true-value="1"
  719. false-value="0"
  720. label="胶条 包角"
  721. class="mr-8"
  722. />
  723. <el-checkbox
  724. v-model={scope.searchParam.if_sponge_drilling}
  725. disabled={_disabled}
  726. true-value="1"
  727. false-value="0"
  728. label="海绵打孔"
  729. />
  730. <el-checkbox v-model={scope.searchParam.iffork} disabled={_disabled} true-value="1" false-value="0" label="弹叉" />
  731. <el-checkbox v-model={scope.searchParam.if_jb} disabled={_disabled} true-value="1" false-value="0" label="卷包" />
  732. </>
  733. );
  734. }
  735. }
  736. },
  737. {
  738. title: "蛇线线径MM",
  739. field: "snake_wire_diameter",
  740. basicinfo: {
  741. el: "input",
  742. rules: [{ validator: numCheck, trigger: "blur" }],
  743. editable: (scope: any) => {
  744. if (Number(scope.searchParam.bednettypeid) > 11) {
  745. return true;
  746. }
  747. return false;
  748. },
  749. editvisible: (scope: any) => {
  750. if (Number(scope.searchParam.bednettypeid) > 11) {
  751. return true;
  752. }
  753. return false;
  754. }
  755. }
  756. },
  757. {
  758. title: "边铁?",
  759. field: "if_side_iron"
  760. },
  761. {
  762. title: "边铁损耗率",
  763. field: "side_iron_lossrate"
  764. },
  765. {
  766. title: "海绵包边物料",
  767. field: "mtrl_sponge_name",
  768. basicinfo: {
  769. editable: ALLOW_EDIT_STATE,
  770. render: (scope: any) => {
  771. const { column, row, status } = scope;
  772. let _label = column.title;
  773. return (
  774. <>
  775. <MtrldefSelect
  776. value={scope.searchParam.sponge_mtrlid}
  777. pricelistidfn={() => getPriceid()}
  778. mtrltype={1}
  779. disabled={!ALLOW_EDIT_STATE.includes(status)}
  780. clearable
  781. placeholder={_label}
  782. onOpenModal={() => fModelChoseMtrl(scope.searchParam, { mtrltype: 1 }, rModelSetMtrlSponge)}
  783. onSelect={(val: any) => rModelSetMtrlSponge(scope.searchParam, val)}
  784. onClear={() => rModelClearMtrlSponge(scope.searchParam)}
  785. >
  786. {{
  787. label: () => scope.searchParam.mtrl_sponge_name
  788. }}
  789. </MtrldefSelect>
  790. </>
  791. );
  792. }
  793. }
  794. },
  795. {
  796. title: "海绵厚度CM",
  797. field: "sponge_thickness",
  798. basicinfo: {
  799. el: "input",
  800. editable: ALLOW_EDIT_STATE,
  801. rules: [{ validator: numCheck, trigger: "blur" }]
  802. }
  803. },
  804. {
  805. title: "海绵高CM",
  806. field: "sponge_height",
  807. basicinfo: {
  808. el: "input",
  809. editable: ALLOW_EDIT_STATE,
  810. rules: [{ validator: numCheck, trigger: "blur" }]
  811. }
  812. },
  813. {
  814. title: "填充海绵物料",
  815. field: "mtrl_sponge_tc_name",
  816. basicinfo: {
  817. editable: ALLOW_EDIT_STATE,
  818. render: (scope: any) => {
  819. const { column, row, status } = scope;
  820. let _label = column.title;
  821. return (
  822. <>
  823. <MtrldefSelect
  824. value={scope.searchParam.sponge_tc_mtrlid}
  825. pricelistidfn={() => getPriceid()}
  826. mtrltype={1}
  827. disabled={!ALLOW_EDIT_STATE.includes(status)}
  828. clearable
  829. placeholder={_label}
  830. onOpenModal={() => fModelChoseMtrl(scope.searchParam, { mtrltype: 1 }, rModelSetMtrlSpongeTc)}
  831. onSelect={(val: any) => rModelSetMtrlSpongeTc(scope.searchParam, val)}
  832. onClear={() => rModelClearMtrlSpongeTc(scope.searchParam)}
  833. >
  834. {{
  835. label: () => scope.searchParam.mtrl_sponge_tc_name
  836. }}
  837. </MtrldefSelect>
  838. </>
  839. );
  840. }
  841. }
  842. },
  843. {
  844. title: "填充海绵厚度CM",
  845. field: "sponge_tc_thickness",
  846. basicinfo: {
  847. el: "input",
  848. editable: ALLOW_EDIT_STATE,
  849. rules: [{ validator: numCheck, trigger: "blur" }]
  850. }
  851. },
  852. {
  853. title: "填充海绵高CM",
  854. field: "sponge_tc_height",
  855. basicinfo: {
  856. el: "input",
  857. editable: ALLOW_EDIT_STATE,
  858. rules: [{ validator: numCheck, trigger: "blur" }]
  859. }
  860. },
  861. {
  862. title: "封边物料",
  863. field: "mtrl_edge_name",
  864. basicinfo: {
  865. editable: ALLOW_EDIT_STATE,
  866. render: (scope: any) => {
  867. const { column, row, status } = scope;
  868. let _label = column.title;
  869. return (
  870. <>
  871. <MtrldefSelect
  872. value={scope.searchParam.edge_mtrlid}
  873. pricelistidfn={() => getPriceid()}
  874. mtrltype={7}
  875. disabled={!ALLOW_EDIT_STATE.includes(status)}
  876. clearable
  877. placeholder={_label}
  878. onOpenModal={() => fModelChoseMtrl(scope.searchParam, { mtrltype: 7 }, rModelSetMtrlEdge)}
  879. onSelect={(val: any) => rModelSetMtrlEdge(scope.searchParam, val)}
  880. onClear={() => rModelClearMtrlEdge(scope.searchParam)}
  881. >
  882. {{
  883. label: () => scope.searchParam.mtrl_edge_name
  884. }}
  885. </MtrldefSelect>
  886. </>
  887. );
  888. }
  889. }
  890. },
  891. {
  892. title: "封边高",
  893. field: "edge_height",
  894. basicinfo: {
  895. el: "input",
  896. editable: ALLOW_EDIT_STATE,
  897. rules: [{ validator: numCheck, trigger: "blur" }]
  898. }
  899. },
  900. {
  901. title: "上垫层材料",
  902. field: "mtrl_felt_name",
  903. basicinfo: {
  904. editable: ALLOW_EDIT_STATE,
  905. render: (scope: any) => {
  906. const { column, row, status } = scope;
  907. let _label = column.title;
  908. return (
  909. <>
  910. <MtrldefSelect
  911. value={scope.searchParam.felt_mtrlid}
  912. pricelistidfn={() => getPriceid()}
  913. mtrltype={7}
  914. disabled={!ALLOW_EDIT_STATE.includes(status)}
  915. clearable
  916. placeholder={_label}
  917. onOpenModal={() => fModelChoseMtrl(scope.searchParam, { mtrltype: 7 }, rModelSetMtrlFelt)}
  918. onSelect={(val: any) => rModelSetMtrlFelt(scope.searchParam, val)}
  919. onClear={() => rModelClearMtrlFelt(scope.searchParam)}
  920. >
  921. {{
  922. label: () => scope.searchParam.mtrl_felt_name
  923. }}
  924. </MtrldefSelect>
  925. </>
  926. );
  927. }
  928. }
  929. },
  930. {
  931. field: "felt_qty",
  932. basicinfo: {
  933. el: "input",
  934. editable: ALLOW_EDIT_STATE,
  935. rules: [{ validator: numCheck, trigger: "blur" }]
  936. }
  937. },
  938. {
  939. title: "下垫层材料",
  940. field: "mtrl_felt_x_name",
  941. basicinfo: {
  942. editable: ALLOW_EDIT_STATE,
  943. render: (scope: any) => {
  944. const { column, row, status } = scope;
  945. let _label = column.title;
  946. return (
  947. <>
  948. <MtrldefSelect
  949. value={scope.searchParam.felt_x_mtrlid}
  950. pricelistidfn={() => getPriceid()}
  951. mtrltype={7}
  952. disabled={!ALLOW_EDIT_STATE.includes(status)}
  953. clearable
  954. placeholder={_label}
  955. onOpenModal={() => fModelChoseMtrl(scope.searchParam, { mtrltype: 7 }, rModelSetMtrlFeltX)}
  956. onSelect={(val: any) => rModelSetMtrlFeltX(scope.searchParam, val)}
  957. onClear={() => rModelClearMtrlFeltX(scope.searchParam)}
  958. >
  959. {{
  960. label: () => scope.searchParam.mtrl_felt_x_name
  961. }}
  962. </MtrldefSelect>
  963. </>
  964. );
  965. }
  966. }
  967. },
  968. {
  969. field: "felt_x_qty",
  970. basicinfo: {
  971. el: "input",
  972. editable: ALLOW_EDIT_STATE,
  973. rules: [{ validator: numCheck, trigger: "blur" }]
  974. }
  975. },
  976. {
  977. title: "弹叉数量",
  978. field: "fork_qty",
  979. basicinfo: {
  980. el: "input",
  981. rules: [{ validator: numCheck, trigger: "blur" }],
  982. editable: (scope: any) => {
  983. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.iffork)) {
  984. return true;
  985. }
  986. return false;
  987. },
  988. editvisible: (scope: any) => {
  989. if (Number(scope.searchParam.iffork)) {
  990. return true;
  991. }
  992. return false;
  993. }
  994. }
  995. },
  996. {
  997. title: "做法",
  998. field: "felt_dscrp",
  999. basicinfo: {
  1000. el: "input",
  1001. editable: ALLOW_EDIT_STATE,
  1002. props: { type: "textarea", rows: 2 }
  1003. }
  1004. },
  1005. {
  1006. title: "胶条?包角?",
  1007. field: "if_rsorwa"
  1008. },
  1009. {
  1010. title: "海绵打孔?",
  1011. field: "if_sponge_drilling"
  1012. },
  1013. {
  1014. title: "登记人",
  1015. field: "createby"
  1016. },
  1017. {
  1018. title: "登记时间",
  1019. field: "createtime"
  1020. },
  1021. {
  1022. title: "总重量",
  1023. field: "sum_weight"
  1024. },
  1025. {
  1026. title: "计划价",
  1027. field: "planprice"
  1028. },
  1029. {
  1030. title: "Bednetid",
  1031. field: "bednetid"
  1032. },
  1033. {
  1034. title: "床网独立销售",
  1035. field: "ifsaleout",
  1036. basicinfo: {
  1037. el: "checkbox",
  1038. editable: ALLOW_EDIT_STATE,
  1039. props: {
  1040. trueValue: "1",
  1041. falseValue: "0"
  1042. }
  1043. }
  1044. },
  1045. {
  1046. title: "包装",
  1047. field: "packtype",
  1048. // enum: [
  1049. // {
  1050. // label: "压包",
  1051. // value: "压包"
  1052. // },
  1053. // {
  1054. // label: "卷包",
  1055. // value: "卷包"
  1056. // },
  1057. // {
  1058. // label: "不压不卷",
  1059. // value: "不压不卷"
  1060. // },
  1061. // {
  1062. // label: "裸包装",
  1063. // value: "裸包装"
  1064. // }
  1065. // ],
  1066. basicinfo: {
  1067. el: "select",
  1068. editable: (scope: any) => {
  1069. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1070. return true;
  1071. }
  1072. return false;
  1073. },
  1074. editvisible: (scope: any) => {
  1075. if (Number(scope.searchParam.ifsaleout)) {
  1076. return true;
  1077. }
  1078. return false;
  1079. },
  1080. render: scope => {
  1081. return (
  1082. <>
  1083. <div class="flx w-full">
  1084. <el-select
  1085. v-model={scope.searchParam.packtype}
  1086. placeholder="方式"
  1087. clearable
  1088. disabled={!ALLOW_EDIT_STATE.includes(scope.status)}
  1089. >
  1090. <el-option label="压包" value="压包" />
  1091. <el-option label="卷包" value="卷包" />
  1092. <el-option label="不压不卷" value="不压不卷" />
  1093. <el-option label="裸包装" value="裸包装" />
  1094. </el-select>
  1095. <el-select
  1096. v-model={scope.searchParam.packmtrl}
  1097. class="ml-4"
  1098. placeholder="材料"
  1099. clearable
  1100. disabled={!ALLOW_EDIT_STATE.includes(scope.status)}
  1101. >
  1102. <el-option label="编辑袋" value="编辑袋" />
  1103. <el-option label="牛皮纸" value="牛皮纸" />
  1104. <el-option label="胶袋" value="胶袋" />
  1105. <el-option label="牛皮纸袋" value="牛皮纸袋" />
  1106. </el-select>
  1107. </div>
  1108. </>
  1109. );
  1110. }
  1111. }
  1112. },
  1113. {
  1114. title: "包装数量",
  1115. field: "packqty",
  1116. basicinfo: {
  1117. el: "input",
  1118. rules: [{ validator: numCheck, trigger: "blur" }],
  1119. editable: (scope: any) => {
  1120. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1121. return true;
  1122. }
  1123. return false;
  1124. },
  1125. editvisible: (scope: any) => {
  1126. if (Number(scope.searchParam.ifsaleout)) {
  1127. return true;
  1128. }
  1129. return false;
  1130. }
  1131. }
  1132. },
  1133. // {
  1134. // title: "包装材料",
  1135. // field: "packmtrl",
  1136. // enum: [
  1137. // {
  1138. // label: "编辑袋",
  1139. // value: "编辑袋"
  1140. // },
  1141. // {
  1142. // label: "牛皮纸",
  1143. // value: "牛皮纸"
  1144. // },
  1145. // {
  1146. // label: "胶袋",
  1147. // value: "胶袋"
  1148. // },
  1149. // {
  1150. // label: "牛皮纸袋",
  1151. // value: "牛皮纸袋"
  1152. // }
  1153. // ],
  1154. // basicinfo: {
  1155. // el: "select",
  1156. // editable: (scope: any) => {
  1157. // if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1158. // return true;
  1159. // }
  1160. // return false;
  1161. // },
  1162. // editvisible: (scope: any) => {
  1163. // if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1164. // return true;
  1165. // }
  1166. // return false;
  1167. // }
  1168. // }
  1169. // },
  1170. {
  1171. title: "运输方式",
  1172. field: "transport_type",
  1173. enum: [
  1174. {
  1175. label: "装车送货(装柜)",
  1176. value: "装车送货(装柜)"
  1177. },
  1178. {
  1179. label: "装车送货(送货运站)",
  1180. value: "装车送货(送货运站)"
  1181. }
  1182. ],
  1183. basicinfo: {
  1184. el: "select",
  1185. editable: (scope: any) => {
  1186. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1187. return true;
  1188. }
  1189. return false;
  1190. },
  1191. editvisible: (scope: any) => {
  1192. if (Number(scope.searchParam.ifsaleout)) {
  1193. return true;
  1194. }
  1195. return false;
  1196. }
  1197. }
  1198. },
  1199. {
  1200. title: "佣金点数",
  1201. field: "commission",
  1202. basicinfo: {
  1203. el: "input",
  1204. props: {
  1205. placeholder: ifsaleout_default.commission + ""
  1206. },
  1207. rules: [{ validator: numCheck, trigger: "blur" }],
  1208. editable: (scope: any) => {
  1209. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1210. return true;
  1211. }
  1212. return false;
  1213. },
  1214. editvisible: (scope: any) => {
  1215. if (Number(scope.searchParam.ifsaleout)) {
  1216. return true;
  1217. }
  1218. return false;
  1219. }
  1220. }
  1221. },
  1222. {
  1223. title: "额外点数",
  1224. field: "other_rate",
  1225. basicinfo: {
  1226. el: "input",
  1227. props: {
  1228. placeholder: ifsaleout_default.other_rate + ""
  1229. },
  1230. rules: [{ validator: numCheck, trigger: "blur" }],
  1231. editable: (scope: any) => {
  1232. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1233. return true;
  1234. }
  1235. return false;
  1236. },
  1237. editvisible: (scope: any) => {
  1238. if (Number(scope.searchParam.ifsaleout)) {
  1239. return true;
  1240. }
  1241. return false;
  1242. }
  1243. }
  1244. },
  1245. {
  1246. title: "FOB",
  1247. field: "fob",
  1248. basicinfo: {
  1249. el: "input",
  1250. props: {
  1251. slots: {
  1252. suffix: () => {
  1253. return <>元</>;
  1254. },
  1255. append: () => {
  1256. return <>元</>;
  1257. }
  1258. }
  1259. },
  1260. rules: [{ validator: numCheck, trigger: "blur" }],
  1261. editable: (scope: any) => {
  1262. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1263. return true;
  1264. }
  1265. return false;
  1266. },
  1267. editvisible: (scope: any) => {
  1268. if (Number(scope.searchParam.ifsaleout)) {
  1269. return true;
  1270. }
  1271. return false;
  1272. }
  1273. }
  1274. },
  1275. {
  1276. title: "税率",
  1277. field: "taxrate",
  1278. basicinfo: {
  1279. el: "input",
  1280. props: {
  1281. placeholder: ifsaleout_default.taxrate + ""
  1282. },
  1283. rules: [{ validator: numCheck, trigger: "blur" }],
  1284. editable: (scope: any) => {
  1285. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1286. return true;
  1287. }
  1288. return false;
  1289. },
  1290. editvisible: (scope: any) => {
  1291. if (Number(scope.searchParam.ifsaleout)) {
  1292. return true;
  1293. }
  1294. return false;
  1295. }
  1296. }
  1297. },
  1298. {
  1299. title: "额外费用",
  1300. field: "extras_cost",
  1301. basicinfo: {
  1302. el: "input",
  1303. rules: [{ validator: numCheck, trigger: "blur" }],
  1304. editable: (scope: any) => {
  1305. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1306. return true;
  1307. }
  1308. return false;
  1309. },
  1310. editvisible: (scope: any) => {
  1311. if (Number(scope.searchParam.ifsaleout)) {
  1312. return true;
  1313. }
  1314. return false;
  1315. }
  1316. }
  1317. },
  1318. {
  1319. title: "汇率",
  1320. field: "moneyrate",
  1321. basicinfo: {
  1322. el: "input",
  1323. props: {
  1324. placeholder: ifsaleout_default.moneyrate + ""
  1325. },
  1326. rules: [{ validator: numCheck, trigger: "blur" }],
  1327. editable: (scope: any) => {
  1328. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1329. return true;
  1330. }
  1331. return false;
  1332. },
  1333. editvisible: (scope: any) => {
  1334. if (Number(scope.searchParam.ifsaleout)) {
  1335. return true;
  1336. }
  1337. return false;
  1338. }
  1339. }
  1340. },
  1341. {
  1342. title: "额外费用备注",
  1343. field: "extras_cost_dscrp",
  1344. basicinfo: {
  1345. el: "input",
  1346. span: 2,
  1347. props: { type: "textarea", rows: 2 },
  1348. editable: (scope: any) => {
  1349. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.ifsaleout)) {
  1350. return true;
  1351. }
  1352. return false;
  1353. },
  1354. editvisible: (scope: any) => {
  1355. if (Number(scope.searchParam.ifsaleout)) {
  1356. return true;
  1357. }
  1358. return false;
  1359. }
  1360. }
  1361. },
  1362. {
  1363. field: "duo_qv_str",
  1364. basicinfo: {
  1365. el: "select",
  1366. editable: (scope: any) => {
  1367. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.bednettypeid) == 11) {
  1368. return true;
  1369. }
  1370. return false;
  1371. },
  1372. editvisible: (scope: any) => {
  1373. if (Number(scope.searchParam.bednettypeid) == 11) {
  1374. return true;
  1375. }
  1376. return false;
  1377. },
  1378. render: (scope: any) => {
  1379. console.log("duo_qv_str scope :>> ", scope);
  1380. let optionRender = [];
  1381. scope.enum.map(item => {
  1382. optionRender.push(<el-option label={item.label} value={item.value} />);
  1383. });
  1384. return (
  1385. <>
  1386. <el-select
  1387. v-model={scope.searchParam.duo_qv_str}
  1388. disabled={!ALLOW_EDIT_STATE.includes(scope.status)}
  1389. clearable
  1390. onChange={val => handelChangeDuoqv(val, scope.enum)}
  1391. >
  1392. {optionRender}
  1393. </el-select>
  1394. </>
  1395. );
  1396. }
  1397. }
  1398. }
  1399. ];
  1400. /**
  1401. * @description 多区select,控制多区明细条数
  1402. * @param val
  1403. */
  1404. const handelChangeDuoqv = (val: any, enumArr: any) => {
  1405. console.log("duo_qv_str val :>> ", val);
  1406. let item = enumArr.find((item: any) => item.value == val);
  1407. let arr = getDuoquVal(item);
  1408. console.log("state.vxeTableMxRef :>> ", state.vxeTableMxRef);
  1409. // console.log("state.vxeTableMxRef.element.get :>> ", state.vxeTableMxRef.element.getTableData());
  1410. // let { fullData } = state.vxeTableMxRef.element.getTableData();
  1411. let num = arr.length;
  1412. state.bednetMxData[0].if_part = Boolean(num > 1);
  1413. console.log("fullData bednetMxData :>> ", state.bednetMxData);
  1414. if (num > 1) {
  1415. state.bednetMxData[0].springid = 0;
  1416. state.bednetMxData[0].springname = "";
  1417. nextTick(() => {
  1418. setTimeout(async () => {
  1419. console.log(
  1420. "state.vxeTableMxSpringRef, state.vxeTableMxSpringRef.getTableData() :>> ",
  1421. state.vxeTableMxSpringRef
  1422. // state.vxeTableMxSpringRef.getTableData()
  1423. );
  1424. const $table = state.vxeTableMxSpringRef.element;
  1425. if ($table) {
  1426. const { fullData: springData } = $table.getTableData();
  1427. console.log("handleAreaChange fullData :>> ", springData, num > 0 && springData.length < num);
  1428. if (springData.length < num) {
  1429. let arr = [];
  1430. // let sum = Number(fullData[0].spring_qty_length);
  1431. // let lengthValSum = 0;
  1432. for (let i = 0; i < num - springData.length; i++) {
  1433. // let lengthVal = 0;
  1434. // if (i < num - springData.length - 1) {
  1435. // if (sum > 0) {
  1436. // lengthVal = (areaArr[i] / total) * sum;
  1437. // lengthValSum += lengthVal;
  1438. // }
  1439. // } else {
  1440. // lengthVal = sum - lengthValSum;
  1441. // }
  1442. // console.log("lengthVal :>> ", lengthVal);
  1443. let _data = {
  1444. ...dw_bednet_mx_spring,
  1445. spring_qty_width: Number(state.bednetMxData[0].spring_qty_width),
  1446. spring_qty_length: 0
  1447. };
  1448. arr.push(_data);
  1449. }
  1450. console.log("$table :>> ", $table, arr);
  1451. await $table.insertAt(arr, -1);
  1452. } else if (springData.length > num) {
  1453. let arrs = springData.filter((item, index) => index + 1 > num);
  1454. await $table.remove(arrs);
  1455. }
  1456. setMxSpringLength();
  1457. }
  1458. }, 200);
  1459. });
  1460. } else {
  1461. // 1
  1462. }
  1463. };
  1464. /**
  1465. * @description 获取多区数据,数组化
  1466. * @param item
  1467. * @returns
  1468. */
  1469. const getDuoquVal = item => {
  1470. let arr = [];
  1471. for (const key in item) {
  1472. if (key.indexOf("area_") > -1) {
  1473. arr.push(Number(item[key]));
  1474. }
  1475. }
  1476. // 忽略数组中尾部出现的多个0
  1477. let i = arr.length - 1;
  1478. while (arr[i] === 0) {
  1479. i--;
  1480. }
  1481. arr = arr.slice(0, i + 1);
  1482. return arr;
  1483. };
  1484. /**
  1485. * @description 设置多区弹簧宽度
  1486. */
  1487. const setMxSpringWidth = row => {
  1488. console.log("setMxSpringWidth val :>> ", row);
  1489. // if (Number(row.if_part)) {
  1490. // state.bednetMxSpringData = state.bednetMxSpringData.map(item => {
  1491. // item.spring_qty_width = row.spring_qty_width;
  1492. // return item;
  1493. // });
  1494. // }
  1495. if (state.vxeTableMxSpringRef) {
  1496. let { fullData: springData } = state.vxeTableMxSpringRef?.element.getTableData();
  1497. springData.forEach((item, index) => {
  1498. item.spring_qty_width = row.spring_qty_width;
  1499. });
  1500. console.log("state.vxeTableMxSpringRef.element :>> ", state.vxeTableMxSpringRef.element);
  1501. state.vxeTableMxSpringRef.element.updateFooter();
  1502. }
  1503. };
  1504. /**
  1505. * @description 设置多区弹簧长度
  1506. */
  1507. const setMxSpringLength = () => {
  1508. const { _mainData, enumMap } = state.LjDetailRef;
  1509. console.log("setMxSpringLength object :>> ", _mainData, enumMap);
  1510. let duoEnum = enumMap.get("duo_qv_str");
  1511. let item = {};
  1512. if (duoEnum) {
  1513. item = duoEnum.find(t => t.value == _mainData.duo_qv_str);
  1514. }
  1515. console.log("setMxSpringLength item :>> ", item);
  1516. let arr = getDuoquVal(item);
  1517. let totality = arr.reduce((a, b) => a + b, 0);
  1518. let { fullData } = state.vxeTableMxRef.element.getTableData();
  1519. let sum = Number(fullData[0].spring_qty_length);
  1520. console.log("arr, totality :>> ", arr, totality, sum);
  1521. if (state.vxeTableMxSpringRef) {
  1522. let { fullData: springData } = state.vxeTableMxSpringRef?.element.getTableData();
  1523. let lengthValSum = 0;
  1524. springData.forEach((item, index) => {
  1525. let lengthVal = 0;
  1526. if (arr.length >= index + 1) {
  1527. console.log("index, arr.length :>> ", index, arr.length);
  1528. if (index <= arr.length - 1) {
  1529. console.log("index == arr.length - 1 :>> ", index, arr.length - 1);
  1530. if (index == arr.length - 1) {
  1531. lengthVal = sum - lengthValSum;
  1532. console.log("lengthVal end:>> ", lengthVal, lengthValSum, sum);
  1533. } else {
  1534. lengthVal = formatIntNumber({ val: (arr[index] / totality) * sum });
  1535. lengthValSum += Number(lengthVal);
  1536. }
  1537. } else {
  1538. lengthVal = 0;
  1539. }
  1540. console.log("lengthVal :>> ", lengthVal);
  1541. }
  1542. item.spring_qty_length = lengthVal;
  1543. });
  1544. console.log("state.vxeTableMxSpringRef.element :>> ", state.vxeTableMxSpringRef.element);
  1545. state.vxeTableMxSpringRef.element.updateFooter();
  1546. }
  1547. };
  1548. const columnsMx_default = ref<ColumnProps<any>[]>([
  1549. {
  1550. field: "bednet_height",
  1551. // editRender: {
  1552. // name: "input"
  1553. // }
  1554. editRender: {},
  1555. editColRender: (scope: any) => {
  1556. const { column, row, status } = scope;
  1557. return (
  1558. <>
  1559. <el-input
  1560. v-model={row.bednet_height}
  1561. onBlur={() => handleBlur(row.bednet_height, row, "bednet_height")}
  1562. style="width: unset"
  1563. />
  1564. </>
  1565. );
  1566. }
  1567. },
  1568. {
  1569. field: "spring_qty_width",
  1570. datatype: "integer",
  1571. editRender: {},
  1572. editColRender: (scope: any) => {
  1573. const { column, row, status } = scope;
  1574. return (
  1575. <>
  1576. <el-input
  1577. v-model={row.spring_qty_width}
  1578. onBlur={() => handleBlur(row.spring_qty_width, row, "spring_qty_width")}
  1579. onChange={() => setMxSpringWidth(row)}
  1580. style="width: unset"
  1581. />
  1582. </>
  1583. );
  1584. }
  1585. },
  1586. {
  1587. field: "spring_qty_length",
  1588. editRender: {},
  1589. editColRender: (scope: any) => {
  1590. const { column, row, status } = scope;
  1591. return (
  1592. <>
  1593. <el-input
  1594. v-model={row.spring_qty_length}
  1595. onBlur={() => handleBlur(row.spring_qty_length, row, "spring_qty_length")}
  1596. onChange={() => setMxSpringLength()}
  1597. style="width: unset"
  1598. />
  1599. </>
  1600. );
  1601. }
  1602. },
  1603. // {
  1604. // field: "if_part"
  1605. // editRender: {},
  1606. // editColRender: (scope: any) => {
  1607. // const { column, row, status } = scope;
  1608. // console.log("if_part row :>> ", row);
  1609. // if (Number(row.if_part) == 1) {
  1610. // row.springid = 0;
  1611. // row.springname = "";
  1612. // }
  1613. // return (
  1614. // <>
  1615. // <el-checkbox v-model={row.if_part} style="display: block"></el-checkbox>
  1616. // </>
  1617. // );
  1618. // }
  1619. // },
  1620. {
  1621. field: "springname",
  1622. editRender: {},
  1623. editColRender: (scope: any) => {
  1624. const { column, row, status } = scope;
  1625. let _label = column.title;
  1626. return (
  1627. <>
  1628. <SpringSelect
  1629. value={row.springid}
  1630. disabled={Number(row.if_part) == 1}
  1631. clearable
  1632. placeholder={_label}
  1633. onOpenModal={() => fModelChoseSpring(row, row.springid, rModelSetSpring)}
  1634. onSelect={(val: any) => rModelSetSpring(row, val)}
  1635. onClear={() => rModelClearSpring(row)}
  1636. />
  1637. </>
  1638. );
  1639. }
  1640. },
  1641. {
  1642. field: "if_side_iron",
  1643. editRender: {},
  1644. editColRender: (scope: any) => {
  1645. const { column, row, status } = scope;
  1646. if (Number(row.if_side_iron) == 0) {
  1647. row.side_iron_qty = 0;
  1648. }
  1649. return (
  1650. <>
  1651. <el-checkbox v-model={row.if_side_iron} class="vxe-edit-col-middle"></el-checkbox>
  1652. </>
  1653. );
  1654. }
  1655. },
  1656. {
  1657. field: "side_iron_qty",
  1658. editRender: {},
  1659. editColRender: (scope: any) => {
  1660. const { column, row, status } = scope;
  1661. return (
  1662. <>
  1663. <el-input v-model={row.side_iron_qty} disabled={Number(row.if_side_iron) == 0} />
  1664. </>
  1665. );
  1666. }
  1667. },
  1668. {
  1669. field: "if_hard_around",
  1670. editRender: {},
  1671. editColRender: (scope: any) => {
  1672. const { column, row, status } = scope;
  1673. if (Number(row.if_hard_around) == 0) {
  1674. row.hard_around_springid = 0;
  1675. row.hard_around_springname = "";
  1676. row.hard_around_row = 0;
  1677. }
  1678. return (
  1679. <>
  1680. <el-checkbox v-model={row.if_hard_around} class="vxe-edit-col-middle"></el-checkbox>
  1681. </>
  1682. );
  1683. }
  1684. },
  1685. {
  1686. field: "hard_around_row",
  1687. editRender: {},
  1688. editColRender: (scope: any) => {
  1689. const { column, row, status } = scope;
  1690. return (
  1691. <>
  1692. <el-input v-model={row.hard_around_row} disabled={Number(row.if_hard_around) == 0} />
  1693. </>
  1694. );
  1695. }
  1696. },
  1697. {
  1698. field: "hard_around_springname",
  1699. editRender: {},
  1700. editColRender: (scope: any) => {
  1701. console.log("hard_around_springname editColRender scope :>> ", scope);
  1702. const { column, row, status } = scope;
  1703. let _label = column.title;
  1704. return (
  1705. <>
  1706. <SpringSelect
  1707. value={row.hard_around_springid}
  1708. disabled={Number(row.if_hard_around) == 0}
  1709. clearable
  1710. placeholder={_label}
  1711. onOpenModal={() => fModelChoseSpring(row, row.hard_around_springid, rModelSetHardAroundSpring)}
  1712. onSelect={(val: any) => rModelSetHardAroundSpring(row, val)}
  1713. onClear={() => rModelClearHardAroundSpring(row)}
  1714. />
  1715. </>
  1716. );
  1717. }
  1718. },
  1719. {
  1720. field: "if_15strip",
  1721. editRender: {},
  1722. editColRender: (scope: any) => {
  1723. const { column, row, status } = scope;
  1724. return (
  1725. <>
  1726. <el-checkbox v-model={row.if_15strip} class="vxe-edit-col-middle"></el-checkbox>
  1727. </>
  1728. );
  1729. }
  1730. },
  1731. {
  1732. field: "fabrics2_mtrlid",
  1733. editRender: {},
  1734. editColRender: (scope: any) => {
  1735. const { column, row, status } = scope;
  1736. let _label = column.title;
  1737. return (
  1738. <>
  1739. <MtrldefSelect
  1740. value={row.fabrics2_mtrlid}
  1741. pricelistidfn={() => getPriceid()}
  1742. mtrltype={2}
  1743. clearable
  1744. placeholder={_label}
  1745. onOpenModal={() => fModelChoseMtrl(row, { mtrltype: 2 }, rModelSetMtrlFabrisc2)}
  1746. onSelect={(val: any) => rModelSetMtrlFabrisc2(row, val)}
  1747. onClear={() => rModelClearMtrlFabrisc2(row)}
  1748. />
  1749. </>
  1750. );
  1751. }
  1752. },
  1753. {
  1754. field: "fabrics1_mtrlid",
  1755. editRender: {},
  1756. editColRender: (scope: any) => {
  1757. const { column, row, status } = scope;
  1758. let _label = column.title;
  1759. return (
  1760. <>
  1761. <MtrldefSelect
  1762. value={row.fabrics1_mtrlid}
  1763. pricelistidfn={() => getPriceid()}
  1764. mtrltype={2}
  1765. clearable
  1766. placeholder={_label}
  1767. onOpenModal={() => fModelChoseMtrl(row, { mtrltype: 2 }, rModelSetMtrlFabrisc1)}
  1768. onSelect={(val: any) => rModelSetMtrlFabrisc1(row, val)}
  1769. onClear={() => rModelClearMtrlFabrisc1(row)}
  1770. />
  1771. </>
  1772. );
  1773. }
  1774. }
  1775. ]);
  1776. const columnsMx = ref<ColumnProps<any>[]>();
  1777. const columnsMxSpring = ref<ColumnProps<any>[]>([]);
  1778. const columnsMxSpring_default = ref<ColumnProps<any>[]>([
  1779. { title: "#", field: "pid", fixed: "left", width: 80 },
  1780. {
  1781. field: "springname",
  1782. editRender: {},
  1783. editColRender: (scope: any) => {
  1784. console.log("springname editColRender scope :>> ", scope);
  1785. const { column, row, status } = scope;
  1786. let _label = column.title;
  1787. return (
  1788. <>
  1789. <SpringSelect
  1790. value={row.springid}
  1791. disabled={Number(row.if_part) == 1}
  1792. clearable
  1793. placeholder={_label}
  1794. onOpenModal={() => fModelChoseSpring(scope.row, row.springid, rModelSetSpring)}
  1795. onSelect={(val: any) => rModelSetSpring(scope.row, val)}
  1796. onClear={() => rModelClearSpring(scope.row)}
  1797. />
  1798. </>
  1799. );
  1800. }
  1801. },
  1802. {
  1803. field: "spring_qty_width",
  1804. editRender: {},
  1805. editColRender: (scope: any) => {
  1806. const { column, row, status } = scope;
  1807. return (
  1808. <>
  1809. <el-input
  1810. v-model={row.spring_qty_width}
  1811. onBlur={() => handleBlur(row.spring_qty_width, row, "spring_qty_width")}
  1812. style="width: unset"
  1813. />
  1814. </>
  1815. );
  1816. }
  1817. },
  1818. {
  1819. field: "spring_qty_length",
  1820. editRender: {},
  1821. editColRender: (scope: any) => {
  1822. const { column, row, status } = scope;
  1823. return (
  1824. <>
  1825. <el-input
  1826. v-model={row.spring_qty_length}
  1827. onBlur={() => handleBlur(row.spring_qty_length, row, "spring_qty_length")}
  1828. style="width: unset"
  1829. />
  1830. </>
  1831. );
  1832. }
  1833. }
  1834. ]);
  1835. const columnsBednet = ref<ColumnProps<any>[]>([{}]);
  1836. /**
  1837. * @description 计算价格
  1838. */
  1839. const wf_cmp_cb = async () => {
  1840. const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
  1841. wf_clear();
  1842. wf_set_if_doublespring();
  1843. if (!wf_check_rule()) return false;
  1844. if (!(await wf_check_required())) return false;
  1845. return true;
  1846. };
  1847. /**
  1848. * @description 清除运算结果
  1849. */
  1850. const wf_clear = () => {
  1851. const { _mainData } = state.LjDetailRef;
  1852. _mainData.spring_mtrl_cost = 0;
  1853. _mainData.spring_hr_cost = 0;
  1854. _mainData.total_mtrl_cost = 0;
  1855. _mainData.total_hr_cost = 0;
  1856. _mainData.total_fees_cost = 0;
  1857. _mainData.total_cost = 0;
  1858. _mainData.nottax_factory_cost = 0;
  1859. _mainData.nottax_dept_cost = 0;
  1860. _mainData.dept_cost = 0;
  1861. _mainData.foreign_cost = 0;
  1862. _mainData.taxes = 0;
  1863. _mainData.snake_wire_mtrl_cost = 0;
  1864. _mainData.pocket_around_spring_cost = 0;
  1865. _mainData.pocket_around_fabrics_cost = 0;
  1866. _mainData.hard_around_mtrl_cost = 0;
  1867. _mainData.hard_around_hr_cost = 0;
  1868. _mainData.glue_price = 0;
  1869. _mainData.felt_price = 0;
  1870. _mainData.felt_mtrl_cost = 0;
  1871. _mainData.felt_hr_cost = 0;
  1872. _mainData.glue_mtrl_cost = 0;
  1873. _mainData.fabrics1_mtrl_cost = 0;
  1874. _mainData.fabrics2_mtrl_cost = 0;
  1875. _mainData.side_iron_mtrl_cost = 0;
  1876. _mainData.side_iron_hr_cost = 0;
  1877. _mainData.side_iron_price = 0;
  1878. _mainData.side_iron_lossrate = 0;
  1879. _mainData.cnail_price = 0;
  1880. _mainData.cnail_mtrl_cost = 0;
  1881. _mainData.cnail_hr_cost = 0;
  1882. _mainData.sponge_mtrl_cost = 0;
  1883. _mainData.sponge_hr_cost = 0;
  1884. _mainData.edge_mtrl_cost = 0;
  1885. _mainData.edge_hr_cost = 0;
  1886. _mainData.fork_mtrl_cost = 0;
  1887. _mainData.fork_hr_cost = 0;
  1888. _mainData.rsorwa_mtrl_cost = 0;
  1889. _mainData.rsorwa_hr_cost = 0;
  1890. _mainData.sponge_drilling_hr_cost = 0;
  1891. _mainData.sponge_price = 0;
  1892. _mainData.edge_price = 0;
  1893. _mainData.fork_price = 0;
  1894. _mainData.rsorwa_price = 0;
  1895. _mainData.felt_mtrl_x_cost = 0;
  1896. _mainData.packet_mtrl_cost = 0;
  1897. _mainData.packet_hr_cost = 0;
  1898. _mainData.sum_weight = 0;
  1899. _mainData.spring_weight_qty = 0;
  1900. _mainData.side_iron_weight_qty = 0;
  1901. _mainData.hard_around_weight_qty = 0;
  1902. _mainData.fabrics1_weight_qty = 0;
  1903. _mainData.fabrics2_weight_qty = 0;
  1904. _mainData.felt_weight_qty = 0;
  1905. _mainData.cnail_weight_qty = 0;
  1906. _mainData.sponge_weight_qty = 0;
  1907. _mainData.sponge_weight_tc_qty = 0;
  1908. _mainData.fork_weight_qty = 0;
  1909. _mainData.edge_weight_qty = 0;
  1910. };
  1911. const wf_set_if_doublespring = () => {
  1912. const { _mainData, enumMap } = state.LjDetailRef;
  1913. const deptEnum = enumMap.get("deptid");
  1914. const bednettypeEnum = enumMap.get("bednettypeid");
  1915. let deptItem = deptEnum.find((item: any) => Number(item.value) == _mainData.deptid);
  1916. let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
  1917. console.log("typeItem :>> ", typeItem, deptItem);
  1918. if (
  1919. typeItem &&
  1920. deptItem &&
  1921. typeItem.label.indexOf("圆网") > -1 &&
  1922. deptItem.label.indexOf("外贸") === -1 &&
  1923. deptItem.label.indexOf("国外") === -1
  1924. ) {
  1925. _mainData.if_doublespring = 1;
  1926. }
  1927. };
  1928. const wf_check_rule = (): boolean => {
  1929. let { fullData: mxlist } = state.vxeTableMxRef.element.getTableData();
  1930. if (!state.vxeTableMxSpringRef) {
  1931. return true;
  1932. }
  1933. let { fullData: springlist } = state.vxeTableMxSpringRef.element.getTableData();
  1934. for (let mx of mxlist) {
  1935. //1.如果没有四周加硬 左边 弹簧个数排列宽 等于 右边每行 弹簧个数排列宽 , 左边 弹簧个数排列长 等于 右边每行合计 弹簧个数排列长
  1936. if (Number(mx.if_hard_around) === 0) {
  1937. // 左边 弹簧个数排列宽 等于 右边每行 弹簧个数排列宽
  1938. let sum_length = 0;
  1939. for (let spring of springlist) {
  1940. sum_length += parseFloat(spring.spring_qty_length);
  1941. if (Number(mx.spring_qty_width) != Number(spring.spring_qty_width)) {
  1942. throw new Error(`多区袋装明细列表,第${spring.pid}行,弹簧个数排列宽填写错误!`);
  1943. }
  1944. }
  1945. if (parseFloat(mx.spring_qty_length) != sum_length) {
  1946. throw new Error(
  1947. `床网明细列表 弹簧个数排列长${parseFloat(
  1948. mx.spring_qty_length
  1949. )}不等于 多区袋装明细列表 弹簧个数排列长合计${sum_length}!`
  1950. );
  1951. }
  1952. } else if (Number(mx.if_hard_around) === 1) {
  1953. // 左边 弹簧个数排列宽 小于 右边每行 弹簧个数排列宽
  1954. let sum_length = 0;
  1955. for (let spring of springlist) {
  1956. sum_length += parseFloat(spring.spring_qty_length);
  1957. if (Number(mx.spring_qty_width) < Number(spring.spring_qty_width)) {
  1958. throw new Error(`多区袋装明细列表,第${spring.pid}行,弹簧个数排列宽填写错误!`);
  1959. }
  1960. }
  1961. //左边 弹簧个数排列长 小于 右边每行合计 弹簧个数排列长
  1962. if (parseFloat(mx.spring_qty_length) < sum_length) {
  1963. throw new Error(
  1964. `床网明细列表 弹簧个数排列长${parseFloat(
  1965. mx.spring_qty_length
  1966. )}小于 多区袋装明细列表 弹簧个数排列长合计${sum_length}!`
  1967. );
  1968. }
  1969. }
  1970. }
  1971. return true;
  1972. };
  1973. const wf_check_required = async (): Promise<boolean> => {
  1974. const { _mainData, enumMap } = state.LjDetailRef;
  1975. let { fullData: mxlist } = state.vxeTableMxRef.element.getTableData();
  1976. //检查有没有填写床网高
  1977. for (let mx of mxlist) {
  1978. if (mx.bednet_height + 0 == 0) {
  1979. throw new Error("请填写床网高");
  1980. } else {
  1981. _mainData.mattress_height = parseFloat(mx.bednet_height);
  1982. }
  1983. }
  1984. // 检查有没有 填写 填充海绵高
  1985. if (_mainData.sponge_tc_mtrlid + 0 > 0) {
  1986. if (_mainData.sponge_tc_thickness + 0 == 0) {
  1987. throw new Error("请填写填充海绵厚度!");
  1988. }
  1989. if (_mainData.sponge_tc_height + 0 == 0) {
  1990. throw new Error("请填写填充海绵厚度!");
  1991. }
  1992. if ((_mainData.sponge_tc_thickness + 0 > 0 || _mainData.sponge_tc_height + 0 > 0) && _mainData.sponge_tc_mtrlid + 0 == 0) {
  1993. throw new Error("请选择填充海绵物料!");
  1994. }
  1995. }
  1996. // 如果 没有填写 海绵高和封边高 自动等于 床网高
  1997. if (_mainData.sponge_mtrlid > 0 && _mainData.sponge_height + 0 <= 0) _mainData.sponge_height = _mainData.mattress_height;
  1998. if (_mainData.edge_mtrlid > 0 && _mainData.edge_height + 0 <= 0) _mainData.edge_height = _mainData.mattress_height;
  1999. _mainData.commission = _mainData.commission && Number(_mainData.commission) !== 0 ? _mainData.commission : 1;
  2000. _mainData.taxrate = _mainData.taxrate && Number(_mainData.taxrate) !== 0 ? _mainData.taxrate : 1;
  2001. _mainData.other_rate = _mainData.other_rate && Number(_mainData.other_rate) !== 0 ? _mainData.other_rate : 1;
  2002. _mainData.moneyrate = _mainData.moneyrate && Number(_mainData.moneyrate) !== 0 ? _mainData.moneyrate : 1;
  2003. if (Number(_mainData.commission) < 1) {
  2004. throw new Error("佣金点数不能小于1!");
  2005. }
  2006. if (Number(_mainData.taxrate) < 1) {
  2007. throw new Error("税率不能小于1!");
  2008. }
  2009. if (Number(_mainData.other_rate) < 1) {
  2010. throw new Error("额外点数不能小于1!");
  2011. }
  2012. if (_mainData.packtype && _mainData.packtype.length > 0) {
  2013. _mainData.packtype = _mainData.packtype.trim();
  2014. if (_mainData.packtype != "不压不卷" && _mainData.packqty + 0 == 0) {
  2015. throw new Error("请填写包装数量!");
  2016. }
  2017. if (_mainData.packtype != "不压不卷" && _mainData.packtype != "裸包装" && _mainData.transport_type + "" == "") {
  2018. throw new Error("请选择运输方式!");
  2019. }
  2020. if (_mainData.packtype == "卷包" && _mainData.packmtrl + "" == "") {
  2021. throw new Error("请选择包装材料!");
  2022. }
  2023. }
  2024. await wf_factory_profitrate();
  2025. if (_mainData.dept_profitrate + 0 == 0) {
  2026. throw new Error("部门利润率不能为0!");
  2027. }
  2028. if (_mainData.bednettypeid + 0 == 0) {
  2029. throw new Error("请选择床网类别!");
  2030. }
  2031. if (_mainData.sponge_mtrlid + 0 > 0 && _mainData.sponge_thickness + 0 == 0) {
  2032. throw new Error("请填写海绵厚度!");
  2033. }
  2034. if (_mainData.sponge_mtrlid + 0 == 0 && _mainData.sponge_thickness + 0 > 0) {
  2035. throw new Error("请选择海绵物料!");
  2036. }
  2037. const bednettypeEnum = enumMap.get("bednettypeid");
  2038. let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
  2039. for (let mx of mxlist) {
  2040. if (mx.bednet_height + 0 == 0) {
  2041. throw new Error(`第${mx.pid}行,请填写床网高!`);
  2042. }
  2043. if (mx.spring_qty_width + 0 == 0) {
  2044. throw new Error(`第${mx.pid}行,请填写弹簧排列个数-宽!`);
  2045. }
  2046. if (mx.spring_qty_length + 0 == 0) {
  2047. throw new Error(`第${mx.pid}行,请填写弹簧排列个数-长!`);
  2048. }
  2049. if (typeItem.label.indexOf("袋装网") > -1 && mx.fabrics1_mtrlid + 0 == 0) {
  2050. throw new Error(`第${mx.pid}行,请选择入袋无纺布!`);
  2051. }
  2052. if (mx.if_side_iron > 0 && mx.side_iron_qty + 0 == 0) {
  2053. throw new Error(`第${mx.pid}行,请填写边铁条数!`);
  2054. }
  2055. }
  2056. return true;
  2057. };
  2058. const wf_replace_expression = (arg_str: string, mx: any) => {
  2059. const { _mainData, enumMap } = state.LjDetailRef;
  2060. // 替换中文符号
  2061. arg_str = arg_str.replace(/(/g, " ( ").replace(/)/g, " ) ");
  2062. arg_str = arg_str.replace(/,/g, " , ");
  2063. const bednettypeEnum = enumMap.get("bednettypeid");
  2064. let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
  2065. // 四周加硬逻辑
  2066. if (mx.if_hard_around + 0 === 1) {
  2067. let ls_temp_str = 0;
  2068. if (typeItem.label.indexOf("袋装") > -1) {
  2069. ls_temp_str = (mx.hard_around_row + 0) * 2;
  2070. } else {
  2071. ls_temp_str = mx.hard_around_row + 0;
  2072. }
  2073. let ls_temp_str_all = ` ( 【弹簧排列个数-宽】 - ${ls_temp_str} ) `;
  2074. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", ls_temp_str_all);
  2075. ls_temp_str_all = ` ( 【弹簧计算个数(宽)】 - ${ls_temp_str} ) `;
  2076. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", ls_temp_str_all);
  2077. ls_temp_str_all = ` ( 【弹簧排列个数-长】 - ${ls_temp_str} ) `;
  2078. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", ls_temp_str_all);
  2079. ls_temp_str_all = ` ( 【弹簧计算个数(长)】 - ${ls_temp_str} ) `;
  2080. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", ls_temp_str_all);
  2081. }
  2082. // 四周口袋逻辑
  2083. if (mx.if_pocket_around + 0 === 1) {
  2084. let ls_temp_str = 0;
  2085. if (typeItem.label.indexOf("袋装") > -1) {
  2086. ls_temp_str = (mx.pocket_around_row + 0) * 2;
  2087. } else {
  2088. ls_temp_str = mx.pocket_around_row + 0;
  2089. }
  2090. let ls_temp_str_all = ` ( 【弹簧排列个数-宽】 - ${ls_temp_str} ) `;
  2091. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", ls_temp_str_all);
  2092. ls_temp_str_all = ` ( 【弹簧计算个数(宽)】 - ${ls_temp_str} ) `;
  2093. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", ls_temp_str_all);
  2094. ls_temp_str_all = ` ( 【弹簧排列个数-长】 - ${ls_temp_str} ) `;
  2095. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", ls_temp_str_all);
  2096. ls_temp_str_all = ` ( 【弹簧计算个数(长)】 - ${ls_temp_str} ) `;
  2097. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", ls_temp_str_all);
  2098. }
  2099. return arg_str;
  2100. };
  2101. const wf_cmp_spring_mtrl_cost_dw2 = (arg_str: string, mx: any) => {
  2102. const { _mainData, enumMap } = state.LjDetailRef;
  2103. // 替换中文符号
  2104. arg_str = arg_str.replace(/(/g, " ( ").replace(/)/g, " ) ");
  2105. arg_str = arg_str.replace(/,/g, " , ");
  2106. const bednettypeEnum = enumMap.get("bednettypeid");
  2107. let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
  2108. arg_str = replaceArgStr(arg_str, "【床垫宽】", _mainData.mattress_width);
  2109. arg_str = replaceArgStr(arg_str, "【床垫长】", _mainData.mattress_length);
  2110. arg_str = replaceArgStr(arg_str, "【床垫高】", _mainData.mattress_height);
  2111. arg_str = replaceArgStr(arg_str, "【双簧】", _mainData.if_doublespring);
  2112. arg_str = replaceArgStr(arg_str, "【床网类别】", typeItem.typename);
  2113. for (let item of state.bednetVarList) {
  2114. if (item.varvalue + 0 <= 0) continue;
  2115. arg_str = replaceArgStr(arg_str, `【${item.varname}】`, item.varvalue + 0);
  2116. }
  2117. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", mx.spring_qty_width);
  2118. arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", mx.spring_qty_length);
  2119. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", mx.spring_qty_width);
  2120. arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", mx.spring_qty_length);
  2121. arg_str = replaceArgStr(arg_str, "【边铁条数】", mx.side_iron_qty);
  2122. arg_str = replaceArgStr(arg_str, "【条数】", mx.side_iron_qty);
  2123. };
  2124. // 替换字符串
  2125. const replaceArgStr = (arg_str: string, findStr: string, replaceStr: any) => {
  2126. return arg_str.replace(findStr, replaceStr);
  2127. };
  2128. /**
  2129. * @description 获取部门利润率
  2130. */
  2131. const wf_factory_profitrate = async () => {
  2132. const { _mainData, enumMap } = state.LjDetailRef;
  2133. console.log("wf_factory_profitrate enumMap :>> ", enumMap);
  2134. let deptEnum = enumMap.get("deptid");
  2135. console.log("deptEnum :>> ", deptEnum);
  2136. if (deptEnum) {
  2137. let depItem = deptEnum.find((item: any) => item.value == _mainData.deptid);
  2138. console.log("depItem :>> ", depItem);
  2139. if (depItem) {
  2140. _mainData.dept_profitrate = parseFloat(depItem.profitrate);
  2141. }
  2142. }
  2143. let _params = {
  2144. dsname: "web_factory_profitratelist",
  2145. queryparams: {
  2146. arg_deptid: _mainData.deptid,
  2147. arg_bednettypeid_mattresstypeid: _mainData.mattresstypeid,
  2148. kind: 0
  2149. }
  2150. };
  2151. let res = await CommonDynamicSelect(_params);
  2152. if (res?.datatable?.length > 0) {
  2153. _mainData.profitrate = parseFloat(res?.datatable[0].profitrate);
  2154. }
  2155. };
  2156. const wf_bednet_var = async (varkind: Number, pricelistid: Number, bednettypeid: Number) => {
  2157. let _params = {
  2158. dsname: "web_bednet_var_define_cw",
  2159. queryparams: {
  2160. varkind,
  2161. pricelistid,
  2162. bednettypeid
  2163. }
  2164. };
  2165. let res = await CommonDynamicSelect(_params);
  2166. if (res?.datatable?.length > 0) {
  2167. state.bednetVarList = res?.datatable;
  2168. }
  2169. };
  2170. /**
  2171. * @description 展示计算公式
  2172. * @param timeout
  2173. */
  2174. const gotoSummy = async (timeout = 0, ifdrawer?: boolean) => {
  2175. if (userInfo.usermode == 1) {
  2176. ElMessage.error("'业务员模式不可以查看计算公式!'");
  2177. return false;
  2178. }
  2179. console.log(
  2180. "state.vxeTableMxRef?.element.getTableData().fullData :>> ",
  2181. state.vxeTableMxRef?.element.getTableData().fullData,
  2182. state.vxeTableMxRef
  2183. );
  2184. let bednet = cloneDeep(state.LjDetailRef._mainData);
  2185. bednet.if_doublenet = Number(bednet.if_doublenet);
  2186. bednet.if_doublespring = Number(bednet.if_doublespring);
  2187. bednet.if_side_iron = Number(bednet.if_side_iron);
  2188. bednet.if_rsorwa = Number(bednet.if_rsorwa);
  2189. bednet.if_sponge_drilling = Number(bednet.if_sponge_drilling);
  2190. bednet.iffork = Number(bednet.iffork);
  2191. bednet.ifsaleout = Number(bednet.ifsaleout);
  2192. bednet.if_jb = Number(bednet.if_jb);
  2193. bednet.flag = Number(bednet.flag);
  2194. let _params: any = {
  2195. bednet: bednet,
  2196. bednetMx: state.vxeTableMxRef?.element.getTableData().fullData ?? [],
  2197. spring: state.vxeTableMxSpringRef?.element.getTableData().fullData ?? []
  2198. };
  2199. let res = await GetComputeBednet(_params);
  2200. console.log("GetComputeBednet res :>> ", res);
  2201. let summaryData = [];
  2202. let fieldParams = [];
  2203. let cpData = {};
  2204. if (!res.message) {
  2205. summaryData = res.formulas;
  2206. fieldParams = res.replace;
  2207. cpData = res.bednet;
  2208. } else {
  2209. setTimeout(() => {
  2210. if (res.message) {
  2211. ElNotification({
  2212. title: "计算失败",
  2213. message: res.message,
  2214. type: "warning"
  2215. });
  2216. }
  2217. }, 100);
  2218. return false;
  2219. }
  2220. console.log("summaryData :>> ", summaryData, fieldParams);
  2221. const toast = useToast();
  2222. if (ifdrawer) {
  2223. state.AllFormulaRef.open(summaryData, fieldParams, cpData);
  2224. toast.clear();
  2225. } else {
  2226. toast(
  2227. {
  2228. component: ToastFormula,
  2229. props: {
  2230. t: t,
  2231. formulas: summaryData,
  2232. // data: cpData,
  2233. fields: fieldParams
  2234. },
  2235. listeners: {
  2236. tomore: () => {
  2237. console.log("tomore summaryData :>> ", summaryData);
  2238. state.AllFormulaRef.open(summaryData, fieldParams, cpData);
  2239. toast.clear();
  2240. },
  2241. refresh: () => {
  2242. gotoSummy();
  2243. }
  2244. }
  2245. },
  2246. {
  2247. position: POSITION.BOTTOM_RIGHT,
  2248. icon: false,
  2249. timeout: timeout,
  2250. closeButton: false,
  2251. toastClassName: "longjoe-toast"
  2252. }
  2253. );
  2254. }
  2255. };
  2256. return {
  2257. ...toRefs(state),
  2258. columns,
  2259. columnsMx,
  2260. columnsMxSpring,
  2261. columnsBednet,
  2262. dw_bednet_mx_spring,
  2263. reload_dw2,
  2264. getData,
  2265. getDataMx,
  2266. getDataMxSpring,
  2267. getDataMxAdd,
  2268. dataCallback,
  2269. wf_cmp_cb,
  2270. setMxSpringLength,
  2271. gotoSummy
  2272. };
  2273. };