inventoryTable.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table
  4. ref="table"
  5. :columns="columns"
  6. height="400"
  7. full-height="calc(100vh - 76px)"
  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. <div style="display: flex">
  17. <el-button
  18. size="small"
  19. type="primary"
  20. icon="el-icon-plus"
  21. class="ele-btn-icon"
  22. @click="handParent('', -1)"
  23. >
  24. 新增
  25. </el-button>
  26. <warehouseAll
  27. @success="warehouseAllChange"
  28. :disabled="!selection.length"
  29. ></warehouseAll>
  30. <el-button
  31. size="small"
  32. type="primary"
  33. class="ele-btn-icon"
  34. style="margin-left: 5px"
  35. @click="handleTaskinstance"
  36. :disabled="!selection.length"
  37. >批量设置工序
  38. </el-button>
  39. <timeDialogAll
  40. @chooseTime="chooseTimeALl"
  41. :disabled="!selection.length"
  42. ></timeDialogAll>
  43. <dateAll
  44. @success="dateAllChange"
  45. :disabled="!selection.length"
  46. ></dateAll>
  47. </div>
  48. </template>
  49. <template v-slot:productName="{ row, $index }">
  50. <el-form-item
  51. :prop="'datasource.' + $index + '.productName'"
  52. :rules="{
  53. required: true,
  54. message: '请输入',
  55. trigger: 'change'
  56. }"
  57. >
  58. <el-input
  59. v-model="row.productName"
  60. placeholder="请输入"
  61. style="width: calc(100% - 70px); margin-right: 10px"
  62. v-if="!row.productCode"
  63. ></el-input>
  64. <div
  65. v-else
  66. style="width: calc(100% - 70px); margin-right: 10px"
  67. class="ellipsis-single"
  68. :title="row.productName"
  69. >{{ row.productName }}</div
  70. >
  71. <el-button
  72. size="small"
  73. type="primary"
  74. @click.native="handParent(row, $index)"
  75. >选择
  76. </el-button>
  77. </el-form-item>
  78. </template>
  79. <template v-slot:batchNo="scope">
  80. <el-form-item :prop="'datasource.' + scope.$index + '.batchNo'">
  81. <el-input v-model="scope.row.batchNo"></el-input>
  82. </el-form-item>
  83. </template>
  84. <template v-slot:totalCount="scope">
  85. <el-form-item
  86. :prop="'datasource.' + scope.$index + '.totalCount'"
  87. :rules="{
  88. required: true,
  89. pattern: numberReg,
  90. message: '请输入数量',
  91. trigger: 'blur'
  92. }"
  93. >
  94. <el-input
  95. v-model="scope.row.totalCount"
  96. @input="changeCount(scope.row, scope.$index)"
  97. placeholder="请输入"
  98. ></el-input>
  99. </el-form-item>
  100. </template>
  101. <template v-slot:productBrand="scope">
  102. <el-form-item
  103. :prop="'datasource.' + scope.$index + '.productBrand'"
  104. v-if="!scope.row.productCode"
  105. >
  106. <el-input v-model="scope.row.productBrand"></el-input>
  107. </el-form-item>
  108. <div v-else>{{ scope.row.productBrand }}</div>
  109. </template>
  110. <template v-slot:brand="scope">
  111. <el-form-item :prop="'datasource.' + scope.$index + '.brand'">
  112. <el-input v-model="scope.row.brand"></el-input>
  113. </el-form-item>
  114. </template>
  115. <template v-slot:modelType="scope">
  116. <el-form-item
  117. :prop="'datasource.' + scope.$index + '.modelType'"
  118. v-if="!scope.row.productCode"
  119. >
  120. <el-input v-model="scope.row.modelType"></el-input>
  121. </el-form-item>
  122. <div v-else>{{ scope.row.modelType }}</div>
  123. </template>
  124. <template v-slot:specification="scope">
  125. <el-form-item
  126. :prop="'datasource.' + scope.$index + '.specification'"
  127. v-if="!scope.row.productCode"
  128. >
  129. <el-input v-model="scope.row.specification"></el-input>
  130. </el-form-item>
  131. <div v-else>{{ scope.row.specification }}</div>
  132. </template>
  133. <template v-slot:measuringUnit="scope">
  134. <el-form-item
  135. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  136. v-if="!scope.row.productCode"
  137. >
  138. <el-input
  139. v-model="scope.row.measuringUnit"
  140. placeholder="请输入"
  141. ></el-input>
  142. </el-form-item>
  143. <div v-else>{{ scope.row.measuringUnit }}</div>
  144. </template>
  145. <template v-slot:remark="scope">
  146. <el-form-item :prop="'datasource.' + scope.$index + '.remark'">
  147. <el-input
  148. v-model="scope.row.remark"
  149. type="textarea"
  150. placeholder="请输入"
  151. ></el-input>
  152. </el-form-item>
  153. </template>
  154. <template v-slot:taskName="scope">
  155. <el-form-item :prop="'datasource.' + scope.$index + '.taskName'">
  156. <el-input
  157. v-model="scope.row.taskName"
  158. placeholder="请选择"
  159. style="width: calc(100% - 70px); margin-right: 10px"
  160. disabled
  161. ></el-input>
  162. <el-button
  163. v-if="scope.row.productCode"
  164. size="small"
  165. type="primary"
  166. @click.native="handleTaskinstance(scope.row, scope.$index)"
  167. >选择
  168. </el-button>
  169. </el-form-item>
  170. </template>
  171. <template v-slot:technicalAnswerName="{ row, $index }">
  172. <el-form-item
  173. :prop="'datasource.' + $index + '.technicalAnswerName'"
  174. :rules="{
  175. required: false,
  176. message: '请输入',
  177. trigger: 'change'
  178. }"
  179. >
  180. <el-input
  181. v-model="row.technicalAnswerName"
  182. placeholder="请输入"
  183. @click.native="handHead(row, $index)"
  184. ></el-input>
  185. </el-form-item>
  186. </template>
  187. <template v-slot:technicalParams="scope">
  188. <el-form-item
  189. :prop="'datasource.' + scope.$index + '.technicalParams'"
  190. :rules="{
  191. required: false,
  192. message: '请输入',
  193. trigger: 'change'
  194. }"
  195. >
  196. <el-input
  197. type="textarea"
  198. v-model="scope.row.technicalParams"
  199. placeholder="请输入"
  200. ></el-input>
  201. </el-form-item>
  202. </template>
  203. <template v-slot:files="scope">
  204. <el-form-item :prop="'datasource.' + scope.$index + '.files'">
  205. <fileMain v-model="scope.row.files"></fileMain>
  206. </el-form-item>
  207. </template>
  208. <template v-slot:technicalDrawings="scope">
  209. <el-form-item
  210. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  211. >
  212. <fileMain v-model="scope.row.technicalDrawings"></fileMain>
  213. </el-form-item>
  214. </template>
  215. <template v-slot:expectReceiveDate="scope">
  216. <el-form-item
  217. v-if="scope.row.arrivalWay == 1"
  218. :prop="'datasource.' + scope.$index + '.expectReceiveDate'"
  219. :rules="{
  220. required: true,
  221. message: '请选择到货日期',
  222. trigger: 'blur'
  223. }"
  224. >
  225. <el-date-picker
  226. style="width: 100%"
  227. clearable
  228. v-model="scope.row.expectReceiveDate"
  229. type="date"
  230. value-format="yyyy-MM-dd"
  231. placeholder="请选择日期"
  232. >
  233. </el-date-picker>
  234. </el-form-item>
  235. <el-form-item v-if="scope.row.arrivalWay == 2">
  236. <el-link
  237. type="primary"
  238. :underline="false"
  239. @click.native="handleMethod(scope.row, scope.$index)"
  240. >
  241. 设置分批时间
  242. </el-link>
  243. </el-form-item>
  244. </template>
  245. <template v-slot:arrivalWay="scope">
  246. <el-form-item
  247. :prop="'datasource.' + scope.$index + '.arrivalWay'"
  248. :rules="{
  249. required: true,
  250. message: '请选择到货方式',
  251. trigger: 'blur'
  252. }"
  253. >
  254. <el-select
  255. v-model="scope.row.arrivalWay"
  256. clearable
  257. style="width: 100%"
  258. >
  259. <el-option
  260. v-for="item in arrivalWayList"
  261. :key="item.value"
  262. :label="item.label"
  263. :value="item.value"
  264. >
  265. </el-option>
  266. </el-select>
  267. </el-form-item>
  268. </template>
  269. <template v-slot:supplierName="scope">
  270. <el-form-item
  271. :prop="'datasource.' + scope.$index + '.supplierName'"
  272. :rules="{
  273. required: isSupplier ? true : false,
  274. trigger: 'change',
  275. message: '请选择供应商'
  276. }"
  277. >
  278. <el-select v-model="scope.row.supplierId" clearable filterable>
  279. <el-option
  280. v-for="i in scope.row.supplierList"
  281. :key="i.id"
  282. :value="i.id"
  283. :label="i.name"
  284. @click.native="getSupInfo(i, scope.$index)"
  285. ></el-option>
  286. </el-select>
  287. </el-form-item>
  288. </template>
  289. <template v-slot:provenance="scope">
  290. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  291. <DictSelection
  292. dictName="产地"
  293. clearable
  294. v-model="scope.row.provenance"
  295. multiple
  296. :isOne="scope.$index == 0"
  297. >
  298. </DictSelection>
  299. </el-form-item>
  300. </template>
  301. <template v-slot:headerProductName="{ column }">
  302. <span class="is-required">{{ column.label }}</span>
  303. </template>
  304. <template v-slot:headerTotalCount="{ column }">
  305. <span class="is-required">{{ column.label }}</span>
  306. </template>
  307. <template v-slot:headerExpectReceiveDate="{ column }">
  308. <span class="is-required">{{ column.label }}</span>
  309. </template>
  310. <template v-slot:headerArrivalWay="{ column }">
  311. <span class="is-required">{{ column.label }}</span>
  312. </template>
  313. <template v-slot:headerSupplierName="{ column }">
  314. <span :class="{ 'is-required': isSupplier }">{{ column.label }}</span>
  315. </template>
  316. <template v-slot:headerWarehouseId="{ column }">
  317. <span
  318. :class="{ 'is-required': ['3', '4', '5'].includes(sourceType) }"
  319. >{{ column.label }}</span
  320. >
  321. </template>
  322. <template v-slot:warehouseId="scope">
  323. <el-form-item
  324. :prop="'datasource.' + scope.$index + '.warehouseId'"
  325. :rules="[
  326. {
  327. required: ['3', '4', '5'].includes(sourceType) ? true : false,
  328. message: '请选择仓库',
  329. trigger: 'blur'
  330. }
  331. ]"
  332. >
  333. <el-select
  334. v-model="scope.row.warehouseId"
  335. placeholder="请选择"
  336. @change="warehouseChange(scope.$index, scope.row)"
  337. >
  338. <el-option
  339. v-for="item in warehouseList"
  340. :key="item.id"
  341. :label="item.name"
  342. :value="item.id"
  343. >
  344. </el-option>
  345. </el-select>
  346. </el-form-item>
  347. </template>
  348. <template v-slot:purchaseCount="scope">
  349. <el-form-item
  350. :prop="'datasource.' + scope.$index + '.purchaseCount'"
  351. :rules="{
  352. required: true,
  353. message: '请输入数量',
  354. trigger: 'change'
  355. }"
  356. >
  357. <el-input
  358. v-model="scope.row.purchaseCount"
  359. placeholder="请输入"
  360. type="number"
  361. :min="0"
  362. @input="changeCount(scope.row, scope.$index)"
  363. >
  364. <template slot="append">
  365. <el-select
  366. v-model="scope.row.purchaseUnitId"
  367. style="width: 80px"
  368. @change="changeCount(scope.row, scope.$index)"
  369. >
  370. <el-option
  371. :label="item.conversionUnit"
  372. :value="item.id"
  373. @click.native="packingChange(item, scope.$index)"
  374. v-for="(item, index) in scope.row.packageDispositionList"
  375. :key="index"
  376. ></el-option>
  377. </el-select>
  378. </template>
  379. </el-input>
  380. </el-form-item>
  381. </template>
  382. <!-- <template v-slot:purchaseUnit="scope">
  383. <el-form-item
  384. style="margin-bottom: 20px"
  385. :prop="'datasource.' + scope.$index + '.purchaseUnitId'"
  386. >
  387. <el-select
  388. v-model="scope.row.purchaseUnitId"
  389. style="width: 100%"
  390. @change="changeCount(scope.row, scope.$index)"
  391. >
  392. <el-option
  393. :label="item.conversionUnit"
  394. :value="item.id"
  395. @click.native="packingChange(item, scope.$index)"
  396. v-for="(item, index) in scope.row.packageDispositionList"
  397. :key="index"
  398. ></el-option>
  399. </el-select>
  400. </el-form-item>
  401. </template> -->
  402. <template v-slot:modelKey="scope">
  403. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  404. <DictSelection
  405. dictName="物品机型"
  406. clearable
  407. v-model="scope.row.modelKey"
  408. :isOne="scope.$index === 0"
  409. filterable
  410. allow-create
  411. default-first-option
  412. >
  413. </DictSelection>
  414. </el-form-item>
  415. </template>
  416. <template v-slot:colorKey="scope">
  417. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  418. <DictSelection
  419. dictName="物品颜色"
  420. clearable
  421. v-model="scope.row.colorKey"
  422. :isOne="scope.$index === 0"
  423. filterable
  424. allow-create
  425. default-first-option
  426. >
  427. </DictSelection>
  428. </el-form-item>
  429. </template>
  430. <!-- 操作列 -->
  431. <template v-slot:action="scope">
  432. <el-popconfirm
  433. class="ele-action"
  434. title="确定要删除吗?"
  435. @confirm="remove(scope.$index)"
  436. >
  437. <template v-slot:reference>
  438. <el-link type="danger" :underline="false" icon="el-icon-delete">
  439. 删除
  440. </el-link>
  441. </template>
  442. </el-popconfirm>
  443. </template>
  444. <template v-slot:goodsLevel="{ row, $index }">
  445. <el-form-item :prop="'datasource.' + $index + '.goodsLevel'">
  446. <el-select v-model="row.goodsLevel" style="width: 100%">
  447. <el-option
  448. :label="item.label"
  449. :value="item.value"
  450. v-for="(item, index) in levelList"
  451. :key="index"
  452. ></el-option>
  453. </el-select>
  454. </el-form-item>
  455. </template>
  456. </ele-pro-table>
  457. <product-list
  458. ref="productListRef"
  459. classType="1"
  460. :is-get-inventory-total="true"
  461. @changeParent="changeParent"
  462. :is-show-c-bom="true"
  463. @getSelectionCbom="getSelectionCbom"
  464. :isSupplier="true"
  465. ></product-list>
  466. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  467. <timeDialog @chooseTime="chooseTime" ref="timeDialogRef"></timeDialog>
  468. <!-- <supplierList
  469. ref="supplierListRef"
  470. :classType="2"
  471. @changeParent="getSupInfo"
  472. ></supplierList> -->
  473. <taskinstance-dialog
  474. ref="taskinstanceDialogRef"
  475. v-if="taskinstanceDialogFlag"
  476. @saveTaskInstance="saveTaskInstance"
  477. :visible.sync="taskinstanceDialogFlag"
  478. ></taskinstance-dialog>
  479. </el-form>
  480. </template>
  481. <script>
  482. import { numberReg } from 'ele-admin';
  483. import productList from '@/BIZComponents/product-list.vue';
  484. import dictMixins from '@/mixins/dictMixins';
  485. import fileUpload from '@/components/upload/fileUpload';
  486. import headList from '@/BIZComponents/user-select/user-select.vue';
  487. import timeDialog from '@/components/timeDialog/index.vue';
  488. import { copyObj } from '@/utils/util';
  489. // import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  490. import { getInventoryTotalAPI } from '@/api/wms';
  491. // import fileMain from '@/components/addDoc/index.vue';
  492. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  493. import { lbjtList } from '@/enum/dict.js';
  494. import tabMixins from '@/mixins/tableColumnsMixin';
  495. import { getWarehouseList } from '@/api/saleManage/saleorder';
  496. import warehouseAll from '@/BIZComponents/warehouseAll.vue';
  497. import { levelList } from '@/enum/dict.js';
  498. import { changeCount } from '@/BIZComponents/setProduct.js';
  499. import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
  500. import timeDialogAll from '@/components/timeDialog/indexAll.vue';
  501. import dateAll from './dateAll.vue';
  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. timeDialogAll,
  526. warehouseAll,
  527. dateAll
  528. },
  529. computed: {
  530. columns() {
  531. let columnsVersion = this.columnsVersion;
  532. return [
  533. {
  534. width: 45,
  535. type: 'index',
  536. columnKey: 'index',
  537. align: 'center'
  538. },
  539. {
  540. label: '选择',
  541. width: 45,
  542. type: 'selection',
  543. columnKey: 'selection',
  544. align: 'center',
  545. fixed: 'left'
  546. },
  547. {
  548. width: 150,
  549. prop: 'productCategoryName',
  550. label: '分类',
  551. showOverflowTooltip: true,
  552. align: 'center'
  553. },
  554. {
  555. width: 140,
  556. prop: 'productCode',
  557. label: '编码',
  558. showOverflowTooltip: true,
  559. align: 'center'
  560. },
  561. {
  562. width: 240,
  563. prop: 'productName',
  564. label: '名称',
  565. slot: 'productName',
  566. headerSlot: 'headerProductName',
  567. showOverflowTooltip: true,
  568. align: 'center'
  569. },
  570. {
  571. width: 240,
  572. prop: 'taskName',
  573. label: '工序',
  574. slot: 'taskName',
  575. showOverflowTooltip: true,
  576. align: 'center'
  577. },
  578. {
  579. width: 110,
  580. prop: 'batchNo',
  581. label: '批次号',
  582. showOverflowTooltip: true,
  583. slot: 'batchNo',
  584. align: 'center'
  585. },
  586. {
  587. prop: 'provenance',
  588. label: '产地',
  589. slot: 'provenance',
  590. align: 'center',
  591. showOverflowTooltip: true,
  592. minWidth: 200
  593. },
  594. {
  595. width: 150,
  596. prop: 'reqTotalCount',
  597. label: '需求数量',
  598. showOverflowTooltip: true,
  599. formatter: (row, column) => {
  600. if (row.reqTotalCount) {
  601. return row.reqTotalCount + ' ' + (row.measuringUnit || '');
  602. }
  603. },
  604. align: 'center'
  605. },
  606. {
  607. width: 250,
  608. prop: 'purchaseCount',
  609. showOverflowTooltip: true,
  610. label: '数量',
  611. slot: 'purchaseCount',
  612. headerSlot: 'headerTotalCount',
  613. align: 'center'
  614. },
  615. // {
  616. // width: 150,
  617. // prop: 'purchaseUnit',
  618. // showOverflowTooltip: true,
  619. // label: '单位',
  620. // slot: 'purchaseUnit',
  621. // align: 'center'
  622. // },
  623. {
  624. width: 120,
  625. prop: 'packingSpecification',
  626. align: 'center',
  627. label: '包装规格',
  628. showOverflowTooltip: true
  629. },
  630. {
  631. width: 90,
  632. prop: 'totalCount',
  633. label: '计量数量',
  634. showOverflowTooltip: true,
  635. formatter: (row, column) => {
  636. if (row.totalCount) {
  637. return row.totalCount + ' ' + (row.measuringUnit || '');
  638. }
  639. },
  640. align: 'center'
  641. },
  642. // {
  643. // width: 100,
  644. // prop: 'measuringUnit',
  645. // showOverflowTooltip: true,
  646. // label: '计量单位',
  647. // slot: 'measuringUnit',
  648. // align: 'center'
  649. // },
  650. {
  651. minWidth: 120,
  652. prop: 'goodsLevel',
  653. showOverflowTooltip: true,
  654. label: '物品级别',
  655. slot: 'goodsLevel',
  656. align: 'center'
  657. },
  658. {
  659. width: 200,
  660. prop: 'warehouseId',
  661. label: '入库仓库',
  662. showOverflowTooltip: true,
  663. slot: 'warehouseId',
  664. headerSlot: 'headerWarehouseId',
  665. align: 'center'
  666. },
  667. {
  668. width: 80,
  669. prop: 'availableCountBase',
  670. showOverflowTooltip: true,
  671. label: '库存数量',
  672. slot: 'availableCountBase',
  673. align: 'center'
  674. },
  675. // {
  676. // width: 120,
  677. // prop: 'singleWeight',
  678. // label: '单重',
  679. // slot: 'singleWeight',
  680. // align: 'center'
  681. // },
  682. {
  683. width: 120,
  684. prop: 'totalWeight',
  685. showOverflowTooltip: true,
  686. label: '重量',
  687. formatter: (row, column) => {
  688. if (row.totalWeight) {
  689. return row.totalWeight + ' ' + (row.weightUnit || '');
  690. }
  691. },
  692. align: 'center'
  693. },
  694. {
  695. width: 160,
  696. prop: 'arrivalWay',
  697. label: '到货方式',
  698. showOverflowTooltip: true,
  699. slot: 'arrivalWay',
  700. headerSlot: 'headerArrivalWay',
  701. align: 'center'
  702. },
  703. {
  704. width: 170,
  705. prop: 'expectReceiveDate',
  706. label: '到货日期',
  707. showOverflowTooltip: true,
  708. slot: 'expectReceiveDate',
  709. headerSlot: 'headerExpectReceiveDate',
  710. align: 'center'
  711. },
  712. {
  713. width: 180,
  714. prop: 'supplierName',
  715. label: '供应商',
  716. showOverflowTooltip: true,
  717. slot: 'supplierName',
  718. // headerSlot: 'headerSupplierName',
  719. align: 'center'
  720. },
  721. {
  722. width: 130,
  723. prop: 'brand',
  724. showOverflowTooltip: true,
  725. label: '品牌',
  726. slot: 'brand',
  727. align: 'center'
  728. },
  729. {
  730. width: 160,
  731. prop: 'technicalDrawings',
  732. label: '图纸附件',
  733. showOverflowTooltip: true,
  734. slot: 'technicalDrawings'
  735. },
  736. {
  737. width: 160,
  738. prop: 'files',
  739. label: '附件',
  740. showOverflowTooltip: true,
  741. slot: 'files'
  742. },
  743. {
  744. width: 150,
  745. prop: 'productBrand',
  746. label: '牌号',
  747. showOverflowTooltip: true,
  748. slot: 'productBrand',
  749. align: 'center'
  750. },
  751. {
  752. width: 130,
  753. prop: 'modelType',
  754. showOverflowTooltip: true,
  755. label: '型号',
  756. slot: 'modelType',
  757. align: 'center'
  758. },
  759. {
  760. width: 120,
  761. prop: 'specification',
  762. label: '规格',
  763. showOverflowTooltip: true,
  764. slot: 'specification',
  765. align: 'center'
  766. },
  767. {
  768. width: 160,
  769. prop: 'modelKey',
  770. label: '机型',
  771. showOverflowTooltip: true,
  772. slot: 'modelKey',
  773. align: 'center'
  774. },
  775. {
  776. width: 160,
  777. showOverflowTooltip: true,
  778. prop: 'colorKey',
  779. label: '颜色',
  780. slot: 'colorKey',
  781. align: 'center'
  782. },
  783. {
  784. width: 120,
  785. prop: 'imgCode',
  786. align: 'center',
  787. label: '图号/件号',
  788. showOverflowTooltip: true
  789. },
  790. {
  791. width: 120,
  792. prop: 'produceType',
  793. align: 'center',
  794. label: '属性类型',
  795. showOverflowTooltip: true,
  796. formatter: (row, column) => {
  797. if (row.produceType) {
  798. return row.produceType
  799. .map((item) => {
  800. return lbjtList[item];
  801. })
  802. .toString();
  803. }
  804. }
  805. },
  806. {
  807. width: 220,
  808. prop: 'remark',
  809. label: '备注',
  810. showOverflowTooltip: true,
  811. slot: 'remark',
  812. align: 'center'
  813. },
  814. {
  815. columnKey: 'action',
  816. label: '操作',
  817. width: 120,
  818. align: 'center',
  819. resizable: false,
  820. slot: 'action',
  821. fixed: 'right',
  822. showOverflowTooltip: true
  823. }
  824. ];
  825. }
  826. },
  827. data() {
  828. const defaultForm = {
  829. key: null,
  830. endTime: '',
  831. isFirst: 0,
  832. name: '',
  833. supplierName: '',
  834. weightUnit: ''
  835. };
  836. return {
  837. levelList,
  838. cacheKeyUrl: 'eos-purchasingManage-purchasePlanManage-inventoryTable',
  839. curIndex: null,
  840. numberReg,
  841. defaultForm,
  842. selection: [],
  843. arrivalWayList: [
  844. { label: '一次性到货', value: 1 },
  845. { label: '分批到货', value: 2 }
  846. ],
  847. form: {
  848. datasource: []
  849. },
  850. taskinstanceDialogFlag: false,
  851. rules: {},
  852. dictList: {},
  853. warehouseList: [],
  854. columnsVersion: 1
  855. };
  856. },
  857. created() {
  858. this.requestDict('生产类型');
  859. getWarehouseList().then((res) => {
  860. this.warehouseList = res;
  861. });
  862. },
  863. methods: {
  864. // 返回列表数据
  865. getTableValue() {
  866. let comitDatasource = this.form.datasource;
  867. if (comitDatasource.length === 0) return [];
  868. comitDatasource.forEach((v) => {
  869. if (v.modelKey) {
  870. v.modelKey = v.modelKey;
  871. }
  872. if (v.colorKey) {
  873. v.colorKey = v.colorKey;
  874. }
  875. v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
  876. v.files = v.files || [];
  877. v.technicalDrawings = v.technicalDrawings || [];
  878. v.arrivalBatch = v.arrivalBatch || [];
  879. v.detailType = this.detailType;
  880. });
  881. return comitDatasource;
  882. },
  883. // //计算单重
  884. // singleWeightChange(row, index) {
  885. // if (row && row.singleWeight && row.totalCount) {
  886. // row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
  887. // this.$set(
  888. // this.form.datasource[index],
  889. // 'totalWeight',
  890. // row.totalWeight
  891. // );
  892. // }
  893. // },
  894. packingChange(item, index) {
  895. this.$set(
  896. this.form.datasource[index],
  897. 'purchaseUnit',
  898. item.conversionUnit
  899. );
  900. },
  901. //改变数量
  902. changeCount(row, index) {
  903. this.$set(
  904. this.form.datasource,
  905. index,
  906. changeCount(row, {
  907. countKey: 'purchaseCount',
  908. unitKey: 'purchaseUnit',
  909. unitIdKey: 'purchaseUnitId'
  910. })
  911. );
  912. this.$forceUpdate();
  913. },
  914. //修改回显
  915. async putTableValue(data) {
  916. if (data && data?.length) {
  917. this.form.datasource = [];
  918. data.forEach((row) => {
  919. if (row.modelKey) {
  920. row.modelKey = row.modelKey?.split(',')?.[0] || '';
  921. }
  922. if (row.colorKey) {
  923. row.colorKey = row.colorKey?.split(',')?.[0] || '';
  924. }
  925. row['reqTotalCount'] = row['reqTotalCount'] || row.totalCount;
  926. row['arrivalWay'] = row.arrivalWay || 1;
  927. let item = JSON.parse(JSON.stringify(row));
  928. item.key = this.form.datasource.length + 1;
  929. item = {
  930. ...this.defaultForm,
  931. ...item
  932. };
  933. this.form.datasource.push(item);
  934. });
  935. console.log(this.form.datasource, 'this.form.datasource');
  936. //获取仓库库存
  937. let productId = this.form.datasource
  938. .filter((item) => item.productCode)
  939. .map((item) => item.productId);
  940. let productCode = this.form.datasource
  941. .filter((item) => item.productCode)
  942. .map((item) => item.productCode);
  943. if (productId?.length) {
  944. let inventoryTotalList = await getInventoryTotalAPI(productCode);
  945. let supplierObj = await contactQueryByCategoryIdsAPI({
  946. categoryIds: productId
  947. });
  948. this.form.datasource.forEach((item, index) => {
  949. this.$set(
  950. this.form.datasource[index],
  951. 'supplierList',
  952. supplierObj[item.productId] || []
  953. );
  954. let find =
  955. inventoryTotalList.find(
  956. (key) => key.code == item.productCode
  957. ) || {};
  958. this.$set(
  959. this.form.datasource[index],
  960. 'availableCountBase',
  961. find.availableCountBase
  962. );
  963. });
  964. }
  965. this.$refs.table.reload();
  966. }
  967. },
  968. handleMethod(row, index) {
  969. this.$refs.timeDialogRef.open(row, index);
  970. },
  971. chooseTime({ arrivalBatch, index }) {
  972. this.$set(
  973. this.form.datasource[index],
  974. 'arrivalBatch',
  975. copyObj(arrivalBatch)
  976. );
  977. },
  978. handleTaskinstance(row, index) {
  979. this.taskinstanceDialogFlag = true;
  980. this.$nextTick(() => {
  981. this.$refs.taskinstanceDialogRef.open(row, index);
  982. });
  983. },
  984. saveTaskInstance(row = {}) {
  985. if (row.index >= 0) {
  986. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  987. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  988. this.$set(
  989. this.form.datasource[row.index],
  990. 'routingId',
  991. row.produceRoutingId
  992. );
  993. } else {
  994. let keyS = this.selection.map((item) => item.key - 1);
  995. keyS.forEach((key) => {
  996. this.$set(this.form.datasource[key], 'taskId', row.id);
  997. this.$set(this.form.datasource[key], 'taskName', row.name);
  998. this.$set(
  999. this.form.datasource[key],
  1000. 'routingId',
  1001. row.produceRoutingId
  1002. );
  1003. });
  1004. }
  1005. },
  1006. chooseTimeALl(data) {
  1007. let keyS = this.selection.map((item) => item.key - 1);
  1008. keyS.forEach((key) => {
  1009. this.$set(
  1010. this.form.datasource[key],
  1011. 'arrivalWay',
  1012. data.deliveryMethod
  1013. );
  1014. if (data.deliveryMethod == 1) {
  1015. this.$set(
  1016. this.form.datasource[key],
  1017. 'expectReceiveDate',
  1018. data.requireDeliveryTime
  1019. );
  1020. } else {
  1021. this.$set(
  1022. this.form.datasource[key],
  1023. 'arrivalBatch',
  1024. copyObj(data.arrivalBatch)
  1025. );
  1026. this.$set(
  1027. this.form.datasource[key],
  1028. 'totalCount',
  1029. data.arrivalBatch
  1030. .map((item) => item.arriveCount)
  1031. .reduce((a, b) => a + b, 0)
  1032. );
  1033. }
  1034. });
  1035. },
  1036. // //获取供应商信息
  1037. // handleGetSup(e, row, index) {
  1038. // this.curIndex = index;
  1039. // if (e.target.nodeName == 'I') {
  1040. // this.$set(this.form.datasource[this.curIndex], 'supplierCode', '');
  1041. // this.$set(this.form.datasource[this.curIndex], 'supplierId', '');
  1042. // this.$set(this.form.datasource[this.curIndex], 'supplierName', '');
  1043. // return;
  1044. // }
  1045. // let item = { id: row.supplierId };
  1046. // this.$refs.supplierListRef.open(item);
  1047. // },
  1048. //选择供应商信息回调
  1049. getSupInfo(obj, index) {
  1050. this.$set(this.form.datasource[index], 'supplierCode', obj.code);
  1051. this.$set(this.form.datasource[index], 'supplierId', obj.id);
  1052. this.$set(this.form.datasource[index], 'supplierName', obj.name);
  1053. },
  1054. async warehouseChange(index, row) {
  1055. const data = this.warehouseList.find(
  1056. (item) => item.id == row.warehouseId
  1057. );
  1058. this.$set(this.form.datasource[index], 'warehouseName', data.name);
  1059. this.$set(this.form.datasource[index], 'warehouseCode', data.code);
  1060. this.$set(this.form.datasource[index], 'warehouseId', data.id);
  1061. },
  1062. //选择产品
  1063. handParent(row, index) {
  1064. // let item = {
  1065. // id: row.productCode
  1066. // };
  1067. this.$refs.productListRef.open(this.form.datasource, index);
  1068. },
  1069. //选择技术人回调
  1070. changeAnswer(obj, idx) {
  1071. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  1072. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  1073. },
  1074. handHead(row, index) {
  1075. let item = {
  1076. id: row.technicalAnswerId
  1077. };
  1078. this.$refs.headRef.open(item, index);
  1079. },
  1080. getSelectionCbom(obj, idx = -1) {
  1081. obj.forEach((item, index) => {
  1082. let i = idx == -1 ? index : idx;
  1083. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1084. row.key = this.form.datasource.length + 1;
  1085. let parasm = idx == -1 ? row : this.form.datasource[i];
  1086. this.$set(parasm, 'productId', item.categoryId);
  1087. // this.$set(parasm, 'id', item.id);
  1088. this.$set(parasm, 'categoryName', item.name);
  1089. this.$set(parasm, 'productCategoryId', item.category.categoryLevelId);
  1090. this.$set(parasm, 'productBrand', item.brandNum);
  1091. this.$set(
  1092. parasm,
  1093. 'productCategoryName',
  1094. item.category.categoryLevelPath
  1095. );
  1096. this.$set(parasm, 'totalCount', item.dosage);
  1097. this.$set(parasm, 'productCode', item.code);
  1098. this.$set(parasm, 'productName', item.name);
  1099. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1100. this.$set(parasm, 'modelType', item.modelType);
  1101. this.$set(parasm, 'weightUnit', item.weightUnit);
  1102. this.$set(parasm, 'measuringUnit', item.unit);
  1103. this.$set(parasm, 'specification', item.specification);
  1104. this.$set(parasm, 'remark', '');
  1105. this.$set(parasm, 'imgCode', item.imgCode);
  1106. this.$set(parasm, 'produceType', item.componentAttribute);
  1107. this.$set(parasm, 'singleWeight', item.roughWeight);
  1108. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  1109. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1110. this.$set(parasm, 'supplierList', item.supplierList);
  1111. this.$set(parasm, 'supplierCode', item.supplierCode);
  1112. this.$set(parasm, 'supplierId', item.supplierId);
  1113. this.$set(parasm, 'supplierName', item.supplierName);
  1114. if (item.modelKey) {
  1115. this.$set(parasm, 'modelKey', item.modelKey?.split(',')?.[0] || '');
  1116. }
  1117. if (item.colorKey) {
  1118. this.$set(parasm, 'colorKey', item.colorKey?.split(',')?.[0] || '');
  1119. }
  1120. this.$set(
  1121. parasm,
  1122. 'packingSpecification',
  1123. item.extField?.packingSpecification
  1124. );
  1125. this.$set(
  1126. parasm,
  1127. 'packageDispositionList',
  1128. item.packageDispositionList
  1129. );
  1130. if (item.packageDispositionList?.length) {
  1131. this.$set(
  1132. parasm,
  1133. 'purchaseUnitId',
  1134. item.packageDispositionList[0].id
  1135. );
  1136. this.$set(
  1137. parasm,
  1138. 'purchaseUnit',
  1139. item.packageDispositionList[0].conversionUnit
  1140. );
  1141. }
  1142. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1143. if (idx == -1) {
  1144. this.form.datasource.push(row);
  1145. }
  1146. });
  1147. },
  1148. warehouseAllChange(data) {
  1149. let keyS = this.selection.map((item) => item.key - 1);
  1150. keyS.forEach((key) => {
  1151. this.$set(this.form.datasource[key], 'warehouseName', data.name);
  1152. this.$set(this.form.datasource[key], 'warehouseCode', data.code);
  1153. this.$set(this.form.datasource[key], 'warehouseId', data.id);
  1154. });
  1155. },
  1156. dateAllChange(data) {
  1157. let keyS = this.selection.map((item) => item.key - 1);
  1158. keyS.forEach((key) => {
  1159. this.$set(this.form.datasource[key], 'expectReceiveDate', data);
  1160. });
  1161. },
  1162. //选择产品回调
  1163. changeParent(obj, idx) {
  1164. obj.forEach((item, index) => {
  1165. let i = idx == -1 ? index : idx;
  1166. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1167. row.key = this.form.datasource.length + 1;
  1168. let parasm = idx == -1 ? row : this.form.datasource[i];
  1169. this.$set(parasm, 'productId', item.id);
  1170. // this.$set(parasm, 'id', item.id);
  1171. this.$set(parasm, 'categoryName', item.name);
  1172. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1173. this.$set(parasm, 'productBrand', item.brandNum);
  1174. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1175. this.$set(parasm, 'productCode', item.code);
  1176. this.$set(parasm, 'productName', item.name);
  1177. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1178. this.$set(parasm, 'modelType', item.modelType);
  1179. this.$set(parasm, 'weightUnit', item.weightUnit);
  1180. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1181. this.$set(parasm, 'specification', item.specification);
  1182. this.$set(parasm, 'singleWeight', item.netWeight);
  1183. row['arrivalWay'] = row.arrivalWay || 1;
  1184. this.$set(parasm, 'supplierList', item.supplierList);
  1185. this.$set(parasm, 'supplierCode', item.supplierCode);
  1186. this.$set(parasm, 'supplierId', item.supplierId);
  1187. this.$set(parasm, 'supplierName', item.supplierName);
  1188. this.$set(parasm, 'remark', '');
  1189. this.$set(parasm, 'imgCode', item.imgCode);
  1190. this.$set(parasm, 'produceType', item.componentAttribute);
  1191. this.$set(parasm, 'approvalNumber', item.extField.approvalNumber);
  1192. if (item.modelKey) {
  1193. this.$set(parasm, 'modelKey', item.modelKey?.split(',')?.[0] || '');
  1194. }
  1195. if (item.colorKey) {
  1196. this.$set(parasm, 'colorKey', item.colorKey?.split(',')?.[0] || '');
  1197. }
  1198. this.$set(
  1199. parasm,
  1200. 'packingSpecification',
  1201. item.extField.packingSpecification
  1202. );
  1203. this.$set(
  1204. parasm,
  1205. 'packageDispositionList',
  1206. item.packageDispositionList
  1207. );
  1208. if (item.packageDispositionList?.length) {
  1209. this.$set(
  1210. parasm,
  1211. 'purchaseUnitId',
  1212. item.packageDispositionList[0].id
  1213. );
  1214. this.$set(
  1215. parasm,
  1216. 'purchaseUnit',
  1217. item.packageDispositionList[0].conversionUnit
  1218. );
  1219. }
  1220. if (item.purchaseOrigins?.length > 0) {
  1221. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1222. }
  1223. console.log(parasm);
  1224. console.log(item);
  1225. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1226. if (idx == -1) {
  1227. this.form.datasource.push(row);
  1228. }
  1229. });
  1230. },
  1231. remove(i) {
  1232. this.form.datasource.splice(i, 1);
  1233. this.setSort();
  1234. },
  1235. // 清空表格
  1236. restTable() {
  1237. this.form.datasource = [];
  1238. },
  1239. // 重新排序
  1240. setSort() {
  1241. this.form.datasource.forEach((n, index) => {
  1242. n.key = index + 1;
  1243. });
  1244. },
  1245. // 添加
  1246. handlAdd() {
  1247. let item = JSON.parse(JSON.stringify(this.defaultForm));
  1248. item.key = this.form.datasource.length + 1;
  1249. this.form.datasource.push(item);
  1250. },
  1251. validateForm1(callback) {
  1252. //开始表单校验
  1253. this.$refs.form.validate((valid, obj) => {
  1254. console.log(valid, obj);
  1255. if (obj) {
  1256. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1257. if (messages.length > 0) {
  1258. this.$message.warning(messages[0].message);
  1259. }
  1260. }
  1261. callback(valid);
  1262. });
  1263. },
  1264. validateForm(callback) {
  1265. //开始表单校验
  1266. this.$refs.form.validate((valid, obj) => {
  1267. console.log(valid, obj);
  1268. if (obj) {
  1269. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1270. if (messages.length > 0) {
  1271. this.$message.warning(messages[0].message);
  1272. }
  1273. }
  1274. // 如果表单校验未通过,不需要进行下面的额外校验
  1275. if (valid) {
  1276. // 额外校验数量和到货日期是否填写
  1277. if (this.form && this.form.datasource) {
  1278. let isDataSourceValid = true;
  1279. let errorItemIndex = -1;
  1280. for (let i = 0; i < this.form.datasource.length; i++) {
  1281. const item = this.form.datasource[i];
  1282. // 检查数量和到货日期是否填写(数量可以为0)
  1283. if (
  1284. item.totalCount == null ||
  1285. item.totalCount === '' ||
  1286. !item.expectReceiveDate
  1287. ) {
  1288. isDataSourceValid = false;
  1289. errorItemIndex = i;
  1290. break; // 找到第一个未填写的项目
  1291. }
  1292. }
  1293. // 如果有未填写的项目
  1294. if (!isDataSourceValid) {
  1295. this.$message.warning(
  1296. `第${
  1297. errorItemIndex + 1
  1298. }项数据未完整填写,请检查数量和到货日期`
  1299. );
  1300. // let currentPage = this.$refs.table.tablePage;
  1301. // const pageSize = this.$refs.table.tableLimit; // 每页显示10条数据
  1302. // const targetPage = Math.floor(errorItemIndex / pageSize) + 1; // 计算目标页码
  1303. // if (currentPage !== targetPage) {
  1304. // currentPage = targetPage;
  1305. // this.$refs.table.reload({ page: currentPage });
  1306. // }
  1307. valid = false;
  1308. }
  1309. }
  1310. }
  1311. callback(valid);
  1312. });
  1313. }
  1314. }
  1315. };
  1316. </script>
  1317. <style lang="scss" scoped>
  1318. .headbox {
  1319. display: flex;
  1320. justify-content: space-between;
  1321. align-items: center;
  1322. .amount {
  1323. font-size: 14px;
  1324. font-weight: bold;
  1325. }
  1326. }
  1327. .time-form .el-form-item {
  1328. margin-bottom: 0 !important;
  1329. }
  1330. ::v-deep .period {
  1331. display: flex;
  1332. .borderleftnone {
  1333. .el-input--medium .el-input__inner {
  1334. border-top-right-radius: 0;
  1335. border-bottom-right-radius: 0;
  1336. }
  1337. }
  1338. .borderrightnone {
  1339. .el-input--medium .el-input__inner {
  1340. border-top-left-radius: 0;
  1341. border-bottom-left-radius: 0;
  1342. }
  1343. }
  1344. }
  1345. ::v-deep .time-form tbody > tr:hover > td {
  1346. background-color: transparent !important;
  1347. }
  1348. ::v-deep .time-form .el-table tr {
  1349. background-color: #ffffff;
  1350. }
  1351. .ellipsis-single {
  1352. white-space: nowrap;
  1353. overflow: hidden;
  1354. text-overflow: ellipsis;
  1355. display: inline-block;
  1356. }
  1357. </style>