inventoryTable.vue 30 KB

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