inventoryTable.vue 13 KB

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