billDetailDialog.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="billDetailDialogFlag"
  6. title="详情"
  7. :close-on-click-modal="false"
  8. append-to-body
  9. width="70%"
  10. :before-close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <ele-pro-table
  15. ref="table"
  16. :needPage="false"
  17. :columns="columns"
  18. max-height="500px"
  19. :datasource="datasource"
  20. :span-method="objectSpanMethod"
  21. cache-key="systemRoleTableBillDetailDialog"
  22. class="time-form"
  23. :need-page="false"
  24. @header-dragend="handleHeaderDragend">
  25. </ele-pro-table>
  26. <div slot="footer" class="footer">
  27. <el-button @click="cancel">返回</el-button>
  28. </div>
  29. </ele-modal>
  30. </template>
  31. <script>
  32. import {getProductsNumberDetail} from "@/api/purchasingManage/purchaseOrder";
  33. import tabMixins from '@/mixins/tableColumnsMixin';
  34. // import fileMain from "@/components/addDoc/index.vue";
  35. export default {
  36. mixins: [tabMixins],
  37. name: "billDetailDialog",
  38. components: {
  39. // fileMain
  40. },
  41. props: {
  42. billDetailDialogFlag: {
  43. type: Boolean,
  44. default: false,
  45. },
  46. },
  47. data() {
  48. return {
  49. cacheKeyUrl: 'views_purchasingManage_purchaseOrder_components_billDetailDialog',
  50. arrName: {
  51. 1: 'requirementIds',
  52. 2: 'planIds',
  53. 3: 'inquiryIds',
  54. 4: 'contractIds',
  55. // 5: 'contractIds',
  56. // 6: 'contractIds',
  57. },
  58. spanArr: [],
  59. type: '',
  60. // 来源类型(1需求/2计划/3核价/4合同),已采下钻时由订单物料清单传入
  61. sourceRelationType: '',
  62. datasource: []
  63. };
  64. },
  65. computed: {
  66. columns() {
  67. this.columnsVersion; // mixin 触发重算
  68. return this.applyColumnWidth([
  69. {
  70. width: 45,
  71. type: 'index',
  72. columnKey: 'index',
  73. align: 'center',
  74. fixed: 'left'
  75. },
  76. {
  77. minWidth: 120,
  78. prop: 'relationType',
  79. label: '单据类型',
  80. align: "center"
  81. },
  82. {
  83. minWidth: 100,
  84. prop: 'sourceCode',
  85. label: '单据编码',
  86. align: "center"
  87. },
  88. {
  89. minWidth: 100,
  90. prop: 'sourceName',
  91. label: '单据名称',
  92. show: this.type != 5,
  93. align: "center"
  94. },
  95. {
  96. minWidth: 100,
  97. prop: 'productCode',
  98. label: '编码',
  99. align: "center"
  100. },
  101. {
  102. minWidth: 100,
  103. prop: 'productName',
  104. label: '名称',
  105. align: "center",
  106. },
  107. {
  108. minWidth: 100,
  109. prop: 'supplierName',
  110. show: this.type == 3,
  111. label: '供应商名称',
  112. align: "center",
  113. },
  114. {
  115. minWidth: 100,
  116. prop: 'supplierCode',
  117. show: this.type == 3,
  118. label: '供应商编码',
  119. align: "center",
  120. },
  121. // {
  122. // width: 80,
  123. // prop: 'doneTotalCount',
  124. // label: '已采数量',
  125. // slot: 'doneTotalCount',
  126. // headerSlot: 'doneTotalCount',
  127. // align: "center"
  128. //
  129. // },
  130. // {
  131. // width: 80,
  132. // prop: 'waitTotalCount',
  133. // label: '待采数量',
  134. // slot: 'waitTotalCount',
  135. // headerSlot: 'waitTotalCount',
  136. // align: "center"
  137. // },
  138. {
  139. minWidth: 80,
  140. prop: 'totalCount',
  141. label: '数量',
  142. align: "center",
  143. },
  144. {
  145. minWidth: 100,
  146. prop: 'weightUnit',
  147. label: '重量单位',
  148. align: "center",
  149. },
  150. {
  151. minWidth: 100,
  152. prop: 'measuringUnit',
  153. label: '计量单位',
  154. align: "center",
  155. },
  156. {
  157. minWidth: 140,
  158. prop: 'deliveryDeadline',
  159. label: this.type == 4 ? '客户期望交期' : '预计到货时间',
  160. align: "center",
  161. },
  162. ]);
  163. },
  164. },
  165. methods: {
  166. async open(row, type, sourceRelationType) {
  167. this.type = type
  168. // 来源类型(1需求/2计划/3核价/4合同),仅已采下钻使用:后端按它区分已采口径
  169. this.sourceRelationType = sourceRelationType
  170. await this.getInquiryData(row, type);
  171. this.getSpanArr()
  172. },
  173. async getInquiryData(row, type = 1) {
  174. let arrName = this.arrName[type]
  175. let params = {
  176. productCode: row.productCode,
  177. relationType: type,
  178. taskId: row.taskId,
  179. batchNo: row.batchNo,
  180. relationIds: this.type != 5 ? (row[arrName] || []) : ([...row.requirementIds, ...row.planIds, ...row.inquiryIds, ...row.contractIds] || [])
  181. }
  182. if (this.type == 5) {
  183. params.sourceRelationType = this.sourceRelationType
  184. }
  185. this.loading = true;
  186. try {
  187. this.datasource = await getProductsNumberDetail(params);
  188. } catch {
  189. this.datasource = [];
  190. }
  191. this.loading = false;
  192. },
  193. objectSpanMethod({row, column, rowIndex, columnIndex}) {
  194. if (this.columns[columnIndex]?.isMerge) {
  195. const _row = this.spanArr[rowIndex]?.sourceCode || 0;
  196. const _col = _row > 0 ? 1 : 0;
  197. return {
  198. rowspan: _row,
  199. colspan: _col
  200. };
  201. }
  202. return {
  203. rowspan: 1,
  204. colspan: 1
  205. };
  206. },
  207. getSpanArr() {
  208. let pos = 0;
  209. this.spanArr = [];
  210. this.datasource.forEach((item, index) => {
  211. if (index === 0) {
  212. let obj = {}
  213. this.columns.forEach(col => {
  214. if (col.isMerge) {
  215. obj[col.prop] = 1
  216. }
  217. });
  218. this.spanArr.push(obj);
  219. } else {
  220. let nameSame = item.sourceCode === this.datasource[index - 1].sourceCode;
  221. if (nameSame) {
  222. this.spanArr[pos].sourceCode += 1;
  223. this.spanArr.push({
  224. relationType: 0,
  225. sourceCode: 0,
  226. sourceName: 0,
  227. });
  228. } else {
  229. pos = index;
  230. let obj = {}
  231. this.columns.forEach(col => {
  232. if (col.isMerge) {
  233. obj[col.prop] = 1
  234. }
  235. });
  236. this.spanArr.push(obj);
  237. }
  238. }
  239. });
  240. },
  241. cancel() {
  242. this.$emit("update:billDetailDialogFlag", false);
  243. },
  244. }
  245. }
  246. </script>
  247. <style scoped lang="scss">
  248. </style>