taskForm.vue 54 KB

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