inventoryTable.vue 41 KB

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