inventoryTable.vue 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <div v-table-scroll-sync class="table-container">
  4. <ele-pro-table
  5. ref="table"
  6. :needPage="false"
  7. :columns="columns"
  8. :datasource="form.datasource"
  9. class="time-form"
  10. :selection.sync="selection"
  11. @columns-change="handleColumnChange"
  12. @header-dragend="handleHeaderDragend"
  13. :cache-key="cacheKeyUrl"
  14. height="350"
  15. full-height="calc(100vh - 76px)"
  16. :show-summary="true"
  17. :summary-method="getSummaries"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <div class="headbox">
  22. <div>
  23. <el-button
  24. v-if="isShowAdd && needProduce != 4"
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="handlAdd"
  30. >
  31. 新增
  32. </el-button>
  33. <el-button
  34. size="small"
  35. type="primary"
  36. icon="el-icon-plus"
  37. class="ele-btn-icon"
  38. @click="handParent()"
  39. v-if="isShowAdd && needProduce == 4"
  40. >
  41. 新增
  42. </el-button>
  43. <el-button
  44. size="small"
  45. type="danger"
  46. icon="el-icon-delete"
  47. class="ele-btn-icon"
  48. :disabled="!selection.length"
  49. @click="batchRemove"
  50. >
  51. 批量删除
  52. </el-button>
  53. </div>
  54. </div>
  55. </template>
  56. <template v-slot:technicalDrawings="{ row, $index }">
  57. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  58. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  59. </el-form-item>
  60. </template>
  61. <template v-slot:remark="{ row, $index }">
  62. <el-form-item :prop="'datasource.' + $index + '.remark'">
  63. <el-input
  64. clearable
  65. v-model="row.remark"
  66. type="textarea"
  67. placeholder="请输入"
  68. />
  69. </el-form-item>
  70. </template>
  71. <template v-slot:packagingStrength="scope">
  72. <el-form-item>
  73. <DictSelection
  74. dict-name="包装强度"
  75. @change="keyChange(scope.$index, scope.row, 'packagingStrength')"
  76. v-model="scope.row.extField.packagingStrength"
  77. :isOne="scope.$index === 0"
  78. ></DictSelection>
  79. </el-form-item>
  80. </template>
  81. <template v-slot:packagingDensity="scope">
  82. <el-form-item>
  83. <DictSelection
  84. dict-name="包装密度"
  85. @change="keyChange(scope.$index, scope.row, 'packagingDensity')"
  86. v-model="scope.row.extField.packagingDensity"
  87. :isOne="scope.$index === 0"
  88. ></DictSelection>
  89. </el-form-item>
  90. </template>
  91. <template v-slot:batchStockId="scope">
  92. <el-form-item :prop="'datasource.' + scope.$index + '.batchStockId'" :rules="[
  93. {
  94. required: scope.row.isLockSaleOrder == 1,
  95. message: '请选择批次号',
  96. trigger: 'blur'
  97. }
  98. ]">
  99. <!-- <el-input v-model="scope.row.batchNo"></el-input> -->
  100. <el-select
  101. v-model="scope.row.batchStockId"
  102. clearable
  103. placeholder="请选择"
  104. :disabled="isSaleOrderLockReadonly(scope.row)"
  105. @change="batchNoChange(scope.$index, scope.row)"
  106. >
  107. <el-option
  108. v-for="item in scope.row.batchNoList || []"
  109. :key="item.id"
  110. :label="item.batchNo"
  111. :value="item.id"
  112. >
  113. </el-option>
  114. </el-select>
  115. </el-form-item>
  116. </template>
  117. <!-- 生产编号 可编辑 -->
  118. <template v-slot:productionCodes="{ row }">
  119. <el-form-item>
  120. <el-input v-model="row.productionCodes"></el-input>
  121. </el-form-item>
  122. </template>
  123. <template v-slot:blockCount="scope">
  124. <el-form-item
  125. :prop="'datasource.' + scope.$index + '.blockCount'"
  126. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  127. >
  128. <el-input
  129. v-model="scope.row.blockCount"
  130. @input="
  131. (val) => tableHandleKeyUp(scope.row, scope.$index, 'blockCount')
  132. "
  133. ></el-input>
  134. </el-form-item>
  135. </template>
  136. <template v-slot:receiveTotalWeight="scope">
  137. <el-form-item
  138. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  139. >
  140. <el-input
  141. type="number"
  142. v-model="scope.row.receiveTotalWeight"
  143. @input="changeSendTotalWeight(scope.row, scope.$index)"
  144. style="width: calc(100% - 70px); margin-right: 10px"
  145. >
  146. <template slot="append">
  147. {{ scope.row.weightUnit }}
  148. </template>
  149. </el-input>
  150. <el-button
  151. size="small"
  152. type="primary"
  153. v-if="entrustedCode"
  154. @click.native="
  155. (e) => handleInnerBound(e, scope.row, scope.$index)
  156. "
  157. >选择
  158. </el-button>
  159. </el-form-item>
  160. </template>
  161. <template v-slot:orderNo="scope">
  162. <el-form-item
  163. :prop="'datasource.' + scope.$index + '.orderNo'"
  164. :rules="[
  165. {
  166. required: false,
  167. message: '请选择订单编号',
  168. trigger: 'blur'
  169. }
  170. ]"
  171. >
  172. <el-select
  173. v-if="needProduce == 4 && orderNoList.length > 1"
  174. v-model="scope.row.orderNo"
  175. placeholder="请选择"
  176. >
  177. <el-option
  178. v-for="item in orderNoList"
  179. :key="item.value"
  180. :label="item.label"
  181. :value="item.value"
  182. >
  183. </el-option>
  184. </el-select>
  185. <span v-else>{{ scope.row.orderNo }}</span>
  186. </el-form-item>
  187. </template>
  188. <template v-slot:sendTotalWeight="scope">
  189. <el-form-item
  190. :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
  191. >
  192. <el-input
  193. type="number"
  194. v-model="scope.row.sendTotalWeight"
  195. style="width: 100%"
  196. @input="changeCount(scope.row, scope.$index, true, 'totalWeight')"
  197. >
  198. <template slot="append">
  199. {{ scope.row.weightUnit }}
  200. </template>
  201. </el-input>
  202. </el-form-item>
  203. </template>
  204. <template v-slot:increaseTotalWeight="scope">
  205. <el-form-item
  206. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  207. >
  208. <el-input
  209. type="number"
  210. v-model="scope.row.increaseTotalWeight"
  211. style="width: 100%"
  212. disabled
  213. >
  214. <template slot="append">
  215. {{ scope.row.weightUnit }}
  216. </template>
  217. </el-input>
  218. </el-form-item>
  219. </template>
  220. <template v-slot:warehouseId="scope">
  221. <el-form-item
  222. :prop="'datasource.' + scope.$index + '.warehouseId'"
  223. :rules="[
  224. {
  225. required: isWarehouseId == 1 || scope.row.isLockSaleOrder == 1,
  226. message: '请选择仓库',
  227. trigger: 'blur'
  228. }
  229. ]"
  230. >
  231. <el-select
  232. v-model="scope.row.warehouseId"
  233. clearable
  234. :disabled="isSaleOrderLockReadonly(scope.row)"
  235. placeholder="请选择"
  236. @change="warehouseChange(scope.$index, scope.row, true)"
  237. >
  238. <el-option
  239. v-for="(item, optIndex) in scope.row.warehouseList"
  240. :key="`${item.warehouseId}_${optIndex}`"
  241. :label="item.warehouseName"
  242. :value="item.warehouseId"
  243. >
  244. </el-option>
  245. </el-select>
  246. </el-form-item>
  247. </template>
  248. <template v-slot:availableCountBase="{ row }">
  249. <span>{{
  250. row.availableCountBase === undefined ||
  251. row.availableCountBase === null
  252. ? 0
  253. : row.availableCountBase
  254. }}</span>
  255. </template>
  256. <template v-slot:singlePrice="scope">
  257. <el-form-item
  258. style="margin-bottom: 20px"
  259. :prop="'datasource.' + scope.$index + '.singlePrice'"
  260. :rules="{
  261. required: true,
  262. message: '请输入正确的单价',
  263. trigger: 'change'
  264. }"
  265. >
  266. <el-input
  267. v-model="scope.row.singlePrice"
  268. placeholder="请输入"
  269. @input="changeCount(scope.row, scope.$index)"
  270. type="number"
  271. >
  272. <template slot="append">元</template>
  273. </el-input>
  274. </el-form-item>
  275. </template>
  276. <template v-slot:singleWeight="scope">
  277. <el-form-item
  278. style="margin-bottom: 20px"
  279. :rules="{
  280. required: false,
  281. trigger: 'change'
  282. }"
  283. :prop="'datasource.' + scope.$index + '.singleWeight'"
  284. >
  285. <el-input
  286. v-model="scope.row.singleWeight"
  287. type="number"
  288. placeholder="请输入"
  289. :disabled="needProduce == 4"
  290. @input="changeCount(scope.row, scope.$index)"
  291. >
  292. <template slot="append">
  293. {{ scope.row.weightUnit }}
  294. </template>
  295. </el-input>
  296. </el-form-item>
  297. </template>
  298. <template v-slot:headerWarehouseNum="{ column }">
  299. <span class="is-required">{{ column.label }}</span>
  300. </template>
  301. <template v-slot:headerWarehouseId="{ column }">
  302. <span :class="isWarehouseId == 1 ? 'is-required' : ''">{{
  303. column.label
  304. }}</span>
  305. </template>
  306. <template v-slot:headerTotalCount="{ column }">
  307. <span class="is-required">{{ column.label }}</span>
  308. </template>
  309. <template v-slot:headerReceiveTotalWeight="{ column }">
  310. <span :class="{ 'is-required': entrustedCode && pricingWay == 2 }">{{
  311. column.label
  312. }}</span>
  313. </template>
  314. <template v-slot:saleCount="scope">
  315. <el-form-item
  316. style="margin-bottom: 20px"
  317. :prop="'datasource.' + scope.$index + '.saleCount'"
  318. :rules="[
  319. {
  320. required: true,
  321. message: '请输入数量',
  322. trigger: 'change'
  323. },
  324. {
  325. validator: (rule, value, callback) => {
  326. if (value === undefined || value === null || value === '') {
  327. callback('请输入数量');
  328. } else if (parseFloat(value) <= 0) {
  329. callback('数量必须大于0');
  330. } else {
  331. callback();
  332. }
  333. },
  334. trigger: 'blur'
  335. }
  336. ]"
  337. >
  338. <el-input
  339. v-model="scope.row.saleCount"
  340. placeholder="请输入"
  341. type="number"
  342. :min="0"
  343. :disabled="sourceType == 4"
  344. @input="changeCount(scope.row, scope.$index, false)"
  345. >
  346. <template slot="append">
  347. <el-select
  348. v-model="scope.row.saleUnitId"
  349. style="width: 80px"
  350. @change="changeCount(scope.row, scope.$index)"
  351. :disabled="clientEnvironmentId == 4 || sourceType == 4"
  352. >
  353. <el-option
  354. :label="item.conversionUnit"
  355. :value="item.id"
  356. v-for="(item, index) in scope.row.packageDispositionList"
  357. :key="index"
  358. ></el-option>
  359. </el-select>
  360. </template>
  361. </el-input>
  362. </el-form-item>
  363. </template>
  364. <template v-slot:cuttingLength="{ row, $index }">
  365. <el-form-item :prop="'datasource.' + $index + '.cuttingLength'">
  366. <el-input v-model="row.cuttingLength" placeholder="请输入">
  367. </el-input>
  368. </el-form-item>
  369. </template>
  370. <!-- <template v-slot:saleUnit="scope">
  371. <el-form-item
  372. style="margin-bottom: 20px"
  373. :prop="'datasource.' + scope.$index + '.saleUnitId'"
  374. >
  375. <el-select
  376. v-model="scope.row.saleUnitId"
  377. style="width: 100%"
  378. @change="changeCount(scope.row, scope.$index)"
  379. :disabled="clientEnvironmentId == 4"
  380. >
  381. <el-option
  382. :label="item.conversionUnit"
  383. :value="item.id"
  384. @click.native="packingChange(item, scope.$index)"
  385. v-for="(item, index) in scope.row.packageDispositionList"
  386. :key="index"
  387. ></el-option>
  388. </el-select>
  389. </el-form-item>
  390. </template> -->
  391. <template v-slot:modelKey="scope">
  392. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  393. <DictSelection
  394. dictName="物品机型"
  395. clearable
  396. v-model="scope.row.modelKey"
  397. :isOne="scope.$index === 0"
  398. filterable
  399. allow-create
  400. default-first-option
  401. >
  402. </DictSelection>
  403. </el-form-item>
  404. </template>
  405. <template v-slot:colorKey="scope">
  406. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  407. <DictSelection
  408. dictName="物品颜色"
  409. clearable
  410. v-model="scope.row.colorKey"
  411. :isOne="scope.$index === 0"
  412. filterable
  413. allow-create
  414. default-first-option
  415. >
  416. </DictSelection>
  417. </el-form-item>
  418. </template>
  419. <!-- 操作列 -->
  420. <template v-slot:action="scope">
  421. <el-popconfirm
  422. class="ele-action"
  423. title="确定要删除吗?"
  424. @confirm="remove(scope.$index)"
  425. >
  426. <template v-slot:reference>
  427. <el-link type="danger" :underline="false" icon="el-icon-delete">
  428. 删除
  429. </el-link>
  430. </template>
  431. </el-popconfirm>
  432. <el-link
  433. type="primary"
  434. :underline="false"
  435. icon="el-icon-edit"
  436. @click="selectStockLedgerDialogOpen(scope.row)"
  437. >
  438. 替代料
  439. </el-link>
  440. </template>
  441. </ele-pro-table>
  442. </div>
  443. <productListNew
  444. ref="productListRef"
  445. @changeParent="changeParent"
  446. ></productListNew>
  447. <!--入库详情-->
  448. <innertboundDetailsDialog
  449. v-if="innerboundDetailsDialogFlag"
  450. ref="innerboundDetailsDialogRef"
  451. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  452. @saveDate="saveInnerDate"
  453. ></innertboundDetailsDialog>
  454. <!-- 库存台账 -->
  455. <stock-ledger-dialog
  456. v-if="stockLedgerDialogFlag"
  457. :stock-ledger-dialog-flag.sync="stockLedgerDialogFlag"
  458. ref="stockLedgerDialogRef"
  459. @getStockLedger="getStockLedger"
  460. ></stock-ledger-dialog>
  461. <selectStockLedgerDialog
  462. ref="selectStockLedgerDialogRef"
  463. @changeParent="replaceTable"
  464. ></selectStockLedgerDialog>
  465. <BIZproductList
  466. ref="BIZproductListRef"
  467. classType="1"
  468. :isGetInventoryTotal="true"
  469. @changeParent="changeParentBiz"
  470. :typeIds="typeIds"
  471. :isFirstRefreshTable="true"
  472. ></BIZproductList>
  473. </el-form>
  474. </template>
  475. <script>
  476. import { numberReg } from 'ele-admin';
  477. import dictMixins from '@/mixins/dictMixins';
  478. import productListNew from './product-listNew.vue';
  479. import {
  480. getWarehouseOutStockInfo,
  481. getIdWarehouseList
  482. } from '@/api/saleManage/saleorder';
  483. import { copyObj } from '@/utils/util';
  484. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  485. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  486. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  487. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  488. import BIZproductList from '@/BIZComponents/product-list.vue';
  489. import tabMixins from '@/mixins/tableColumnsMixin';
  490. import { levelList, pricingWayList, lbjtList } from '@/enum/dict.js';
  491. import { changeCount, formatPrice } from '@/BIZComponents/setProduct.js';
  492. import { parameterGetByCode } from '@/api/main/index.js';
  493. import { getSummaries } from '@/utils/util.js';
  494. import { getBatchList } from '@/api/wms';
  495. import Vue from 'vue';
  496. export default {
  497. mixins: [dictMixins, getDynamicsColumns, tabMixins],
  498. props: {
  499. orderId: String,
  500. orderIds: String,
  501. orderNos: String,
  502. needProduce: [String, Number],
  503. entrustedCode: String,
  504. pricingWay: [String, Number],
  505. isShowAdd: {
  506. type: Boolean,
  507. default: true
  508. },
  509. typeIds: {
  510. type: Array,
  511. default: () => []
  512. },
  513. oldProductList: {
  514. type: Array,
  515. default: () => []
  516. },
  517. sourceType: {
  518. type: [String, Number],
  519. default: ''
  520. },
  521. isTotalCount: {
  522. default: 0
  523. },
  524. isReturnGoodsCreate: {
  525. type: Boolean,
  526. default: false
  527. }
  528. },
  529. components: {
  530. // fileMain,
  531. innertboundDetailsDialog,
  532. productListNew,
  533. stockLedgerDialog,
  534. selectStockLedgerDialog,
  535. BIZproductList
  536. },
  537. data() {
  538. const defaultForm = {
  539. key: null,
  540. endTime: '',
  541. isFirst: 0,
  542. name: '',
  543. startTime: '',
  544. workHour: '',
  545. technicalDrawings: []
  546. // warehouseCode:"",
  547. // warehouseId:'',
  548. // warehouseName:'',
  549. };
  550. return {
  551. cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable-2026082501',
  552. current: {},
  553. childrenColumns: [
  554. {
  555. width: 45,
  556. type: 'selection',
  557. columnKey: 'selection',
  558. align: 'center'
  559. },
  560. {
  561. width: 45,
  562. type: 'index',
  563. columnKey: 'index',
  564. align: 'center',
  565. fixed: 'left'
  566. },
  567. {
  568. minWidth: 100,
  569. prop: 'code',
  570. label: '编码',
  571. align: 'center'
  572. },
  573. {
  574. minWidth: 140,
  575. prop: 'barcodes',
  576. label: '发货条码',
  577. align: 'center'
  578. },
  579. {
  580. minWidth: 100,
  581. prop: 'engrave',
  582. label: '刻码',
  583. align: 'center'
  584. }
  585. ],
  586. selection: [],
  587. discountTotalPrice: 0.0,
  588. allPrice: 0.0,
  589. curIndex: null,
  590. innerboundDetailsDialogFlag: false,
  591. stockLedgerDialogFlag: false,
  592. numberReg,
  593. defaultForm,
  594. warehouseList: [],
  595. dynamicsColumns: [],
  596. isWarehouseId: 0,
  597. blockCountColumn: {},
  598. form: {
  599. datasource: []
  600. },
  601. rules: {},
  602. columnsVersion: 1
  603. };
  604. },
  605. created() {
  606. this.requestDict('产地');
  607. this.requestDict('生产类型');
  608. parameterGetByCode({
  609. code: 'eom_saleManage_invoice_warehouseId'
  610. }).then((res) => {
  611. if (res.value) {
  612. this.isWarehouseId = res.value;
  613. }
  614. });
  615. },
  616. computed: {
  617. canHandl() {
  618. return this.form.datasource.length;
  619. },
  620. clientEnvironmentId() {
  621. return this.$store.state.user.info.clientEnvironmentId;
  622. },
  623. orderNoList() {
  624. const temp = this.orderNos?.split(',') || [];
  625. return temp.map((item) => {
  626. return {
  627. label: item,
  628. value: item
  629. };
  630. });
  631. },
  632. columns() {
  633. let columnsVersion = this.columnsVersion;
  634. return [
  635. {
  636. width: 45,
  637. type: 'selection',
  638. columnKey: 'selection',
  639. align: 'center',
  640. fixed: 'left'
  641. },
  642. {
  643. width: 60,
  644. type: 'index',
  645. columnKey: 'index',
  646. align: 'center',
  647. fixed: 'left'
  648. },
  649. {
  650. minWidth: 200,
  651. prop: 'orderNo',
  652. label: '订单编码',
  653. align: 'center',
  654. slot: 'orderNo',
  655. fixed: 'left'
  656. },
  657. {
  658. width: 200,
  659. prop: 'productName',
  660. label: '名称',
  661. slot: 'productName',
  662. align: 'center'
  663. },
  664. {
  665. width: 120,
  666. prop: 'productCode',
  667. label: '编码',
  668. slot: 'productCode',
  669. align: 'center'
  670. },
  671. {
  672. width: 200,
  673. prop: 'productCategoryName',
  674. label: '类型',
  675. slot: 'productCategoryName',
  676. align: 'center'
  677. },
  678. {
  679. width: 140,
  680. prop: 'pricingWay',
  681. label: '计价方式',
  682. align: 'center',
  683. fixed: 'left',
  684. formatter: (row, column) => {
  685. return pricingWayList.find((item) => item.id == row.pricingWay)
  686. ?.name;
  687. }
  688. },
  689. {
  690. width: 160,
  691. prop: 'batchStockId',
  692. label: '批次号',
  693. slot: 'batchStockId',
  694. align: 'center'
  695. },
  696. {
  697. minWidth: 180,
  698. prop: 'systemBatchNo',
  699. label: '系统内部批次号',
  700. align: 'center',
  701. formatter: (row) => row.systemBatchNo || '-'
  702. },
  703. {
  704. width: 160,
  705. prop: 'productBrand',
  706. label: '牌号',
  707. slot: 'productBrand',
  708. align: 'center'
  709. },
  710. {
  711. width: 120,
  712. prop: 'modelType',
  713. label: '型号',
  714. slot: 'modelType',
  715. align: 'center'
  716. },
  717. {
  718. width: 120,
  719. prop: 'specification',
  720. label: '规格',
  721. slot: 'specification',
  722. align: 'center'
  723. },
  724. {
  725. width: 160,
  726. prop: 'modelKey',
  727. label: '机型',
  728. slot: 'modelKey',
  729. align: 'center'
  730. },
  731. {
  732. width: 160,
  733. prop: 'colorKey',
  734. label: '颜色',
  735. slot: 'colorKey',
  736. align: 'center'
  737. },
  738. {
  739. minWidth: 160,
  740. prop: 'productionCodes',
  741. label: '生产编号',
  742. align: 'center',
  743. slot: 'productionCodes'
  744. },
  745. {
  746. minWidth: 280,
  747. prop: 'productionRequirements',
  748. label: '生产要求',
  749. align: 'center'
  750. },
  751. {
  752. minWidth: 120,
  753. prop: 'goodsLevel',
  754. label: '物品级别',
  755. formatter: (_row, _column, cellValue) => {
  756. return levelList.find((item) => item.value == _row.goodsLevel)
  757. ?.label;
  758. },
  759. align: 'center'
  760. },
  761. ...this.dynamicsColumns,
  762. {
  763. width: 120,
  764. prop: 'customerMark',
  765. label: '客户代号',
  766. slot: 'customerMark',
  767. align: 'center'
  768. },
  769. {
  770. width: 200,
  771. prop: 'warehouseId',
  772. label: '仓库名称',
  773. slot: 'warehouseId',
  774. headerSlot: 'headerWarehouseId',
  775. align: 'center'
  776. },
  777. {
  778. width: 100,
  779. prop: 'stockCountBase',
  780. label: '库存数量',
  781. align: 'center'
  782. },
  783. {
  784. width: 100,
  785. prop: 'availableCountBase',
  786. label: '可用数量',
  787. slot: 'availableCountBase',
  788. align: 'center'
  789. },
  790. // {
  791. // width: 100,
  792. // prop: 'stockLedger',
  793. // label: '发货明细',
  794. // slot: 'stockLedger',
  795. // align: 'center'
  796. // },
  797. {
  798. width: 250,
  799. prop: 'saleCount',
  800. label: '发货数量',
  801. slot: 'saleCount',
  802. headerSlot: 'headerTotalCount',
  803. align: 'center'
  804. },
  805. {
  806. width: 150,
  807. prop: 'pendingShipmentQuantity',
  808. label: '待发数量',
  809. align: 'center'
  810. },
  811. {
  812. width: 100,
  813. prop: 'notSendTotalCount',
  814. label: '未出库数量',
  815. align: 'center',
  816. formatter: (row, column) => {
  817. // if (row.notSendTotalCount) {
  818. return row.notSendTotalCount;
  819. // }
  820. }
  821. },
  822. {
  823. width: 100,
  824. prop: 'notGenerateSendCount',
  825. label: '未发数量',
  826. align: 'center',
  827. formatter: (row, column) => {
  828. // if (row.notGenerateSendCount) {
  829. return row.notGenerateSendCount;
  830. // }
  831. }
  832. },
  833. {
  834. width: 120,
  835. prop: 'totalCount',
  836. label: '计量数量',
  837. formatter: (row, column) => {
  838. // if (row.totalCount) {
  839. return row.totalCount + ' ' + row.measuringUnit;
  840. // }
  841. },
  842. align: 'center'
  843. },
  844. {
  845. width: 120,
  846. prop: 'orderTotalCount',
  847. label: '订单数量',
  848. formatter: (row, column) => {
  849. if (row.orderTotalCount) {
  850. return row.orderTotalCount + ' ' + row.measuringUnit;
  851. }
  852. },
  853. align: 'center'
  854. },
  855. {
  856. width: 120,
  857. prop: 'packingSpecification',
  858. align: 'center',
  859. label: '包装规格',
  860. showOverflowTooltip: true
  861. },
  862. // {
  863. // width: 80,
  864. // prop: 'measuringUnit',
  865. // label: '计量单位',
  866. // slot: 'measuringUnit',
  867. // align: 'center'
  868. // },
  869. this.clientEnvironmentId == 4
  870. ? {
  871. width: 150,
  872. prop: 'blockCount',
  873. label: '发货块数',
  874. slot: 'blockCount',
  875. align: 'center'
  876. }
  877. : { width: 1 },
  878. {
  879. width: 200,
  880. prop: 'singleWeight',
  881. slot: 'singleWeight',
  882. label: '单重',
  883. align: 'center'
  884. },
  885. {
  886. width: 250,
  887. prop: 'receiveTotalWeight',
  888. label: '收货总重',
  889. slot: 'receiveTotalWeight',
  890. align: 'center',
  891. headerSlot: 'headerReceiveTotalWeight'
  892. },
  893. {
  894. width: 220,
  895. prop: 'sendTotalWeight',
  896. label: '发货总重',
  897. slot: 'sendTotalWeight',
  898. align: 'center'
  899. },
  900. {
  901. width: 220,
  902. prop: 'increaseTotalWeight',
  903. label: '增重重量',
  904. slot: 'increaseTotalWeight',
  905. align: 'center'
  906. },
  907. {
  908. width: 180,
  909. prop: 'singlePrice',
  910. label: '单价',
  911. slot: 'singlePrice',
  912. align: 'center'
  913. },
  914. {
  915. width: 160,
  916. prop: 'taxRate',
  917. label: '税率',
  918. formatter: (_row, _column, cellValue) => {
  919. return _row.taxRate ? _row.taxRate + '%' : '';
  920. },
  921. align: 'center'
  922. },
  923. {
  924. width: 180,
  925. prop: 'notaxSinglePrice',
  926. label: '不含税单价',
  927. align: 'center'
  928. },
  929. {
  930. width: 160,
  931. prop: 'discountSinglePrice',
  932. label: '折后单价',
  933. slot: 'discountSinglePrice',
  934. align: 'center'
  935. },
  936. {
  937. width: 120,
  938. prop: 'totalPrice',
  939. label: '合计',
  940. slot: 'totalPrice',
  941. align: 'center'
  942. },
  943. {
  944. width: 160,
  945. prop: 'notaxTotalPrice',
  946. label: '含税合计',
  947. align: 'center'
  948. },
  949. {
  950. width: 120,
  951. prop: 'discountTotalPrice',
  952. label: '折后合计',
  953. slot: 'discountTotalPrice',
  954. align: 'center'
  955. },
  956. {
  957. minWidth: 280,
  958. prop: 'cuttingLength',
  959. label: '裁线米段',
  960. align: 'center',
  961. slot: 'cuttingLength'
  962. },
  963. {
  964. width: 120,
  965. prop: 'imgCode',
  966. align: 'center',
  967. label: '图号/件号',
  968. showOverflowTooltip: true
  969. },
  970. {
  971. width: 120,
  972. prop: 'produceType',
  973. align: 'center',
  974. label: '属性类型',
  975. formatter: (row, column) => {
  976. if (row.produceType) {
  977. return row.produceType
  978. .map((item) => {
  979. return lbjtList[item];
  980. })
  981. .toString();
  982. }
  983. },
  984. showOverflowTooltip: true
  985. },
  986. {
  987. width: 200,
  988. prop: 'guaranteePeriod',
  989. label: '有效期',
  990. slot: 'guaranteePeriod',
  991. formatter: (_row, _column, cellValue) => {
  992. let val = '';
  993. if (_row.guaranteePeriod) {
  994. val += _row.guaranteePeriod;
  995. }
  996. if (_row.guaranteePeriodUnitName) {
  997. val += _row.guaranteePeriodUnitName;
  998. }
  999. return val;
  1000. },
  1001. align: 'center'
  1002. },
  1003. {
  1004. width: 200,
  1005. prop: 'guaranteePeriodDeadline',
  1006. label: '有效期截止日期',
  1007. slot: 'guaranteePeriodDeadline',
  1008. align: 'center'
  1009. },
  1010. {
  1011. prop: 'provenance',
  1012. label: '产地',
  1013. slot: 'provenance',
  1014. align: 'center',
  1015. // show:this.contractBookType==2,
  1016. minWidth: 200,
  1017. showOverflowTooltip: true,
  1018. formatter: (row, column) => {
  1019. return row.provenance && row.provenance.length
  1020. ? row.provenance
  1021. .map((item) => this.getDictValue('产地', item))
  1022. .join(',')
  1023. : '';
  1024. }
  1025. },
  1026. {
  1027. width: 130,
  1028. prop: 'technicalAnswerName',
  1029. label: '技术答疑人',
  1030. slot: 'technicalAnswerName',
  1031. align: 'center'
  1032. },
  1033. {
  1034. width: 220,
  1035. prop: 'technicalParams',
  1036. label: '技术参数',
  1037. slot: 'technicalParams',
  1038. align: 'center'
  1039. },
  1040. {
  1041. width: 240,
  1042. prop: 'technicalDrawings',
  1043. label: '技术图纸',
  1044. slot: 'technicalDrawings',
  1045. align: 'center'
  1046. },
  1047. {
  1048. width: 220,
  1049. prop: 'remark',
  1050. label: '备注',
  1051. slot: 'remark',
  1052. align: 'center'
  1053. },
  1054. {
  1055. columnKey: 'action',
  1056. label: '操作',
  1057. width: 200,
  1058. align: 'center',
  1059. resizable: false,
  1060. slot: 'action',
  1061. fixed: 'right',
  1062. showOverflowTooltip: true
  1063. }
  1064. ];
  1065. }
  1066. },
  1067. mounted() {
  1068. // this.clientEnvironmentId =
  1069. },
  1070. methods: {
  1071. formatPrice,
  1072. isSaleOrderLockReadonly(row) {
  1073. if (row.hasSendRejectedOrWithdrawn == 1) {
  1074. return false;
  1075. }
  1076. const orderType = row.needProduce ?? this.needProduce;
  1077. return orderType == 0 || (orderType == 1 && row.isLockSaleOrder == 1);
  1078. },
  1079. dedupeBatchNoList(list) {
  1080. const seen = new Set();
  1081. return (list || []).filter((item) => {
  1082. if (seen.has(item.id)) {
  1083. return false;
  1084. }
  1085. seen.add(item.id);
  1086. return true;
  1087. });
  1088. },
  1089. getSummaries(param) {
  1090. return getSummaries(
  1091. param,
  1092. ['saleCount', 'blockCount', 'totalCount'],
  1093. ' '
  1094. );
  1095. },
  1096. //发货明细选择
  1097. stockLedgerSelect(row, index) {
  1098. this.curIndex = index;
  1099. this.stockLedgerDialogFlag = true;
  1100. this.$nextTick(() => {
  1101. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  1102. });
  1103. },
  1104. packingChange(item, index) {
  1105. this.$set(this.form.datasource[index], 'saleUnit', item.conversionUnit);
  1106. },
  1107. //获取
  1108. getStockLedger(sendProductDetail) {
  1109. if (!this.form.datasource[this.curIndex].sendProductDetail)
  1110. this.form.datasource[this.curIndex].sendProductDetail = [];
  1111. let row = this.form.datasource[this.curIndex];
  1112. row.sendProductDetail.push(...sendProductDetail);
  1113. this.form.datasource[this.curIndex] = row;
  1114. this.$refs['childrenTable' + this.curIndex].reload();
  1115. this.$refs.table.reload();
  1116. },
  1117. //删除发货明细
  1118. stockLedgerRemove(PIndex) {
  1119. let row = this.form.datasource[PIndex];
  1120. this.selection.forEach((item) => {
  1121. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  1122. row.sendProductDetail.splice(index, 1);
  1123. });
  1124. this.form.datasource[PIndex] = row;
  1125. this.$refs['childrenTable' + PIndex].reload();
  1126. this.$refs.table.reload();
  1127. this.selection = [];
  1128. },
  1129. // 将接口返回的库存数量和可用数量同步到当前物品清单行。
  1130. setWarehouseOutStock(index, stockInfo) {
  1131. const stockCountBase = stockInfo?.stockCountBase || 0;
  1132. const availableCountBase = stockInfo?.availableCountBase || 0;
  1133. this.$set(
  1134. this.form.datasource[index],
  1135. 'stockCountBase',
  1136. stockCountBase
  1137. );
  1138. this.$set(
  1139. this.form.datasource[index],
  1140. 'availableCountBase',
  1141. availableCountBase
  1142. );
  1143. // 保留原字段,兼容已有发货数量校验和提交逻辑。
  1144. this.$set(
  1145. this.form.datasource[index],
  1146. 'warehouseNum',
  1147. availableCountBase
  1148. );
  1149. },
  1150. async refreshWarehouseOutStock(index, row) {
  1151. if (!row.warehouseId) {
  1152. this.setWarehouseOutStock(index, {});
  1153. return;
  1154. }
  1155. const stockInfo = await getWarehouseOutStockInfo({
  1156. warehouseId: row.warehouseId,
  1157. code: row.productCode,
  1158. batchNo: row.batchNo,
  1159. systemBatchNo: row.systemBatchNo,
  1160. colorKey: row.colorKey,
  1161. modelType: row.modelType
  1162. });
  1163. this.setWarehouseOutStock(index, stockInfo);
  1164. },
  1165. async warehouseChange(index, row, isReset = false) {
  1166. console.log('warehouseChange', index, row.warehouseId, isReset);
  1167. const data = row.warehouseList.find(
  1168. (item) => item.warehouseId == row.warehouseId
  1169. );
  1170. console.log('warehouseChange', data);
  1171. this.$set(
  1172. this.form.datasource[index],
  1173. 'warehouseName',
  1174. data?.warehouseName || ''
  1175. );
  1176. this.$set(
  1177. this.form.datasource[index],
  1178. 'warehouseCode',
  1179. data?.warehouseCode || 0
  1180. );
  1181. const tempBatchNoList = await getBatchList({
  1182. warehouseId: data?.warehouseId || '',
  1183. categoryCode: row.productCode,
  1184. colorKey: row.colorKey,
  1185. modelType: row.modelType,
  1186. });
  1187. this.$set(
  1188. this.form.datasource[index],
  1189. 'batchNoList',
  1190. this.dedupeBatchNoList(tempBatchNoList?.list)
  1191. );
  1192. if (isReset) {
  1193. this.$set(this.form.datasource[index], 'batchStockId', '');
  1194. this.$set(this.form.datasource[index], 'batchNo', '');
  1195. this.$set(this.form.datasource[index], 'systemBatchNo', '');
  1196. }
  1197. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1198. },
  1199. //批次号选择
  1200. async batchNoChange(index, row) {
  1201. if (!row.batchStockId) {
  1202. this.$set(this.form.datasource[index], 'batchStockId', '');
  1203. this.$set(this.form.datasource[index], 'batchNo', '');
  1204. this.$set(this.form.datasource[index], 'systemBatchNo', '');
  1205. // this.$set(this.form.datasource[index], 'warehouseNum', '');
  1206. const tempWarehouse = await getIdWarehouseList({
  1207. categoryId: this.form.datasource[index].productId
  1208. });
  1209. // 有仓库列表
  1210. if (tempWarehouse?.length) {
  1211. console.log('666~~~~!!', index, tempWarehouse);
  1212. this.$set(
  1213. this.form.datasource[index],
  1214. 'warehouseList',
  1215. tempWarehouse
  1216. );
  1217. }
  1218. await this.refreshWarehouseOutStock(
  1219. index,
  1220. this.form.datasource[index]
  1221. );
  1222. return;
  1223. }
  1224. const data = row.batchNoList.find(
  1225. (item) => item.id == row.batchStockId
  1226. );
  1227. this.$set(this.form.datasource[index], 'batchNo', data.batchNo);
  1228. this.$set(
  1229. this.form.datasource[index],
  1230. 'systemBatchNo',
  1231. data.systemBatchNo
  1232. );
  1233. await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
  1234. },
  1235. //改变数量
  1236. changeCount(row, index, isBlockCount = true, weightType) {
  1237. if (weightType == 'totalWeight') {
  1238. this.$set(
  1239. this.form.datasource[index],
  1240. 'totalWeight',
  1241. this.form.datasource[index].sendTotalWeight
  1242. );
  1243. }
  1244. this.$set(
  1245. this.form.datasource,
  1246. index,
  1247. changeCount(
  1248. row,
  1249. {
  1250. countKey: 'saleCount',
  1251. unitKey: 'saleUnit',
  1252. unitIdKey: 'saleUnitId'
  1253. },
  1254. false,
  1255. weightType
  1256. )
  1257. );
  1258. this.$set(
  1259. this.form.datasource[index],
  1260. 'sendTotalWeight',
  1261. this.form.datasource[index].totalWeight
  1262. );
  1263. this.changeSendTotalWeight(row, index);
  1264. this.getNotaxSinglePrice();
  1265. this.$forceUpdate();
  1266. if (this.clientEnvironmentId == 4 && !isBlockCount) {
  1267. this.tableHandleKeyUp(row, index, 'sum');
  1268. }
  1269. },
  1270. //修改发货总重
  1271. changeSendTotalWeight(row, index) {
  1272. this.curIndex = index;
  1273. this.setIcreaseTotalWeight(row);
  1274. },
  1275. keyChange(index, row, key) {
  1276. this.$set(
  1277. this.form.datasource[index],
  1278. 'extField.' + key,
  1279. row.extField[key]
  1280. );
  1281. this.$forceUpdate();
  1282. },
  1283. //设置增重总重
  1284. setIcreaseTotalWeight(row) {
  1285. let receiveTotalWeight = Number(
  1286. this.form.datasource[this.curIndex]?.receiveTotalWeight
  1287. );
  1288. let sendTotalWeight = Number(
  1289. this.form.datasource[this.curIndex]?.sendTotalWeight
  1290. );
  1291. if (sendTotalWeight) {
  1292. let increaseTotalWeight = sendTotalWeight - receiveTotalWeight;
  1293. this.$set(
  1294. this.form.datasource[this.curIndex],
  1295. 'increaseTotalWeight',
  1296. increaseTotalWeight.toFixed(4)
  1297. );
  1298. if (row.pricingWay == 3) {
  1299. this.$set(
  1300. this.form.datasource[this.curIndex],
  1301. 'totalPrice',
  1302. (increaseTotalWeight * row.singlePrice).toFixed(2)
  1303. );
  1304. }
  1305. }
  1306. this.$refs.table.reload();
  1307. this.$forceUpdate();
  1308. },
  1309. //计算不含税单价
  1310. getNotaxSinglePrice() {
  1311. this.form.datasource.forEach((item, index) => {
  1312. if (item.singlePrice && item.taxRate) {
  1313. this.$set(
  1314. this.form.datasource[index],
  1315. 'notaxSinglePrice',
  1316. formatPrice(item.singlePrice / (1 + item.taxRate / 100))
  1317. );
  1318. } else {
  1319. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1320. }
  1321. });
  1322. },
  1323. //入库单详情
  1324. handleInnerBound(e, rows, index) {
  1325. this.curIndex = index;
  1326. this.innerboundDetailsDialogFlag = true;
  1327. this.$nextTick(() => {
  1328. let row = {
  1329. code: this.entrustedCode
  1330. };
  1331. this.$refs.innerboundDetailsDialogRef.init(row);
  1332. });
  1333. },
  1334. //选择入库单信息
  1335. saveInnerDate(data = []) {
  1336. let totalWeight = data.reduce((num, row) => {
  1337. num += Number(row.weight);
  1338. return num;
  1339. }, 0);
  1340. this.$set(
  1341. this.form.datasource[this.curIndex],
  1342. 'receiveTotalWeight',
  1343. totalWeight
  1344. );
  1345. console.log(totalWeight, 'totalWeight');
  1346. this.setIcreaseTotalWeight(this.form.datasource[this.curIndex]);
  1347. },
  1348. // getWeightPrice() {
  1349. // let increaseTotalWeight =
  1350. // this.form.datasource[this.curIndex].increaseTotalWeight;
  1351. // let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  1352. // let discountSinglePrice =
  1353. // this.form.datasource[this.curIndex].discountSinglePrice;
  1354. // this.$set(
  1355. // this.form.datasource[this.curIndex],
  1356. // 'totalPrice',
  1357. // (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  1358. // );
  1359. // this.$set(
  1360. // this.form.datasource[this.curIndex],
  1361. // 'discountTotalPrice',
  1362. // (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  1363. // );
  1364. // },
  1365. // 表格:模数、数量(方)、块数输入框 输入事件
  1366. tableHandleKeyUp(row, index, name) {
  1367. if (row.specification) {
  1368. let modelArr = row.specification.split('*');
  1369. let modelLong = modelArr[0]; // model规格长度
  1370. let modeWide = modelArr[1]; // model规格宽度
  1371. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1372. modeHight = Number(modeHight);
  1373. if (name === 'sum') {
  1374. // row.blockCount = Math.floor(
  1375. // row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1376. // );
  1377. this.$set(
  1378. this.form.datasource[index],
  1379. 'blockCount',
  1380. Math.floor(
  1381. row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  1382. )
  1383. );
  1384. } else if (name === 'blockCount') {
  1385. row.totalCount =
  1386. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1387. 1000000;
  1388. row.saleCount = row.totalCount;
  1389. this.changeCount(row, index, true);
  1390. }
  1391. }
  1392. },
  1393. //选择产品回调
  1394. async changeParent(obj) {
  1395. console.log(obj, 'obj');
  1396. obj.forEach((item) => {
  1397. item.orderTotalCount = item.totalCount;
  1398. item.id = '';
  1399. });
  1400. this.putTableValue(copyObj(obj));
  1401. },
  1402. //选择产品回调
  1403. changeParentBiz(obj = [], idx) {
  1404. console.log('obj~~~', obj, idx);
  1405. obj.forEach(async (item, index) => {
  1406. let i = idx == -1 ? index : idx;
  1407. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1408. row.key = this.form.datasource.length + 1;
  1409. row['tempId'] = this.form.datasource.length + 1;
  1410. let parasm = idx == -1 ? row : this.form.datasource[i];
  1411. console.log('parasm~~~~222', parasm);
  1412. this.$set(parasm, 'productId', item.id);
  1413. this.$set(parasm, 'categoryName', item.name);
  1414. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1415. this.$set(parasm, 'productBrand', item.brandNum);
  1416. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1417. this.$set(parasm, 'productCode', item.code);
  1418. this.$set(parasm, 'productName', item.name);
  1419. this.$set(parasm, 'modelType', item.modelType);
  1420. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1421. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1422. this.$set(parasm, 'specification', item.specification);
  1423. this.$set(parasm, 'weightUnit', item.weightUnit);
  1424. this.$set(parasm, 'imgCode', item.imgCode);
  1425. this.$set(parasm, 'produceType', item.componentAttribute);
  1426. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1427. this.$set(parasm, 'extField', item.extField || {});
  1428. this.$set(parasm, 'singleWeight', item.netWeight);
  1429. this.$set(parasm, 'pricingWay', item.pricingWay || 1);
  1430. this.$set(parasm, 'singlePrice', 0);
  1431. this.$set(parasm, 'discountSinglePrice', 0);
  1432. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  1433. this.$set(parasm, 'orderNo', this.orderNoList[0]?.value || '');
  1434. if (item.modelKey) {
  1435. this.$set(parasm, 'modelKey', item.modelKey);
  1436. }
  1437. if (item.colorKey) {
  1438. this.$set(parasm, 'colorKey', item.colorKey);
  1439. }
  1440. this.$set(parasm, 'receiveTotalWeight', 0);
  1441. this.$set(parasm, 'sendTotalWeight', 0);
  1442. this.$set(parasm, 'increaseTotalWeight', 0);
  1443. this.$set(
  1444. parasm,
  1445. 'packageDispositionList',
  1446. item.packageDispositionList
  1447. );
  1448. if (item.packageDispositionList?.length) {
  1449. this.$set(parasm, 'saleUnitId', item.packageDispositionList[0].id);
  1450. this.$set(
  1451. parasm,
  1452. 'saleUnit',
  1453. item.packageDispositionList[0].conversionUnit
  1454. );
  1455. }
  1456. this.$set(
  1457. parasm,
  1458. 'warehouseList',
  1459. await getIdWarehouseList({
  1460. categoryId: item.id
  1461. })
  1462. );
  1463. const templist = await getBatchList({
  1464. categoryCode: item.code,
  1465. warehouseId: item.warehouseId,
  1466. colorKey: item.colorKey,
  1467. modelType: item.modelType,
  1468. size: -1
  1469. });
  1470. this.$set(
  1471. parasm,
  1472. 'batchNoList',
  1473. this.dedupeBatchNoList(templist?.list)
  1474. );
  1475. console.log('parasm~~~~333', parasm);
  1476. this.$set(
  1477. parasm,
  1478. 'packingSpecification',
  1479. item.extField?.packingSpecification
  1480. );
  1481. this.$set(
  1482. parasm,
  1483. 'supplierMark',
  1484. this.form.datasource[0]?.supplierMark
  1485. );
  1486. if (item.purchaseOrigins?.length > 0) {
  1487. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1488. }
  1489. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1490. console.log('parasm~~~~', parasm);
  1491. console.log('row~~~~', row);
  1492. if (idx == -1) {
  1493. this.form.datasource.push(row);
  1494. }
  1495. console.log('this.form.datasource~~~~', this.form.datasource);
  1496. });
  1497. },
  1498. replaceTable(list) {
  1499. console.log('list~~~~', list);
  1500. list.forEach((item) => {
  1501. item['relationId'] = this.current.tempId;
  1502. });
  1503. this.$emit('replaceTableChange', list);
  1504. },
  1505. // validateTotalCount(row) {
  1506. // return (rule, value, callback) => {
  1507. // if (isNaN(value) || Number(value) <= 0) {
  1508. // this.$message.error('请输入大于0的数');
  1509. // callback(false);
  1510. // } else else {
  1511. // callback();
  1512. // }
  1513. // };
  1514. // },
  1515. // 返回列表数据
  1516. getTableValue() {
  1517. let comitDatasource = this.form.datasource;
  1518. if (comitDatasource.length === 0) return [];
  1519. comitDatasource.forEach(async (v) => {
  1520. // 清空批次时同步清理批次库存 ID,避免更新接口残留旧批次。
  1521. if (!v.batchNo) {
  1522. v.batchNo = '';
  1523. v.systemBatchNo = '';
  1524. v.batchStockId = '';
  1525. }
  1526. if (v.modelKey) {
  1527. v.modelKey = v.modelKey;
  1528. }
  1529. if (v.colorKey) {
  1530. v.colorKey = v.colorKey;
  1531. }
  1532. v.totalCount = Number(v.totalCount);
  1533. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1534. ? v.technicalDrawings
  1535. : [];
  1536. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  1537. ? v.customerReqFiles
  1538. : [];
  1539. v.industryArtFiles = v.industryArtFiles || [];
  1540. v.otherFiles = v.otherFiles || [];
  1541. });
  1542. return comitDatasource;
  1543. },
  1544. getPrice() {
  1545. return [this.allPrice];
  1546. },
  1547. //修改回显
  1548. putTableValue(data, isInit) {
  1549. if (isInit) {
  1550. this.form.datasource = [];
  1551. }
  1552. if (data) {
  1553. this.setValue(data);
  1554. }
  1555. },
  1556. setValue(data) {
  1557. console.log('setValue~~~~~~', data, this.sourceType);
  1558. let indexS = [];
  1559. data.forEach((item, index) => {
  1560. if (item.modelKey) {
  1561. this.$set(data[index], 'modelKey', item.modelKey);
  1562. }
  1563. if (item.colorKey) {
  1564. this.$set(data[index], 'colorKey', item.colorKey);
  1565. }
  1566. item.receiveTotalWeight = item.receiveTotalWeight || 0;
  1567. // console.log('item~~~~', item, this.sourceType);
  1568. // if(!this.isReturnGoodsCreate) {
  1569. // console.log('isReturnGoodsCreate', this.isReturnGoodsCreate)
  1570. // item.totalCount = item.notGenerateSendCount || item.totalCount;
  1571. // // item.saleCount = item.notGenerateSendCount || item.saleCount;
  1572. // let total = item.totalCount || 0;
  1573. // let _endIndex = 0; //计算单重需要
  1574. // if (item.packageDispositionList) {
  1575. // let endIndex = item.packageDispositionList.findIndex(
  1576. // (ite) => item.saleUnitId == ite.id
  1577. // );
  1578. // _endIndex = endIndex;
  1579. // let packageData = item.packageDispositionList.find(
  1580. // (ite) => item.saleUnitId== ite.id
  1581. // );
  1582. // item.saleUnitId = packageData?.conversionUnit;
  1583. // if (item.weightUnit == item.measuringUnit && item.singleWeight) {
  1584. // item.packageDispositionList[1].packageCell = item.singleWeight;
  1585. // }
  1586. // for (; 0 < endIndex; endIndex--) {
  1587. // total = Vue.prototype.$math.format(
  1588. // total / item.packageDispositionList[endIndex].packageCell,
  1589. // 14
  1590. // );
  1591. // }
  1592. // }
  1593. // item.saleCount = total;
  1594. // }
  1595. // this.changeCount(item, index, false);
  1596. if (item.weightUnit == item.measuringUnit) {
  1597. item.sendTotalWeight = item.sendTotalWeight || item.totalCount;
  1598. } else {
  1599. item.sendTotalWeight =
  1600. item.sendTotalWeight || Number(item.totalWeight) || 0;
  1601. }
  1602. if (this.outsourceSendCode) {
  1603. item.increaseTotalWeight =
  1604. Number(item.receiveTotalWeight) - Number(item.sendTotalWeight);
  1605. item.increaseTotalWeight;
  1606. } else {
  1607. item.increaseTotalWeight =
  1608. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  1609. }
  1610. // item['sendTotalWeight'] = item.sendTotalWeigh;
  1611. // item['increaseTotalWeight'] = item.increaseTotalWeight;
  1612. item['tempId'] = this.form.datasource.length;
  1613. indexS.push(this.form.datasource.length);
  1614. this.$set(
  1615. this.form.datasource,
  1616. this.form.datasource.length,
  1617. copyObj(item)
  1618. );
  1619. // this.form.datasource.push(item);
  1620. });
  1621. this.form.datasource.forEach(async (item, index) => {
  1622. if (indexS.includes(index)) {
  1623. if (!item.batchNo) {
  1624. console.log('111~~~~', index);
  1625. this.$set(
  1626. this.form.datasource[index],
  1627. 'warehouseList',
  1628. await getIdWarehouseList({
  1629. categoryId: item.productId
  1630. })
  1631. );
  1632. if (item.warehouseId) {
  1633. await this.refreshWarehouseOutStock(
  1634. index,
  1635. this.form.datasource[index]
  1636. );
  1637. } else if (this.form.datasource[index]?.warehouseList?.length) {
  1638. this.$set(
  1639. this.form.datasource[index],
  1640. 'warehouseId',
  1641. this.form.datasource[index]?.warehouseList[0].warehouseId
  1642. );
  1643. await this.warehouseChange(index, this.form.datasource[index]);
  1644. }
  1645. const templist = await getBatchList({
  1646. categoryCode: item.productCode,
  1647. warehouseId: item.warehouseId,
  1648. colorKey: item.colorKey,
  1649. modelType: item.modelType,
  1650. size: -1
  1651. });
  1652. // console.log('templist~~~~', index, templist.list);
  1653. // 批次号
  1654. this.$set(
  1655. this.form.datasource[index],
  1656. 'batchNoList',
  1657. this.dedupeBatchNoList(templist?.list)
  1658. );
  1659. // console.log(this.form.datasource[index]);
  1660. } else {
  1661. this.setBatchAndWarehouse(item, index);
  1662. }
  1663. }
  1664. });
  1665. },
  1666. async setBatchAndWarehouse(item, index) {
  1667. console.log('333~~~~', index);
  1668. // 通过产品编码查仓库
  1669. const tempWarehouse = await getIdWarehouseList({
  1670. categoryId: item.productId
  1671. });
  1672. // 有仓库列表
  1673. if (tempWarehouse?.length) {
  1674. console.log('666~~~~', index, tempWarehouse);
  1675. this.$set(
  1676. this.form.datasource[index],
  1677. 'warehouseList',
  1678. tempWarehouse
  1679. );
  1680. if (!item.warehouseId) {
  1681. if (this.form.datasource[index]?.warehouseList?.length) {
  1682. this.$set(
  1683. this.form.datasource[index],
  1684. 'warehouseId',
  1685. this.form.datasource[index]?.warehouseList[0].warehouseId
  1686. );
  1687. await this.warehouseChange(index, this.form.datasource[index]);
  1688. }
  1689. }
  1690. const templist1 = await getBatchList({
  1691. categoryCode: item.productCode,
  1692. warehouseId: item.warehouseId,
  1693. colorKey: item.colorKey,
  1694. modelType: item.modelType,
  1695. size: -1
  1696. });
  1697. let tempBatchNoList = this.dedupeBatchNoList(templist1?.list);
  1698. console.log('888~~~~', index, item.batchNo);
  1699. // 优先按批次明细ID匹配,无ID时按系统批次和业务批次兼容匹配
  1700. const batchNoObj = tempBatchNoList.find(
  1701. (i) =>
  1702. (item.batchStockId && i.id == item.batchStockId) ||
  1703. (!item.batchStockId &&
  1704. i.batchNo == item.batchNo &&
  1705. (!item.systemBatchNo || i.systemBatchNo == item.systemBatchNo))
  1706. );
  1707. if (batchNoObj) {
  1708. this.$set(
  1709. this.form.datasource[index],
  1710. 'batchStockId',
  1711. batchNoObj.id
  1712. );
  1713. this.$set(
  1714. this.form.datasource[index],
  1715. 'systemBatchNo',
  1716. batchNoObj.systemBatchNo || ''
  1717. );
  1718. await this.refreshWarehouseOutStock(
  1719. index,
  1720. this.form.datasource[index]
  1721. );
  1722. } else {
  1723. //不存在
  1724. // 批次列表添加不存在的批次号对象
  1725. tempBatchNoList.push({
  1726. batchNo: item.batchNo,
  1727. id: 999,
  1728. measureQuantity: 0
  1729. });
  1730. tempBatchNoList = this.dedupeBatchNoList(tempBatchNoList);
  1731. // 设置为不存在的批次ID
  1732. this.$set(this.form.datasource[index], 'batchStockId', 999);
  1733. this.$set(this.form.datasource[index], 'warehouseNum', '');
  1734. this.$set(this.form.datasource[index], 'stockCountBase', '');
  1735. this.$set(this.form.datasource[index], 'availableCountBase', '');
  1736. this.$set(this.form.datasource[index], 'warehouseId', '');
  1737. }
  1738. // // 批次号
  1739. this.$set(
  1740. this.form.datasource[index],
  1741. 'batchNoList',
  1742. this.dedupeBatchNoList(tempBatchNoList)
  1743. );
  1744. } else {
  1745. if (item.batchNo) {
  1746. const tempBatchNoList = [
  1747. {
  1748. batchNo: item.batchNo,
  1749. id: 999,
  1750. measureQuantity: 0
  1751. }
  1752. ];
  1753. this.$set(
  1754. this.form.datasource[index],
  1755. 'batchNoList',
  1756. tempBatchNoList
  1757. );
  1758. this.$set(this.form.datasource[index], 'batchStockId', 999);
  1759. this.$set(this.form.datasource[index], 'warehouseNum', '');
  1760. this.$set(this.form.datasource[index], 'stockCountBase', '');
  1761. this.$set(this.form.datasource[index], 'availableCountBase', '');
  1762. }
  1763. }
  1764. },
  1765. remove(i) {
  1766. this.form.datasource.splice(i, 1);
  1767. this.setSort();
  1768. },
  1769. // 批量删除选中的物品
  1770. batchRemove() {
  1771. if (!this.selection.length) {
  1772. return this.$message.warning('请先勾选要删除的数据');
  1773. }
  1774. this.$confirm(
  1775. `确定要删除选中的 ${this.selection.length} 条物品吗?`,
  1776. '提示',
  1777. { type: 'warning' }
  1778. )
  1779. .then(() => {
  1780. const rows = this.selection;
  1781. this.form.datasource = this.form.datasource.filter(
  1782. (row) => !rows.includes(row)
  1783. );
  1784. this.selection = [];
  1785. if (this.$refs.table && this.$refs.table.clearSelection) {
  1786. this.$refs.table.clearSelection();
  1787. }
  1788. this.setSort();
  1789. this.$message.success('删除成功');
  1790. })
  1791. .catch(() => {});
  1792. },
  1793. // 重新排序
  1794. setSort() {
  1795. this.form.datasource.forEach((n, index) => {
  1796. n.key = index + 1;
  1797. });
  1798. },
  1799. //选择产品
  1800. handParent() {
  1801. console.log('this.type~~~~111', this.orderId);
  1802. if (!this.orderId && !this.orderIds)
  1803. return this.$message.error('请先选择订单');
  1804. this.$refs.BIZproductListRef.open('', -1);
  1805. },
  1806. // 添加
  1807. handlAdd() {
  1808. console.log('this.type~~~~222', this.orderId);
  1809. if (!this.orderId && !this.orderIds)
  1810. return this.$message.error('请先选择订单');
  1811. this.$refs.productListRef.open(this.oldProductList);
  1812. },
  1813. //库存台账
  1814. selectStockLedgerDialogOpen(row) {
  1815. this.current = row;
  1816. this.$refs.selectStockLedgerDialogRef.open();
  1817. },
  1818. validateForm(callback) {
  1819. //开始表单校验
  1820. this.$refs.form.validate((valid, obj) => {
  1821. // 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
  1822. const groups = this.form.datasource.reduce((result, item) => {
  1823. const key = item.orderProductId
  1824. ? `order:${item.orderProductId}`
  1825. : `product:${item.productCode}|${item.batchNo || ''}|${item.colorKey || ''}|${item.modelType || ''}`;
  1826. const group = result[key] || { totalCount: 0, remainingCount: Number(item.notGenerateSendCount) || 0, productCode: item.productCode };
  1827. group.totalCount += Number(item.totalCount) || 0;
  1828. group.remainingCount = Math.max(group.remainingCount, Number(item.notGenerateSendCount) || 0);
  1829. result[key] = group;
  1830. return result;
  1831. }, {});
  1832. const exceededItems = Object.values(groups).filter(
  1833. (item) => item.totalCount > item.remainingCount
  1834. );
  1835. // 退货单退货不校验数量,实物赔偿无法计算
  1836. if (
  1837. exceededItems.length > 0 &&
  1838. this.sourceType != 3 &&
  1839. this.needProduce != 4
  1840. ) {
  1841. // 提取产品名称,生成详细提示消息
  1842. const productNames = exceededItems
  1843. .map((item) => item.productCode)
  1844. .join('、');
  1845. this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
  1846. callback(false);
  1847. return;
  1848. }
  1849. if (obj) {
  1850. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1851. if (messages.length > 0) {
  1852. this.$message.warning(messages[0].message);
  1853. }
  1854. }
  1855. callback(valid);
  1856. });
  1857. }
  1858. }
  1859. };
  1860. </script>
  1861. <style lang="scss" scoped>
  1862. ::v-deep .el-table .warning-row {
  1863. background: #d9ecff;
  1864. }
  1865. .headbox {
  1866. display: flex;
  1867. justify-content: flex-start;
  1868. align-items: center;
  1869. .amount {
  1870. font-size: 14px;
  1871. font-weight: bold;
  1872. padding-right: 30px;
  1873. }
  1874. }
  1875. .time-form .el-form-item {
  1876. margin-bottom: 0 !important;
  1877. }
  1878. ::v-deep .period {
  1879. display: flex;
  1880. .borderleftnone {
  1881. .el-input--medium .el-input__inner {
  1882. border-top-right-radius: 0;
  1883. border-bottom-right-radius: 0;
  1884. }
  1885. }
  1886. .borderrightnone {
  1887. .el-input--medium .el-input__inner {
  1888. border-top-left-radius: 0;
  1889. border-bottom-left-radius: 0;
  1890. }
  1891. }
  1892. }
  1893. ::v-deep .time-form tbody > tr:hover > td {
  1894. background-color: transparent !important;
  1895. }
  1896. // ::v-deep .time-form .el-table tr {
  1897. // background-color: #ffffff;
  1898. // }
  1899. .pricebox {
  1900. display: flex;
  1901. justify-content: flex-start;
  1902. align-items: center;
  1903. font-weight: bold;
  1904. }
  1905. </style>