inventoryTable.vue 32 KB

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