inventoryTable.vue 35 KB

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