index.tsx 83 KB

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