inventoryTable.vue 37 KB

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