inventoryTable.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  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. :rules="{
  317. required: isSupplier?true:false,
  318. trigger: 'change',
  319. message: '请选择供应商',
  320. }"
  321. >
  322. <el-input
  323. clearable
  324. @click.native="(e) => handleGetSup(e, scope.row, scope.$index)"
  325. v-model="scope.row.supplierName"
  326. placeholder="请输入"
  327. ></el-input>
  328. </el-form-item>
  329. </template>
  330. <template v-slot:provenance="scope">
  331. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  332. <DictSelection
  333. dictName="产地"
  334. clearable
  335. v-model="scope.row.provenance"
  336. multiple
  337. >
  338. </DictSelection>
  339. </el-form-item>
  340. </template>
  341. <template v-slot:headerProductName="{ column }">
  342. <span class="is-required">{{ column.label }}</span>
  343. </template>
  344. <template v-slot:headerTotalCount="{ column }">
  345. <span class="is-required">{{ column.label }}</span>
  346. </template>
  347. <template v-slot:headerExpectReceiveDate="{ column }">
  348. <span class="is-required">{{ column.label }}</span>
  349. </template>
  350. <template v-slot:headerArrivalWay="{ column }">
  351. <span class="is-required">{{ column.label }}</span>
  352. </template>
  353. <template v-slot:headerSupplierName="{ column }">
  354. <span :class="{ 'is-required': isSupplier }">{{
  355. column.label
  356. }}</span>
  357. </template>
  358. <template v-slot:headerWarehouseId="{ column }">
  359. <span
  360. :class="{ 'is-required': ['3', '4', '5'].includes(sourceType) }"
  361. >{{ column.label }}</span
  362. >
  363. </template>
  364. <template v-slot:warehouseId="scope">
  365. <el-form-item
  366. style="margin-bottom: 20px"
  367. :prop="'datasource.' + scope.$index + '.warehouseId'"
  368. :rules="[
  369. {
  370. required: ['3', '4', '5'].includes(sourceType) ? true : false,
  371. message: '请选择仓库',
  372. trigger: 'blur'
  373. }
  374. ]"
  375. >
  376. <el-select
  377. v-model="scope.row.warehouseId"
  378. placeholder="请选择"
  379. @change="warehouseChange(scope.$index, scope.row)"
  380. >
  381. <el-option
  382. v-for="item in warehouseList"
  383. :key="item.id"
  384. :label="item.name"
  385. :value="item.id"
  386. >
  387. </el-option>
  388. </el-select>
  389. </el-form-item>
  390. </template>
  391. <!-- 操作列 -->
  392. <template v-slot:action="scope">
  393. <el-popconfirm
  394. class="ele-action"
  395. title="确定要删除吗?"
  396. @confirm="remove(scope.$index)"
  397. >
  398. <template v-slot:reference>
  399. <el-link type="danger" :underline="false" icon="el-icon-delete">
  400. 删除
  401. </el-link>
  402. </template>
  403. </el-popconfirm>
  404. </template>
  405. <template v-slot:goodsLevel="{ row, $index }">
  406. <el-form-item :prop="'datasource.' + $index + '.goodsLevel'">
  407. <el-select v-model="row.goodsLevel" style="width: 100%">
  408. <el-option
  409. :label="item.label"
  410. :value="item.value"
  411. v-for="(item, index) in levelList"
  412. :key="index"
  413. ></el-option>
  414. </el-select>
  415. </el-form-item>
  416. </template>
  417. </ele-pro-table>
  418. <product-list
  419. ref="productListRef"
  420. classType="1"
  421. :is-get-inventory-total="true"
  422. @changeParent="changeParent"
  423. :is-show-c-bom="true"
  424. @getSelectionCbom="getSelectionCbom"
  425. ></product-list>
  426. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  427. <timeDialog @chooseTime="chooseTime" ref="timeDialogRef"></timeDialog>
  428. <supplierList
  429. ref="supplierListRef"
  430. :classType="2"
  431. @changeParent="getSupInfo"
  432. ></supplierList>
  433. <taskinstance-dialog
  434. ref="taskinstanceDialogRef"
  435. v-if="taskinstanceDialogFlag"
  436. @saveTaskInstance="saveTaskInstance"
  437. :visible.sync="taskinstanceDialogFlag"
  438. ></taskinstance-dialog>
  439. </el-form>
  440. </template>
  441. <script>
  442. import { numberReg } from 'ele-admin';
  443. import productList from '@/BIZComponents/product-list.vue';
  444. import dictMixins from '@/mixins/dictMixins';
  445. import fileUpload from '@/components/upload/fileUpload';
  446. import headList from '@/BIZComponents/user-select/user-select.vue';
  447. import timeDialog from '@/components/timeDialog/index.vue';
  448. import { copyObj } from '@/utils/util';
  449. import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  450. import { getInventoryTotalAPI } from '@/api/wms';
  451. // import fileMain from '@/components/addDoc/index.vue';
  452. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  453. import { lbjtList } from '@/enum/dict.js';
  454. import tabMixins from '@/mixins/tableColumnsMixin';
  455. import { getWarehouseList } from '@/api/saleManage/saleorder';
  456. import warehouseAll from '@/BIZComponents/warehouseAll.vue';
  457. import { levelList } from '@/enum/dict.js';
  458. export default {
  459. mixins: [dictMixins, tabMixins],
  460. props: {
  461. isSupplier: {
  462. type: Boolean,
  463. default: false
  464. },
  465. detailType: {
  466. type: Number,
  467. default: 0
  468. },
  469. sourceType: {
  470. default: ''
  471. }
  472. },
  473. components: {
  474. taskinstanceDialog,
  475. // fileMain,
  476. supplierList,
  477. productList,
  478. fileUpload,
  479. headList,
  480. timeDialog,
  481. warehouseAll
  482. },
  483. computed: {
  484. columns() {
  485. return [
  486. {
  487. width: 45,
  488. type: 'index',
  489. columnKey: 'index',
  490. align: 'center'
  491. },
  492. {
  493. label: '选择',
  494. width: 45,
  495. type: 'selection',
  496. columnKey: 'selection',
  497. align: 'center',
  498. fixed: 'left'
  499. },
  500. {
  501. width: 150,
  502. prop: 'productCategoryName',
  503. label: '分类',
  504. slot: 'productCategoryName',
  505. align: 'center'
  506. },
  507. {
  508. width: 140,
  509. prop: 'productCode',
  510. label: '编码',
  511. slot: 'productCode',
  512. align: 'center'
  513. },
  514. {
  515. width: 240,
  516. prop: 'productName',
  517. label: '名称',
  518. slot: 'productName',
  519. headerSlot: 'headerProductName',
  520. align: 'center'
  521. },
  522. {
  523. width: 240,
  524. prop: 'taskName',
  525. label: '工序',
  526. slot: 'taskName',
  527. align: 'center'
  528. },
  529. {
  530. width: 110,
  531. prop: 'batchNo',
  532. label: '批次号',
  533. slot: 'batchNo',
  534. align: 'center'
  535. },
  536. {
  537. prop: 'provenance',
  538. label: '产地',
  539. slot: 'provenance',
  540. align: 'center',
  541. showOverflowTooltip: true,
  542. minWidth: 200
  543. },
  544. {
  545. width: 150,
  546. prop: 'reqTotalCount',
  547. label: '需求数量',
  548. align: 'center'
  549. },
  550. {
  551. width: 90,
  552. prop: 'totalCount',
  553. label: '数量',
  554. slot: 'totalCount',
  555. headerSlot: 'headerTotalCount',
  556. align: 'center'
  557. },
  558. {
  559. minWidth: 120,
  560. prop: 'goodsLevel',
  561. label: '物品级别',
  562. slot: 'goodsLevel',
  563. align: 'center'
  564. },
  565. {
  566. width: 200,
  567. prop: 'warehouseId',
  568. label: '入库仓库',
  569. slot: 'warehouseId',
  570. headerSlot: 'headerWarehouseId',
  571. align: 'center'
  572. },
  573. {
  574. width: 80,
  575. prop: 'availableCountBase',
  576. label: '库存数量',
  577. slot: 'availableCountBase',
  578. align: 'center'
  579. },
  580. // {
  581. // width: 120,
  582. // prop: 'singleWeight',
  583. // label: '单重',
  584. // slot: 'singleWeight',
  585. // align: 'center'
  586. // },
  587. {
  588. width: 120,
  589. prop: 'totalWeight',
  590. label: '重量',
  591. slot: 'totalWeight',
  592. align: 'center'
  593. },
  594. {
  595. width: 160,
  596. prop: 'arrivalWay',
  597. label: '到货方式',
  598. slot: 'arrivalWay',
  599. headerSlot: 'headerArrivalWay',
  600. align: 'center'
  601. },
  602. {
  603. width: 170,
  604. prop: 'expectReceiveDate',
  605. label: '到货日期',
  606. slot: 'expectReceiveDate',
  607. headerSlot: 'headerExpectReceiveDate',
  608. align: 'center'
  609. },
  610. {
  611. width: 130,
  612. prop: 'supplierName',
  613. label: '供应商',
  614. slot: 'supplierName',
  615. // headerSlot: 'headerSupplierName',
  616. align: 'center'
  617. },
  618. {
  619. width: 130,
  620. prop: 'brand',
  621. label: '品牌',
  622. slot: 'brand',
  623. align: 'center'
  624. },
  625. {
  626. width: 160,
  627. prop: 'technicalDrawings',
  628. label: '图纸附件',
  629. slot: 'technicalDrawings'
  630. },
  631. {
  632. width: 160,
  633. prop: 'files',
  634. label: '附件',
  635. slot: 'files'
  636. },
  637. {
  638. width: 150,
  639. prop: 'productBrand',
  640. label: '牌号',
  641. slot: 'productBrand',
  642. align: 'center'
  643. },
  644. {
  645. width: 130,
  646. prop: 'modelType',
  647. label: '型号',
  648. slot: 'modelType',
  649. align: 'center'
  650. },
  651. {
  652. width: 120,
  653. prop: 'specification',
  654. label: '规格',
  655. slot: 'specification',
  656. align: 'center'
  657. },
  658. {
  659. width: 120,
  660. prop: 'imgCode',
  661. align: 'center',
  662. label: '图号/件号',
  663. showOverflowTooltip: true
  664. },
  665. {
  666. width: 120,
  667. prop: 'produceType',
  668. align: 'center',
  669. label: '属性类型',
  670. showOverflowTooltip: true,
  671. formatter: (row, column) => {
  672. if (row.produceType) {
  673. return row.produceType
  674. .map((item) => {
  675. return lbjtList[item];
  676. })
  677. .toString();
  678. }
  679. }
  680. },
  681. {
  682. width: 120,
  683. prop: 'packingSpecification',
  684. align: 'center',
  685. label: '包装规格',
  686. showOverflowTooltip: true
  687. },
  688. {
  689. width: 100,
  690. prop: 'measuringUnit',
  691. label: '单位',
  692. slot: 'measuringUnit',
  693. align: 'center'
  694. },
  695. {
  696. width: 220,
  697. prop: 'remark',
  698. label: '备注',
  699. slot: 'remark',
  700. align: 'center'
  701. },
  702. {
  703. columnKey: 'action',
  704. label: '操作',
  705. width: 120,
  706. align: 'center',
  707. resizable: false,
  708. slot: 'action',
  709. fixed: 'right',
  710. showOverflowTooltip: true
  711. }
  712. ];
  713. }
  714. },
  715. data() {
  716. const defaultForm = {
  717. key: null,
  718. endTime: '',
  719. isFirst: 0,
  720. name: '',
  721. supplierName: '',
  722. weightUnit: ''
  723. };
  724. return {
  725. levelList,
  726. cacheKeyUrl: 'eos-purchasingManage-purchasePlanManage-inventoryTable',
  727. curIndex: null,
  728. numberReg,
  729. defaultForm,
  730. selection: [],
  731. arrivalWayList: [
  732. { label: '一次性到货', value: 1 },
  733. { label: '分批到货', value: 2 }
  734. ],
  735. form: {
  736. datasource: []
  737. },
  738. taskinstanceDialogFlag: false,
  739. rules: {},
  740. dictList: {},
  741. warehouseList: []
  742. };
  743. },
  744. created() {
  745. this.requestDict('生产类型');
  746. getWarehouseList().then((res) => {
  747. this.warehouseList = res;
  748. });
  749. },
  750. methods: {
  751. // 返回列表数据
  752. getTableValue() {
  753. let comitDatasource = this.form.datasource;
  754. if (comitDatasource.length === 0) return [];
  755. comitDatasource.forEach((v) => {
  756. v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
  757. v.files = v.files || [];
  758. v.technicalDrawings = v.technicalDrawings || [];
  759. v.arrivalBatch = v.arrivalBatch || [];
  760. v.detailType = this.detailType;
  761. });
  762. return comitDatasource;
  763. },
  764. //计算单重
  765. singleWeightChange(row, index) {
  766. if (row && row.singleWeight && row.totalCount) {
  767. row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
  768. this.$set(
  769. this.form.datasource[index],
  770. 'totalWeight',
  771. row.totalWeight
  772. );
  773. }
  774. },
  775. //修改回显
  776. async putTableValue(data) {
  777. if (data && data?.length) {
  778. this.form.datasource = [];
  779. data.forEach((row) => {
  780. row['reqTotalCount'] = row['reqTotalCount'] || row.totalCount;
  781. row['arrivalWay'] = row.arrivalWay || 1;
  782. let item = JSON.parse(JSON.stringify(row));
  783. item.key = this.form.datasource.length + 1;
  784. item = {
  785. ...this.defaultForm,
  786. ...item
  787. };
  788. this.form.datasource.push(item);
  789. });
  790. let codeList = this.form.datasource.map((item) => item.productCode);
  791. //获取仓库库存
  792. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  793. this.form.datasource.forEach((item) => {
  794. let find =
  795. inventoryTotalList.find((key) => key.code == item.productCode) ||
  796. {};
  797. item.availableCountBase = find.availableCountBase;
  798. });
  799. this.$refs.table.reload();
  800. }
  801. },
  802. handleMethod(row, index) {
  803. this.$refs.timeDialogRef.open(row, index);
  804. },
  805. chooseTime({ arrivalBatch, index }) {
  806. this.$set(
  807. this.form.datasource[index],
  808. 'arrivalBatch',
  809. copyObj(arrivalBatch)
  810. );
  811. },
  812. handleTaskinstance(row, index) {
  813. this.taskinstanceDialogFlag = true;
  814. this.$nextTick(() => {
  815. this.$refs.taskinstanceDialogRef.open(row, index);
  816. });
  817. },
  818. saveTaskInstance(row = {}) {
  819. if (row.index >= 0) {
  820. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  821. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  822. this.$set(
  823. this.form.datasource[row.index],
  824. 'routingId',
  825. row.produceRoutingId
  826. );
  827. } else {
  828. let keyS = this.selection.map((item) => item.key - 1);
  829. keyS.forEach((key) => {
  830. this.$set(this.form.datasource[key], 'taskId', row.id);
  831. this.$set(this.form.datasource[key], 'taskName', row.name);
  832. this.$set(
  833. this.form.datasource[key],
  834. 'routingId',
  835. row.produceRoutingId
  836. );
  837. });
  838. }
  839. },
  840. //获取供应商信息
  841. handleGetSup(e, row, index) {
  842. this.curIndex = index;
  843. if (e.target.nodeName == 'I') {
  844. this.$set(this.form.datasource[this.curIndex], 'supplierCode', '');
  845. this.$set(this.form.datasource[this.curIndex], 'supplierId', '');
  846. this.$set(this.form.datasource[this.curIndex], 'supplierName', '');
  847. return;
  848. }
  849. let item = { id: row.supplierId };
  850. this.$refs.supplierListRef.open(item);
  851. },
  852. //选择供应商信息回调
  853. getSupInfo(obj) {
  854. let params = {
  855. supplierCode: obj.code,
  856. supplierId: obj.id,
  857. supplierName: obj.name
  858. };
  859. this.$set(
  860. this.form.datasource[this.curIndex],
  861. 'supplierCode',
  862. params.supplierCode
  863. );
  864. this.$set(
  865. this.form.datasource[this.curIndex],
  866. 'supplierId',
  867. params.supplierId
  868. );
  869. this.$set(
  870. this.form.datasource[this.curIndex],
  871. 'supplierName',
  872. params.supplierName
  873. );
  874. },
  875. async warehouseChange(index, row) {
  876. const data = this.warehouseList.find(
  877. (item) => item.id == row.warehouseId
  878. );
  879. this.$set(this.form.datasource[index], 'warehouseName', data.name);
  880. this.$set(this.form.datasource[index], 'warehouseCode', data.code);
  881. this.$set(this.form.datasource[index], 'warehouseId', data.id);
  882. },
  883. //选择产品
  884. handParent(row, index) {
  885. // let item = {
  886. // id: row.productCode
  887. // };
  888. this.$refs.productListRef.open(this.form.datasource, index);
  889. },
  890. //选择技术人回调
  891. changeAnswer(obj, idx) {
  892. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  893. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  894. },
  895. handHead(row, index) {
  896. let item = {
  897. id: row.technicalAnswerId
  898. };
  899. this.$refs.headRef.open(item, index);
  900. },
  901. getSelectionCbom(obj, idx = -1) {
  902. obj.forEach((item, index) => {
  903. let i = idx == -1 ? index : idx;
  904. let row = JSON.parse(JSON.stringify(this.defaultForm));
  905. row.key = this.form.datasource.length + 1;
  906. let parasm = idx == -1 ? row : this.form.datasource[i];
  907. this.$set(parasm, 'productId', item.id);
  908. // this.$set(parasm, 'id', item.id);
  909. this.$set(parasm, 'categoryName', item.name);
  910. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  911. this.$set(parasm, 'productBrand', item.brandNum);
  912. this.$set(
  913. parasm,
  914. 'productCategoryName',
  915. item.category.categoryLevelPath
  916. );
  917. this.$set(parasm, 'totalCount', item.dosage);
  918. this.$set(parasm, 'productCode', item.code);
  919. this.$set(parasm, 'productName', item.name);
  920. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  921. this.$set(parasm, 'modelType', item.modelType);
  922. this.$set(parasm, 'weightUnit', item.weightUnit);
  923. this.$set(parasm, 'measuringUnit', item.unit);
  924. this.$set(parasm, 'specification', item.specification);
  925. this.$set(parasm, 'remark', '');
  926. this.$set(parasm, 'imgCode', item.imgCode);
  927. this.$set(parasm, 'produceType', item.componentAttribute);
  928. this.$set(parasm, 'singleWeight', item.roughWeight);
  929. this.$set(parasm, 'goodsLevel', item.level);
  930. this.$set(parasm, 'approvalNumber', item.extField.approvalNumber);
  931. this.$set(
  932. parasm,
  933. 'packingSpecification',
  934. item.extField.packingSpecification
  935. );
  936. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  937. if (idx == -1) {
  938. this.form.datasource.push(row);
  939. }
  940. });
  941. },
  942. warehouseAllChange(data) {
  943. let keyS = this.selection.map((item) => item.key - 1);
  944. keyS.forEach((key) => {
  945. this.$set(this.form.datasource[key], 'warehouseName', data.name);
  946. this.$set(this.form.datasource[key], 'warehouseCode', data.code);
  947. this.$set(this.form.datasource[key], 'warehouseId', data.id);
  948. });
  949. },
  950. //选择产品回调
  951. changeParent(obj, idx) {
  952. obj.forEach((item, index) => {
  953. let i = idx == -1 ? index : idx;
  954. let row = JSON.parse(JSON.stringify(this.defaultForm));
  955. row.key = this.form.datasource.length + 1;
  956. let parasm = idx == -1 ? row : this.form.datasource[i];
  957. this.$set(parasm, 'productId', item.id);
  958. // this.$set(parasm, 'id', item.id);
  959. this.$set(parasm, 'categoryName', item.name);
  960. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  961. this.$set(parasm, 'productBrand', item.brandNum);
  962. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  963. this.$set(parasm, 'productCode', item.code);
  964. this.$set(parasm, 'productName', item.name);
  965. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  966. this.$set(parasm, 'modelType', item.modelType);
  967. this.$set(parasm, 'weightUnit', item.weightUnit);
  968. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  969. this.$set(parasm, 'specification', item.specification);
  970. this.$set(parasm, 'singleWeight', item.netWeight);
  971. row['arrivalWay'] = row.arrivalWay || 1;
  972. this.$set(parasm, 'remark', '');
  973. this.$set(parasm, 'imgCode', item.imgCode);
  974. this.$set(parasm, 'produceType', item.componentAttribute);
  975. this.$set(parasm, 'approvalNumber', item.extField.approvalNumber);
  976. this.$set(
  977. parasm,
  978. 'packingSpecification',
  979. item.extField.packingSpecification
  980. );
  981. if (item.purchaseOrigins?.length > 0) {
  982. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  983. }
  984. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  985. if (idx == -1) {
  986. this.form.datasource.push(row);
  987. }
  988. });
  989. },
  990. remove(i) {
  991. this.form.datasource.splice(i, 1);
  992. this.setSort();
  993. },
  994. // 清空表格
  995. restTable() {
  996. this.form.datasource = [];
  997. },
  998. // 重新排序
  999. setSort() {
  1000. this.form.datasource.forEach((n, index) => {
  1001. n.key = index + 1;
  1002. });
  1003. },
  1004. // 添加
  1005. handlAdd() {
  1006. let item = JSON.parse(JSON.stringify(this.defaultForm));
  1007. item.key = this.form.datasource.length + 1;
  1008. this.form.datasource.push(item);
  1009. },
  1010. validateForm(callback) {
  1011. //开始表单校验
  1012. this.$refs.form.validate((valid, obj) => {
  1013. if (obj) {
  1014. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1015. if (messages.length > 0) {
  1016. this.$message.warning(messages[0].message);
  1017. }
  1018. }
  1019. callback(valid);
  1020. });
  1021. }
  1022. }
  1023. };
  1024. </script>
  1025. <style lang="scss" scoped>
  1026. .headbox {
  1027. display: flex;
  1028. justify-content: space-between;
  1029. align-items: center;
  1030. .amount {
  1031. font-size: 14px;
  1032. font-weight: bold;
  1033. }
  1034. }
  1035. .time-form .el-form-item {
  1036. margin-bottom: 0 !important;
  1037. }
  1038. ::v-deep .period {
  1039. display: flex;
  1040. .borderleftnone {
  1041. .el-input--medium .el-input__inner {
  1042. border-top-right-radius: 0;
  1043. border-bottom-right-radius: 0;
  1044. }
  1045. }
  1046. .borderrightnone {
  1047. .el-input--medium .el-input__inner {
  1048. border-top-left-radius: 0;
  1049. border-bottom-left-radius: 0;
  1050. }
  1051. }
  1052. }
  1053. ::v-deep .time-form tbody > tr:hover > td {
  1054. background-color: transparent !important;
  1055. }
  1056. ::v-deep .time-form .el-table tr {
  1057. background-color: #ffffff;
  1058. }
  1059. </style>