inventoryTable.vue 26 KB

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