taskForm.vue 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. <template>
  2. <view class="">
  3. <u-sticky offset-top="50">
  4. <u-subsection fontSize='25' mode='subsection' :list="list" :current="curNow" @change="sectionChange"
  5. activeColor='#157A2C'></u-subsection>
  6. </u-sticky>
  7. <view v-show="curNow===0">
  8. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
  9. <u-form-item label="收货单编码" prop="receiveNo" borderBottom>
  10. <u--input style="width: 100%;" disabled v-model="form.receiveNo"></u--input>
  11. </u-form-item>
  12. <u-form-item label="订单编码" prop="orderNo" borderBottom>
  13. <u--input style="width: 100%;" disabled v-model="form.orderNo"></u--input>
  14. </u-form-item>
  15. <u-form-item label="制单人" prop="makerName" borderBottom>
  16. <u--input style="width: 100%;" disabled v-model="form.makerName"></u--input>
  17. </u-form-item>
  18. <u-form-item label="供应商名称" prop="supplierName" borderBottom>
  19. <u--input style="width: 100%;" disabled v-model="form.supplierName"></u--input>
  20. </u-form-item>
  21. <u-form-item label="供应商联系人" prop="linkName" borderBottom>
  22. <u--input style="width: 100%;" disabled v-model="form.linkName"></u--input>
  23. </u-form-item>
  24. <u-form-item label="供应商电话" prop="linkPhone" borderBottom>
  25. <u--input style="width: 100%;" disabled v-model="form.linkPhone"></u--input>
  26. </u-form-item>
  27. <u-form-item label="车牌" prop="carNo" borderBottom>
  28. <u--input style="width: 100%;" disabled v-model="form.carNo"></u--input>
  29. </u-form-item>
  30. <u-form-item label="收货日期" prop="receiveDate" borderBottom>
  31. <u--input style="width: 100%;" disabled v-model="form.receiveDate"></u--input>
  32. </u-form-item>
  33. <u-form-item label="委外发货单编码" prop="outsourceSendCode" borderBottom>
  34. <u--input style="width: 100%;" disabled v-model="form.outsourceSendCode"></u--input>
  35. </u-form-item>
  36. <u-form-item label="附件" prop="receiveFiles" borderBottom>
  37. <fileMain v-model="form.receiveFiles" type="view"></fileMain>
  38. </u-form-item>
  39. </u--form>
  40. </view>
  41. <view v-show="curNow===1">
  42. <view v-for="(item,index) in form['productList']" :key="index">
  43. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
  44. <u-row v-for="(key,index1) in tableField" :key="index1">
  45. <u-col :span="12">
  46. <u-form-item :label="key.label" prop="categoryName" borderBottom>
  47. <text>{{ key.formatter ? key.formatter(item) : (item[key.field] || '-') }}</text>
  48. </u-form-item>
  49. </u-col>
  50. </u-row>
  51. </u--form>
  52. <u-gap height="40" bgColor="#f0f0f0"></u-gap>
  53. </view>
  54. </view>
  55. <view v-show="curNow===2">
  56. <u--form style="margin: 0 20px;" labelPosition="left" :model="formData" ref="outForm" :rules="outRules" labelWidth='140rpx'>
  57. <u-form-item label="物品类型" prop="extInfo.assetType" borderBottom>
  58. <u--input style="width: 100%;" disabled v-model="formData.extInfo.assetTypeName"></u--input>
  59. </u-form-item>
  60. <u-form-item label="入库类型" prop="bizType" borderBottom>
  61. <u--input style="width: 100%;" disabled v-model="formData.bizTypeStr"></u--input>
  62. </u-form-item>
  63. <u-form-item label="单据来源" prop="sourceBizNo" borderBottom>
  64. <u--input style="width: 100%;" disabled v-model="formData.sourceBizNo"></u--input>
  65. </u-form-item>
  66. <u-form-item label="入库时间" prop="storageTime" borderBottom>
  67. <uni-datetime-picker type="datetime" v-model="formData.storageTime" />
  68. </u-form-item>
  69. <u-form-item label="入库登记人" prop="extInfo.createUserName" borderBottom>
  70. <u--input style="width: 100%;" disabled v-model="formData.extInfo.createUserName"></u--input>
  71. </u-form-item>
  72. <u-form-item label="审核人" prop="approvalUserName" borderBottom>
  73. <u--input disabled style="width: 100%;" v-model="formData.approvalUserName"></u--input>
  74. </u-form-item>
  75. <u-form-item label="备注" prop="remark" borderBottom>
  76. <u--input style="width: 100%;" v-model="formData.remark"></u--input>
  77. </u-form-item>
  78. </u--form>
  79. </view>
  80. <view class="tab-content" v-show="curNow===3">
  81. <!-- 批量操作按钮 -->
  82. <view class="batch-actions" v-if="productList.length > 0">
  83. <u-button type="success" plain size="small" text="批量保存" @click="listSaveArrs" :disabled="packingList.length > 0"></u-button>
  84. <picker v-if="packingList.length === 0" class="info-picker" :value="warehouseIndex" :range="warehouseListOption" range-key="name" @change="(e) => handleWareHouse(e, productList)">
  85. <u-button type="success" plain size="small" text="批量选择仓库" v-if="packingList.length === 0"></u-button>
  86. </picker>
  87. </view>
  88. <view v-if="productList.length === 0" class="empty-tip" style="text-align: center; color: #999; font-size: 28rpx; padding: 100rpx 0;">
  89. 暂无产品信息
  90. </view>
  91. <view v-else>
  92. <view class="product-card" v-for="(row, index) in productList" :key="index">
  93. <view class="card-header">
  94. <text class="product-name">{{ row.categoryName || '-' }}</text>
  95. <text class="product-code">{{ row.categoryCode || '-' }}</text>
  96. <!-- <text class="card-index">{{ index + 1 }}</text> -->
  97. </view>
  98. <view class="card-body">
  99. <!-- 批次号 - isSave为false时可编辑 -->
  100. <view class="info-row edit-row">
  101. <text class="info-label">批次号 <text class="required">*</text></text>
  102. <u--input v-if="!row.isSave" class="info-input" type="text" v-model="row.batchNo" placeholder="请输入批次号" />
  103. <text v-else class="info-value">{{ row.batchNo || '-' }}</text>
  104. </view>
  105. <!-- 数量 - isSave为false时可编辑 -->
  106. <view class="info-row edit-row">
  107. <text class="info-label">数量 <text class="required">*</text></text>
  108. <u--input v-if="!row.isSave" class="info-input" type="number" v-model="row.packingQuantity" placeholder="请输入数量" @input="computeNum(row, index, true)" />
  109. <text v-else class="info-value">{{ row.packingQuantity || '-' }}</text>
  110. </view>
  111. <!-- 单位选择 -->
  112. <view class="info-row edit-row">
  113. <text class="info-label">单位 <text class="required">*</text></text>
  114. <picker v-if="!row.isSave" class="info-picker" :value="row.packingUnitIndex" :range="row.packingSpecificationOption" range-key="conversionUnit" @change="(e) => onPackingUnitChange(e, row, index)">
  115. <view class="picker-value">{{ row.packingUnit || '请选择单位' }}</view>
  116. </picker>
  117. <text v-else class="info-value">{{ row.packingUnit || '-' }}</text>
  118. </view>
  119. <!-- 包装完好与否 -->
  120. <view class="info-row edit-row" v-if="isShowPackage">
  121. <text class="info-label">包装完好 <text class="required">*</text></text>
  122. <picker v-if="!row.isSave" class="info-picker" :value="row.ifPackageOkIndex" :range="packageOkOptions" range-key="label" @change="(e) => onPackageOkChange(e, row)">
  123. <view class="picker-value">{{ row.ifPackageOkLabel || '请选择' }}</view>
  124. </picker>
  125. <text v-else class="info-value">{{ row.ifPackageOk == 1 ? '是' : row.ifPackageOk == 0 ? '否' : '-' }}</text>
  126. </view>
  127. <!-- 拆包装责任人 -->
  128. <view class="info-row edit-row" v-if="isShowPackage">
  129. <text class="info-label">拆包责任人 <text class="required">*</text></text>
  130. <input v-if="!row.isSave" class="info-input" type="text" v-model="row.unpackUserName" placeholder="请选择" readonly @click="handHead(row, index)" />
  131. <text v-else class="info-value">{{ row.unpackUserName || '-' }}</text>
  132. </view>
  133. <!-- 只读字段 -->
  134. <view class="info-row">
  135. <text class="info-label">计量数量</text>
  136. <text class="info-value">{{ row.measureQuantity || '0' }}</text>
  137. </view>
  138. <view class="info-row">
  139. <text class="info-label">计量单位</text>
  140. <text class="info-value">{{ row.measureUnit || '-' }}</text>
  141. </view>
  142. <!-- 单重 -->
  143. <view class="info-row edit-row">
  144. <text class="info-label">单重</text>
  145. <u--input v-if="!row.isSave" class="info-input" type="digit" v-model="row.singleWeight" placeholder="请输入单重" :disabled="row.weightUnit == row.packingUnit" @input="inputsingleWeight(row, index)" />
  146. <text v-else class="info-value">{{ row.singleWeight || '0' }} {{ row.weightUnit || '' }}</text>
  147. </view>
  148. <!-- 总重 -->
  149. <view class="info-row edit-row">
  150. <text class="info-label">总重</text>
  151. <u--input v-if="!row.isSave" class="info-input" type="digit" v-model="row.weight" placeholder="请输入总重" :disabled="row.weightUnit == row.packingUnit" @input="inputWeight(row, index)" />
  152. <text v-else class="info-value">{{ row.weight || '0' }} {{ row.weightUnit || '' }}</text>
  153. </view>
  154. <view class="info-row">
  155. <text class="info-label">重量单位</text>
  156. <text class="info-value">{{ row.weightUnit || '-' }}</text>
  157. </view>
  158. <view class="info-row">
  159. <text class="info-label">生产要求</text>
  160. <text class="info-value">{{ row.productionRequirements || '-' }}</text>
  161. </view>
  162. <view class="info-row">
  163. <text class="info-label">包装规格</text>
  164. <text class="info-value">{{ row.packingSpecificationLabel ? row.packingSpecificationLabel.join(', ') : '-' }}</text>
  165. </view>
  166. <view class="info-row">
  167. <text class="info-label">允许拆包</text>
  168. <text class="info-value">{{ row.isUnpack == 1 ? '是' : '否' }}</text>
  169. </view>
  170. <!-- 仓库 - 必填 -->
  171. <view class="info-row edit-row">
  172. <text class="info-label">仓库 <text class="required">*</text></text>
  173. <picker v-if="!row.isSave" class="info-picker" :value="row.warehouseIndex" :range="warehouseListOption" range-key="name" @change="(e) => onWarehouseChange(e, row)">
  174. <view class="picker-value">{{ row.warehouseName || '请选择仓库' }}</view>
  175. </picker>
  176. <text v-else class="info-value" :class="{ 'red-text': !row.warehouseName }">{{ row.warehouseName || '请选择仓库' }}</text>
  177. </view>
  178. <!-- 供应商 -->
  179. <view class="info-row edit-row">
  180. <text class="info-label">供应商</text>
  181. <picker v-if="!row.isSave" class="info-picker" :value="row.supplierIndex" :range="row.supplierListOptions" range-key="name" @change="(e) => onSupplierChange(e, row)">
  182. <view class="picker-value">{{ row.supplierName || '请选择供应商' }}</view>
  183. </picker>
  184. <text v-else class="info-value">{{ row.supplierName || '-' }}</text>
  185. </view>
  186. <view class="info-row">
  187. <text class="info-label">供应商代号</text>
  188. <text class="info-value">{{ row.supplierCode || '-' }}</text>
  189. </view>
  190. <!-- 采购原因 -->
  191. <view class="info-row edit-row">
  192. <text class="info-label">采购原因</text>
  193. <u--input v-if="!row.isSave" class="info-input" type="text" v-model="row.purpose" placeholder="请输入采购原因" />
  194. <text v-else class="info-value">{{ row.purpose || '-' }}</text>
  195. </view>
  196. <view class="info-row">
  197. <text class="info-label">是否质检</text>
  198. <text class="info-value">{{ row.qualityControl == 1 ? '是' : '否' }}</text>
  199. </view>
  200. <!-- 生产日期 -->
  201. <view class="info-row edit-row">
  202. <text class="info-label">生产日期</text>
  203. <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailProductionDate" @change="(e) => onDateChange(e, row, 'detailProductionDate')">
  204. <view class="picker-value" :class="{ 'placeholder': !row.detailProductionDate }">{{ row.detailProductionDate || '请选择日期' }}</view>
  205. </picker> -->
  206. <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailProductionDate" />
  207. <text v-else class="info-value">{{ row.detailProductionDate || '-' }}</text>
  208. </view>
  209. <!-- 采购日期 -->
  210. <view class="info-row edit-row">
  211. <text class="info-label">采购日期</text>
  212. <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailPurchaseDate" @change="(e) => onDateChange(e, row, 'detailPurchaseDate')">
  213. <view class="picker-value" :class="{ 'placeholder': !row.detailPurchaseDate }">{{ row.detailPurchaseDate || '请选择日期' }}</view>
  214. </picker> -->
  215. <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailPurchaseDate" />
  216. <text v-else class="info-value">{{ row.detailPurchaseDate || '-' }}</text>
  217. </view>
  218. <!-- 失效日期 -->
  219. <view class="info-row edit-row">
  220. <text class="info-label">失效日期</text>
  221. <!-- <picker v-if="!row.isSave" class="info-picker" mode="date" :value="row.detailExpireDate" @change="(e) => onDateChange(e, row, 'detailExpireDate')">
  222. <view class="picker-value" :class="{ 'placeholder': !row.detailExpireDate }">{{ row.detailExpireDate || '请选择日期' }}</view>
  223. </picker> -->
  224. <uni-datetime-picker v-if="!row.isSave" type="datetime" v-model="row.detailExpireDate" />
  225. <text v-else class="info-value">{{ row.detailExpireDate || '-' }}</text>
  226. </view>
  227. <!-- 机型 - 单选 -->
  228. <view class="info-row edit-row">
  229. <text class="info-label">机型</text>
  230. <picker v-if="!row.isSave" class="info-picker" mode="selector" :value="row.modelIndex" :range="modelOptions" range-key="dictValue" @change="(e) => onModelChange(e, index)">
  231. <view class="picker-value">{{ row.modelKeyName || '请选择机型' }}</view>
  232. </picker>
  233. <text v-else class="info-value">{{ row.modelKeyName || '-' }}</text>
  234. </view>
  235. <!-- 颜色 - 单选 -->
  236. <view class="info-row edit-row">
  237. <text class="info-label">颜色</text>
  238. <picker v-if="!row.isSave" class="info-picker" mode="selector" :value="row.colorIndex" :range="colorOptions" range-key="dictValue" @change="(e) => onColorChange(e, index)">
  239. <view class="picker-value">{{ row.colorKeyName || '请选择颜色' }}</view>
  240. </picker>
  241. <text v-else class="info-value">{{ row.colorKeyName || '-' }}</text>
  242. </view>
  243. </view>
  244. <view class="card-footer">
  245. <view class="action-buttons">
  246. <u-button v-if="!row.isSave" type="primary" size="small" text="保存" @click="listSave(row, index)"></u-button>
  247. <u-button v-else type="primary" size="small" text="编辑" @click="editProductList(row, index)"></u-button>
  248. <u-button type="error" size="small" text="删除" @click="listDel(row, index)"></u-button>
  249. </view>
  250. </view>
  251. </view>
  252. </view>
  253. <view class="add" @click="addProduct">
  254. <u-icon name="plus" color="#fff"></u-icon>
  255. </view>
  256. </view>
  257. <view class="tab-content" v-show="curNow===4">
  258. <!-- 包装明细 -->
  259. <view v-if="showPackingList.length > 0" class="packing-section">
  260. <view class="section-title">
  261. <text>包装明细</text>
  262. </view>
  263. <view class="packing-card" v-for="(item, index) in showPackingList" :key="'pkg-' + index">
  264. <view class="info-row">
  265. <text class="info-label">编码</text>
  266. <text class="info-value">{{ item.categoryCode || '-' }}</text>
  267. </view>
  268. <view class="info-row">
  269. <text class="info-label">名称</text>
  270. <text class="info-value">{{ item.categoryName || '-' }}</text>
  271. </view>
  272. <view class="info-row">
  273. <text class="info-label">批次号</text>
  274. <text class="info-value">{{ item.batchNo || '-' }}</text>
  275. </view>
  276. <view class="info-row">
  277. <text class="info-label">包装编码</text>
  278. <text class="info-value">{{ item.packageNo || '-' }}</text>
  279. </view>
  280. <view class="info-row">
  281. <text class="info-label">包装数量</text>
  282. <text class="info-value">{{ item.packingQuantity || '0' }} {{ item.packingUnit || '' }}</text>
  283. </view>
  284. <view class="info-row">
  285. <text class="info-label">计量数量</text>
  286. <text class="info-value">{{ item.measureQuantity || '0' }} {{ item.measureUnit || '' }}</text>
  287. </view>
  288. <view class="info-row">
  289. <text class="info-label">仓库</text>
  290. <text class="info-value">{{ item.warehouseName || '-' }}</text>
  291. </view>
  292. <view class="info-row">
  293. <text class="info-label">物料代号</text>
  294. <text class="info-value">{{ item.materielDesignation || '-' }}</text>
  295. </view>
  296. <view class="info-row">
  297. <text class="info-label">客户代号</text>
  298. <text class="info-value">{{ item.clientCode || '-' }}</text>
  299. </view>
  300. <view class="info-row">
  301. <text class="info-label">重量</text>
  302. <text class="info-value">{{ item.weight || '0' }} {{ item.weightUnit || '' }}</text>
  303. </view>
  304. <view class="info-row">
  305. <text class="info-label">生产日期</text>
  306. <text class="info-value">{{ item.productionDate || '-' }}</text>
  307. </view>
  308. <view class="info-row">
  309. <text class="info-label">采购日期</text>
  310. <text class="info-value">{{ item.purchaseDate || '-' }}</text>
  311. </view>
  312. </view>
  313. </view>
  314. </view>
  315. </view>
  316. </template>
  317. <script>
  318. import {
  319. purchaseOrderReceiveGetByIdAPI
  320. } from '@/api/wt/index.js'
  321. import { sceneState, qualityResultsOptions, qualityStatus, qualityResults } from '@/enum/dict.js'
  322. import fileMain from "@/pages/doc/index.vue"
  323. import { parameterGetByCode } from '@/api/mainData/index.js'
  324. import { getListByNameOrModeType, getCode, contactQueryByCategoryIdsAPI, getCategoryPackageDisposition, getProduceTreeByPid, warehouseDefinitionList, getAssetNum, getWarehouseList, isVerifyRepeatIsStock } from '@/api/warehouseManagement/index.js'
  325. import { mapGetters, mapActions } from 'vuex'
  326. import { unary } from 'lodash'
  327. export default {
  328. components: {
  329. fileMain
  330. },
  331. props: {
  332. businessId: {
  333. default: ''
  334. },
  335. taskDefinitionKey: {
  336. default: ''
  337. },
  338. },
  339. computed: {
  340. ...mapGetters(['dict', 'getDict', 'getDictValue']),
  341. // 颜色选项(数组)
  342. colorOptions() {
  343. return this.dict?.product_color_key || []
  344. },
  345. // 机型选项(数组)
  346. modelOptions() {
  347. return this.dict?.product_model_key || []
  348. },
  349. list() {
  350. return this.showPackingList.length > 0 ? ['收货信息', '物品清单', '入库信息', '产品信息', '包装明细'] : ['收货信息', '物品清单', '入库信息', '产品信息']
  351. },
  352. tableField() {
  353. const priceField = [
  354. { label: '单价', field: 'singlePrice' },
  355. { label: '不含税单价', field: 'notaxSinglePrice' },
  356. { label: '折后单价', field: 'discountSinglePrice' },
  357. { label: '合计', field: 'totalPrice' },
  358. { label: '折后合计', field: 'discountTotalPrice' },
  359. ]
  360. const baseField = [
  361. { label: '名称', field: 'productName' },
  362. { label: '编码', field: 'productCode' },
  363. { label: '类型', field: 'productCategoryName' },
  364. { label: '批次号', field: 'batchNo' },
  365. { label: '规格', field: 'specification' },
  366. { label: '型号', field: 'modelType' },
  367. { label: '包装规格', field: 'packingSpecification' },
  368. { label: '供应商代号', field: 'supplierMark' },
  369. { label: '仓库名称', field: 'warehouseName' },
  370. { label: '收货数量', field: 'purchaseCount', formatter: (row) => (row.purchaseCount || '-') + row.purchaseUnit },
  371. { label: '单重', field: 'singleWeight', formatter: (row) => row.singleWeight ? row.singleWeight + ' ' + row.weightUnit : '-' },
  372. { label: '发货总重', field: 'sendTotalWeight', formatter: (row) => row.sendTotalWeight ? row.sendTotalWeight + ' ' + row.weightUnit : '-' },
  373. { label: '收货总重', field: 'receiveTotalWeight', formatter: (row) => row.receiveTotalWeight ? row.receiveTotalWeight + ' ' + row.weightUnit : '-' },
  374. { label: '增重重量', field: 'increaseTotalWeight', formatter: (row) => row.increaseTotalWeight ? row.increaseTotalWeight + ' ' + row.weightUnit : '-' },
  375. { label: '计量数量', field: 'totalCount', formatter: (row) => (row.totalCount || '-') + row.measuringUnit },
  376. { label: '是否来料检验', field: 'isComeCheck', formatter: (row) => row.isComeCheck == 1 ? '是' : '否' },
  377. ]
  378. return this.taskDefinitionKey == 'storeManagerApprove' && this.isHidePrice == 0 ? baseField : [...baseField, ...priceField]
  379. },
  380. tableField2() {
  381. return [
  382. { label: '名称', field: 'categoryName' },
  383. { label: '编码', field: 'categoryCode' },
  384. { label: '型号', field: 'categoryModel' },
  385. { label: '规格', field: 'specification' },
  386. { label: '牌号', field: 'brandNum' },
  387. { label: '批次号', field: 'batchNo' },
  388. { label: '数量', field: 'packingQuantity' },
  389. { label: '单位', field: 'packingUnit' },
  390. { label: '单重', field: 'singleWeight' },
  391. { label: '总重', field: 'weight' },
  392. { label: '重量单位', field: 'weightUnit' },
  393. { label: '供应商', field: 'supplierId' },
  394. { label: '仓库', field: 'warehouseName' },
  395. { label: '颜色', field: 'colorKey' },
  396. { label: '机型', field: 'modelKey' },
  397. { label: '采购原因', field: 'purpose' },
  398. { label: '生产日期', field: 'detailProductionDate' },
  399. { label: '采购日期', field: 'detailPurchaseDate' },
  400. { label: '失效日期', field: 'detailExpireDate' },
  401. { label: '是否质检', field: 'qualityControl' },
  402. { label: '包装规格', field: 'packingSpecificationLabel' },
  403. { label: '允许拆包', field: 'isUnpack' },
  404. { label: '计量数量', field: 'measureQuantity' },
  405. { label: '计量单位', field: 'measureUnit' },
  406. { label: '生产要求', field: 'weightUnit' },
  407. { label: '供应商名称', field: 'supplierName' },
  408. { label: '供应商代号', field: 'supplierCode' },
  409. { label: '产地', field: 'supplierCode' },
  410. ]
  411. }
  412. },
  413. data() {
  414. return {
  415. form: {},
  416. userInfo: {},
  417. formData: {
  418. bizType: '',
  419. bizTypeStr: '',
  420. storageTime: '',
  421. qualityControl: '',
  422. extInfo: {
  423. assetType: [],
  424. assetTypeName: ''
  425. }
  426. },
  427. isHidePrice: 0,
  428. warehouseIndex: 0,
  429. curNow: 0,
  430. packingSpecificationOption: [],
  431. productList: [],
  432. packingList: [],
  433. showPackingList: [],
  434. goodsLists: [],
  435. outRules: {},
  436. sceneState,
  437. qualityResultsOptions,
  438. qualityStatus,
  439. qualityResults,
  440. isWrapTable: true,
  441. pageSize: 20,
  442. pickingPageNum: 1,
  443. visibleDialog: false,
  444. title: '选择产品',
  445. loadTree: true,
  446. isShowPackage: false,
  447. packageOkOptions: [
  448. { label: '是', value: 1 },
  449. { label: '否', value: 0 }
  450. ],
  451. }
  452. },
  453. beforeDestroy() {
  454. uni.$off('setSelectList')
  455. },
  456. created() {
  457. uni.$on('setSelectList', async data => {
  458. // uni.removeStorageSync('productList')
  459. console.log('setSelectList~~~', data)
  460. if (data?.length) {
  461. // 获取批次号
  462. const batchNo = await getCode('lot_number_code');
  463. // 获取供应商
  464. const supplierList = await contactQueryByCategoryIdsAPI({
  465. categoryIds: data.map((item) => item.id)
  466. });
  467. // 获取包装规格
  468. let packingSpecification = await getCategoryPackageDisposition({
  469. categoryIds: data.map((item) => item.id)
  470. });
  471. this.packingSpecificationOption = data.map((item) => {
  472. return packingSpecification
  473. .filter((ite) => item.id == ite.categoryId)
  474. .sort((a, b) => a.sort - b.sort);
  475. });
  476. const newSpecificationOption = this.packingSpecificationOption;
  477. let productList = data.map((item, index) => {
  478. // 显示规格
  479. let packingSpecificationLabel = this.packingSpecificationOption[index].map((item) => {
  480. if (item.sort > 0) {
  481. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  482. }
  483. }).filter((item) => !!item);
  484. return {
  485. index:
  486. this.productList.length - 1 > -1
  487. ? this.productList[this.productList.length - 1].index + index + 1 : this.productList.length + index,
  488. categoryId: item.id, // 物品id
  489. categoryName: item.name, // 物品名称
  490. categoryCode: item.code, // 物品编码
  491. categoryModel: item.modelType, // 物品型号
  492. specification: item.specification, // 规格
  493. modelKey: item.modelKey ? item.modelKey : '', // 机型
  494. modelKeyName: item.modelKey ? (this.modelOptions.find(o => o.dictCode === item.modelKey)?.dictValue || '') : '',
  495. modelIndex: item.modelKey ? this.modelOptions.findIndex(o => o.dictCode === item.modelKey) : -1,
  496. colorKey: item.colorKey ? item.colorKey : '', // 颜色
  497. colorKeyName: item.colorKey ? (this.colorOptions.find(o => o.dictCode === item.colorKey)?.dictValue || '') : '',
  498. colorIndex: item.colorKey ? this.colorOptions.findIndex(o => o.dictCode === item.colorKey) : -1,
  499. brandNum: item.brandNum, // 牌号
  500. batchNo: batchNo, // 批次号
  501. supplierListOptions: supplierList[item.id], // 供应商列表
  502. supplierId: '', // 供应商id
  503. supplierCode: item.supplierCode, // 供应商代号
  504. supplierName: item.supplierName, // 供应商名称
  505. measureType: item.measureType, // 计量类型
  506. approvalNumber: item.approvalNumber, // 批准文号
  507. packingSpecification: item.packingSpecification, // 包装规格
  508. packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
  509. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  510. minPackingQuantity: '', // 最小包装单元数量
  511. packingQuantity: '', // 包装数量
  512. packingUnit: item.measuringUnit, // 单位
  513. packingUnitId: newSpecificationOption[index].find(
  514. (v) => v.conversionUnit == item.measuringUnit
  515. )?.id, // 单位
  516. measureQuantity: 0, // 计量数量
  517. measureUnit: item.measuringUnit, // 计量单位
  518. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  519. weight: 0, // 重量
  520. singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, // 单重
  521. pricingWay: item.pricingWay,
  522. weightUnit: item.weightUnit, // 重量单位
  523. totalMoney: item.totalPrice, // 总价
  524. unitPrice: item.unitPrice, // 单价
  525. purpose: '', // 用途
  526. isUnpack: item.isUnpack // 是否允许拆包
  527. };
  528. });
  529. this.productList = this.productList.concat(productList);
  530. }
  531. })
  532. },
  533. async mounted() {
  534. this.userInfo = uni.getStorageSync('userInfo')
  535. await this.requestDict('产地')
  536. await this.requestDict('不拆物料层规格')
  537. await this.requestDict('物品颜色')
  538. await this.requestDict('物品机型')
  539. await this.getListItems()
  540. await this.getwarehouseList()
  541. await parameterGetByCode({ code: 'eom_purchase_invoice_approval_price' }).then((res) => {
  542. this.isHidePrice = res.value;
  543. });
  544. await this.getDetailData(this.businessId);
  545. await this.getNowFormatDate();
  546. },
  547. watch: {
  548. packingList: {
  549. handler(newVal) {
  550. console.log('packingList~~', newVal)
  551. this.showPackingList = newVal.slice(0, this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1));
  552. this.pickingPageNum = Math.ceil(this.showPackingList.length / this.pageSize);
  553. },
  554. deep: true
  555. }
  556. },
  557. methods: {
  558. ...mapActions('dict', ['requestDict']),
  559. // 获取当前时间 YYYY-MM-DD HH:mm:ss
  560. getCurrentTime() {
  561. const now = new Date();
  562. const year = now.getFullYear();
  563. const month = String(now.getMonth() + 1).padStart(2, '0');
  564. const day = String(now.getDate()).padStart(2, '0');
  565. const hours = String(now.getHours()).padStart(2, '0');
  566. const minutes = String(now.getMinutes()).padStart(2, '0');
  567. const seconds = String(now.getSeconds()).padStart(2, '0');
  568. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  569. },
  570. //获取仓库
  571. async getwarehouseList() {
  572. let res = await getWarehouseList()
  573. this.warehouseListOption = res.data.map(item => {
  574. return {
  575. id: item.id,
  576. name: item.name
  577. }
  578. })
  579. },
  580. handleWareHouse(e, row) {
  581. const val = e.detail.value;
  582. const warehouseItem = this.warehouseListOption[val];
  583. if (warehouseItem) {
  584. this.productList.forEach((item, index) => {
  585. this.$set(this.productList[index], 'warehouseId', warehouseItem.id);
  586. this.$set(this.productList[index], 'warehouseName', warehouseItem.name);
  587. this.$set(this.productList[index], 'warehouseIds', [warehouseItem.id]);
  588. this.$set(this.productList[index], 'warehouseNames', [warehouseItem.name]);
  589. });
  590. }
  591. },
  592. // 获取物品列表
  593. async getListItems() {
  594. const res = await getProduceTreeByPid({});
  595. this.goodsLists = res;
  596. },
  597. sectionChange(index) {
  598. this.curNow = index;
  599. },
  600. async getDetailData(id) {
  601. const data = await purchaseOrderReceiveGetByIdAPI(id);
  602. this.form = data;
  603. this.initFormData()
  604. },
  605. initFormData() {
  606. const defaultTime = '00:00:00';
  607. this.formData.type = 1;
  608. this.formData.bizType = this.form.outsourceSendCode ? 10 : 2;
  609. const currentTime = this.getCurrentTime();
  610. if (this.formData.bizType == 2 || this.formData.bizType == 6) {
  611. this.formData.storageTime = this.form.receiveDate
  612. ? `${this.form.receiveDate} ${defaultTime}`
  613. : currentTime;
  614. } else {
  615. this.formData.storageTime = currentTime;
  616. }
  617. this.formData.bizTypeStr = sceneState.find(item => item.code == this.formData.bizType)?.label || ''
  618. if (this.form.receiveNo != null && this.form.receiveNo != '') {
  619. this.$set(this.formData, 'sourceBizNo', this.form.receiveNo);
  620. } else {
  621. uni.showToast({ title: '未获取到单据来源!', icon: 'none' });
  622. }
  623. this.formData.extInfo.createUserId = this.form.createUserId || this.userInfo.userId || '';
  624. this.formData.extInfo.createUserName = this.form.createUserName || this.userInfo.name || '';
  625. this.formData.extInfo.deliveryPhone = this.userInfo.phone || '';
  626. this.formData.createUserId = this.form.createUserId || this.userInfo.userId || '';
  627. this.formData.createUserName = this.form.createUserName || this.userInfo.name || '';
  628. this.formData.extInfo.deptName = this.form.deptName || this.userInfo.deptName || '';
  629. this.formData.approvalUserName = this.form.approvalUserName || this.userInfo.name;
  630. this.formData.approvalUserId = this.form.approvalUserId || this.userInfo.userId;
  631. if (this.form.productList?.length > 0) {
  632. let detailPurchaseDate;
  633. if (this.formData.bizType == '2' || this.formData.bizType == '10') {
  634. detailPurchaseDate = this.form.purchaseDate || `${this.form.receiveDate} ${defaultTime}`;
  635. }
  636. let codeList = this.form.productList.map((item) => item.productCode || item.categoryCode);
  637. getListByNameOrModeType({ codeList }).then(async (res) => {
  638. if (res.length <= 0) {
  639. uni.showToast({ title: '未获取到物品信息!', icon: 'none' });
  640. return;
  641. }
  642. this.formData.extInfo.assetType = Array.from(new Set(res.map((item) => item.categoryLevelPathIdParent)));
  643. this.formData.extInfo.assetTypeName = this.formData.extInfo.assetType.map(id => {
  644. const item = this.goodsLists.find(g => g.id == id);
  645. return item?.name || id;
  646. }).join(',');
  647. const batchNo1 = await getCode('lot_number_code');
  648. const supplierList = await contactQueryByCategoryIdsAPI({ categoryIds: res.map((item) => item.id) });
  649. let packingSpecification = await getCategoryPackageDisposition({ categoryIds: res.map((item) => item.id) });
  650. this.packingSpecificationOption = res.map((item) => {
  651. return packingSpecification.filter((ite) => item.id == ite.categoryId).sort((a, b) => a.sort - b.sort);
  652. });
  653. this.productList = res.map((item, index) => {
  654. let filtersItem = this.form.productList.find((detailItem) => item.code == detailItem.productCode || item.code == detailItem.categoryCode);
  655. let packingSpecificationLabel = this.packingSpecificationOption[index].map((item) => {
  656. if (item.sort > 0) {
  657. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  658. }
  659. }).filter((item) => !!item);
  660. const newSpecificationOption = this.packingSpecificationOption;
  661. let warehouseId = filtersItem.warehouseId;
  662. let warehouseName = filtersItem.warehouseName;
  663. let measureQuantity = filtersItem.totalCountNew || filtersItem.totalCount || 0;
  664. if ((filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight) && item.weightUnit == item.measuringUnit) {
  665. measureQuantity = filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight;
  666. }
  667. let packingQuantity = filtersItem.totalCountNew || filtersItem.purchaseCount || filtersItem.totalCount || 0;
  668. let packingUnit = filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
  669. let unitPrice = filtersItem.singlePrice || 0;
  670. let pricingWay = filtersItem.pricingWay || '';
  671. let singleWeight = filtersItem.singleWeight || 0;
  672. let weight = filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight || singleWeight * measureQuantity;
  673. let warehouseIds = [];
  674. let warehouseNames = [];
  675. for (let i = 0; i < filtersItem.totalCount; i++) {
  676. warehouseIds.push(filtersItem.warehouseId);
  677. warehouseNames.push(filtersItem.warehouseName);
  678. }
  679. let totalMoney = filtersItem.totalPrice || 0;
  680. let batchNo = filtersItem.batchNo || batchNo1;
  681. return {
  682. index: this.productList.length + index,
  683. categoryId: item.id,
  684. categoryName: item.name,
  685. categoryCode: item.code,
  686. categoryModel: item.modelType,
  687. specification: item.specification,
  688. brandNum: item.brandNum,
  689. batchNo: batchNo,
  690. supplierListOptions: supplierList[item.id],
  691. supplierId: this.form.supplierId,
  692. productionRequirements: filtersItem.productionRequirements,
  693. supplierCode: this.formData.bizType == 2 || this.formData.bizType == 7 ? filtersItem.supplierMark : item.supplierCode,
  694. supplierName: this.form.supplierName,
  695. approvalNumber: item.approvalNumber,
  696. packingSpecification: item.packingSpecification,
  697. packingSpecificationOption: newSpecificationOption[index],
  698. packingSpecificationLabel: packingSpecificationLabel,
  699. packingQuantity: this.form.productList[index] && this.form.productList[index].isAllPackageData == 1
  700. ? this.form.productList[index].packingCount : packingQuantity,
  701. packingUnit: this.form.productList[index] && this.form.productList[index].isAllPackageData == 1
  702. ? this.form.productList[index].packingUnit : packingUnit,
  703. measureQuantity: this.form.productList[index] && this.form.productList[index].isAllPackageData == 1
  704. ? this.form.productList[index].quantity : measureQuantity,
  705. measureUnit: this.form.productList[index] && this.form.productList[index].isAllPackageData == 1
  706. ? this.form.productList[index].measuringUnit : item.measuringUnit,
  707. packingUnitId: filtersItem.purchaseUnitId || filtersItem.saleUnitId,
  708. modelKey: filtersItem.modelKey ? filtersItem.modelKey : '',
  709. colorKey: filtersItem.colorKey ? filtersItem.colorKey : '',
  710. measureType: item.measureType,
  711. netWeight: item.netWeight > -1 ? item.netWeight : 0,
  712. singleWeight: singleWeight || 0,
  713. weight: weight || 0,
  714. weightUnit: item.weightUnit,
  715. totalMoney: totalMoney,
  716. unitPrice: item.unitPrice || unitPrice,
  717. pricingWay: pricingWay,
  718. purpose: '',
  719. detailPurchaseDate,
  720. detailExpireDate: this.form.productList.find((product) => product.productId == item.id)?.guaranteePeriodDeadline,
  721. detailProductionDate: this.form.productList.find((product) => product.productId == item.id)?.productionDate,
  722. provenance: filtersItem.provenance,
  723. isUnpack: item.isUnpack,
  724. warehouseId,
  725. warehouseName,
  726. warehouseIds,
  727. warehouseNames,
  728. qualityControl: filtersItem?.isComeCheck
  729. };
  730. });
  731. this.$nextTick(() => {
  732. this.batchSave();
  733. });
  734. });
  735. }
  736. },
  737. // 赋值入库时间
  738. getNowFormatDate() {
  739. const obj = this.getNowDate();
  740. const defaultTime = '00:00:00';
  741. const currentTime = `${obj.hour}:${obj.minute}:${obj.second}`;
  742. if (this.formData.bizType === 2 || this.formData.bizType === '2' || this.formData.bizType === 6 || this.formData.bizType === '6') {
  743. this.formData.storageTime = this.form.receiveDate
  744. ? `${this.form.receiveDate} ${defaultTime}`
  745. : `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
  746. } else {
  747. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
  748. }
  749. },
  750. // 获取当前时间函数
  751. getNowDate() {
  752. let date = new Date(),
  753. obj = {
  754. year: date.getFullYear(),
  755. month: date.getMonth() + 1,
  756. strDate: date.getDate(),
  757. hour: date.getHours(),
  758. minute: date.getMinutes(),
  759. second: date.getSeconds()
  760. };
  761. Object.keys(obj).forEach((key) => {
  762. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  763. });
  764. return obj;
  765. },
  766. changeCount(number) {
  767. // 移动端兼容的数字转字符串方法,避免浮点数精度显示问题
  768. const num = Number(number || 0);
  769. return isNaN(num) ? '0' : String(num);
  770. },
  771. selectSupplier(val, row) {
  772. row.supplierId = val;
  773. row.supplierName = row.supplierListOptions.filter((item) => item.id == val)[0]?.name;
  774. row.supplierCode = row.supplierListOptions.filter((item) => item.id == val)[0]?.serialNo;
  775. },
  776. inputsingleWeight(row, index) {
  777. if (row.measureUnit == row.weightUnit) {
  778. row.weight = row.singleWeight * row.packingQuantity;
  779. row.measureQuantity = row.weight;
  780. } else {
  781. row.weight = row.singleWeight * row.measureQuantity;
  782. }
  783. },
  784. inputWeight(row, index) {
  785. if (row.measureUnit == row.weightUnit) {
  786. row.measureQuantity = row.weight;
  787. row.singleWeight = Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000;
  788. } else {
  789. row.singleWeight = row.measureQuantity ? row.weight / row.measureQuantity : 0;
  790. }
  791. },
  792. // 计算最小单元数量
  793. async computeNum(row, index, isClear) {
  794. let data = row.packingSpecificationOption.find((item) => item.id == row.packingUnitId);
  795. if (data) {
  796. row.packingUnit = data.conversionUnit;
  797. }
  798. if (isClear && row.packingQuantity < 0) {
  799. this.$set(this.productList[index], 'packingQuantity', 1);
  800. }
  801. if (row.packingQuantity && row.packingUnit) {
  802. const res = await warehouseDefinitionList({});
  803. if (res.length == 1) {
  804. let name = res[0]?.factoryName + '-' + res[0]?.name;
  805. this.$set(this.productList[index], 'warehouseId', res[0].id);
  806. this.$set(this.productList[index], 'warehouseName', name);
  807. } else {
  808. this.$set(this.productList[index], 'warehouseId', '');
  809. this.$set(this.productList[index], 'warehouseName', '');
  810. }
  811. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  812. return row.measuringUnit == ite.packingUnit && ite.packingUnit != ite.conversionUnit;
  813. });
  814. let endIndex = row.packingSpecificationOption.findIndex((ite) => data.id == ite.id);
  815. let total = Number(row.packingQuantity);
  816. if (row.packingUnit == row.measureUnit && row.measureUnit == '立方' && row.netWeight) {
  817. total = Number(row.packingQuantity) * row.netWeight;
  818. } else {
  819. for (; 0 < endIndex; endIndex--) {
  820. total = this.$math.format(row.packingSpecificationOption[endIndex].packageCell * total, 14);
  821. }
  822. }
  823. row.measureQuantity = this.changeCount(total);
  824. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)?.dictValue;
  825. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)?.dictValue;
  826. if (packingBoolen && measureBoolen && row.packingUnit != 'L') {
  827. row.weight = total;
  828. }
  829. let weight = 0;
  830. if (row.measureUnit == row.weightUnit) {
  831. weight = row.measureQuantity;
  832. if (row.weightUnit == row.packageUnit) {
  833. row.singleWeight = 0;
  834. } else {
  835. row.singleWeight = Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000;
  836. }
  837. } else if (row.singleWeight) {
  838. weight = row.measureQuantity * Number(row.singleWeight);
  839. }
  840. this.$set(this.productList[index], 'weight', weight);
  841. }
  842. },
  843. // 添加产品
  844. addProduct() {
  845. if (this.formData.extInfo.assetType.length <= 0) {
  846. return uni.showToast({ title: '请选择物品类型', icon: 'none' });
  847. }
  848. if (!this.formData.bizType) {
  849. return uni.showToast({ title: '请选择入库类型', icon: 'none' });
  850. }
  851. this.visibleDialog = true;
  852. uni.navigateTo({
  853. url: '/pages/warehouse/enterHouse/selectEnterType?assetType=' + this.formData.extInfo.assetType
  854. })
  855. },
  856. // 批量保存
  857. async batchSave() {
  858. try {
  859. for (let i = 0; i < this.productList.length; i++) {
  860. const row = this.productList[i];
  861. if (!row.isSave) {
  862. await this.listSave(row, i);
  863. }
  864. }
  865. } catch (error) {
  866. console.log('保存失败', error);
  867. }
  868. },
  869. listSave(row, index) {
  870. // 必填项校验
  871. if (!row.batchNo) {
  872. uni.showToast({ title: '请填写批次号', icon: 'none' });
  873. return;
  874. }
  875. if (!row.packingQuantity && row.packingQuantity !== 0) {
  876. uni.showToast({ title: '请填写数量', icon: 'none' });
  877. return;
  878. }
  879. if (!row.packingUnit) {
  880. uni.showToast({ title: '请选择单位', icon: 'none' });
  881. return;
  882. }
  883. if (!row.warehouseId) {
  884. uni.showToast({ title: '请选择仓库', icon: 'none' });
  885. return;
  886. }
  887. },
  888. // 物品批量保存前校验
  889. validateForm() {
  890. return new Promise((resolve, reject) => {
  891. for (let i = 0; i < this.productList.length; i++) {
  892. const row = this.productList[i];
  893. // 已保存的不需要校验
  894. if (row.isSave) continue;
  895. if (!row.batchNo) {
  896. uni.showToast({ title: `第${i + 1}行:请填写批次号`, icon: 'none' });
  897. reject(new Error('批次号必填'));
  898. return;
  899. }
  900. if (!row.packingQuantity && row.packingQuantity !== 0) {
  901. uni.showToast({ title: `第${i + 1}行:请填写数量`, icon: 'none' });
  902. reject(new Error('数量必填'));
  903. return;
  904. }
  905. if (!row.packingUnit) {
  906. uni.showToast({ title: `第${i + 1}行:请选择单位`, icon: 'none' });
  907. reject(new Error('单位必填'));
  908. return;
  909. }
  910. if (!row.warehouseId) {
  911. uni.showToast({ title: `第${i + 1}行:请选择仓库`, icon: 'none' });
  912. reject(new Error('仓库必填'));
  913. return;
  914. }
  915. }
  916. resolve();
  917. });
  918. },
  919. listSave(row, index) {
  920. // 必填项校验
  921. if (!row.batchNo) {
  922. uni.showToast({ title: '请填写批次号', icon: 'none' });
  923. return;
  924. }
  925. if (!row.packingQuantity && row.packingQuantity !== 0) {
  926. uni.showToast({ title: '请填写数量', icon: 'none' });
  927. return;
  928. }
  929. if (!row.packingUnit) {
  930. uni.showToast({ title: '请选择单位', icon: 'none' });
  931. return;
  932. }
  933. if (!row.warehouseId) {
  934. uni.showToast({ title: '请选择仓库', icon: 'none' });
  935. return;
  936. }
  937. // 判断单位和计量单位是否为不拆物料层规格
  938. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)?.dictValue;
  939. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)?.dictValue;
  940. let packingNum = 0;
  941. if (packingBoolen) {
  942. if (!row.isUnpack && row.packingUnit == '立方') {
  943. packingNum = 1;
  944. } else {
  945. let filterArr = row.packingSpecificationOption.filter((item) => {
  946. return item.packageUnit == row.packingUnit && item.packageUnit != item.conversionUnit;
  947. });
  948. if (filterArr?.length) {
  949. packingNum = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  950. }
  951. }
  952. }
  953. let measureNum = row.packingQuantity;
  954. let num = 0;
  955. if (measureBoolen) {
  956. let splitIndex = row.packingSpecificationOption.findIndex((item) =>
  957. item.conversionUnit == row.packingUnit && item.packageUnit != item.conversionUnit
  958. );
  959. for (; splitIndex > 1; splitIndex--) {
  960. measureNum = this.$math.format(measureNum * row.packingSpecificationOption[splitIndex].packageCell, 14);
  961. }
  962. } else {
  963. if (row.packingSpecificationOption[1]?.packageCell) {
  964. num = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
  965. } else {
  966. num = row.packingQuantity;
  967. }
  968. }
  969. if (row.packingSpecificationLabel?.length < 1) {
  970. uni.showToast({ title: '请到主数据维护包装组信息!', icon: 'none' });
  971. return;
  972. }
  973. // 不拆包
  974. if (!row.isUnpack) {
  975. if (row.packingUnit != row.measureUnit) {
  976. getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: row.packingQuantity }]).then(() => {});
  977. } else {
  978. getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: 0 }]).then(() => {});
  979. }
  980. } else {
  981. if (!packingNum) {
  982. if (row.packingUnitId) {
  983. let splitIndex = row.packingSpecificationOption.findIndex((item) => item.id == row.packingUnitId);
  984. if (splitIndex == 0) {
  985. packingNum = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
  986. }
  987. if (splitIndex == 1) {
  988. packingNum = row.packingQuantity;
  989. }
  990. for (; splitIndex > 1; splitIndex--) {
  991. packingNum = Math.ceil(row.packingQuantity * row.packingSpecificationOption[splitIndex].packageCell);
  992. }
  993. } else {
  994. packingNum = Math.ceil(row.measureQuantity / row.packingSpecificationOption[1]?.packageCell);
  995. }
  996. }
  997. getAssetNum([{ assetCode: row.categoryCode + row.index, batchNum: row.batchNo, num: packingNum }]).then(() => {});
  998. }
  999. this.$set(this.productList[index], 'isSave', true);
  1000. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  1001. this.$set(this.productList[index], 'warehouseName', row.warehouseName);
  1002. this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
  1003. this.$set(this.productList[index], 'warehouseNames', row.warehouseName);
  1004. },
  1005. editProductList(row, index) {
  1006. this.$set(this.productList[index], 'isSave', false);
  1007. },
  1008. deleteProductList(row, index) {
  1009. uni.showModal({
  1010. title: '提示',
  1011. content: '确定删除该产品吗?',
  1012. success: (res) => {
  1013. if (res.confirm) {
  1014. this.productList.splice(index, 1);
  1015. }
  1016. }
  1017. });
  1018. },
  1019. saveProductList(row, index) {
  1020. this.listSave(row, index);
  1021. },
  1022. addStock() {
  1023. this.addProduct();
  1024. },
  1025. // 入库
  1026. async getReturnStorage() {
  1027. if (this.productList.length <= 0) {
  1028. uni.showToast({ title: '请先添加产品信息', icon: 'none' });
  1029. return;
  1030. }
  1031. let boolen = this.productList.every((item) => item.isSave);
  1032. if (!boolen) {
  1033. uni.showToast({ title: '请先保存所有产品信息', icon: 'none' });
  1034. return;
  1035. }
  1036. if (this.isShowPackage) {
  1037. const userNameLength = this.productList.filter(
  1038. (item) => !item.unpackUserName
  1039. ).length;
  1040. const packgeLength = this.productList.filter(
  1041. (item) => !item.ifPackageOk
  1042. ).length;
  1043. if (userNameLength || packgeLength) {
  1044. uni.showToast({ title: '请先填写拆包装责任人和包装完好与否', icon: 'none' });
  1045. return;
  1046. }
  1047. }
  1048. // 处理包装数据
  1049. let _packingList = [];
  1050. _packingList = this.packingList.map((packingItem) => {
  1051. let _taskId = null;
  1052. let _workOrderId = null;
  1053. // if ([1].includes(this.formData.bizType)) {
  1054. // _workOrderId = this.detailList[0]?.workOrderId;
  1055. // _taskId = this.detailList[0]?.taskId;
  1056. // } else {
  1057. _workOrderId = this.form.productList[0]?.workOrderId;
  1058. _taskId = this.form.productList[0]?.taskId;
  1059. // }
  1060. // if (packingItem.modelKey) {
  1061. // packingItem.modelKey = packingItem.modelKey.toString();
  1062. // }
  1063. // if (packingItem.colorKey) {
  1064. // packingItem.colorKey = packingItem.colorKey.toString();
  1065. // }
  1066. return {
  1067. ...packingItem,
  1068. workOrderId: _workOrderId,
  1069. taskId: _taskId,
  1070. outsourceBatchNo: this.form.productList[0]?.batchNo,
  1071. outsourceCode: this.form.productList[0]?.sourceCode,
  1072. // materialDetailList: this.materialList.filter(
  1073. // (item) => item.parentIndex === packingItem.index
  1074. // )
  1075. };
  1076. });
  1077. // 处理产品数据
  1078. this.productList = this.productList.map((productItem) => {
  1079. // if (productItem.modelKey) {
  1080. // productItem.modelKey = productItem.modelKey.toString();
  1081. // }
  1082. // if (productItem.colorKey) {
  1083. // productItem.colorKey = productItem.colorKey.toString();
  1084. // }
  1085. return {
  1086. ...productItem,
  1087. outInDetailRecordRequestList: _packingList.filter(
  1088. (item) => item.parentIndex === productItem.index
  1089. )
  1090. };
  1091. });
  1092. this.formData.outInDetailList = this.productList;
  1093. let obj = uni.$u.deepClone(this.formData);
  1094. // 处理物品类型assetType
  1095. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1096. obj.extInfo.documentSource = this.formData.sourceBizNo;
  1097. obj.extInfo.deptName = this.formData.extInfo.deptName;
  1098. obj.extInfo.supplierName = this.form.supplierName;
  1099. obj.extInfo.deliveryPhone = this.formData.extInfo.deliveryPhone;
  1100. // 处理仓库id
  1101. let warehouseId = [];
  1102. let warehouseName = [];
  1103. let warehouseIds = this.productList.map((item) => item.warehouseIds).flat();
  1104. let warehouseNames = this.productList.map((item) => item.warehouseNames).flat();
  1105. warehouseIds.forEach((item, index) => {
  1106. if (!warehouseId.includes(item)) {
  1107. warehouseId.push(item);
  1108. warehouseName.push(warehouseNames[index]);
  1109. }
  1110. });
  1111. obj.warehouseIds = warehouseId;
  1112. obj.warehouseNames = warehouseName;
  1113. obj._packingList = _packingList;
  1114. const isVerifyData = await isVerifyRepeatIsStock({
  1115. categoryCodes: this.productList.map((item) => item.categoryCode),
  1116. batchNos: this.productList.map((item) => item.batchNo)
  1117. });
  1118. return new Promise((resolve, reject) => {
  1119. if (isVerifyData?.length) {
  1120. uni.showModal({
  1121. title: '提示',
  1122. content: `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
  1123. .map((item) => item.categoryName)
  1124. .join(',')}已有入库记录,是否继续入库!`,
  1125. confirmText: '是',
  1126. cancelText: '否',
  1127. success: (res) => {
  1128. if (res.confirm) {
  1129. resolve(obj);
  1130. } else {
  1131. resolve(false);
  1132. }
  1133. }
  1134. });
  1135. } else {
  1136. resolve(obj);
  1137. }
  1138. });
  1139. },
  1140. // 获取表数据
  1141. getTableValue() {
  1142. return new Promise(async (resolve, reject) => {
  1143. try {
  1144. const returnStorageData = await this.getReturnStorage();
  1145. resolve({
  1146. form: this.form,
  1147. returnStorageData,
  1148. });
  1149. } catch(e) {
  1150. reject(e);
  1151. }
  1152. });
  1153. },
  1154. // 单位选择变化
  1155. onPackingUnitChange(e, row, index) {
  1156. const val = e.detail.value;
  1157. const item = row.packingSpecificationOption[val];
  1158. if (item) {
  1159. row.packingUnitId = item.id;
  1160. row.packingUnit = item.conversionUnit;
  1161. this.computeNum(row, index);
  1162. }
  1163. },
  1164. // 包装完好选择变化
  1165. onPackageOkChange(e, row) {
  1166. const val = e.detail.value;
  1167. row.ifPackageOkIndex = val;
  1168. row.ifPackageOk = this.packageOkOptions[val].value;
  1169. row.ifPackageOkLabel = this.packageOkOptions[val].label;
  1170. },
  1171. // 仓库选择变化
  1172. onWarehouseChange(e, row) {
  1173. const val = e.detail.value;
  1174. const item = this.warehouseListOption[val];
  1175. if (item) {
  1176. row.warehouseId = item.id;
  1177. row.warehouseName = item.name;
  1178. row.warehouseIndex = val;
  1179. }
  1180. },
  1181. // 供应商选择变化
  1182. onSupplierChange(e, row) {
  1183. const val = e.detail.value;
  1184. const item = row.supplierListOptions[val];
  1185. if (item) {
  1186. row.supplierId = item.id;
  1187. row.supplierName = item.name;
  1188. row.supplierCode = item.serialNo;
  1189. }
  1190. },
  1191. // 颜色选择变化
  1192. onColorChange(e, index) {
  1193. const val = Number(e.detail.value);
  1194. const item = this.colorOptions[val];
  1195. if (item) {
  1196. this.$set(this.productList[index], 'colorKey', item.dictCode);
  1197. this.$set(this.productList[index], 'colorKeyName', item.dictValue);
  1198. this.$set(this.productList[index], 'colorIndex', val);
  1199. }
  1200. },
  1201. // 机型选择变化
  1202. onModelChange(e, index) {
  1203. const val = Number(e.detail.value);
  1204. const item = this.modelOptions[val];
  1205. if (item) {
  1206. this.$set(this.productList[index], 'modelKey', item.dictCode);
  1207. this.$set(this.productList[index], 'modelKeyName', item.dictValue);
  1208. this.$set(this.productList[index], 'modelIndex', val);
  1209. }
  1210. },
  1211. // 日期选择变化
  1212. onDateChange(e, row, field) {
  1213. row[field] = e.detail.value;
  1214. },
  1215. //入库明细删除
  1216. listDel(row, index) {
  1217. this.productList.splice(index, 1);
  1218. this.deletePackingAndMaterial(row);
  1219. },
  1220. // 根据产品信息删除包装和物料
  1221. deletePackingAndMaterial(row) {
  1222. // 删除包装(去掉不相同的包装)
  1223. this.packingList = this.packingList.filter(
  1224. (item) => item.parentIndex !== row.index
  1225. );
  1226. this.showPackingList = this.showPackingList.filter(
  1227. (item) => item.parentIndex !== row.index
  1228. );
  1229. this.pickingPageNum = Math.ceil(
  1230. this.showPackingList.length / this.pageSize
  1231. );
  1232. // 删除物料(获取相同物料)
  1233. // let packingIndexs = this.packingList.map((item) => item.index);
  1234. // this.materialList = this.materialList.filter((item) =>
  1235. // packingIndexs.includes(item.parentIndex)
  1236. // // );
  1237. // this.showMaterialList = this.showMaterialList.filter((item) =>
  1238. // packingIndexs.includes(item.parentIndex)
  1239. // );
  1240. // this.materielPageNum = Math.ceil(
  1241. // this.showMaterialList.length / this.pageSize
  1242. // );
  1243. },
  1244. // 产品批量保存
  1245. async listSaveArrs() {
  1246. this.validateForm()
  1247. .then(async () => {
  1248. // 批量获取包装编码并处理
  1249. let packingCodePrams = this.productList.map((row) => {
  1250. // 判断单位和计量单位是否为不拆物料层规格
  1251. let packingBoolen = !!this.getDict(
  1252. '不拆物料层规格',
  1253. row.packingUnit
  1254. ).dictValue;
  1255. let measureBoolen = !!this.getDict(
  1256. '不拆物料层规格',
  1257. row.measureUnit
  1258. ).dictValue;
  1259. let num = 0;
  1260. if (packingBoolen) {
  1261. let filterArr = row.packingSpecificationOption.filter(
  1262. (item) => {
  1263. return (
  1264. item.packageUnit == row.packingUnit &&
  1265. item.packageUnit != item.conversionUnit
  1266. );
  1267. }
  1268. );
  1269. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  1270. }
  1271. if (row.isSave) {
  1272. return {};
  1273. } else {
  1274. // 处理单位为KG类的情况
  1275. if (packingBoolen) {
  1276. return {
  1277. assetCode: row.categoryCode + row.index,
  1278. batchNum: row.batchNo,
  1279. num
  1280. };
  1281. } else {
  1282. if (row.isUnpack == 1) {
  1283. if (measureBoolen) {
  1284. // 处理单位不为KG类,计量单位为KG类的情况
  1285. let num = row.packingQuantity;
  1286. let splitIndex = row.packingSpecificationOption.findIndex(
  1287. (item) =>
  1288. item.conversionUnit == row.packingUnit &&
  1289. item.packageUnit != item.conversionUnit
  1290. );
  1291. for (; splitIndex > 1; splitIndex--) {
  1292. num = this.$math.format(
  1293. num *
  1294. row.packingSpecificationOption[splitIndex]
  1295. .packageCell,
  1296. 14
  1297. );
  1298. }
  1299. return {
  1300. assetCode: row.categoryCode + row.index,
  1301. batchNum: row.batchNo,
  1302. num
  1303. };
  1304. } else {
  1305. // 处理拆包到最小包装单元数量的情况
  1306. return {
  1307. assetCode: row.categoryCode + row.index,
  1308. batchNum: row.batchNo,
  1309. num: row.measureQuantity
  1310. };
  1311. }
  1312. } else {
  1313. return {
  1314. assetCode: row.categoryCode + row.index,
  1315. batchNum: row.batchNo,
  1316. num
  1317. };
  1318. }
  1319. }
  1320. }
  1321. });
  1322. console.log('packingCodePrams', packingCodePrams);
  1323. let filterPackingCodePrams = packingCodePrams.filter(
  1324. (item) => item.assetCode
  1325. );
  1326. console.log('filterPackingCodePrams', filterPackingCodePrams);
  1327. let { data } = await getAssetNum(filterPackingCodePrams);
  1328. let packingCodeList = [];
  1329. packingCodePrams.forEach((item, index) => {
  1330. packingCodeList[index] = data.filter(
  1331. (ite) => ite.assetCode == item.assetCode
  1332. );
  1333. });
  1334. // 批量生成包装
  1335. this.productList.map((row, index) => {
  1336. if (!row.isSave) {
  1337. this.generateWrappers(row, index, packingCodeList[index]);
  1338. this.$set(this.productList[index], 'isSave', true);
  1339. }
  1340. });
  1341. // 加载虚拟列表数据(分页)
  1342. // this.pickingFetchData();
  1343. // this.materielFetchData();
  1344. })
  1345. .catch((err) => {
  1346. console.log(err);
  1347. });
  1348. },
  1349. // 生成包装
  1350. generateWrappers(row, productIndex, packingCodeList) {
  1351. console.log(packingCodeList, 'packingCodeList', row.measureType);
  1352. if (!row.measureType)
  1353. return uni.showToast({
  1354. title: '请到主数据维计量类型!',
  1355. icon: 'none'
  1356. });
  1357. console.log('包装数据--------', row);
  1358. // console.log('包装规格----', row.packingSpecificationOption);
  1359. console.log('计量单位----', row.measureUnit);
  1360. let packingList = [];
  1361. // let obj = this.getNowDate();
  1362. let productionDate = row.detailProductionDate || '';
  1363. let purchaseDate = row.detailPurchaseDate || '';
  1364. let expireDate = row.detailExpireDate || '';
  1365. console.log(expireDate, 'expireDate');
  1366. console.log(
  1367. this.formData.bizType,
  1368. 'bizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizType'
  1369. );
  1370. if (this.formData.bizType == '1') {
  1371. // 生产入库
  1372. productionDate = this.getNowDate();
  1373. // this.curDateType = 'productionDate';
  1374. }
  1375. // 判断单位和计量单位是否为不拆物料层规格
  1376. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit).dictValue;
  1377. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit).dictValue;
  1378. let num = row.packingQuantity;
  1379. let filterArr = [];
  1380. // 处理单位为KG类的情况
  1381. if (packingBoolen) {
  1382. console.log(
  1383. packingBoolen,
  1384. 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
  1385. );
  1386. if (!row.isUnpack && row.packingUnit == '立方') {
  1387. num = 1;
  1388. } else {
  1389. filterArr = row.packingSpecificationOption.filter((item) => {
  1390. return (
  1391. item.packageUnit == row.packingUnit &&
  1392. item.packageUnit != item.conversionUnit
  1393. );
  1394. });
  1395. num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
  1396. }
  1397. } else {
  1398. // if (row.isUnpack == 1) {
  1399. if (measureBoolen) {
  1400. // 处理单位不为KG类,计量单位为KG类的情况
  1401. let splitIndex = row.packingSpecificationOption.findIndex(
  1402. (item) =>
  1403. item.conversionUnit == row.packingUnit &&
  1404. item.packageUnit != item.conversionUnit
  1405. );
  1406. for (; splitIndex > 1; splitIndex--) {
  1407. num = this.$math.format(
  1408. num * row.packingSpecificationOption[splitIndex].packageCell,
  1409. 14
  1410. );
  1411. }
  1412. } else {
  1413. if (row.packingSpecificationOption[1]?.packageCell) {
  1414. num = Math.ceil(
  1415. row.measureQuantity /
  1416. row.packingSpecificationOption[1]?.packageCell
  1417. );
  1418. filterArr = row.packingSpecificationOption.filter((item) => {
  1419. return (
  1420. item.packageUnit == row.packingUnit &&
  1421. item.packageUnit != item.conversionUnit
  1422. );
  1423. });
  1424. }
  1425. }
  1426. }
  1427. console.log('num-----------', num);
  1428. for (let index = 0; index < packingCodeList.length; index++) {
  1429. let measureQuantity = 1;
  1430. let packingQuantity = 1;
  1431. let packingUnit = row.packingUnit;
  1432. // 处理单位为KG类,计算每桶KG值
  1433. if (packingBoolen) {
  1434. measureQuantity = Number(row.packingQuantity) > this.$math.format(filterArr[0].packageCell * (index + 1), 14) ? filterArr[0].packageCell : Numbe(row.packingQuantity) - this.$math.format(filterArr[0].packageCell * index, 14);
  1435. console.log(measureQuantity, 'measureQuantit1111y');
  1436. } else {
  1437. console.log('1 拆--------', measureBoolen);
  1438. //计量单位等于重量单位并且有总重 计量数量=总重/包装数
  1439. if (row.weightUnit == row.measureUnit && row.weight) {
  1440. measureQuantity = Math.trunc((row.weight / packingCodeList.length) * 10000) / 10000;
  1441. } else if (measureBoolen) {
  1442. let splitIndex = row.packingSpecificationOption.findIndex((item) =>
  1443. item.conversionUnit == row.packingUnit &&
  1444. item.packageUnit != item.conversionUnit
  1445. );
  1446. for (; splitIndex > 0; splitIndex--) {
  1447. measureQuantity = this.$math.format(
  1448. measureQuantity *
  1449. row.packingSpecificationOption[splitIndex].packageCell,
  1450. 14
  1451. );
  1452. }
  1453. } else {
  1454. measureQuantity = row.packingSpecificationOption[1].packageCell;
  1455. }
  1456. console.log(measureQuantity, 'measureQuantity');
  1457. }
  1458. let clientCode = '';
  1459. if (this.bizType == 2) {
  1460. clientCode = row?.customerMark;
  1461. } else if (this.bizType != 2) {
  1462. clientCode = row.extInfo?.clientCode;
  1463. }
  1464. console.log(filterArr[0], 'filterArr[0]');
  1465. let status = null;
  1466. if (row.qualityControl == 1) {
  1467. status = 0;
  1468. } else {
  1469. status = 2;
  1470. }
  1471. let item = {
  1472. index: row.index + '-' + index, // 包装索引
  1473. warehouseId: row.warehouseId, // 仓库id
  1474. warehouseName: row.warehouseName, // 仓库名称
  1475. categoryName: row.categoryName, // 产品名称
  1476. categoryCode: row.categoryCode, // 产品编码
  1477. categoryModel: row.categoryModel, // 物品型号
  1478. specification: row.specification, // 规格
  1479. supplierCode: row.supplierCode, // 供应商编码
  1480. supplierName: row.supplierName, // 供应商名称
  1481. brandNum: row.brandNum, // 牌号
  1482. parentIndex: row.index, // 产品索引
  1483. batchNo: row.batchNo, // 批次号
  1484. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  1485. packingQuantity: packingQuantity, // 包装数量
  1486. modelKey: row.modelKey, // 机型
  1487. colorKey: row.colorKey, //颜色
  1488. measureQuantity: measureQuantity, // 计量数量
  1489. measureUnit: row.isUnpack
  1490. ? measureBoolen
  1491. ? row.packingSpecificationOption[1]
  1492. ? row.packingSpecificationOption[1].packageUnit
  1493. : row.packingSpecificationOption[0].packageUnit
  1494. : row.measureUnit
  1495. : row.measureUnit, // 计量单位
  1496. weight: 0, // 重量
  1497. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  1498. weightUnit: row.weightUnit, // 重量单位
  1499. netWeight: row.netWeight, // 净重
  1500. barcodes: '', // 发货条码
  1501. clientCode: clientCode, // 客户代号
  1502. materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
  1503. engrave: '', // 刻码
  1504. isUnpack: row.isUnpack, // 是否允许拆包
  1505. productionDate: productionDate, // 生产日期
  1506. purchaseDate: purchaseDate, // 采购时间
  1507. expireDate: expireDate, //失效日期
  1508. result: 1, // 结果(1合格 2不合格)
  1509. qualityControl: row.qualityControl,
  1510. status: status // 状态(0=未质检 1待检 2已检)
  1511. };
  1512. if (row.isUnpack) {
  1513. // 第二层条件: packingBoolen
  1514. if (packingBoolen) {
  1515. // 空值保护: 确保 filterArr[0] 存在
  1516. item.packingUnit = row.packingSpecificationOption[1].conversionUnit;
  1517. } else {
  1518. // 第三层条件: measureBoolen
  1519. if (measureBoolen) {
  1520. // 处理 packingSpecificationOption 的索引
  1521. const option =
  1522. row.packingSpecificationOption?.[1] ||
  1523. row.packingSpecificationOption?.[0];
  1524. item.packingUnit = option?.conversionUnit;
  1525. } else {
  1526. item.packingUnit =
  1527. row.packingSpecificationOption[1].conversionUnit;
  1528. }
  1529. }
  1530. }
  1531. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit).dictValue;
  1532. //计量单位等于重量单位
  1533. if (row.weightUnit == row.measureUnit) {
  1534. item.weight = item.measureQuantity
  1535. ? Number(item.measureQuantity)
  1536. : 0;
  1537. } else if (outBoolen) {
  1538. // 计量单位为KG类,直接替换
  1539. item.weight = item.measureQuantity
  1540. ? Number(item.measureQuantity)
  1541. : 0;
  1542. } else {
  1543. console.log('计量单位为不为KG类======================');
  1544. // 计量单位为不为KG类,重新统计计算
  1545. let inBoolen = !!this.getDict('不拆物料层规格', item.packingSpecificationOption[0].packageUnit).dictValue;
  1546. let startIndex = item.packingSpecificationOption.findIndex(
  1547. (ite) => {
  1548. return (
  1549. item.measureUnit == ite.packingUnit &&
  1550. ite.packingUnit != ite.conversionUnit
  1551. );
  1552. }
  1553. );
  1554. let endIndex = item.packingSpecificationOption.findIndex(
  1555. (ite) => item.packingUnit == ite.conversionUnit
  1556. );
  1557. if (measureBoolen) {
  1558. let total = item.packingQuantity ? Number(item.packingQuantity) : 0;
  1559. for (; startIndex < endIndex; endIndex--) {
  1560. total = this.$math.format(item.packingSpecificationOption[endIndex].packageCell * total, 14);
  1561. }
  1562. if (inBoolen) {
  1563. // 第二层为KG类
  1564. item.weight = total ? Number(total) : 0;
  1565. } else {
  1566. // 第二层不为KG类
  1567. item.weight = this.$math.format(total * item.netWeight, 14);
  1568. }
  1569. } else if (!measureBoolen) {
  1570. if (inBoolen) {
  1571. // 第二层为KG类
  1572. item.weight = item.measureQuantity ? Number(item.measureQuantity) : 0;
  1573. } else {
  1574. // 第二层不为KG类
  1575. if (row.singleWeight && item.measureQuantity) {
  1576. item.weight = Number(item.measureQuantity) * Number(row.singleWeight);
  1577. } else {
  1578. item.weight = 0;
  1579. }
  1580. }
  1581. }
  1582. }
  1583. packingList.push(item);
  1584. console.log(
  1585. packingList,
  1586. 'packingList!!!!!!!!!!!!!!!!!!拆'
  1587. );
  1588. }
  1589. // 单独点击保存并插入对应位置(包装)
  1590. if (productIndex == 0) {
  1591. this.packingList.splice(productIndex, 0, ...packingList);
  1592. } else {
  1593. let packingIndex = this.packingList.findLastIndex(
  1594. (item) =>
  1595. item.parentIndex == this.productList[productIndex - 1].index
  1596. );
  1597. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  1598. }
  1599. let remainder = 0;
  1600. if (row.weightUnit != row.measureUnit) {
  1601. remainder =
  1602. row.measureQuantity %
  1603. row.packingSpecificationOption[1]?.packageCell;
  1604. }
  1605. if (remainder > 0) {
  1606. let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
  1607. let index = this.packingList.findIndex(
  1608. (packingItem) => packingItem.packageNo == onlyCode
  1609. );
  1610. this.$set(this.packingList[index], 'measureQuantity', remainder);
  1611. if (row.singleWeight) {
  1612. this.$set(
  1613. this.packingList[index],
  1614. 'weight',
  1615. row.singleWeight * remainder
  1616. );
  1617. }
  1618. }
  1619. },
  1620. }
  1621. }
  1622. </script>
  1623. <style scoped>
  1624. .add {
  1625. width: 96rpx;
  1626. height: 96rpx;
  1627. border-radius: 48rpx;
  1628. background: #3c9cff;
  1629. position: fixed;
  1630. bottom: 100rpx;
  1631. right: 24rpx;
  1632. display: flex;
  1633. align-items: center;
  1634. justify-content: center;
  1635. z-index: 99;
  1636. }
  1637. /* 产品卡片样式 */
  1638. .product-card {
  1639. background: #fff;
  1640. margin: 20rpx;
  1641. border-radius: 12rpx;
  1642. padding: 24rpx;
  1643. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  1644. }
  1645. .card-header {
  1646. display: flex;
  1647. justify-content: space-between;
  1648. align-items: center;
  1649. padding-bottom: 20rpx;
  1650. border-bottom: 1rpx solid #eee;
  1651. margin-bottom: 20rpx;
  1652. }
  1653. .product-name {
  1654. font-size: 28rpx;
  1655. font-weight: bold;
  1656. color: #333;
  1657. }
  1658. .product-code {
  1659. font-size: 26rpx;
  1660. color: #333;
  1661. }
  1662. .card-body {
  1663. padding: 0;
  1664. }
  1665. .info-row {
  1666. display: flex;
  1667. justify-content: space-between;
  1668. align-items: center;
  1669. padding: 16rpx 0;
  1670. border-bottom: 1rpx solid #f5f5f5;
  1671. }
  1672. .info-row:last-child {
  1673. border-bottom: none;
  1674. }
  1675. .info-label {
  1676. font-size: 28rpx;
  1677. color: #666;
  1678. min-width: 160rpx;
  1679. }
  1680. .info-value {
  1681. font-size: 28rpx;
  1682. color: #333;
  1683. text-align: right;
  1684. flex: 1;
  1685. }
  1686. .red-text {
  1687. color: #ff0000 !important;
  1688. }
  1689. .card-footer {
  1690. margin-top: 20rpx;
  1691. padding-top: 20rpx;
  1692. border-top: 1rpx solid #eee;
  1693. }
  1694. .action-buttons {
  1695. display: flex;
  1696. gap: 20rpx;
  1697. }
  1698. /* 包装明细样式 */
  1699. .packing-section {
  1700. margin-top: 40rpx;
  1701. padding: 0 20rpx;
  1702. }
  1703. .section-title {
  1704. font-size: 32rpx;
  1705. font-weight: bold;
  1706. color: #333;
  1707. padding: 20rpx 0;
  1708. }
  1709. .packing-card {
  1710. background: #fff;
  1711. border-radius: 12rpx;
  1712. padding: 24rpx;
  1713. margin-bottom: 20rpx;
  1714. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  1715. }
  1716. /* 批量操作按钮 */
  1717. .batch-actions {
  1718. display: flex;
  1719. gap: 20rpx;
  1720. padding: 20rpx;
  1721. background: #f8f8f8;
  1722. margin-bottom: 20rpx;
  1723. }
  1724. /* 卡片序号 */
  1725. .card-index {
  1726. font-size: 24rpx;
  1727. color: #999;
  1728. background: #f0f0f0;
  1729. padding: 4rpx 16rpx;
  1730. border-radius: 20rpx;
  1731. }
  1732. /* 编辑行样式 */
  1733. .edit-row {
  1734. background: #fafafa;
  1735. }
  1736. /* 必填标识 */
  1737. .required {
  1738. color: #ff0000;
  1739. }
  1740. /* 输入框样式 */
  1741. .info-input {
  1742. flex: 1;
  1743. text-align: right;
  1744. font-size: 28rpx;
  1745. color: #333;
  1746. padding: 8rpx 0;
  1747. }
  1748. /* picker选择器样式 */
  1749. .info-picker {
  1750. flex: 1;
  1751. /* text-align: right; */
  1752. }
  1753. .picker-value {
  1754. font-size: 28rpx;
  1755. color: #333;
  1756. padding: 16rpx 32rpx 16rpx 16rpx;
  1757. /* background: #f0f0f0; */
  1758. border-radius: 8rpx;
  1759. display: inline-block;
  1760. min-width: 160rpx;
  1761. /* text-align: center; */
  1762. position: relative;
  1763. width: 100%;
  1764. border: 1rpx solid #dadbde;
  1765. }
  1766. .picker-value::after {
  1767. content: '';
  1768. position: absolute;
  1769. right: 8rpx;
  1770. top: 50%;
  1771. transform: translateY(-50%);
  1772. border: 8rpx solid transparent;
  1773. border-top-color: #666;
  1774. }
  1775. .picker-value.placeholder {
  1776. color: #999;
  1777. /* background: #e8e8e8; */
  1778. }
  1779. /* 仓库选择样式 */
  1780. .warehouse-select {
  1781. flex: 1;
  1782. text-align: right;
  1783. padding: 8rpx 0;
  1784. }
  1785. /* 多选组件样式 */
  1786. .multi-select-container {
  1787. flex: 1;
  1788. display: flex;
  1789. flex-wrap: wrap;
  1790. gap: 16rpx;
  1791. padding: 8rpx 0;
  1792. }
  1793. .multi-select-item {
  1794. display: flex;
  1795. align-items: center;
  1796. gap: 8rpx;
  1797. background: #f0f0f0;
  1798. padding: 8rpx 16rpx;
  1799. border-radius: 8rpx;
  1800. font-size: 24rpx;
  1801. }
  1802. .multi-select-label {
  1803. color: #333;
  1804. }
  1805. /* 颜色选择器触发器样式 */
  1806. .color-picker-trigger {
  1807. flex: 1;
  1808. display: flex;
  1809. justify-content: flex-end;
  1810. }
  1811. </style>