inventoryTable.vue 26 KB

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