inventoryTable.vue 34 KB

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