inventoryTable.vue 14 KB

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