inventoryTable.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. :toolkit="[]"
  8. :datasource="form.datasource"
  9. cache-key="systemRoleTable17"
  10. class="time-form"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <div class="headbox">
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-plus"
  19. class="ele-btn-icon"
  20. @click="handlAdd"
  21. >
  22. 新增
  23. </el-button>
  24. </div>
  25. </template>
  26. <template v-slot:productName="{ row, $index }">
  27. <el-form-item
  28. style="margin-bottom: 20px"
  29. :prop="'datasource.' + $index + '.productName'"
  30. :rules="{
  31. required: true,
  32. message: '请输入',
  33. trigger: 'change'
  34. }"
  35. >
  36. <el-input
  37. v-model="row.productName"
  38. placeholder="请输入"
  39. style="width: 60%; margin-right: 10px"
  40. :disabled="!!row.productCode"
  41. ></el-input>
  42. <el-button
  43. size="small"
  44. type="primary"
  45. @click.native="handParent(row, $index)"
  46. >选择</el-button
  47. >
  48. </el-form-item>
  49. </template>
  50. <template v-slot:productCode="scope">
  51. <el-form-item
  52. style="margin-bottom: 20px"
  53. :prop="'datasource.' + scope.$index + '.productCode'"
  54. >
  55. <el-input v-model="scope.row.productCode" disabled></el-input>
  56. </el-form-item>
  57. </template>
  58. <template v-slot:productCategoryName="scope">
  59. <el-form-item
  60. style="margin-bottom: 20px"
  61. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  62. >
  63. <el-input v-model="scope.row.productCategoryName" disabled></el-input>
  64. </el-form-item>
  65. </template>
  66. <template v-slot:totalCount="scope">
  67. <el-form-item
  68. style="margin-bottom: 20px"
  69. :prop="'datasource.' + scope.$index + '.totalCount'"
  70. :rules="{
  71. required: true,
  72. pattern: numberReg,
  73. message: '请输入数字',
  74. trigger: 'blur'
  75. }"
  76. >
  77. <el-input
  78. v-model="scope.row.totalCount"
  79. placeholder="请输入"
  80. ></el-input>
  81. </el-form-item>
  82. </template>
  83. <template v-slot:productBrand="scope">
  84. <el-form-item
  85. style="margin-bottom: 20px"
  86. :prop="'datasource.' + scope.$index + '.productBrand'"
  87. >
  88. <el-input
  89. v-model="scope.row.productBrand"
  90. :disabled="!!scope.row.productCode"
  91. ></el-input>
  92. </el-form-item>
  93. </template>
  94. <template v-slot:brand="scope">
  95. <el-form-item
  96. style="margin-bottom: 20px"
  97. :prop="'datasource.' + scope.$index + '.brand'"
  98. >
  99. <el-input v-model="scope.row.brand"></el-input>
  100. </el-form-item>
  101. </template>
  102. <template v-slot:modelType="scope">
  103. <el-form-item
  104. style="margin-bottom: 20px"
  105. :prop="'datasource.' + scope.$index + '.modelType'"
  106. >
  107. <el-input
  108. v-model="scope.row.modelType"
  109. :disabled="!!scope.row.productCode"
  110. ></el-input>
  111. </el-form-item>
  112. </template>
  113. <template v-slot:specification="scope">
  114. <el-form-item
  115. style="margin-bottom: 20px"
  116. :prop="'datasource.' + scope.$index + '.specification'"
  117. >
  118. <el-input
  119. v-model="scope.row.specification"
  120. :disabled="!!scope.row.productCode"
  121. ></el-input>
  122. </el-form-item>
  123. </template>
  124. <template v-slot:measuringUnit="scope">
  125. <el-form-item
  126. style="margin-bottom: 20px"
  127. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  128. >
  129. <el-input
  130. v-model="scope.row.measuringUnit"
  131. placeholder="请输入"
  132. :disabled="!!scope.row.productCode"
  133. ></el-input>
  134. </el-form-item>
  135. </template>
  136. <template v-slot:remark="scope">
  137. <el-form-item
  138. style="margin-bottom: 20px"
  139. :prop="'datasource.' + scope.$index + '.remark'"
  140. >
  141. <el-input
  142. v-model="scope.row.remark"
  143. type="textarea"
  144. placeholder="请输入"
  145. ></el-input>
  146. </el-form-item>
  147. </template>
  148. <template v-slot:technicalAnswerName="{ row, $index }">
  149. <el-form-item
  150. style="margin-bottom: 20px"
  151. :prop="'datasource.' + $index + '.technicalAnswerName'"
  152. :rules="{
  153. required: false,
  154. message: '请输入',
  155. trigger: 'change'
  156. }"
  157. >
  158. <el-input
  159. v-model="row.technicalAnswerName"
  160. placeholder="请输入"
  161. @click.native="handHead(row, $index)"
  162. ></el-input>
  163. </el-form-item>
  164. </template>
  165. <template v-slot:technicalParams="scope">
  166. <el-form-item
  167. style="margin-bottom: 20px"
  168. :prop="'datasource.' + scope.$index + '.technicalParams'"
  169. :rules="{
  170. required: false,
  171. message: '请输入',
  172. trigger: 'change'
  173. }"
  174. >
  175. <el-input
  176. type="textarea"
  177. v-model="scope.row.technicalParams"
  178. placeholder="请输入"
  179. ></el-input>
  180. </el-form-item>
  181. </template>
  182. <template v-slot:files="scope">
  183. <el-form-item
  184. style="margin-bottom: 20px"
  185. :prop="'datasource.' + scope.$index + '.files'"
  186. >
  187. <fileMain v-model="scope.row.files" ></fileMain>
  188. <!-- <fileUpload-->
  189. <!-- v-model="scope.row.files"-->
  190. <!-- module="main"-->
  191. <!-- :showLib="false"-->
  192. <!-- :limit="5"-->
  193. <!-- />-->
  194. </el-form-item>
  195. </template>
  196. <template v-slot:technicalDrawings="scope">
  197. <el-form-item
  198. style="margin-bottom: 20px"
  199. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  200. >
  201. <fileMain v-model="scope.row.technicalDrawings" ></fileMain>
  202. <!-- <fileUpload-->
  203. <!-- v-model="scope.row.technicalDrawings"-->
  204. <!-- module="main"-->
  205. <!-- :showLib="false"-->
  206. <!-- :limit="5"-->
  207. <!-- />-->
  208. </el-form-item>
  209. </template>
  210. <template v-slot:expectReceiveDate="scope">
  211. <el-form-item
  212. v-if="scope.row.arrivalWay == 1"
  213. style="margin-bottom: 20px"
  214. :prop="'datasource.' + scope.$index + '.expectReceiveDate'"
  215. :rules="{
  216. required: true,
  217. message: '请选择日期',
  218. trigger: 'blur'
  219. }"
  220. >
  221. <el-date-picker
  222. style="width: 100%"
  223. clearable
  224. v-model="scope.row.expectReceiveDate"
  225. type="date"
  226. value-format="yyyy-MM-dd"
  227. placeholder="请选择日期"
  228. >
  229. </el-date-picker>
  230. </el-form-item>
  231. <el-form-item
  232. style="margin-bottom: 20px"
  233. v-if="scope.row.arrivalWay == 2"
  234. >
  235. <el-link
  236. type="primary"
  237. :underline="false"
  238. @click.native="handleMethod(scope.row)"
  239. >
  240. 设置分批时间
  241. </el-link>
  242. </el-form-item>
  243. </template>
  244. <template v-slot:arrivalWay="scope">
  245. <el-form-item
  246. :prop="'datasource.' + scope.$index + '.arrivalWay'"
  247. :rules="{
  248. required: true,
  249. message: '请选择',
  250. trigger: 'blur'
  251. }"
  252. >
  253. <el-select
  254. v-model="scope.row.arrivalWay"
  255. clearable
  256. style="width: 100%"
  257. >
  258. <el-option
  259. v-for="item in arrivalWayList"
  260. :key="item.value"
  261. :label="item.label"
  262. :value="item.value"
  263. >
  264. </el-option>
  265. </el-select>
  266. </el-form-item>
  267. </template>
  268. <!-- 操作列 -->
  269. <template v-slot:action="scope">
  270. <el-popconfirm
  271. class="ele-action"
  272. title="确定要删除吗?"
  273. @confirm="remove(scope.$index)"
  274. >
  275. <template v-slot:reference>
  276. <el-link type="danger" :underline="false" icon="el-icon-delete">
  277. 删除
  278. </el-link>
  279. </template>
  280. </el-popconfirm>
  281. </template>
  282. </ele-pro-table>
  283. <product-list
  284. ref="productListRef"
  285. :isSole="true"
  286. @changeParent="changeParent"
  287. ></product-list>
  288. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  289. <timeDialog @chooseTime="chooseTime" ref="timeDialogRef"></timeDialog>
  290. </el-form>
  291. </template>
  292. <script>
  293. import { numberReg } from 'ele-admin';
  294. import productList from '@/views/bpm/handleTask/components/quotation/product-list.vue';
  295. import dictMixins from '@/mixins/dictMixins';
  296. import fileUpload from '@/components/upload/fileUpload';
  297. import headList from '@/components/headList';
  298. import timeDialog from '@/components/timeDialog/index.vue';
  299. import fileMain from "@/components/addDoc/index.vue";
  300. export default {
  301. mixins: [dictMixins],
  302. components: {
  303. fileMain,
  304. productList,
  305. fileUpload,
  306. headList,timeDialog
  307. },
  308. data() {
  309. const defaultForm = {
  310. key: null,
  311. endTime: '',
  312. isFirst: 0,
  313. name: ''
  314. };
  315. return {
  316. arrivalWayList: [
  317. { label: '一次性到货', value: 1 },
  318. { label: '分批到货', value: 2 }
  319. ],
  320. numberReg,
  321. defaultForm,
  322. form: {
  323. datasource: []
  324. },
  325. rules: {},
  326. columns: [
  327. {
  328. width: 45,
  329. type: 'index',
  330. columnKey: 'index',
  331. align: 'center',
  332. fixed: 'left'
  333. },
  334. {
  335. width: 150,
  336. prop: 'productCategoryName',
  337. label: '分类',
  338. slot: 'productCategoryName'
  339. },
  340. {
  341. width: 140,
  342. prop: 'productCode',
  343. label: '编码',
  344. slot: 'productCode'
  345. },
  346. {
  347. width: 240,
  348. prop: 'productName',
  349. label: '名称',
  350. slot: 'productName'
  351. },
  352. {
  353. width: 150,
  354. prop: 'productBrand',
  355. label: '牌号',
  356. slot: 'productBrand'
  357. },
  358. {
  359. width: 130,
  360. prop: 'modelType',
  361. label: '型号',
  362. slot: 'modelType'
  363. },
  364. {
  365. width: 120,
  366. prop: 'specification',
  367. label: '规格',
  368. slot: 'specification'
  369. },
  370. {
  371. width: 80,
  372. prop: 'totalCount',
  373. label: '数量',
  374. slot: 'totalCount'
  375. },
  376. {
  377. width: 100,
  378. prop: 'measuringUnit',
  379. label: '单位',
  380. slot: 'measuringUnit'
  381. },
  382. {
  383. width: 130,
  384. prop: 'brand',
  385. label: '品牌',
  386. slot: 'brand'
  387. },
  388. {
  389. width: 160,
  390. prop: 'arrivalWay',
  391. label: '到货方式',
  392. slot: 'arrivalWay',
  393. headerSlot: 'headerArrivalWay'
  394. },
  395. {
  396. width: 170,
  397. prop: 'expectReceiveDate',
  398. label: '到货日期',
  399. slot: 'expectReceiveDate',
  400. headerSlot: 'headerExpectReceiveDate'
  401. },
  402. {
  403. width: 160,
  404. prop: 'technicalDrawings',
  405. label: '图纸附件',
  406. slot: 'technicalDrawings'
  407. },
  408. {
  409. width: 140,
  410. prop: 'files',
  411. label: '附件',
  412. slot: 'files'
  413. },
  414. {
  415. width: 220,
  416. prop: 'remark',
  417. label: '备注',
  418. slot: 'remark'
  419. },
  420. {
  421. columnKey: 'action',
  422. label: '操作',
  423. width: 120,
  424. align: 'center',
  425. resizable: false,
  426. slot: 'action',
  427. fixed: 'right',
  428. showOverflowTooltip: true
  429. }
  430. ]
  431. };
  432. },
  433. methods: {
  434. // 返回列表数据
  435. getTableValue() {
  436. let comitDatasource = this.form.datasource;
  437. if (comitDatasource.length === 0) return [];
  438. comitDatasource.forEach((v) => {
  439. v.totalPrice = (v.totalCount * v.singlePrice)?.toFixed(2) || 0;
  440. v.files = v.files || [];
  441. v.technicalDrawings = v.technicalDrawings || [];
  442. v.arrivalBatch = v.arrivalBatch || [];
  443. });
  444. return comitDatasource;
  445. },
  446. //修改回显
  447. putTableValue(data) {
  448. if (data && data?.length) {
  449. this.form.datasource = data;
  450. }
  451. },
  452. handleMethod(row) {
  453. this.$refs.timeDialogRef.open(row);
  454. },
  455. chooseTime(row, arrivalBatch) {
  456. row.arrivalBatch = copyObj(arrivalBatch);
  457. console.log(row, 'row');
  458. },
  459. //选择产品
  460. handParent(row, index) {
  461. // let item = {
  462. // id: row.productCode
  463. // };
  464. this.$refs.productListRef.open(this.form.datasource, index);
  465. },
  466. //选择技术人回调
  467. changeAnswer(obj, idx) {
  468. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  469. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  470. },
  471. handHead(row, index) {
  472. let item = {
  473. id: row.technicalAnswerId
  474. };
  475. this.$refs.headRef.open(item, index);
  476. },
  477. //选择产品回调
  478. changeParent(obj, idx) {
  479. // if (
  480. // obj.code &&
  481. // this.form.datasource
  482. // .map((item) => item.productCode)
  483. // .includes(obj.code)
  484. // ) {
  485. // this.$message.warning('不能选择重复的产品');
  486. // return;
  487. // }
  488. this.$set(this.form.datasource[idx], 'id', obj.id);
  489. this.$set(this.form.datasource[idx], 'categoryName', obj.name);
  490. this.$set(
  491. this.form.datasource[idx],
  492. 'productCategoryId',
  493. obj.categoryLevelId
  494. );
  495. this.$set(this.form.datasource[idx], 'productBrand', obj.brandNum);
  496. this.$set(
  497. this.form.datasource[idx],
  498. 'productCategoryName',
  499. obj.categoryLevelPath
  500. );
  501. this.$set(this.form.datasource[idx], 'productCode', obj.code);
  502. this.$set(this.form.datasource[idx], 'productName', obj.name);
  503. this.$set(this.form.datasource[idx], 'modelType', obj.modelType);
  504. this.$set(
  505. this.form.datasource[idx],
  506. 'measuringUnit',
  507. obj.measuringUnit
  508. );
  509. this.$set(
  510. this.form.datasource[idx],
  511. 'specification',
  512. obj.specification
  513. );
  514. this.$set(this.form.datasource[idx], 'remark', '');
  515. },
  516. remove(i) {
  517. this.form.datasource.splice(i, 1);
  518. this.setSort();
  519. },
  520. // 清空表格
  521. restTable() {
  522. this.form.datasource = [];
  523. },
  524. // 重新排序
  525. setSort() {
  526. this.form.datasource.forEach((n, index) => {
  527. n.key = index + 1;
  528. });
  529. },
  530. // 添加
  531. handlAdd() {
  532. let item = JSON.parse(JSON.stringify(this.defaultForm));
  533. item.key = this.form.datasource.length + 1;
  534. this.form.datasource.push(item);
  535. },
  536. validateForm(callback) {
  537. //开始表单校验
  538. this.$refs.form.validate((valid) => {
  539. callback(valid);
  540. });
  541. }
  542. }
  543. };
  544. </script>
  545. <style lang="scss" scoped>
  546. .headbox {
  547. display: flex;
  548. justify-content: space-between;
  549. align-items: center;
  550. .amount {
  551. font-size: 14px;
  552. font-weight: bold;
  553. }
  554. }
  555. .time-form .el-form-item {
  556. margin-bottom: 0 !important;
  557. }
  558. ::v-deep .period {
  559. display: flex;
  560. .borderleftnone {
  561. .el-input--medium .el-input__inner {
  562. border-top-right-radius: 0;
  563. border-bottom-right-radius: 0;
  564. }
  565. }
  566. .borderrightnone {
  567. .el-input--medium .el-input__inner {
  568. border-top-left-radius: 0;
  569. border-bottom-left-radius: 0;
  570. }
  571. }
  572. }
  573. ::v-deep .time-form tbody > tr:hover > td {
  574. background-color: transparent !important;
  575. }
  576. ::v-deep .time-form .el-table tr {
  577. background-color: #ffffff;
  578. }
  579. </style>