inventoryTable.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  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. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <div class="headbox">
  15. <el-button
  16. v-if="isShowAdd && needProduce != 4"
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="handlAdd"
  22. >
  23. 新增
  24. </el-button>
  25. <el-button
  26. v-if="isShowAdd && needProduce == 4"
  27. size="small"
  28. type="primary"
  29. icon="el-icon-plus"
  30. class="ele-btn-icon"
  31. @click="handParent()"
  32. >
  33. 新增
  34. </el-button>
  35. </div>
  36. </template>
  37. <template v-slot:technicalDrawings="{ row, $index }">
  38. <el-form-item :prop="'datasource.' + $index + '.technicalDrawings'">
  39. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  40. </el-form-item>
  41. </template>
  42. <template v-slot:remark="{ row, $index }">
  43. <el-form-item :prop="'datasource.' + $index + '.remark'">
  44. <el-input
  45. clearable
  46. v-model="row.remark"
  47. type="textarea"
  48. placeholder="请输入"
  49. />
  50. </el-form-item>
  51. </template>
  52. <template v-slot:stockLedger="scope">
  53. <el-form-item>
  54. <el-popover
  55. @hide="() => (selection = [])"
  56. placement="right"
  57. width="60%"
  58. trigger="hover"
  59. >
  60. <ele-pro-table
  61. :ref="'childrenTable' + scope.$index"
  62. row-key="id"
  63. max-height="300px"
  64. :selection.sync="selection"
  65. :needPage="false"
  66. :columns="childrenColumns"
  67. :datasource="scope.row.sendProductDetail"
  68. cache-key="stockLedgerRoleTable"
  69. class="time-form"
  70. >
  71. <!-- 表头工具栏 -->
  72. <template v-slot:toolbar="childrenScope">
  73. <div class="headbox">
  74. <el-button
  75. size="small"
  76. type="primary"
  77. icon="el-icon-plus"
  78. class="ele-btn-icon"
  79. @click="stockLedgerSelect(scope.row, scope.$index)"
  80. >
  81. 选择
  82. </el-button>
  83. <el-button
  84. size="small"
  85. type="danger"
  86. icon="el-icon-delete"
  87. class="ele-btn-icon"
  88. :disabled="!selection.length"
  89. @click="stockLedgerRemove(scope.$index)"
  90. >
  91. 删除
  92. </el-button>
  93. </div>
  94. </template>
  95. </ele-pro-table>
  96. <el-button type="text" slot="reference">明细</el-button>
  97. </el-popover>
  98. </el-form-item>
  99. </template>
  100. <template v-slot:packagingStrength="scope">
  101. <el-form-item
  102. :prop="'datasource.' + scope.$index + '.packagingStrength'"
  103. >
  104. <DictSelection
  105. dict-name="包装强度"
  106. v-model="scope.row.extField.packagingStrength"
  107. ></DictSelection>
  108. </el-form-item>
  109. </template>
  110. <template v-slot:packagingDensity="scope">
  111. <el-form-item
  112. :prop="'datasource.' + scope.$index + '.packagingDensity'"
  113. >
  114. <DictSelection
  115. dict-name="包装密度"
  116. v-model="scope.row.extField.packagingDensity"
  117. ></DictSelection>
  118. </el-form-item>
  119. </template>
  120. <template v-slot:totalCount="scope">
  121. <el-form-item
  122. :prop="'datasource.' + scope.$index + '.totalCount'"
  123. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  124. >
  125. <el-input
  126. v-model="scope.row.totalCount"
  127. @input="(val) => changeCount1(scope.row, scope.$index)"
  128. ></el-input>
  129. </el-form-item>
  130. </template>
  131. <template v-slot:batchNo="scope">
  132. <el-form-item :prop="'datasource.' + scope.$index + '.batchNo'">
  133. <el-input v-model="scope.row.batchNo" v-no-chinese></el-input>
  134. </el-form-item>
  135. </template>
  136. <template v-slot:blockCount="scope">
  137. <el-form-item
  138. :prop="'datasource.' + scope.$index + '.blockCount'"
  139. :rules="[{ required: true, message: '请输入', trigger: 'blur' }]"
  140. >
  141. <el-input
  142. v-model="scope.row.blockCount"
  143. @input="
  144. (val) => tableHandleKeyUp(scope.row, scope.$index, 'blockCount')
  145. "
  146. ></el-input>
  147. </el-form-item>
  148. </template>
  149. <template v-slot:receiveTotalWeight="scope">
  150. <el-form-item
  151. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  152. >
  153. <el-input-number
  154. :controls="false"
  155. v-model="scope.row.receiveTotalWeight"
  156. @input="changeSendTotalWeight(scope.row, scope.$index)"
  157. style="width: 60%; margin-right: 10px"
  158. >
  159. </el-input-number>
  160. <el-button
  161. size="small"
  162. type="primary"
  163. v-if="entrustedCode"
  164. @click.native="(e) => handleInnerBound(e, scope.row, scope.$index)"
  165. >选择
  166. </el-button>
  167. </el-form-item>
  168. </template>
  169. <template v-slot:sendTotalWeight="scope">
  170. <el-form-item :prop="'datasource.' + scope.$index + '.sendTotalWeight'">
  171. <el-input-number
  172. :controls="false"
  173. v-model="scope.row.sendTotalWeight"
  174. style="width: 100%"
  175. @input="changeSendTotalWeight(scope.row, scope.$index)"
  176. >
  177. </el-input-number>
  178. </el-form-item>
  179. </template>
  180. <template v-slot:increaseTotalWeight="scope">
  181. <el-form-item
  182. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  183. >
  184. <el-input-number
  185. :controls="false"
  186. v-model="scope.row.increaseTotalWeight"
  187. style="width: 100%"
  188. >
  189. </el-input-number>
  190. </el-form-item>
  191. </template>
  192. <template v-slot:warehouseId="scope">
  193. <el-form-item
  194. :prop="'datasource.' + scope.$index + '.warehouseId'"
  195. :rules="[{ required: true, message: '请选择仓库', trigger: 'blur' }]"
  196. >
  197. <el-select
  198. v-model="scope.row.warehouseId"
  199. placeholder="请选择"
  200. @change="warehouseChange(scope.$index, scope.row)"
  201. >
  202. <el-option
  203. v-for="item in scope.row.warehouseList"
  204. :key="item.warehouseId"
  205. :label="item.warehouseName"
  206. :value="item.warehouseId"
  207. >
  208. </el-option>
  209. </el-select>
  210. </el-form-item>
  211. </template>
  212. <template v-slot:singlePrice="scope">
  213. <el-form-item
  214. style="margin-bottom: 20px"
  215. :prop="'datasource.' + scope.$index + '.singlePrice'"
  216. :rules="{
  217. required: true,
  218. message: '请输入正确的单价',
  219. trigger: 'change'
  220. }"
  221. >
  222. <el-input
  223. v-model="scope.row.singlePrice"
  224. placeholder="请输入"
  225. @input="changeCount"
  226. type="number"
  227. >
  228. <template slot="append">元</template>
  229. </el-input>
  230. </el-form-item>
  231. </template>
  232. <template v-slot:notaxSinglePrice="scope">
  233. <el-form-item
  234. style="margin-bottom: 20px"
  235. :prop="'datasource.' + scope.$index + '.notaxSinglePrice'"
  236. >
  237. <el-input
  238. v-model="scope.row.notaxSinglePrice"
  239. placeholder="请输入"
  240. type="number"
  241. >
  242. <template slot="append">元</template>
  243. </el-input>
  244. </el-form-item>
  245. </template>
  246. <template v-slot:singleWeight="scope" v-if="needProduce == 4">
  247. <el-form-item
  248. style="margin-bottom: 20px"
  249. :rules="{
  250. required: false,
  251. pattern: numberReg,
  252. trigger: 'change'
  253. }"
  254. :prop="'datasource.' + scope.$index + '.singleWeight'"
  255. >
  256. <el-input
  257. v-model="scope.row.singleWeight"
  258. placeholder="请输入"
  259. ></el-input>
  260. </el-form-item>
  261. </template>
  262. <template v-slot:headerWarehouseNum="{ column }">
  263. <span class="is-required">{{ column.label }}</span>
  264. </template>
  265. <template v-slot:headerWarehouseId="{ column }">
  266. <span class="is-required">{{ column.label }}</span>
  267. </template>
  268. <template v-slot:headerTotalCount="{ column }">
  269. <span class="is-required">{{ column.label }}</span>
  270. </template>
  271. <template v-slot:headerReceiveTotalWeight="{ column }">
  272. <span :class="{ 'is-required': entrustedCode && pricingWay == 2 }">{{
  273. column.label
  274. }}</span>
  275. </template>
  276. <!-- 操作列 -->
  277. <template v-slot:action="scope">
  278. <el-popconfirm
  279. class="ele-action"
  280. title="确定要删除吗?"
  281. @confirm="remove(scope.$index)"
  282. >
  283. <template v-slot:reference>
  284. <el-link type="danger" :underline="false" icon="el-icon-delete">
  285. 删除
  286. </el-link>
  287. </template>
  288. </el-popconfirm>
  289. <el-link
  290. type="primary"
  291. :underline="false"
  292. icon="el-icon-edit"
  293. @click="selectStockLedgerDialogOpen(scope.row)"
  294. >
  295. 替代料
  296. </el-link>
  297. </template>
  298. </ele-pro-table>
  299. <product-list
  300. ref="productListRef"
  301. :orderId="orderId"
  302. @changeParent="changeParent"
  303. ></product-list>
  304. <!--入库详情-->
  305. <innertboundDetailsDialog
  306. v-if="innerboundDetailsDialogFlag"
  307. ref="innerboundDetailsDialogRef"
  308. :innerboundDetailsDialogFlag.sync="innerboundDetailsDialogFlag"
  309. @saveDate="saveInnerDate"
  310. ></innertboundDetailsDialog>
  311. <!-- 库存台账 -->
  312. <stock-ledger-dialog
  313. v-if="stockLedgerDialogFlag"
  314. :stock-ledger-dialog-flag.sync="stockLedgerDialogFlag"
  315. ref="stockLedgerDialogRef"
  316. @getStockLedger="getStockLedger"
  317. ></stock-ledger-dialog>
  318. <selectStockLedgerDialog
  319. ref="selectStockLedgerDialogRef"
  320. @changeParent="replaceTable"
  321. ></selectStockLedgerDialog>
  322. <BIZproductList
  323. ref="BIZproductListRef"
  324. classType="1"
  325. :isGetInventoryTotal="true"
  326. @changeParent="changeParentBiz"
  327. :typeIds="typeIds"
  328. :isFirstRefreshTable="true"
  329. ></BIZproductList>
  330. </el-form>
  331. </template>
  332. <script>
  333. import { numberReg } from 'ele-admin';
  334. import dictMixins from '@/mixins/dictMixins';
  335. import productList from './product-list.vue';
  336. import {
  337. getWarehouseList,
  338. getWarehouseOutStock,
  339. getIdWarehouseList
  340. } from '@/api/saleManage/saleorder';
  341. import { copyObj } from '@/utils/util';
  342. import { getFile } from '@/api/system/file';
  343. import innertboundDetailsDialog from '@/BIZComponents/innerboundDetailsDialog.vue';
  344. import stockLedgerDialog from './stockLedger/stockLedgerDialog.vue';
  345. import { fieldModelAPI } from '@/api/main';
  346. import getDynamicsColumns from '@/mixins/getDynamicsColumns';
  347. import fileMain from '@/components/addDoc/index.vue';
  348. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  349. import BIZproductList from '@/BIZComponents/product-list.vue';
  350. import { lbjtList } from '@/enum/dict.js';
  351. import { parameterGetByCode } from '@/api/main/index.js';
  352. import tabMixins from '@/mixins/tableColumnsMixin';
  353. export default {
  354. mixins: [dictMixins, getDynamicsColumns,tabMixins],
  355. props: {
  356. orderId: String,
  357. needProduce: [String, Number],
  358. entrustedCode: String,
  359. pricingWay: [String, Number],
  360. isShowAdd: {
  361. type: Boolean,
  362. default: true
  363. },
  364. typeIds: {
  365. type: Array,
  366. default: () => []
  367. }
  368. },
  369. components: {
  370. fileMain,
  371. innertboundDetailsDialog,
  372. productList,
  373. stockLedgerDialog,
  374. selectStockLedgerDialog,
  375. BIZproductList
  376. },
  377. data() {
  378. const defaultForm = {
  379. key: null,
  380. endTime: '',
  381. isFirst: 0,
  382. name: '',
  383. startTime: '',
  384. workHour: '',
  385. technicalDrawings: []
  386. // warehouseCode:"",
  387. // warehouseId:'',
  388. // warehouseName:'',
  389. };
  390. return {
  391. cacheKeyUrl: 'eos-saleManage-invoice-inventoryTable',
  392. current: {},
  393. childrenColumns: [
  394. {
  395. width: 45,
  396. type: 'selection',
  397. columnKey: 'selection',
  398. align: 'center'
  399. },
  400. {
  401. width: 45,
  402. type: 'index',
  403. columnKey: 'index',
  404. align: 'center',
  405. fixed: 'left'
  406. },
  407. {
  408. minWidth: 100,
  409. prop: 'code',
  410. label: '编码',
  411. align: 'center'
  412. },
  413. {
  414. minWidth: 140,
  415. prop: 'barcodes',
  416. label: '发货条码',
  417. align: 'center'
  418. },
  419. {
  420. minWidth: 100,
  421. prop: 'engrave',
  422. label: '刻码',
  423. align: 'center'
  424. }
  425. ],
  426. selection: [],
  427. discountTotalPrice: 0.0,
  428. allPrice: 0.0,
  429. curIndex: null,
  430. innerboundDetailsDialogFlag: false,
  431. stockLedgerDialogFlag: false,
  432. numberReg,
  433. defaultForm,
  434. warehouseList: [],
  435. dynamicsColumns: [],
  436. form: {
  437. datasource: []
  438. },
  439. rules: {},
  440. isTotalCount: 0
  441. };
  442. },
  443. created() {
  444. this.requestDict('产地');
  445. this.requestDict('生产类型');
  446. //销售发货数量是否限制不能大于采购总数//0否 1是
  447. parameterGetByCode({
  448. code: 'saleOrder_invoice_productList_totalCount'
  449. }).then((res) => {
  450. this.isTotalCount = res.value;
  451. });
  452. },
  453. computed: {
  454. canHandl() {
  455. return this.form.datasource.length;
  456. },
  457. contractId() {
  458. return this.$store.state.order.contractId;
  459. },
  460. clientEnvironmentId() {
  461. return this.$store.state.user.info.clientEnvironmentId;
  462. },
  463. columns() {
  464. return [
  465. {
  466. width: 45,
  467. type: 'index',
  468. columnKey: 'index',
  469. align: 'center',
  470. fixed: 'left'
  471. },
  472. {
  473. width: 200,
  474. prop: 'productName',
  475. label: '名称',
  476. slot: 'productName',
  477. align: 'center'
  478. },
  479. {
  480. width: 120,
  481. prop: 'productCode',
  482. label: '编码',
  483. slot: 'productCode',
  484. align: 'center'
  485. },
  486. {
  487. width: 200,
  488. prop: 'productCategoryName',
  489. label: '类型',
  490. slot: 'productCategoryName',
  491. align: 'center'
  492. },
  493. {
  494. width: 160,
  495. prop: 'batchNo',
  496. label: '批次号',
  497. slot: 'batchNo',
  498. align: 'center'
  499. },
  500. {
  501. width: 160,
  502. prop: 'productBrand',
  503. label: '牌号',
  504. slot: 'productBrand',
  505. align: 'center'
  506. },
  507. {
  508. width: 120,
  509. prop: 'modelType',
  510. label: '型号',
  511. slot: 'modelType',
  512. align: 'center'
  513. },
  514. {
  515. width: 120,
  516. prop: 'specification',
  517. label: '规格',
  518. slot: 'specification',
  519. align: 'center'
  520. },
  521. {
  522. width: 120,
  523. prop: 'imgCode',
  524. align: 'center',
  525. label: '图号/件号',
  526. showOverflowTooltip: true
  527. },
  528. {
  529. width: 120,
  530. prop: 'produceType',
  531. align: 'center',
  532. label: '属性类型',
  533. formatter: (row, column) => {
  534. if (row.produceType) {
  535. return row.produceType
  536. .map((item) => {
  537. return lbjtList[item];
  538. })
  539. .toString();
  540. }
  541. },
  542. showOverflowTooltip: true
  543. },
  544. ...this.dynamicsColumns,
  545. {
  546. width: 120,
  547. prop: 'customerMark',
  548. label: '客户代号',
  549. slot: 'customerMark',
  550. align: 'center'
  551. },
  552. {
  553. width: 200,
  554. prop: 'warehouseId',
  555. label: '仓库名称',
  556. slot: 'warehouseId',
  557. headerSlot: 'headerWarehouseId',
  558. align: 'center'
  559. },
  560. {
  561. width: 100,
  562. prop: 'warehouseNum',
  563. label: '库存',
  564. align: 'center',
  565. slot: 'warehouseNum'
  566. },
  567. // {
  568. // width: 100,
  569. // prop: 'stockLedger',
  570. // label: '发货明细',
  571. // slot: 'stockLedger',
  572. // align: 'center'
  573. // },
  574. {
  575. width: 120,
  576. prop: 'totalCount',
  577. label: '发货数量',
  578. slot: 'totalCount',
  579. headerSlot: 'headerTotalCount',
  580. align: 'center'
  581. },
  582. {
  583. width: 120,
  584. prop: 'orderTotalCount',
  585. label: '订单数量',
  586. slot: 'orderTotalCount',
  587. align: 'center'
  588. },
  589. {
  590. width: 80,
  591. prop: 'measuringUnit',
  592. label: '计量单位',
  593. slot: 'measuringUnit',
  594. align: 'center'
  595. },
  596. {
  597. width: 120,
  598. prop: 'blockCount',
  599. label: '发货块数',
  600. slot: 'blockCount',
  601. align: 'center',
  602. show: this.clientEnvironmentId == '4'
  603. },
  604. {
  605. width: 120,
  606. prop: 'singleWeight',
  607. label: '单重',
  608. slot: 'singleWeight',
  609. align: 'center'
  610. },
  611. {
  612. width: 200,
  613. prop: 'receiveTotalWeight',
  614. label: '收货总重',
  615. slot: 'receiveTotalWeight',
  616. align: 'center',
  617. headerSlot: 'headerReceiveTotalWeight'
  618. },
  619. {
  620. width: 100,
  621. prop: 'sendTotalWeight',
  622. label: '发货总重',
  623. slot: 'sendTotalWeight',
  624. align: 'center'
  625. },
  626. {
  627. width: 100,
  628. prop: 'increaseTotalWeight',
  629. label: '增重重量',
  630. slot: 'increaseTotalWeight',
  631. align: 'center'
  632. },
  633. {
  634. width: 100,
  635. prop: 'weightUnit',
  636. label: '重量单位',
  637. slot: 'weightUnit',
  638. align: 'center'
  639. },
  640. // {
  641. // width: 160,
  642. // prop: 'pricingWay',
  643. // label: '计价方式',
  644. // slot: 'pricingWay',
  645. // align: 'center',
  646. // formatter: (row, column) => {
  647. // return row.pricingWay == 1
  648. // ? '按数量计费'
  649. // : row.pricingWay == 2
  650. // ? '按重量计费'
  651. // : '';
  652. // }
  653. // },
  654. // {
  655. // width: 180,
  656. // prop: 'singlePrice',
  657. // label: '单价',
  658. // slot: 'singlePrice',
  659. // align: 'center'
  660. // },
  661. // {
  662. // width: 160,
  663. // prop: 'taxRate',
  664. // label: '税率',
  665. // formatter: (_row, _column, cellValue) => {
  666. // return _row.taxRate ? _row.taxRate + '%' : '';
  667. // },
  668. // align: 'center'
  669. // },
  670. // {
  671. // width: 180,
  672. // prop: 'notaxSinglePrice',
  673. // label: '不含税单价',
  674. // slot: 'notaxSinglePrice',
  675. // align: 'center'
  676. // },
  677. // {
  678. // width: 160,
  679. // prop: 'discountSinglePrice',
  680. // label: '折后单价',
  681. // slot: 'discountSinglePrice',
  682. // align: 'center'
  683. // },
  684. // {
  685. // width: 120,
  686. // prop: 'totalPrice',
  687. // label: '合计',
  688. // slot: 'totalPrice',
  689. // align: 'center'
  690. // },
  691. // {
  692. // width: 160,
  693. // prop: 'notaxTotalPrice',
  694. // label: '含税合计',
  695. // align: 'center'
  696. // },
  697. // {
  698. // width: 120,
  699. // prop: 'discountTotalPrice',
  700. // label: '折后合计',
  701. // slot: 'discountTotalPrice',
  702. // align: 'center'
  703. // },
  704. {
  705. width: 80,
  706. prop: 'deliveryDays',
  707. label: '交期(天)',
  708. slot: 'deliveryDays',
  709. align: 'center'
  710. },
  711. {
  712. width: 200,
  713. prop: 'guaranteePeriod',
  714. label: '质保期',
  715. slot: 'guaranteePeriod',
  716. formatter: (_row, _column, cellValue) => {
  717. let val = '';
  718. if (_row.guaranteePeriod) {
  719. val += _row.guaranteePeriod;
  720. }
  721. if (_row.guaranteePeriodUnitName) {
  722. val += _row.guaranteePeriodUnitName;
  723. }
  724. return val;
  725. },
  726. align: 'center'
  727. },
  728. {
  729. prop: 'provenance',
  730. label: '产地',
  731. slot: 'provenance',
  732. align: 'center',
  733. // show:this.contractBookType==2,
  734. minWidth: 200,
  735. showOverflowTooltip: true,
  736. formatter: (row, column) => {
  737. return row.provenance && row.provenance.length
  738. ? row.provenance
  739. .map((item) => this.getDictValue('产地', item))
  740. .join(',')
  741. : '';
  742. }
  743. },
  744. {
  745. width: 130,
  746. prop: 'technicalAnswerName',
  747. label: '技术答疑人',
  748. slot: 'technicalAnswerName',
  749. align: 'center'
  750. },
  751. {
  752. width: 220,
  753. prop: 'technicalParams',
  754. label: '技术参数',
  755. slot: 'technicalParams',
  756. align: 'center'
  757. },
  758. {
  759. width: 240,
  760. prop: 'technicalDrawings',
  761. label: '技术图纸',
  762. slot: 'technicalDrawings',
  763. align: 'center'
  764. },
  765. {
  766. width: 220,
  767. prop: 'remark',
  768. label: '备注',
  769. slot: 'remark',
  770. align: 'center'
  771. },
  772. {
  773. columnKey: 'action',
  774. label: '操作',
  775. width: 180,
  776. align: 'center',
  777. resizable: false,
  778. slot: 'action',
  779. fixed: 'right',
  780. showOverflowTooltip: true
  781. }
  782. ];
  783. }
  784. },
  785. methods: {
  786. downloadFile(file) {
  787. getFile({ objectName: file.storePath }, file.name);
  788. },
  789. //发货明细选择
  790. stockLedgerSelect(row, index) {
  791. this.curIndex = index;
  792. this.stockLedgerDialogFlag = true;
  793. this.$nextTick(() => {
  794. this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
  795. });
  796. },
  797. changeCount1(row, index) {
  798. this.tableHandleKeyUp(row, index, 'sum');
  799. this.changeCount();
  800. },
  801. //改变数量
  802. changeCount() {
  803. this.form.datasource.forEach((item, index) => {
  804. if (item.pricingWay == 1) {
  805. this.$set(
  806. this.form.datasource[index],
  807. 'discountTotalPrice',
  808. item.discountSinglePrice * item.totalCount
  809. );
  810. this.$set(
  811. this.form.datasource[index],
  812. 'totalPrice',
  813. item.singlePrice * item.totalCount
  814. );
  815. }
  816. if (item.pricingWay == 2) {
  817. this.$set(
  818. this.form.datasource[index],
  819. 'discountTotalPrice',
  820. item.discountSinglePrice *
  821. item.totalCount *
  822. (item.singleWeight || 0)
  823. );
  824. this.$set(
  825. this.form.datasource[index],
  826. 'totalPrice',
  827. item.singlePrice * item.totalCount * (item.singleWeight || 0)
  828. );
  829. }
  830. });
  831. },
  832. //获取
  833. getStockLedger(sendProductDetail) {
  834. if (!this.form.datasource[this.curIndex].sendProductDetail)
  835. this.form.datasource[this.curIndex].sendProductDetail = [];
  836. let row = this.form.datasource[this.curIndex];
  837. row.sendProductDetail.push(...sendProductDetail);
  838. this.form.datasource[this.curIndex] = row;
  839. this.$refs['childrenTable' + this.curIndex].reload();
  840. this.$refs.table.reload();
  841. },
  842. //删除发货明细
  843. stockLedgerRemove(PIndex) {
  844. let row = this.form.datasource[PIndex];
  845. this.selection.forEach((item) => {
  846. let index = row.sendProductDetail.findIndex((i) => i.id == item.id);
  847. row.sendProductDetail.splice(index, 1);
  848. });
  849. this.form.datasource[PIndex] = row;
  850. this.$refs['childrenTable' + PIndex].reload();
  851. this.$refs.table.reload();
  852. this.selection = [];
  853. },
  854. async warehouseChange(index, row) {
  855. const data = row.warehouseList.find(
  856. (item) => item.warehouseId == row.warehouseId
  857. );
  858. this.$set(
  859. this.form.datasource[index],
  860. 'warehouseName',
  861. data.warehouseName
  862. );
  863. this.$set(
  864. this.form.datasource[index],
  865. 'warehouseCode',
  866. data.warehouseCode
  867. );
  868. const warehouseOutStock = await getWarehouseOutStock({
  869. warehouseId: data.warehouseId,
  870. code: row.productCode
  871. });
  872. this.$set(
  873. this.form.datasource[index],
  874. 'warehouseNum',
  875. warehouseOutStock || 0
  876. );
  877. },
  878. //修改发货总重
  879. changeSendTotalWeight(row, index) {
  880. this.curIndex = index;
  881. this.setIcreaseTotalWeight(row);
  882. },
  883. //入库单详情
  884. handleInnerBound(e, rows, index) {
  885. this.curIndex = index;
  886. this.innerboundDetailsDialogFlag = true;
  887. this.$nextTick(() => {
  888. let row = {
  889. code: this.entrustedCode
  890. };
  891. this.$refs.innerboundDetailsDialogRef.init(row);
  892. });
  893. },
  894. //选择入库单信息
  895. saveInnerDate(data = []) {
  896. let totalWeight = data.reduce((num, row) => {
  897. num += Number(row.weight);
  898. return num;
  899. }, 0);
  900. this.$set(
  901. this.form.datasource[this.curIndex],
  902. 'receiveTotalWeight',
  903. totalWeight
  904. );
  905. console.log(totalWeight, 'totalWeight');
  906. this.setIcreaseTotalWeight(this.form.datasource[this.curIndex]);
  907. },
  908. getWeightPrice() {
  909. let increaseTotalWeight =
  910. this.form.datasource[this.curIndex].increaseTotalWeight;
  911. let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  912. let discountSinglePrice =
  913. this.form.datasource[this.curIndex].discountSinglePrice;
  914. this.$set(
  915. this.form.datasource[this.curIndex],
  916. 'totalPrice',
  917. (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  918. );
  919. this.$set(
  920. this.form.datasource[this.curIndex],
  921. 'discountTotalPrice',
  922. (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  923. );
  924. },
  925. //设置增重总重
  926. setIcreaseTotalWeight(row) {
  927. let receiveTotalWeight = Number(
  928. this.form.datasource[this.curIndex]?.receiveTotalWeight
  929. );
  930. let sendTotalWeight = Number(
  931. this.form.datasource[this.curIndex]?.sendTotalWeight
  932. );
  933. this.$set(
  934. this.form.datasource[this.curIndex],
  935. 'increaseTotalWeight',
  936. (sendTotalWeight - receiveTotalWeight).toFixed(2)
  937. );
  938. if (row.pricingWay == 2) {
  939. this.getWeightPrice();
  940. }
  941. this.$refs.table.reload();
  942. this.$forceUpdate();
  943. },
  944. // 表格:模数、数量(方)、块数输入框 输入事件
  945. tableHandleKeyUp(row, index, name) {
  946. if (row.specification) {
  947. let modelArr = row.specification.split('*');
  948. let modelLong = modelArr[0]; // model规格长度
  949. let modeWide = modelArr[1]; // model规格宽度
  950. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  951. modeHight = Number(modeHight);
  952. if (name === 'sum') {
  953. row.blockCount = Math.floor(
  954. row.totalCount / ((modelLong * modeWide * modeHight) / 1000000)
  955. );
  956. } else if (name === 'blockCount') {
  957. row.totalCount =
  958. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  959. 1000000;
  960. this.changeCount();
  961. }
  962. }
  963. },
  964. //选择产品回调
  965. async changeParent(obj, idx) {
  966. obj.orderTotalCount = obj.totalCount;
  967. obj.id = '';
  968. obj['tempId'] = idx;
  969. this.$set(
  970. this.form.datasource,
  971. this.form.datasource.length,
  972. copyObj(obj)
  973. );
  974. },
  975. //选择产品回调
  976. changeParentBiz(obj = [], idx) {
  977. obj.forEach(async (item, index) => {
  978. let i = idx == -1 ? index : idx;
  979. let row = JSON.parse(JSON.stringify(this.defaultForm));
  980. row.key = this.form.datasource.length + 1;
  981. let parasm = idx == -1 ? row : this.form.datasource[i];
  982. this.$set(parasm, 'productId', item.id);
  983. this.$set(parasm, 'categoryName', item.name);
  984. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  985. this.$set(parasm, 'productBrand', item.brandNum);
  986. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  987. this.$set(parasm, 'productCode', item.code);
  988. this.$set(parasm, 'productName', item.name);
  989. this.$set(parasm, 'modelType', item.modelType);
  990. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  991. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  992. this.$set(parasm, 'specification', item.specification);
  993. this.$set(parasm, 'weightUnit', item.weightUnit);
  994. this.$set(parasm, 'imgCode', item.imgCode);
  995. this.$set(parasm, 'produceType', item.componentAttribute);
  996. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  997. this.$set(parasm, 'extField', item.extField || {});
  998. this.$set(parasm, 'singleWeight', item.netWeight);
  999. this.$set(parasm, 'pricingWay', item.pricingWay || 1);
  1000. this.$set(parasm, 'singlePrice', 0);
  1001. this.$set(parasm, 'discountSinglePrice', 0);
  1002. this.$set(parasm, 'receiveTotalWeight', 0);
  1003. this.$set(parasm, 'sendTotalWeight', 0);
  1004. this.$set(parasm, 'increaseTotalWeight', 0);
  1005. this.$set(
  1006. parasm,
  1007. 'warehouseList',
  1008. await getIdWarehouseList({
  1009. categoryId: item.id
  1010. })
  1011. );
  1012. this.$set(
  1013. parasm,
  1014. 'packingSpecification',
  1015. item.extField?.packingSpecification
  1016. );
  1017. this.$set(
  1018. parasm,
  1019. 'supplierMark',
  1020. this.form.datasource[0]?.supplierMark
  1021. );
  1022. if (item.purchaseOrigins?.length > 0) {
  1023. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1024. }
  1025. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1026. if (idx == -1) {
  1027. this.form.datasource.push(row);
  1028. }
  1029. });
  1030. },
  1031. replaceTable(list) {
  1032. list.forEach((item) => {
  1033. item['relationId'] = this.current.tempId;
  1034. });
  1035. this.$emit('replaceTableChange', list);
  1036. },
  1037. // validateTotalCount(row) {
  1038. // return (rule, value, callback) => {
  1039. // if (isNaN(value) || Number(value) <= 0) {
  1040. // this.$message.error('请输入大于0的数');
  1041. // callback(false);
  1042. // } else else {
  1043. // callback();
  1044. // }
  1045. // };
  1046. // },
  1047. // 返回列表数据
  1048. getTableValue() {
  1049. let comitDatasource = this.form.datasource;
  1050. if (comitDatasource.length === 0) return [];
  1051. comitDatasource.forEach(async (v) => {
  1052. v.totalCount = Number(v.totalCount);
  1053. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1054. ? v.technicalDrawings
  1055. : [];
  1056. v.customerReqFiles = Array.isArray(v.customerReqFiles)
  1057. ? v.customerReqFiles
  1058. : [];
  1059. v.industryArtFiles = v.industryArtFiles || [];
  1060. v.otherFiles = v.otherFiles || [];
  1061. });
  1062. return comitDatasource;
  1063. },
  1064. getPrice() {
  1065. return [this.allPrice];
  1066. },
  1067. //修改回显
  1068. putTableValue(data) {
  1069. if (data) {
  1070. this.form.datasource = data;
  1071. data.forEach(async (item, index) => {
  1072. if (item.warehouseId) {
  1073. this.$set(
  1074. this.form.datasource[index],
  1075. 'warehouseNum',
  1076. await getWarehouseOutStock({
  1077. warehouseId: item.warehouseId,
  1078. code: item.productCode
  1079. })
  1080. );
  1081. }
  1082. this.$set(
  1083. this.form.datasource[index],
  1084. 'warehouseList',
  1085. await getIdWarehouseList({
  1086. categoryId: item.productId
  1087. })
  1088. );
  1089. //保存初始收货总重
  1090. this.oldReceiveTotalWeight = this.form.datasource.map((item) => {
  1091. return {
  1092. productCode: item.productCode,
  1093. oldReceiveTotalWeight: item.receiveTotalWeight
  1094. };
  1095. });
  1096. this.form.datasource.forEach((item, index) => {
  1097. this.$set(
  1098. this.form.datasource[index],
  1099. 'receiveTotalWeight',
  1100. item.receiveTotalWeight || 0
  1101. );
  1102. item.sendTotalWeight =
  1103. item.sendTotalWeight ||
  1104. Number(item.totalCount) * Number(item.singleWeight) ||
  1105. 0;
  1106. if (this.outsourceSendCode) {
  1107. item.increaseTotalWeight =
  1108. Number(item.receiveTotalWeight) -
  1109. Number(item.sendTotalWeight);
  1110. } else {
  1111. item.increaseTotalWeight =
  1112. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  1113. }
  1114. });
  1115. this.changeCount();
  1116. });
  1117. }
  1118. },
  1119. remove(i) {
  1120. this.form.datasource.splice(i, 1);
  1121. this.setSort();
  1122. },
  1123. // 清空表格
  1124. restTable() {
  1125. this.form.datasource = [];
  1126. },
  1127. // 重新排序
  1128. setSort() {
  1129. this.form.datasource.forEach((n, index) => {
  1130. n.key = index + 1;
  1131. });
  1132. },
  1133. //选择产品
  1134. handParent() {
  1135. if (!this.orderId) return this.$message.error('请先选择订单');
  1136. this.$refs.BIZproductListRef.open('', -1);
  1137. },
  1138. // 添加
  1139. handlAdd() {
  1140. if (!this.orderId) return this.$message.error('请先选择订单');
  1141. this.$refs.productListRef.open(this.form.datasource);
  1142. },
  1143. //库存台账
  1144. selectStockLedgerDialogOpen(row) {
  1145. this.current = row;
  1146. this.$refs.selectStockLedgerDialogRef.open();
  1147. },
  1148. validateForm(callback) {
  1149. //开始表单校验
  1150. this.$refs.form.validate((valid, obj) => {
  1151. let is = false;
  1152. this.form.datasource.forEach((item) => {
  1153. if (Number(item.totalCount) > item.orderTotalCount) {
  1154. is = true;
  1155. }
  1156. });
  1157. if (is) {
  1158. this.$message.warning('发货数量大于订单总数量');
  1159. if (this.isTotalCount == 1) {
  1160. callback(false);
  1161. }
  1162. }
  1163. if (obj) {
  1164. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1165. if (messages.length > 0) {
  1166. this.$message.warning(messages[0].message);
  1167. }
  1168. }
  1169. callback(valid);
  1170. });
  1171. }
  1172. }
  1173. };
  1174. </script>
  1175. <style lang="scss" scoped>
  1176. .headbox {
  1177. display: flex;
  1178. justify-content: flex-start;
  1179. align-items: center;
  1180. .amount {
  1181. font-size: 14px;
  1182. font-weight: bold;
  1183. padding-right: 30px;
  1184. }
  1185. }
  1186. .time-form .el-form-item {
  1187. margin-bottom: 0 !important;
  1188. }
  1189. ::v-deep .period {
  1190. display: flex;
  1191. .borderleftnone {
  1192. .el-input--medium .el-input__inner {
  1193. border-top-right-radius: 0;
  1194. border-bottom-right-radius: 0;
  1195. }
  1196. }
  1197. .borderrightnone {
  1198. .el-input--medium .el-input__inner {
  1199. border-top-left-radius: 0;
  1200. border-bottom-left-radius: 0;
  1201. }
  1202. }
  1203. }
  1204. ::v-deep .time-form tbody > tr:hover > td {
  1205. background-color: transparent !important;
  1206. }
  1207. ::v-deep .time-form .el-table tr {
  1208. background-color: #ffffff;
  1209. }
  1210. .pricebox {
  1211. display: flex;
  1212. justify-content: flex-start;
  1213. align-items: center;
  1214. font-weight: bold;
  1215. }
  1216. </style>