inventoryTable.vue 34 KB

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