taskForm.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748
  1. <template>
  2. <view class="">
  3. <u-sticky offset-top="50">
  4. <view class="subsection-wrap">
  5. <u-subsection
  6. fontSize="25"
  7. mode="subsection"
  8. :list="tabList"
  9. :current="curNow"
  10. @change="sectionChange"
  11. activeColor="#157A2C"
  12. ></u-subsection>
  13. </view>
  14. </u-sticky>
  15. <!-- Tab 0: 入库单详情 -->
  16. <view v-show="curNow === 0" class="basic_info">
  17. <view class="info_header">
  18. <view class="info_title">入库单详情</view>
  19. <u-gap height="4" bgColor="#1890FF"></u-gap>
  20. </view>
  21. <view class="info_content">
  22. <u-row>
  23. <u-col span="4">
  24. <view class="label">物品名称:</view>
  25. </u-col>
  26. <u-col span="8">
  27. <view class="value">{{ form.categoryName || "—" }}</view>
  28. </u-col>
  29. </u-row>
  30. <u-row>
  31. <u-col span="4">
  32. <view class="label">物品编码:</view>
  33. </u-col>
  34. <u-col span="8">
  35. <view class="value">{{ form.categoryCode || "—" }}</view>
  36. </u-col>
  37. </u-row>
  38. <u-row>
  39. <u-col span="4">
  40. <view class="label">物品分类:</view>
  41. </u-col>
  42. <u-col span="8">
  43. <view class="value">{{ form.categoryLevelName || "—" }}</view>
  44. </u-col>
  45. </u-row>
  46. <u-row>
  47. <u-col span="4">
  48. <view class="label">包装数量:</view>
  49. </u-col>
  50. <u-col span="8">
  51. <view class="value">{{ totalPackage || "—" }}</view>
  52. </u-col>
  53. </u-row>
  54. <u-row>
  55. <u-col span="4">
  56. <view class="label">计量数量:</view>
  57. </u-col>
  58. <u-col span="8">
  59. <view class="value">{{ totalCount || "—" }}</view>
  60. </u-col>
  61. </u-row>
  62. </view>
  63. </view>
  64. <!-- Tab 1: 基本信息 -->
  65. <view v-show="curNow === 1" class="basic_info">
  66. <view class="info_header">
  67. <view class="info_title">基本信息</view>
  68. <u-gap height="4" bgColor="#1890FF"></u-gap>
  69. </view>
  70. <view class="info_content">
  71. <u-row>
  72. <u-col span="4">
  73. <view class="label">物品类型:</view>
  74. </u-col>
  75. <u-col span="8">
  76. <view class="value">{{ assetTypeLabel || "—" }}</view>
  77. </u-col>
  78. </u-row>
  79. <u-row>
  80. <u-col span="4">
  81. <view class="label">入库类型:</view>
  82. </u-col>
  83. <u-col span="8">
  84. <view class="value">{{ bizTypeLabel || "—" }}</view>
  85. </u-col>
  86. </u-row>
  87. <u-row>
  88. <u-col span="4">
  89. <view class="label">单据来源:</view>
  90. </u-col>
  91. <u-col span="8">
  92. <view class="value">{{ formData.sourceBizNo || "—" }}</view>
  93. </u-col>
  94. </u-row>
  95. <u-row>
  96. <u-col span="4">
  97. <view class="label">入库时间:</view>
  98. </u-col>
  99. <u-col span="8">
  100. <view class="value">{{ formData.storageTime || "—" }}</view>
  101. </u-col>
  102. </u-row>
  103. <u-row>
  104. <u-col span="4">
  105. <view class="label">入库登记人:</view>
  106. </u-col>
  107. <u-col span="8">
  108. <view class="value">{{ formData.createUserName || "—" }}</view>
  109. </u-col>
  110. </u-row>
  111. <u-row>
  112. <u-col span="4">
  113. <view class="label">审核人:</view>
  114. </u-col>
  115. <u-col span="8">
  116. <view class="value">{{ formData.approvalUserName || "—" }}</view>
  117. </u-col>
  118. </u-row>
  119. <u-row>
  120. <u-col span="4">
  121. <view class="label">备注:</view>
  122. </u-col>
  123. <u-col span="8">
  124. <view class="value">{{ formData.remark || "—" }}</view>
  125. </u-col>
  126. </u-row>
  127. </view>
  128. </view>
  129. <!-- Tab 2: 产品信息 -->
  130. <view v-show="curNow === 2" class="basic_info">
  131. <view class="info_header">
  132. <view class="info_title">产品信息</view>
  133. <u-gap height="4" bgColor="#1890FF"></u-gap>
  134. </view>
  135. <view v-if="!productList.length" class="empty_text"> 暂无产品信息 </view>
  136. <view v-for="(row, idx) in productList" :key="idx" class="card_box">
  137. <view class="card_title">产品 {{ idx + 1 }}</view>
  138. <u-row>
  139. <u-col span="3">
  140. <view class="label">编码:</view>
  141. </u-col>
  142. <u-col span="9">
  143. <view class="value">{{ row.categoryCode || "—" }}</view>
  144. </u-col>
  145. </u-row>
  146. <u-row>
  147. <u-col span="3">
  148. <view class="label">名称:</view>
  149. </u-col>
  150. <u-col span="9">
  151. <view class="value">{{ row.categoryName || "—" }}</view>
  152. </u-col>
  153. </u-row>
  154. <u-row>
  155. <u-col span="3">
  156. <view class="label">牌号:</view>
  157. </u-col>
  158. <u-col span="9">
  159. <view class="value">{{ row.brandNum || "—" }}</view>
  160. </u-col>
  161. </u-row>
  162. <u-row>
  163. <u-col span="3">
  164. <view class="label">型号:</view>
  165. </u-col>
  166. <u-col span="9">
  167. <view class="value">{{ row.categoryModel || "—" }}</view>
  168. </u-col>
  169. </u-row>
  170. <u-row>
  171. <u-col span="3">
  172. <view class="label">规格:</view>
  173. </u-col>
  174. <u-col span="9">
  175. <view class="value">{{ row.specification || "—" }}</view>
  176. </u-col>
  177. </u-row>
  178. <u-row>
  179. <u-col span="3">
  180. <view class="label">批次号:</view>
  181. </u-col>
  182. <u-col span="9">
  183. <view class="value">{{ row.batchNo || "—" }}</view>
  184. </u-col>
  185. </u-row>
  186. <u-row>
  187. <u-col span="3">
  188. <view class="label">包装数量:</view>
  189. </u-col>
  190. <u-col span="9">
  191. <view class="value">{{ row.packingQuantityDisplay || "—" }}</view>
  192. </u-col>
  193. </u-row>
  194. <u-row>
  195. <u-col span="3">
  196. <view class="label">计量数量:</view>
  197. </u-col>
  198. <u-col span="9">
  199. <view class="value">{{ row.measureQuantityDisplay || "—" }}</view>
  200. </u-col>
  201. </u-row>
  202. <u-row>
  203. <u-col span="3">
  204. <view class="label">重量:</view>
  205. </u-col>
  206. <u-col span="9">
  207. <view class="value">{{ row.weightDisplay || "—" }}</view>
  208. </u-col>
  209. </u-row>
  210. <u-row>
  211. <u-col span="3">
  212. <view class="label">包装规格:</view>
  213. </u-col>
  214. <u-col span="9">
  215. <view class="value">{{ row.packingSpecification || "—" }}</view>
  216. </u-col>
  217. </u-row>
  218. <u-row>
  219. <u-col span="3">
  220. <view class="label">仓库:</view>
  221. </u-col>
  222. <u-col span="9">
  223. <view class="value">{{ row.warehouseName || "—" }}</view>
  224. </u-col>
  225. </u-row>
  226. <u-row>
  227. <u-col span="3">
  228. <view class="label">供应商:</view>
  229. </u-col>
  230. <u-col span="9">
  231. <view class="value">{{ row.supplierName || "—" }}</view>
  232. </u-col>
  233. </u-row>
  234. <u-row>
  235. <u-col span="3">
  236. <view class="label">供应商代号:</view>
  237. </u-col>
  238. <u-col span="9">
  239. <view class="value">{{ row.supplierCode || "—" }}</view>
  240. </u-col>
  241. </u-row>
  242. <u-row>
  243. <u-col span="3">
  244. <view class="label">机型:</view>
  245. </u-col>
  246. <u-col span="9">
  247. <view class="value">{{ formatField(row.modelKey) }}</view>
  248. </u-col>
  249. </u-row>
  250. <u-row>
  251. <u-col span="3">
  252. <view class="label">颜色:</view>
  253. </u-col>
  254. <u-col span="9">
  255. <view class="value">{{ formatField(row.colorKey) }}</view>
  256. </u-col>
  257. </u-row>
  258. <u-row>
  259. <u-col span="3">
  260. <view class="label">生产要求:</view>
  261. </u-col>
  262. <u-col span="9">
  263. <view class="value">{{ row.productionRequirements || "—" }}</view>
  264. </u-col>
  265. </u-row>
  266. </view>
  267. </view>
  268. <!-- Tab 3: 包装明细 -->
  269. <view v-show="curNow === 3" class="basic_info">
  270. <view class="info_header">
  271. <view class="info_title">包装明细</view>
  272. <u-gap height="4" bgColor="#1890FF"></u-gap>
  273. </view>
  274. <view v-if="!packingList.length" class="empty_text"> 暂无包装明细 </view>
  275. <view v-for="(row, idx) in packingList" :key="idx" class="card_box">
  276. <view class="card_title">包装 {{ idx + 1 }}</view>
  277. <u-row>
  278. <u-col span="3">
  279. <view class="label">编码:</view>
  280. </u-col>
  281. <u-col span="9">
  282. <view class="value">{{ row.categoryCode || "—" }}</view>
  283. </u-col>
  284. </u-row>
  285. <u-row>
  286. <u-col span="3">
  287. <view class="label">名称:</view>
  288. </u-col>
  289. <u-col span="9">
  290. <view class="value">{{ row.categoryName || "—" }}</view>
  291. </u-col>
  292. </u-row>
  293. <u-row>
  294. <u-col span="3">
  295. <view class="label">批次号:</view>
  296. </u-col>
  297. <u-col span="9">
  298. <view class="value">{{ row.batchNo || "—" }}</view>
  299. </u-col>
  300. </u-row>
  301. <u-row>
  302. <u-col span="3">
  303. <view class="label">包装编码:</view>
  304. </u-col>
  305. <u-col span="9">
  306. <view class="value">{{ row.packageNo || "—" }}</view>
  307. </u-col>
  308. </u-row>
  309. <u-row>
  310. <u-col span="3">
  311. <view class="label">包装数量:</view>
  312. </u-col>
  313. <u-col span="9">
  314. <view class="value">{{ row.packingQuantityDisplay || "—" }}</view>
  315. </u-col>
  316. </u-row>
  317. <u-row>
  318. <u-col span="3">
  319. <view class="label">计量数量:</view>
  320. </u-col>
  321. <u-col span="9">
  322. <view class="value">{{ row.measureQuantityDisplay || "—" }}</view>
  323. </u-col>
  324. </u-row>
  325. <u-row>
  326. <u-col span="3">
  327. <view class="label">重量:</view>
  328. </u-col>
  329. <u-col span="9">
  330. <view class="value">{{ row.weightDisplay || "—" }}</view>
  331. </u-col>
  332. </u-row>
  333. <u-row>
  334. <u-col span="3">
  335. <view class="label">仓库:</view>
  336. </u-col>
  337. <u-col span="9">
  338. <view class="value">{{ row.warehouseName || "—" }}</view>
  339. </u-col>
  340. </u-row>
  341. <u-row>
  342. <u-col span="3">
  343. <view class="label">物料代号:</view>
  344. </u-col>
  345. <u-col span="9">
  346. <view class="value">{{ row.materielDesignation || "—" }}</view>
  347. </u-col>
  348. </u-row>
  349. <u-row>
  350. <u-col span="3">
  351. <view class="label">客户代号:</view>
  352. </u-col>
  353. <u-col span="9">
  354. <view class="value">{{ row.clientCode || "—" }}</view>
  355. </u-col>
  356. </u-row>
  357. <u-row>
  358. <u-col span="3">
  359. <view class="label">发货条码:</view>
  360. </u-col>
  361. <u-col span="9">
  362. <view class="value">{{ row.barcodes || "—" }}</view>
  363. </u-col>
  364. </u-row>
  365. <u-row>
  366. <u-col span="3">
  367. <view class="label">刻码:</view>
  368. </u-col>
  369. <u-col span="9">
  370. <view class="value">{{ row.engrave || "—" }}</view>
  371. </u-col>
  372. </u-row>
  373. <u-row>
  374. <u-col span="3">
  375. <view class="label">供应商:</view>
  376. </u-col>
  377. <u-col span="9">
  378. <view class="value">{{ row.supplierName || "—" }}</view>
  379. </u-col>
  380. </u-row>
  381. <u-row>
  382. <u-col span="3">
  383. <view class="label">供应商代号:</view>
  384. </u-col>
  385. <u-col span="9">
  386. <view class="value">{{ row.supplierCode || "—" }}</view>
  387. </u-col>
  388. </u-row>
  389. <u-row>
  390. <u-col span="3">
  391. <view class="label">机型:</view>
  392. </u-col>
  393. <u-col span="9">
  394. <view class="value">{{ formatField(row.modelKey) }}</view>
  395. </u-col>
  396. </u-row>
  397. <u-row>
  398. <u-col span="3">
  399. <view class="label">颜色:</view>
  400. </u-col>
  401. <u-col span="9">
  402. <view class="value">{{ formatField(row.colorKey) }}</view>
  403. </u-col>
  404. </u-row>
  405. <u-row>
  406. <u-col span="3">
  407. <view class="label">质检结果:</view>
  408. </u-col>
  409. <u-col span="9">
  410. <view class="value">{{ row.resultLabel || "—" }}</view>
  411. </u-col>
  412. </u-row>
  413. <u-row>
  414. <u-col span="3">
  415. <view class="label">质检状态:</view>
  416. </u-col>
  417. <u-col span="9">
  418. <view class="value">{{ row.statusLabel || "—" }}</view>
  419. </u-col>
  420. </u-row>
  421. <u-row>
  422. <u-col span="3">
  423. <view class="label">生产日期:</view>
  424. </u-col>
  425. <u-col span="9">
  426. <view class="value">{{ row.productionDate || "—" }}</view>
  427. </u-col>
  428. </u-row>
  429. <u-row>
  430. <u-col span="3">
  431. <view class="label">采购日期:</view>
  432. </u-col>
  433. <u-col span="9">
  434. <view class="value">{{ row.purchaseDate || "—" }}</view>
  435. </u-col>
  436. </u-row>
  437. </view>
  438. </view>
  439. </view>
  440. </template>
  441. <script>
  442. import {
  443. getStorageDetail,
  444. allCategoryLevel,
  445. getLoginUser,
  446. } from "@/api/wt/index.js";
  447. import {
  448. getListByNameOrModeType,
  449. getCategoryPackageDisposition,
  450. getCode,
  451. getAssetNum,
  452. isVerifyRepeatIsStock,
  453. } from "@/api/warehouseManagement/index.js";
  454. const INPUT_SCENE_STATE = [
  455. { code: 1, label: "生产入库" },
  456. { code: 2, label: "采购入库" },
  457. { code: 3, label: "退货入库" },
  458. { code: 4, label: "委外入库" },
  459. { code: 5, label: "受托入库" },
  460. { code: 6, label: "调拨入库" },
  461. { code: 7, label: "委外退货入库" },
  462. { code: 8, label: "委外采购入库" },
  463. { code: 9, label: "仓库委外入库" },
  464. { code: 10, label: "采购退货入库" },
  465. { code: 99, label: "其他入库" },
  466. ];
  467. const QUALITY_RESULTS = {
  468. 0: "无",
  469. 1: "合格",
  470. 2: "不合格",
  471. 3: "让步接收",
  472. };
  473. const QUALITY_STATUS = {
  474. 0: "未质检",
  475. 1: "待检",
  476. 2: "已质检",
  477. };
  478. export default {
  479. props: {
  480. businessId: {
  481. default: "",
  482. },
  483. taskDefinitionKey: {
  484. default: "",
  485. },
  486. },
  487. data() {
  488. return {
  489. form: {},
  490. formData: {
  491. type: 1,
  492. bizType: "",
  493. sourceBizNo: "",
  494. storageTime: "",
  495. createUserId: "",
  496. createUserName: "",
  497. approvalUserId: "",
  498. approvalUserName: "",
  499. remark: "",
  500. extInfo: {
  501. assetType: [],
  502. assetTypeName: "",
  503. deptCode: "",
  504. deptName: "",
  505. createUserName: "",
  506. createUserId: "",
  507. deliveryPhone: "",
  508. documentSource: "",
  509. supplierName: "",
  510. },
  511. outInDetailList: [],
  512. },
  513. tabList: ["入库单详情", "基本信息", "产品信息", "包装明细"],
  514. curNow: 0,
  515. productList: [],
  516. packingList: [],
  517. assetTypeMapping: {},
  518. isDetail: false,
  519. totalPackage: "",
  520. totalCount: "",
  521. };
  522. },
  523. computed: {
  524. bizType() {
  525. return this.taskDefinitionKey === "wmsBizType4" ? 4 : 1;
  526. },
  527. bizTypeLabel() {
  528. const item = INPUT_SCENE_STATE.find(
  529. (s) => s.code === Number(this.formData.bizType),
  530. );
  531. return item ? item.label : "";
  532. },
  533. assetTypeLabel() {
  534. const types = this.formData.extInfo.assetType;
  535. if (Array.isArray(types)) {
  536. return types
  537. .map((id) => this.assetTypeMapping[id] || "")
  538. .filter(Boolean)
  539. .join("、");
  540. }
  541. if (typeof types === "string" && types) {
  542. return types
  543. .split(",")
  544. .map((id) => this.assetTypeMapping[id.trim()] || "")
  545. .filter(Boolean)
  546. .join("、");
  547. }
  548. return "";
  549. },
  550. },
  551. async mounted() {
  552. await this.loadAssetTypeMapping();
  553. await this.getDetailData(this.businessId);
  554. await this.getLoginUserData();
  555. },
  556. methods: {
  557. sectionChange(index) {
  558. this.curNow = index;
  559. },
  560. formatField(val) {
  561. if (Array.isArray(val)) return val.join(",") || "—";
  562. return val || "—";
  563. },
  564. async loadAssetTypeMapping() {
  565. try {
  566. const data = await allCategoryLevel();
  567. const list = Array.isArray(data) ? data : data?.data || [];
  568. const obj = {};
  569. list.forEach((item) => {
  570. obj[item.id] = item.name;
  571. });
  572. this.assetTypeMapping = obj;
  573. } catch (e) {
  574. console.warn("加载物品分类失败", e);
  575. }
  576. },
  577. async getDetailData(id) {
  578. try {
  579. const data = await getStorageDetail(id);
  580. this.form = data;
  581. this.isDetail = data.detailList?.[0]?.isAllPackageData == 1;
  582. this.totalPackage = this.isDetail
  583. ? (data.detailList[0].packingCount || "") +
  584. (data.detailList[0]?.packingUnit || "")
  585. : data.detailList.length + (data.detailList[0]?.packingUnit || "");
  586. this.totalCount =
  587. (data.totalCount || "") + (data.detailList?.[0]?.measuringUnit || "");
  588. this.form.detailList = (data.detailList || []).map((item) => ({
  589. ...item,
  590. productName: item.categoryName,
  591. productCode: item.categoryCode,
  592. }));
  593. let categoryLevelTopIds = data.detailList.map(
  594. (item) => item.rootCategoryLevelId,
  595. );
  596. let filterCategoryLevelTopIds = [
  597. ...new Set(categoryLevelTopIds.filter(Boolean)),
  598. ];
  599. data.categoryLevelTopId = filterCategoryLevelTopIds.join(",");
  600. if (this.taskDefinitionKey === "wmsBizType4") {
  601. this.form.totalCount = data.detailList.reduce(
  602. (sum, item) => sum + (item.quantity || 0),
  603. 0,
  604. );
  605. }
  606. await this.initFormData();
  607. await this.initProducts();
  608. } catch (e) {
  609. console.warn("获取入库单详情失败", e);
  610. }
  611. },
  612. async initFormData() {
  613. this.formData.type = 1;
  614. this.formData.bizType = this.bizType;
  615. this.formData.sourceBizNo = this.form.code || "";
  616. const categoryLevelTopIds = (this.form.detailList || [])
  617. .map((item) => item.rootCategoryLevelId)
  618. .filter(Boolean);
  619. this.formData.extInfo.assetType = [...new Set(categoryLevelTopIds)];
  620. this.formData.extInfo.documentSource = this.form.code || "";
  621. this.formData.extInfo.supplierName = this.form.supplierName || "";
  622. this.getNowFormatDate();
  623. },
  624. getNowFormatDate() {
  625. const now = new Date();
  626. const pad = (n) => String(n).padStart(2, "0");
  627. this.formData.storageTime = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
  628. },
  629. async getLoginUserData() {
  630. try {
  631. const data = await getLoginUser();
  632. this.formData.createUserId =
  633. this.form.createUserId || data.userId || "";
  634. this.formData.createUserName =
  635. this.form.createUserName || data.name || "";
  636. this.formData.approvalUserId =
  637. this.form.approvalUserId || data.userId || "";
  638. this.formData.approvalUserName =
  639. this.form.approvalUserName || data.name || "";
  640. this.formData.extInfo.createUserId =
  641. this.form.createUserId || data.userId || "";
  642. this.formData.extInfo.createUserName =
  643. this.form.createUserName || data.name || "";
  644. this.formData.extInfo.deliveryPhone = data.phone || "";
  645. this.formData.extInfo.deptName =
  646. this.form.deptName || data.deptName || "";
  647. } catch (e) {
  648. console.warn("获取登录用户数据失败", e);
  649. }
  650. },
  651. async initProducts() {
  652. const detailList = this.form.detailList || [];
  653. if (!detailList.length) return;
  654. const codeList = detailList
  655. .map((item) => item.productCode || item.categoryCode)
  656. .filter(Boolean);
  657. if (!codeList.length) {
  658. this.buildFromDetailList(detailList);
  659. return;
  660. }
  661. try {
  662. const categoryList = await getListByNameOrModeType({ codeList });
  663. if (!categoryList || !categoryList.length) {
  664. this.buildFromDetailList(detailList);
  665. return;
  666. }
  667. const assetTypes = [
  668. ...new Set(
  669. categoryList
  670. .map((item) => item.categoryLevelPathIdParent)
  671. .filter(Boolean),
  672. ),
  673. ];
  674. if (assetTypes.length) {
  675. this.formData.extInfo.assetType = assetTypes;
  676. }
  677. let batchNo = "";
  678. try {
  679. batchNo = await getCode("lot_number_code");
  680. } catch (e) {
  681. console.warn("获取批次号失败", e);
  682. }
  683. let packingSpecs = [];
  684. try {
  685. packingSpecs = await getCategoryPackageDisposition({
  686. categoryIds: categoryList.map((item) => item.id),
  687. });
  688. } catch (e) {
  689. console.warn("获取包装规格失败", e);
  690. }
  691. const isMoreProduct = categoryList.length > 1;
  692. this.productList = categoryList.map((item, index) => {
  693. const detail =
  694. detailList.find(
  695. (d) => item.code === (d.productCode || d.categoryCode),
  696. ) ||
  697. detailList[index] ||
  698. {};
  699. const weightUnit = item.weightUnit || "";
  700. const itemPackingSpecs = (packingSpecs || [])
  701. .filter((s) => s.categoryId === item.id)
  702. .sort((a, b) => a.sort - b.sort);
  703. const packingSpecLabel = itemPackingSpecs
  704. .map((s) =>
  705. s.sort > 0
  706. ? `${s.packageCell}${s.packageUnit}/${s.conversionUnit}`
  707. : null,
  708. )
  709. .filter(Boolean)
  710. .join(", ");
  711. let packingQuantity,
  712. measureQuantity,
  713. packUnit,
  714. measureUnit,
  715. warehouseId,
  716. warehouseName,
  717. warehouseIds,
  718. warehouseNames,
  719. modelKey,
  720. colorKey,
  721. packingUnitId;
  722. if (this.isDetail) {
  723. // isAllPackageData==1: 对齐PC端 saleProductList 路径
  724. packUnit =
  725. detail.packingUnit || item.packingUnit || "";
  726. measureUnit =
  727. detail.measuringUnit || item.measuringUnit || "";
  728. packingQuantity =
  729. detail.packingCount || detail.quantity || 0;
  730. measureQuantity = detail.quantity || 0;
  731. warehouseId = detail.warehouseId || "";
  732. warehouseName = detail.warehouseName || "";
  733. warehouseIds = detail.warehouseId
  734. ? [detail.warehouseId]
  735. : [];
  736. warehouseNames = detail.warehouseName
  737. ? [detail.warehouseName]
  738. : [];
  739. modelKey = detail.modelKey
  740. ? detail.modelKey.split(",")
  741. : "";
  742. colorKey = detail.colorKey
  743. ? detail.colorKey.split(",")
  744. : "";
  745. packingUnitId =
  746. detail.purchaseUnitId || detail.saleUnitId || "";
  747. } else {
  748. // isAllPackageData!=1: 对齐PC端 detailList 路径
  749. packUnit = item.packingUnit || "";
  750. measureUnit = item.measuringUnit || "";
  751. const matchDetails = detailList.filter(
  752. (d) =>
  753. (d.productCode || d.categoryCode) === item.code,
  754. );
  755. packingQuantity = isMoreProduct
  756. ? matchDetails.length
  757. : detailList.length;
  758. measureQuantity = isMoreProduct
  759. ? matchDetails.reduce(
  760. (sum, d) => sum + (d.quantity || 0),
  761. 0,
  762. )
  763. : this.form.totalCount || 0;
  764. if (isMoreProduct) {
  765. warehouseId =
  766. matchDetails[0]?.warehouseId || "";
  767. warehouseName =
  768. matchDetails[0]?.warehouseName || "";
  769. warehouseIds = matchDetails.map(
  770. (d) => d.warehouseId,
  771. );
  772. warehouseNames = matchDetails.map(
  773. (d) => d.warehouseName,
  774. );
  775. } else {
  776. warehouseId = this.form.warehouseId || "";
  777. warehouseName = this.form.warehouseName || "";
  778. warehouseIds = Array(detailList.length).fill(
  779. this.form.warehouseId || "",
  780. );
  781. warehouseNames = Array(detailList.length).fill(
  782. this.form.warehouseName || "",
  783. );
  784. }
  785. if (this.bizType == 1) {
  786. modelKey = this.form.modelKey
  787. ? this.form.modelKey.split(",")
  788. : "";
  789. colorKey = this.form.colorKey
  790. ? this.form.colorKey.split(",")
  791. : "";
  792. } else {
  793. modelKey = item.modelKey
  794. ? item.modelKey.split(",")
  795. : "";
  796. colorKey = item.colorKey
  797. ? item.colorKey.split(",")
  798. : "";
  799. }
  800. packingUnitId = "";
  801. }
  802. let weight = detail.weight || 0;
  803. if (
  804. (detail.sendTotalWeight || detail.receiveTotalWeight) &&
  805. item.weightUnit === item.measuringUnit
  806. ) {
  807. weight =
  808. detail.sendTotalWeight || detail.receiveTotalWeight;
  809. }
  810. const singleWeight = detail.singleWeight || 0;
  811. if (!weight && singleWeight) {
  812. weight = singleWeight * measureQuantity;
  813. }
  814. return {
  815. index,
  816. categoryId: item.id,
  817. categoryName: item.name,
  818. categoryCode: item.code,
  819. categoryModel: item.modelType || "",
  820. specification: item.specification || "",
  821. brandNum: item.brandNum || "",
  822. batchNo: this.isDetail
  823. ? detail.batchNo || batchNo
  824. : [1, 3, 6].includes(this.bizType)
  825. ? detailList[0]?.batchNo || batchNo
  826. : batchNo,
  827. packingQuantity,
  828. packingUnit: packUnit,
  829. packingQuantityDisplay:
  830. packingQuantity !== 0
  831. ? `${packingQuantity}${packUnit}`
  832. : "",
  833. measureQuantity,
  834. measureUnit: measureUnit,
  835. measuringUnit: measureUnit,
  836. measureQuantityDisplay:
  837. measureQuantity !== 0
  838. ? `${measureQuantity}${measureUnit}`
  839. : "",
  840. measureType: item.measureType,
  841. weight,
  842. weightUnit,
  843. weightDisplay:
  844. weight !== 0 ? `${weight}${weightUnit}` : "",
  845. singleWeight,
  846. warehouseId,
  847. warehouseName,
  848. warehouseIds,
  849. warehouseNames,
  850. supplierName:
  851. detail.supplierName || item.supplierName || "",
  852. supplierCode:
  853. detail.supplierCode || item.supplierCode || "",
  854. supplierId:
  855. detail.supplierId || this.form.supplierId || "",
  856. productionRequirements:
  857. detail.productionRequirements || "",
  858. packingSpecification:
  859. item.packingSpecification ||
  860. packingSpecLabel ||
  861. "",
  862. packingSpecificationOption: itemPackingSpecs,
  863. packingUnitId,
  864. modelKey,
  865. colorKey,
  866. netWeight:
  867. item.netWeight > -1 ? item.netWeight : 0,
  868. isUnpack: item.isUnpack,
  869. qualityControl: detail.qualityControl,
  870. extField: item.extField || {},
  871. isSave: true,
  872. outInDetailRecordRequestList: [],
  873. };
  874. });
  875. await this.buildPackingList(batchNo);
  876. this.formData.outInDetailList = this.productList;
  877. } catch (e) {
  878. console.warn("初始化产品数据失败", e);
  879. this.buildFromDetailList(detailList);
  880. }
  881. },
  882. buildFromDetailList(detailList) {
  883. this.productList = detailList.map((item, index) => {
  884. const packUnit = item.packingUnit || "";
  885. const measureUnit = item.measuringUnit || "";
  886. const pQty = item.packingCount || item.quantity || 0;
  887. const mQty = item.quantity || item.measureQuantity || 0;
  888. return {
  889. index,
  890. categoryId: item.categoryId || item.id || "",
  891. categoryName: item.categoryName || "",
  892. categoryCode: item.categoryCode || "",
  893. categoryModel: item.modelType || "",
  894. specification: item.specification || "",
  895. brandNum: item.brandNum || "",
  896. batchNo: item.batchNo || "",
  897. packingQuantity: pQty,
  898. packingUnit: packUnit,
  899. packingQuantityDisplay: pQty ? `${pQty}${packUnit}` : "",
  900. measureQuantity: mQty,
  901. measureUnit: measureUnit,
  902. measuringUnit: measureUnit,
  903. measureQuantityDisplay: mQty ? `${mQty}${measureUnit}` : "",
  904. weight: item.weight || 0,
  905. weightUnit: item.weightUnit || "",
  906. weightDisplay: item.weight
  907. ? `${item.weight}${item.weightUnit || ""}`
  908. : "",
  909. singleWeight: item.singleWeight || 0,
  910. warehouseId: item.warehouseId || "",
  911. warehouseName: item.warehouseName || "",
  912. warehouseIds: item.warehouseId ? [item.warehouseId] : [],
  913. warehouseNames: item.warehouseName ? [item.warehouseName] : [],
  914. supplierName: item.supplierName || "",
  915. supplierCode: item.supplierCode || "",
  916. supplierId: item.supplierId || "",
  917. productionRequirements: item.productionRequirements || "",
  918. packingSpecification: item.packingSpecification || "",
  919. isSave: true,
  920. outInDetailRecordRequestList: [],
  921. };
  922. });
  923. this.productList.forEach((product) => {
  924. product.outInDetailRecordRequestList = [
  925. this.buildDefaultPackingEntry(product),
  926. ];
  927. });
  928. this.packingList = this.productList.flatMap(
  929. (p) => p.outInDetailRecordRequestList,
  930. );
  931. this.formData.outInDetailList = this.productList;
  932. },
  933. buildDefaultPackingEntry(product) {
  934. const detail =
  935. (this.form.detailList || []).find(
  936. (d) => (d.productCode || d.categoryCode) === product.categoryCode,
  937. ) || {};
  938. return {
  939. packageNo: "",
  940. categoryCode: product.categoryCode,
  941. categoryName: product.categoryName,
  942. batchNo: product.batchNo,
  943. packingQuantity: product.packingQuantity,
  944. packingUnit: product.packingUnit,
  945. packingQuantityDisplay: product.packingQuantityDisplay,
  946. measureQuantity: product.measureQuantity,
  947. measureUnit: product.measureUnit,
  948. measureQuantityDisplay: product.measureQuantityDisplay,
  949. weight: product.weight,
  950. weightUnit: product.weightUnit,
  951. weightDisplay: product.weightDisplay,
  952. warehouseId: product.warehouseId,
  953. warehouseName: product.warehouseName,
  954. materielDesignation: "",
  955. clientCode: "",
  956. barcodes: "",
  957. engrave: "",
  958. supplierName: product.supplierName,
  959. supplierCode: product.supplierCode,
  960. result: 0,
  961. status: 0,
  962. resultLabel: QUALITY_RESULTS[0],
  963. statusLabel: QUALITY_STATUS[0],
  964. productionDate: "",
  965. purchaseDate: "",
  966. modelKey: product.modelKey || "",
  967. colorKey: product.colorKey || "",
  968. workOrderId: detail.workOrderId || "",
  969. taskId: detail.taskId || "",
  970. };
  971. },
  972. _getNowDateStr() {
  973. const now = new Date();
  974. const pad = (n) => String(n).padStart(2, "0");
  975. return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`;
  976. },
  977. _isNonSplitUnit(unit) {
  978. if (!unit) return false;
  979. const u = unit.toUpperCase();
  980. return ["KG", "G", "L", "ML"].includes(u) || unit === "立方";
  981. },
  982. async buildPackingList(batchNo) {
  983. const detailList = this.form.detailList || [];
  984. const isMoreProduct = this.productList.length > 1;
  985. let productionDate = "";
  986. let purchaseDate = "";
  987. if (this.bizType == 1) {
  988. productionDate = this._getNowDateStr();
  989. }
  990. if (this.isDetail) {
  991. // isAllPackageData == 1: 对齐PC端 saleProductList → batchSave → generateWrappers 路径
  992. // 从 productList 生成包装明细
  993. try {
  994. for (const product of this.productList) {
  995. if (
  996. !product.packingQuantity ||
  997. product.packingQuantity <= 0
  998. )
  999. continue;
  1000. const packingSpecOption =
  1001. product.packingSpecificationOption || [];
  1002. const packingBoolen = this._isNonSplitUnit(
  1003. product.packingUnit,
  1004. );
  1005. const measureBoolen = this._isNonSplitUnit(
  1006. product.measureUnit,
  1007. );
  1008. let packingNum = Number(product.packingQuantity);
  1009. let filterArr = [];
  1010. if (packingBoolen) {
  1011. if (
  1012. !product.isUnpack &&
  1013. product.packingUnit === "立方"
  1014. ) {
  1015. packingNum = 1;
  1016. } else {
  1017. filterArr = packingSpecOption.filter(
  1018. (s) =>
  1019. s.packageUnit === product.packingUnit &&
  1020. s.packageUnit !== s.conversionUnit,
  1021. );
  1022. if (filterArr.length) {
  1023. packingNum = Math.ceil(
  1024. product.packingQuantity /
  1025. filterArr[0].packageCell,
  1026. );
  1027. }
  1028. }
  1029. } else {
  1030. if (product.isUnpack) {
  1031. if (measureBoolen) {
  1032. let splitIndex =
  1033. packingSpecOption.findIndex(
  1034. (s) =>
  1035. s.conversionUnit ===
  1036. product.packingUnit &&
  1037. s.packageUnit !== s.conversionUnit,
  1038. );
  1039. let num = product.packingQuantity;
  1040. for (; splitIndex > 1; splitIndex--) {
  1041. num =
  1042. num *
  1043. packingSpecOption[splitIndex]
  1044. .packageCell;
  1045. }
  1046. packingNum = Math.ceil(num);
  1047. } else {
  1048. if (product.packingUnitId) {
  1049. let splitIndex =
  1050. packingSpecOption.findIndex(
  1051. (s) => s.id == product.packingUnitId,
  1052. );
  1053. if (splitIndex == 0) {
  1054. packingNum = Math.ceil(
  1055. product.measureQuantity /
  1056. (packingSpecOption[1]?.packageCell ||
  1057. 1),
  1058. );
  1059. } else if (splitIndex == 1) {
  1060. packingNum = product.packingQuantity;
  1061. } else {
  1062. for (
  1063. ;
  1064. splitIndex > 1;
  1065. splitIndex--
  1066. ) {
  1067. packingNum = Math.ceil(
  1068. product.packingQuantity *
  1069. packingSpecOption[splitIndex]
  1070. .packageCell,
  1071. );
  1072. }
  1073. }
  1074. } else if (
  1075. packingSpecOption[1]?.packageCell
  1076. ) {
  1077. packingNum = Math.ceil(
  1078. product.measureQuantity /
  1079. packingSpecOption[1].packageCell,
  1080. );
  1081. filterArr = packingSpecOption.filter(
  1082. (s) =>
  1083. s.packageUnit ===
  1084. product.packingUnit &&
  1085. s.packageUnit !== s.conversionUnit,
  1086. );
  1087. }
  1088. }
  1089. } else {
  1090. if (
  1091. product.measureUnit === product.packingUnit
  1092. ) {
  1093. packingNum = 0;
  1094. } else {
  1095. packingNum = Number(
  1096. product.packingQuantity,
  1097. );
  1098. }
  1099. }
  1100. }
  1101. if (packingNum <= 0) packingNum = 1;
  1102. let packageNos = [];
  1103. try {
  1104. const assetNumRes = await getAssetNum([
  1105. {
  1106. assetCode:
  1107. product.categoryCode + product.index,
  1108. batchNum: product.batchNo,
  1109. num: packingNum,
  1110. },
  1111. ]);
  1112. packageNos = assetNumRes?.data || [];
  1113. } catch (e) {
  1114. console.warn("获取包装编码失败", e);
  1115. }
  1116. const qualityStatus =
  1117. product.qualityControl == 1 ? 0 : 2;
  1118. const packingEntries = [];
  1119. for (let i = 0; i < packageNos.length; i++) {
  1120. let measureQuantity = 1;
  1121. let packingQuantity = 1;
  1122. if (packingBoolen) {
  1123. const cell =
  1124. filterArr[0]?.packageCell || 1;
  1125. measureQuantity =
  1126. Number(product.packingQuantity) >
  1127. cell * (i + 1)
  1128. ? cell
  1129. : Number(product.packingQuantity) -
  1130. cell * i;
  1131. } else {
  1132. if (
  1133. product.weightUnit ===
  1134. product.measureUnit &&
  1135. product.weight
  1136. ) {
  1137. measureQuantity =
  1138. Math.trunc(
  1139. (product.weight /
  1140. packageNos.length) *
  1141. 10000,
  1142. ) / 10000;
  1143. } else if (measureBoolen) {
  1144. let splitIndex =
  1145. packingSpecOption.findIndex(
  1146. (s) =>
  1147. s.conversionUnit ===
  1148. product.packingUnit &&
  1149. s.packageUnit !== s.conversionUnit,
  1150. );
  1151. measureQuantity = 1;
  1152. for (; splitIndex > 0; splitIndex--) {
  1153. measureQuantity =
  1154. measureQuantity *
  1155. packingSpecOption[splitIndex]
  1156. .packageCell;
  1157. }
  1158. } else {
  1159. measureQuantity =
  1160. packingSpecOption[1]?.packageCell || 1;
  1161. }
  1162. }
  1163. let clientCode = "";
  1164. if (this.bizType == 2) {
  1165. clientCode =
  1166. product.customerMark || "";
  1167. } else {
  1168. clientCode =
  1169. product.extInfo?.clientCode || "";
  1170. }
  1171. let packingUnit = product.packingUnit;
  1172. if (product.isUnpack) {
  1173. if (packingBoolen) {
  1174. packingUnit =
  1175. packingSpecOption[1]
  1176. ?.conversionUnit ||
  1177. product.packingUnit;
  1178. } else if (measureBoolen) {
  1179. packingUnit =
  1180. (
  1181. packingSpecOption[1] ||
  1182. packingSpecOption[0]
  1183. )?.conversionUnit ||
  1184. product.packingUnit;
  1185. } else {
  1186. packingUnit =
  1187. packingSpecOption[1]
  1188. ?.conversionUnit ||
  1189. product.packingUnit;
  1190. }
  1191. }
  1192. let measureUnit = product.isUnpack
  1193. ? measureBoolen
  1194. ? (
  1195. packingSpecOption[1] ||
  1196. packingSpecOption[0]
  1197. )?.packageUnit ||
  1198. product.measureUnit
  1199. : product.measureUnit
  1200. : product.measureUnit;
  1201. let weight = 0;
  1202. if (
  1203. product.weightUnit === product.measureUnit
  1204. ) {
  1205. weight = measureQuantity
  1206. ? Number(measureQuantity)
  1207. : 0;
  1208. } else if (
  1209. product.singleWeight &&
  1210. measureQuantity
  1211. ) {
  1212. weight =
  1213. Number(measureQuantity) *
  1214. Number(product.singleWeight);
  1215. }
  1216. packingEntries.push({
  1217. index: product.index + "-" + i,
  1218. warehouseId: product.warehouseId || "",
  1219. warehouseName:
  1220. product.warehouseName || "",
  1221. categoryName:
  1222. product.categoryName || "",
  1223. categoryCode:
  1224. product.categoryCode || "",
  1225. categoryModel:
  1226. product.categoryModel || "",
  1227. specification:
  1228. product.specification || "",
  1229. supplierCode:
  1230. product.supplierCode || "",
  1231. supplierName:
  1232. product.supplierName || "",
  1233. brandNum: product.brandNum || "",
  1234. parentIndex: product.index,
  1235. batchNo: product.batchNo || batchNo,
  1236. packageNo:
  1237. packageNos[i]?.onlyCode || "",
  1238. packingQuantity: packingQuantity,
  1239. modelKey: product.modelKey || "",
  1240. colorKey: product.colorKey || "",
  1241. packingUnit: packingUnit,
  1242. measureQuantity: measureQuantity,
  1243. measureUnit: measureUnit,
  1244. weight: weight,
  1245. packingSpecificationOption:
  1246. product.packingSpecificationOption ||
  1247. [],
  1248. weightUnit:
  1249. product.weightUnit || "",
  1250. netWeight: product.netWeight || 0,
  1251. barcodes: "",
  1252. clientCode: clientCode,
  1253. materielDesignation:
  1254. product.extInfo?.materielCode ||
  1255. "",
  1256. engrave: "",
  1257. isUnpack: product.isUnpack,
  1258. productionDate: productionDate,
  1259. purchaseDate: "",
  1260. result: 1,
  1261. qualityControl:
  1262. product.qualityControl,
  1263. status: qualityStatus,
  1264. resultLabel:
  1265. QUALITY_RESULTS[1] || "合格",
  1266. statusLabel:
  1267. QUALITY_STATUS[qualityStatus] ||
  1268. "未质检",
  1269. workOrderId: "",
  1270. taskId: "",
  1271. });
  1272. }
  1273. // 处理尾包余数
  1274. if (
  1275. product.weightUnit !== product.measureUnit &&
  1276. packingSpecOption[1]?.packageCell
  1277. ) {
  1278. const remainder =
  1279. product.measureQuantity %
  1280. packingSpecOption[1].packageCell;
  1281. if (
  1282. remainder > 0 &&
  1283. packingEntries.length > 0
  1284. ) {
  1285. const lastEntry =
  1286. packingEntries[
  1287. packingEntries.length - 1
  1288. ];
  1289. lastEntry.measureQuantity = remainder;
  1290. if (product.singleWeight) {
  1291. lastEntry.weight =
  1292. product.singleWeight * remainder;
  1293. }
  1294. }
  1295. }
  1296. product.outInDetailRecordRequestList =
  1297. packingEntries;
  1298. this.packingList.push(...packingEntries);
  1299. }
  1300. } catch (e) {
  1301. console.warn("生成包装明细失败", e);
  1302. }
  1303. } else {
  1304. // isAllPackageData != 1: 对齐PC端 detailList 路径
  1305. // detailList 每条记录即是一个包装, 直接映射
  1306. const product0 = this.productList[0] || {};
  1307. let getAssetNumPr = isMoreProduct
  1308. ? detailList.map((val) => ({
  1309. assetCode: val.productCode,
  1310. batchNum: val.productBrand,
  1311. num: 1,
  1312. }))
  1313. : [
  1314. {
  1315. assetCode:
  1316. (product0.categoryCode || "") +
  1317. (product0.index ?? 0),
  1318. batchNum: product0.batchNo || "",
  1319. num: detailList.length,
  1320. },
  1321. ];
  1322. let packingCodeList = [];
  1323. try {
  1324. const assetNumRes = await getAssetNum(
  1325. getAssetNumPr,
  1326. );
  1327. packingCodeList = assetNumRes?.data || [];
  1328. } catch (e) {
  1329. console.warn("获取包装编码失败", e);
  1330. }
  1331. this.packingList = detailList.map(
  1332. (item, index) => {
  1333. const matchProduct = isMoreProduct
  1334. ? this.productList.find(
  1335. (val) =>
  1336. val.categoryCode ===
  1337. item.productCode,
  1338. ) || product0
  1339. : product0;
  1340. let clientCode = "";
  1341. if (this.bizType == 2) {
  1342. clientCode = item.customerMark || "";
  1343. } else {
  1344. clientCode =
  1345. item.clientCode ||
  1346. item.extInfo?.clientCode ||
  1347. "";
  1348. }
  1349. return {
  1350. index:
  1351. (isMoreProduct
  1352. ? matchProduct.index
  1353. : product0.index) +
  1354. "-" +
  1355. index,
  1356. warehouseId:
  1357. item.warehouseId ||
  1358. (product0.warehouseIds || [])[index] ||
  1359. "",
  1360. warehouseName:
  1361. item.warehouseName ||
  1362. (product0.warehouseNames || [])[
  1363. index
  1364. ] ||
  1365. "",
  1366. categoryName:
  1367. item.productName ||
  1368. product0.categoryName ||
  1369. "",
  1370. categoryCode:
  1371. item.productCode ||
  1372. product0.categoryCode ||
  1373. "",
  1374. categoryModel:
  1375. item.modelType ||
  1376. product0.categoryModel ||
  1377. "",
  1378. specification:
  1379. item.specification ||
  1380. product0.specification ||
  1381. "",
  1382. brandNum:
  1383. item.productBrand ||
  1384. product0.brandNum ||
  1385. "",
  1386. colorKey: (
  1387. item.colorKey
  1388. ? item.colorKey.split(",")
  1389. : ""
  1390. ) || product0.colorKey || "",
  1391. modelKey: (
  1392. item.modelKey
  1393. ? item.modelKey.split(",")
  1394. : ""
  1395. ) || product0.modelKey || "",
  1396. parentIndex: isMoreProduct
  1397. ? matchProduct.index
  1398. : product0.index,
  1399. batchNo: product0.batchNo || batchNo,
  1400. packageNo:
  1401. item.packageNo ||
  1402. item.packingCode ||
  1403. packingCodeList[index]?.onlyCode ||
  1404. "",
  1405. packingQuantity: 1,
  1406. packingUnit: item.packingUnit || "",
  1407. measureQuantity:
  1408. item.quantity ||
  1409. item.measureQuantity ||
  1410. 0,
  1411. measureUnit:
  1412. item.measuringUnit ||
  1413. item.measureUnit ||
  1414. "",
  1415. supplierCode:
  1416. item.supplierCode || "",
  1417. supplierId: item.supplierId || "",
  1418. supplierName:
  1419. item.supplierName || "",
  1420. weight: item.packingWeight || 0,
  1421. singleWeight:
  1422. item.singleWeight || 0,
  1423. pricingWay: item.pricingWay || "",
  1424. weightUnit:
  1425. item.weightUnit ||
  1426. product0.weightUnit ||
  1427. "",
  1428. packingSpecificationOption:
  1429. isMoreProduct
  1430. ? matchProduct.packingSpecificationOption ||
  1431. []
  1432. : product0.packingSpecificationOption ||
  1433. [],
  1434. netWeight: product0.netWeight || 0,
  1435. barcodes:
  1436. item.barcodes ||
  1437. item.sendCode ||
  1438. "",
  1439. clientCode: clientCode,
  1440. materielDesignation:
  1441. item.materielDesignation ||
  1442. item.extInfo?.materielCode ||
  1443. "",
  1444. engrave:
  1445. item.engrave ||
  1446. item.extInfo?.engrave ||
  1447. "",
  1448. isUnpack: product0.isUnpack,
  1449. productionDate: productionDate,
  1450. purchaseDate: purchaseDate,
  1451. result: 1,
  1452. status: 2,
  1453. resultLabel:
  1454. QUALITY_RESULTS[1] || "合格",
  1455. statusLabel:
  1456. QUALITY_STATUS[2] || "已质检",
  1457. serialNumber:
  1458. item.productSequence || "",
  1459. workOrderId:
  1460. item.workOrderId || "",
  1461. taskId: item.taskId || "",
  1462. };
  1463. },
  1464. );
  1465. this.productList.forEach((product) => {
  1466. product.outInDetailRecordRequestList =
  1467. this.packingList.filter(
  1468. (p) =>
  1469. p.categoryCode ===
  1470. product.categoryCode,
  1471. );
  1472. });
  1473. }
  1474. },
  1475. async getReturnStorage() {
  1476. if (!this.productList.length) {
  1477. uni.showToast({ title: "暂无产品信息!", icon: "none" });
  1478. return null;
  1479. }
  1480. const detailList = this.form.detailList || [];
  1481. const _packingList = this.packingList.map((packingItem) => {
  1482. let _workOrderId = null;
  1483. let _taskId = null;
  1484. if ([1].includes(this.bizType)) {
  1485. _workOrderId = detailList[0]?.workOrderId;
  1486. _taskId = detailList[0]?.taskId;
  1487. }
  1488. const processed = { ...packingItem };
  1489. if (processed.modelKey) {
  1490. processed.modelKey = processed.modelKey.toString();
  1491. }
  1492. if (processed.colorKey) {
  1493. processed.colorKey = processed.colorKey.toString();
  1494. }
  1495. return {
  1496. ...processed,
  1497. workOrderId: _workOrderId,
  1498. taskId: _taskId,
  1499. materialDetailList: [],
  1500. };
  1501. });
  1502. const processedProductList = this.productList.map((productItem) => {
  1503. const processed = { ...productItem };
  1504. if (processed.modelKey) {
  1505. processed.modelKey = processed.modelKey.toString();
  1506. }
  1507. if (processed.colorKey) {
  1508. processed.colorKey = processed.colorKey.toString();
  1509. }
  1510. return {
  1511. ...processed,
  1512. outInDetailRecordRequestList: _packingList.filter(
  1513. (item) => item.parentIndex === productItem.index,
  1514. ),
  1515. };
  1516. });
  1517. const obj = JSON.parse(JSON.stringify(this.formData));
  1518. obj.type = 1;
  1519. if (Array.isArray(obj.extInfo.assetType)) {
  1520. obj.extInfo.assetType = obj.extInfo.assetType.join(",");
  1521. }
  1522. obj.extInfo.documentSource = obj.sourceBizNo;
  1523. obj.extInfo.deptName = this.formData.extInfo.deptName || "";
  1524. obj.extInfo.supplierName = this.form.supplierName || "";
  1525. const warehouseId = [];
  1526. const warehouseName = [];
  1527. processedProductList.forEach((item) => {
  1528. const ids = item.warehouseIds || [];
  1529. const names = item.warehouseNames || [];
  1530. ids.forEach((id, idx) => {
  1531. if (id && !warehouseId.includes(id)) {
  1532. warehouseId.push(id);
  1533. warehouseName.push(names[idx] || "");
  1534. }
  1535. });
  1536. });
  1537. obj.warehouseIds = warehouseId;
  1538. obj.warehouseNames = warehouseName;
  1539. obj.outInDetailList = processedProductList;
  1540. obj._packingList = _packingList;
  1541. try {
  1542. const isVerifyData = await isVerifyRepeatIsStock({
  1543. categoryCodes: this.productList.map((item) => item.categoryCode),
  1544. batchNos: this.productList.map((item) => item.batchNo),
  1545. });
  1546. if (isVerifyData?.length) {
  1547. return new Promise((resolve) => {
  1548. uni.showModal({
  1549. title: "提示",
  1550. content: `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
  1551. .map((item) => item.categoryName)
  1552. .join(",")}已有入库记录,是否继续入库!`,
  1553. confirmText: "是",
  1554. cancelText: "否",
  1555. success: (modalRes) => {
  1556. if (modalRes.confirm) {
  1557. resolve(obj);
  1558. } else {
  1559. resolve(false);
  1560. }
  1561. },
  1562. });
  1563. });
  1564. }
  1565. } catch (e) {
  1566. console.warn("验证重复入库失败", e);
  1567. }
  1568. return obj;
  1569. },
  1570. async getTableValue() {
  1571. const returnStorageData = await this.getReturnStorage();
  1572. return {
  1573. form: this.form,
  1574. returnStorageData: returnStorageData || {},
  1575. };
  1576. },
  1577. },
  1578. };
  1579. </script>
  1580. <style lang="scss">
  1581. .subsection-wrap {
  1582. background: #f5f7fa;
  1583. padding: 0 16rpx 12rpx;
  1584. }
  1585. .basic_info {
  1586. box-sizing: border-box;
  1587. padding: 0 20rpx;
  1588. }
  1589. .info_header {
  1590. margin-top: 10rpx;
  1591. }
  1592. .info_title {
  1593. position: relative;
  1594. padding: 16rpx 50rpx;
  1595. font-size: 36rpx;
  1596. color: #606266;
  1597. }
  1598. .info_title::after {
  1599. content: "";
  1600. position: absolute;
  1601. top: 16rpx;
  1602. left: 0px;
  1603. width: 16rpx;
  1604. height: 50rpx;
  1605. background: #1890ff;
  1606. }
  1607. .info_content {
  1608. .label {
  1609. padding: 20rpx 0;
  1610. text-align: right;
  1611. font-size: 28rpx;
  1612. font-weight: 700;
  1613. color: #6e6e6e;
  1614. }
  1615. .value {
  1616. padding: 20rpx 0;
  1617. font-size: 28rpx;
  1618. color: #606266;
  1619. }
  1620. }
  1621. .card_box {
  1622. box-sizing: border-box;
  1623. padding: 20rpx;
  1624. margin: 20rpx;
  1625. width: calc(100% - 40rpx);
  1626. border-radius: 20rpx;
  1627. box-shadow: 0 0 12rpx -6rpx #000;
  1628. .card_title {
  1629. font-size: 32rpx;
  1630. font-weight: 700;
  1631. color: #666;
  1632. margin-bottom: 10rpx;
  1633. }
  1634. .label {
  1635. padding: 18rpx 0;
  1636. text-align: right;
  1637. font-size: 28rpx;
  1638. font-weight: 700;
  1639. color: #6e6e6e;
  1640. }
  1641. .value {
  1642. padding: 18rpx 0;
  1643. font-size: 28rpx;
  1644. color: #606266;
  1645. }
  1646. }
  1647. .empty_text {
  1648. text-align: center;
  1649. color: #909399;
  1650. font-size: 28rpx;
  1651. padding: 80rpx 0;
  1652. }
  1653. </style>