inventoryTableDetails.vue 17 KB

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