inventoryTable.vue 32 KB

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