inventoryTableDetails.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <el-form ref="form">
  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. <template v-slot:technicalDrawings="scope">
  13. <el-form-item
  14. style="margin-bottom: 20px"
  15. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  16. >
  17. <fileMain
  18. v-model="scope.row.technicalDrawings"
  19. type="view"
  20. ></fileMain>
  21. </el-form-item>
  22. </template>
  23. <template v-slot:customerReqFiles="scope">
  24. <el-form-item
  25. style="margin-bottom: 20px"
  26. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  27. >
  28. <fileMain v-model="scope.row.customerReqFiles" type="view"></fileMain>
  29. </el-form-item>
  30. </template>
  31. <template v-slot:industryArtFiles="scope">
  32. <el-form-item
  33. style="margin-bottom: 20px"
  34. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  35. >
  36. <fileMain v-model="scope.row.industryArtFiles" type="view"></fileMain>
  37. </el-form-item>
  38. </template>
  39. <template v-slot:otherFiles="scope">
  40. <el-form-item
  41. style="margin-bottom: 20px"
  42. :prop="'datasource.' + scope.$index + '. otherFiles'"
  43. >
  44. <fileMain v-model="scope.row.otherFiles" type="view"></fileMain>
  45. </el-form-item>
  46. </template>
  47. <!-- 表头工具栏 -->
  48. <template v-slot:toolbar>
  49. <div class="headbox">
  50. <div class="pricebox">
  51. <span class="amount" v-if="isAllPrice">总计:{{ allPrice }}元</span>
  52. <span class="amount" v-if="isDiscountTotalPrice"
  53. >优惠后总金额:{{ form.discountTotalPrice }}元</span
  54. >
  55. </div>
  56. </div>
  57. </template>
  58. </ele-pro-table>
  59. </el-form>
  60. </template>
  61. <script>
  62. import dictMixins from '@/mixins/dictMixins';
  63. import fileMain from '@/components/addDoc/index.vue';
  64. import { contactQueryByCategoryIdsAPI } from '@/api/bpm/components/supplierManage/contact';
  65. const dayjs = require('dayjs');
  66. import {lbjtList } from '@/enum/dict.js';
  67. export default {
  68. mixins: [dictMixins],
  69. components: {
  70. fileMain
  71. },
  72. props: {
  73. isDiscountTotalPrice: {
  74. default: false,
  75. type: Boolean
  76. },
  77. isDiscount: {
  78. //折让
  79. type: Boolean,
  80. default: true
  81. },
  82. isCustomerMark: {
  83. //客户代号必填
  84. type: Boolean,
  85. default: false
  86. },
  87. pageName: {
  88. default: ''
  89. },
  90. isChangeCount: {
  91. //默认计算
  92. type: Boolean,
  93. default: true
  94. },
  95. contractBookType: {
  96. //合同类型 1销售 2采购
  97. type: [String, Number],
  98. default: 1
  99. },
  100. isAllPrice: {
  101. //是否显示合计
  102. type: Boolean,
  103. default: true
  104. }
  105. },
  106. data() {
  107. return {
  108. allPrice: 0,
  109. form: {
  110. discountTotalPrice: 0,
  111. datasource: []
  112. }
  113. };
  114. },
  115. computed: {
  116. columns() {
  117. return [
  118. {
  119. width: 45,
  120. type: 'index',
  121. columnKey: 'index',
  122. align: 'center'
  123. },
  124. {
  125. width: 280,
  126. prop: 'productName',
  127. label: '名称',
  128. slot: 'productName',
  129. headerSlot: 'headerProductName',
  130. align: 'center'
  131. },
  132. {
  133. width: 120,
  134. prop: 'productCode',
  135. label: '编码',
  136. slot: 'productCode',
  137. align: 'center'
  138. },
  139. {
  140. width: 200,
  141. prop: 'productCategoryName',
  142. label: '类型',
  143. slot: 'productCategoryName',
  144. align: 'center'
  145. },
  146. {
  147. width: 120,
  148. prop: 'specification',
  149. label: '规格',
  150. slot: 'specification',
  151. align: 'center'
  152. },
  153. {
  154. width: 200,
  155. prop: 'customerMark',
  156. label: '客户代号',
  157. slot: 'customerMark',
  158. headerSlot: 'headerCustomerMark',
  159. align: 'center',
  160. show: this.contractBookType == 1
  161. },
  162. {
  163. width: 200,
  164. prop: 'customerMark',
  165. label: '供应商代号',
  166. slot: 'customerMark',
  167. headerSlot: 'headerSupplierMark',
  168. align: 'center',
  169. show: this.contractBookType == 2
  170. },
  171. {
  172. minWidth: 120,
  173. prop: 'entrustedEnterpriseId',
  174. label: '受托企业',
  175. slot: 'entrustedEnterpriseId',
  176. show: this.isCustomerMark,
  177. align: 'center',
  178. showOverflowTooltip: true,
  179. formatter: (row, column) => {
  180. return (
  181. (this.supplierObj &&
  182. this.supplierObj[row.productId]?.find(
  183. (item) => item.id === row.entrustedEnterpriseId
  184. )?.name) ||
  185. ''
  186. );
  187. }
  188. },
  189. {
  190. width: 150,
  191. prop: 'totalCount',
  192. label: '数量',
  193. slot: 'totalCount',
  194. headerSlot: 'headerTotalCount',
  195. align: 'center'
  196. },
  197. {
  198. width: 120,
  199. prop: 'measuringUnit',
  200. label: '计量单位',
  201. slot: 'measuringUnit',
  202. align: 'center'
  203. },
  204. {
  205. minWidth: 110,
  206. prop: 'sendTotalCount',
  207. label: '已发货数量',
  208. slot: 'sendTotalCount',
  209. show: this.pageName == 'send',
  210. align: 'center'
  211. },
  212. {
  213. minWidth: 110,
  214. prop: 'notSendTotalCount',
  215. label: '未发货数量',
  216. slot: 'notSendTotalCount',
  217. show: this.pageName == 'send',
  218. align: 'center'
  219. },
  220. {
  221. width: 120,
  222. prop: 'singleWeight',
  223. label: '单重',
  224. slot: 'singleWeight',
  225. headerSlot: 'headerSingleWeight',
  226. align: 'center'
  227. },
  228. {
  229. width: 120,
  230. prop: 'totalWeight',
  231. label: '总重',
  232. slot: 'totalWeight',
  233. align: 'center'
  234. },
  235. {
  236. width: 120,
  237. prop: 'weightUnit',
  238. label: '重量单位',
  239. slot: 'weightUnit',
  240. align: 'center'
  241. },
  242. {
  243. width: 160,
  244. prop: 'pricingWay',
  245. label: '计价方式',
  246. slot: 'pricingWay',
  247. align: 'center',
  248. formatter: (row, column) => {
  249. return row.pricingWay == 1
  250. ? '按数量计费'
  251. : row.pricingWay == 2
  252. ? '按重量计费'
  253. : '';
  254. }
  255. },
  256. {
  257. width: 200,
  258. prop: 'singlePrice',
  259. label: '单价',
  260. slot: 'singlePrice',
  261. headerSlot: 'headerSinglePrice',
  262. align: 'center'
  263. },
  264. {
  265. width: 160,
  266. prop: 'taxRate',
  267. label: '税率',
  268. formatter: (_row, _column, cellValue) => {
  269. return _row.taxRate
  270. ? _row.taxRate+'%'
  271. : '';
  272. },
  273. align: 'center'
  274. },
  275. {
  276. width: 160,
  277. prop: 'notaxSinglePrice',
  278. label: '不含税单价',
  279. align: 'center'
  280. },
  281. {
  282. width: 160,
  283. prop: 'discountSinglePrice',
  284. label: '折让单价',
  285. align: 'center',
  286. show: this.isDiscount,
  287. formatter: (_row, _column, cellValue) => {
  288. return _row.discountSinglePrice
  289. ? Number(_row.discountSinglePrice).toFixed(2)
  290. : '';
  291. }
  292. },
  293. {
  294. width: 120,
  295. prop: 'totalPrice',
  296. label: '合计',
  297. slot: 'totalPrice',
  298. align: 'center'
  299. },
  300. {
  301. width: 160,
  302. prop: 'discountTotalPrice',
  303. label: '折让合计',
  304. align: 'center',
  305. show: this.isDiscount,
  306. formatter: (_row, _column, cellValue) => {
  307. return _row.discountTotalPrice
  308. ? Number(_row.discountTotalPrice).toFixed(2)
  309. : '';
  310. }
  311. },
  312. {
  313. width: 160,
  314. prop: 'productBrand',
  315. label: '牌号',
  316. slot: 'productBrand',
  317. align: 'center'
  318. },
  319. {
  320. width: 120,
  321. prop: 'modelType',
  322. label: '型号',
  323. slot: 'modelType',
  324. align: 'center'
  325. },
  326. {
  327. width: 120,
  328. prop: 'imgCode',
  329. align: 'center',
  330. label: '图号/件号',
  331. showOverflowTooltip: true
  332. },
  333. {
  334. prop: 'provenance',
  335. label: '产地',
  336. slot: 'provenance',
  337. align: 'center',
  338. minWidth: 200,
  339. showOverflowTooltip: true,
  340. formatter: (row, column) => {
  341. return row.provenance && row.provenance.length
  342. ? row.provenance
  343. .map((item) => this.getDictValue('产地', item))
  344. .join(',')
  345. : '';
  346. }
  347. },
  348. {
  349. width: 120,
  350. prop: 'produceType',
  351. align: 'center',
  352. label: '属性类型',
  353. showOverflowTooltip: true,
  354. formatter: (row, column) => {
  355. if(row.produceType){
  356. return row.produceType.map(item=>{
  357. return lbjtList[item]
  358. }).toString()
  359. }
  360. }
  361. },
  362. {
  363. minWidth: 240,
  364. prop: 'taskName',
  365. label: '工序',
  366. slot: 'taskName',
  367. align: 'center'
  368. },
  369. {
  370. width: 120,
  371. prop: 'packingSpecification',
  372. align: 'center',
  373. label: '包装规格',
  374. showOverflowTooltip: true
  375. },
  376. {
  377. width: 160,
  378. prop: 'customerExpectDeliveryDeadline',
  379. label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
  380. slot: 'customerExpectDeliveryDeadline',
  381. headerSlot: 'headerCustomerExpectDeliveryDeadline',
  382. align: 'center'
  383. },
  384. {
  385. width: 160,
  386. prop: 'produceDeliveryDeadline',
  387. label: '生产交付交期',
  388. slot: 'produceDeliveryDeadline',
  389. headerSlot: 'headerProduceDeliveryDeadline',
  390. show: this.contractBookType == 1,
  391. align: 'center'
  392. },
  393. {
  394. width: 200,
  395. prop: 'guaranteePeriod',
  396. label: '质保期',
  397. slot: 'guaranteePeriod',
  398. headerSlot: 'headerCustomerExpectDeliveryDeadline',
  399. align: 'center',
  400. formatter: (_row, _column, cellValue) => {
  401. return (
  402. (_row.guaranteePeriod || '') + _row.guaranteePeriodUnitName
  403. );
  404. }
  405. },
  406. {
  407. width: 200,
  408. prop: 'guaranteePeriodDeadline',
  409. label: '质保期截止日期',
  410. slot: 'guaranteePeriodDeadline',
  411. align: 'center'
  412. },
  413. {
  414. width: 220,
  415. prop: 'customerReqFiles',
  416. label: '客户需求',
  417. slot: 'customerReqFiles',
  418. align: 'center'
  419. },
  420. {
  421. width: 130,
  422. prop: 'technicalAnswerName',
  423. label: '技术答疑人',
  424. slot: 'technicalAnswerName',
  425. align: 'center'
  426. },
  427. {
  428. width: 220,
  429. prop: 'technicalParams',
  430. label: '技术参数',
  431. slot: 'technicalParams',
  432. align: 'center'
  433. },
  434. {
  435. width: 240,
  436. prop: 'technicalDrawings',
  437. label: '技术图纸',
  438. slot: 'technicalDrawings',
  439. align: 'center'
  440. },
  441. {
  442. width: 240,
  443. prop: 'technologyRouteName',
  444. label: '工艺路线',
  445. slot: 'technologyRouteName',
  446. align: 'center'
  447. },
  448. {
  449. width: 240,
  450. prop: 'industryArtFiles',
  451. label: '工艺附件',
  452. slot: 'industryArtFiles',
  453. align: 'center'
  454. },
  455. {
  456. width: 240,
  457. prop: 'otherFiles',
  458. label: '其他附件',
  459. slot: 'otherFiles',
  460. align: 'center'
  461. },
  462. {
  463. width: 220,
  464. prop: 'remark',
  465. label: '备注',
  466. slot: 'remark',
  467. align: 'center'
  468. }
  469. ]
  470. }
  471. },
  472. created() {
  473. this.requestDict('生产类型');
  474. this.requestDict('产地');
  475. this.requestDict('保质期单位');
  476. },
  477. methods: {
  478. async getSupplierObj(productList, queryName) {
  479. try {
  480. let categoryIds = productList.map((item) => item[queryName]);
  481. return await contactQueryByCategoryIdsAPI({
  482. categoryIds,
  483. isQueryEE: 1
  484. });
  485. } catch (e) {
  486. return Promise.resolve({});
  487. }
  488. },
  489. // 返回列表数据
  490. getTableValue() {
  491. let comitDatasource = this.form.datasource;
  492. if (comitDatasource.length === 0) return [];
  493. comitDatasource.forEach((v) => {
  494. if (v.guaranteePeriodUnitCode) {
  495. v.guaranteePeriodUnitName = this.getDictValue(
  496. '保质期单位',
  497. v.guaranteePeriodUnitCode
  498. );
  499. }
  500. v.technicalDrawings = v.technicalDrawings ? v.technicalDrawings : [];
  501. v.customerReqFiles = v.customerReqFiles || [];
  502. v.industryArtFiles = v.industryArtFiles || [];
  503. v.otherFiles = v.otherFiles || [];
  504. });
  505. return comitDatasource;
  506. },
  507. setDeliveryDays() {
  508. console.log(this.form.datasource, 'this.form.datasource');
  509. this.form.datasource.forEach((item, i) => {
  510. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  511. item.guaranteePeriodUnitCode
  512. );
  513. this.$set(
  514. this.form.datasource[i],
  515. 'guaranteePeriodDeadline',
  516. guaranteePeriodUnitName != 'second'
  517. ? this.setDay(item.guaranteePeriod, guaranteePeriodUnitName)
  518. : ''
  519. );
  520. // }
  521. });
  522. },
  523. guaranteePeriodUnit(code) {
  524. return code == 3
  525. ? 'day'
  526. : code == 4
  527. ? 'month'
  528. : code == 5
  529. ? 'year'
  530. : 'second';
  531. },
  532. setDay(addDay, dateType = 'day') {
  533. console.log(addDay);
  534. return dayjs(this.contractStartDate || new Date())
  535. .add(addDay, dateType)
  536. .format('YYYY-MM-DD');
  537. },
  538. //修改回显
  539. async putTableValue(data) {
  540. console.log(data, 'dasdas');
  541. let productList =
  542. (data &&
  543. (data.quoteProductList || data.productList || data.detailList)) ||
  544. [];
  545. if (productList) {
  546. this.form.datasource = productList;
  547. this.allPrice =
  548. data.totalAmount || data.totalPrice || data?.contractVO?.totalPrice;
  549. if (this.isDiscountTotalPrice) {
  550. this.form.discountTotalPrice =
  551. data.payAmount ||
  552. data.discountTotalPrice ||
  553. data?.contractVO?.discountTotalPrice;
  554. }
  555. this.setDeliveryDays();
  556. this.supplierObj = await this.getSupplierObj(
  557. productList,
  558. 'productId'
  559. );
  560. this.$refs.table.reload();
  561. }
  562. }
  563. }
  564. };
  565. </script>
  566. <style lang="scss" scoped>
  567. .headbox {
  568. display: flex;
  569. justify-content: space-between;
  570. align-items: center;
  571. .amount {
  572. font-size: 14px;
  573. font-weight: bold;
  574. padding-right: 30px;
  575. }
  576. }
  577. .time-form .el-form-item {
  578. margin-bottom: 0 !important;
  579. }
  580. ::v-deep .period {
  581. display: flex;
  582. .borderleftnone {
  583. .el-input--medium .el-input__inner {
  584. border-top-right-radius: 0;
  585. border-bottom-right-radius: 0;
  586. }
  587. }
  588. .borderrightnone {
  589. .el-input--medium .el-input__inner {
  590. border-top-left-radius: 0;
  591. border-bottom-left-radius: 0;
  592. }
  593. }
  594. }
  595. ::v-deep .time-form tbody > tr:hover > td {
  596. background-color: transparent !important;
  597. }
  598. ::v-deep .time-form .el-table tr {
  599. background-color: #ffffff;
  600. }
  601. .pricebox {
  602. display: flex;
  603. justify-content: flex-start;
  604. align-items: center;
  605. font-weight: bold;
  606. }
  607. </style>