inventoryTable.vue 51 KB

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