inventoryTable.vue 34 KB

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