billDetailDialog.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. >
  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 fileMain from "@/components/addDoc/index.vue";
  34. export default {
  35. name: "billDetailDialog",
  36. components: {fileMain},
  37. props: {
  38. billDetailDialogFlag: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. },
  43. data() {
  44. return {
  45. arrName: {
  46. 1: 'requirementIds',
  47. 2: 'planIds',
  48. 3: 'inquiryIds',
  49. 4: 'contractIds',
  50. // 5: 'contractIds',
  51. // 6: 'contractIds',
  52. },
  53. spanArr: [],
  54. type: '',
  55. datasource: []
  56. };
  57. },
  58. computed: {
  59. columns() {
  60. return [
  61. {
  62. width: 45,
  63. type: 'index',
  64. columnKey: 'index',
  65. align: 'center',
  66. fixed: 'left'
  67. },
  68. {
  69. minWidth: 120,
  70. prop: 'relationType',
  71. label: '单据类型',
  72. align: "center"
  73. },
  74. {
  75. minWidth: 100,
  76. prop: 'sourceCode',
  77. label: '单据编码',
  78. align: "center"
  79. },
  80. {
  81. minWidth: 100,
  82. prop: 'sourceName',
  83. label: '单据名称',
  84. show: this.type != 5,
  85. align: "center"
  86. },
  87. {
  88. minWidth: 100,
  89. prop: 'productCode',
  90. label: '编码',
  91. align: "center"
  92. },
  93. {
  94. minWidth: 100,
  95. prop: 'productName',
  96. label: '名称',
  97. align: "center",
  98. },
  99. {
  100. minWidth: 100,
  101. prop: 'supplierName',
  102. show: this.type == 3,
  103. label: '供应商名称',
  104. align: "center",
  105. },
  106. {
  107. minWidth: 100,
  108. prop: 'supplierCode',
  109. show: this.type == 3,
  110. label: '供应商编码',
  111. align: "center",
  112. },
  113. // {
  114. // width: 80,
  115. // prop: 'doneTotalCount',
  116. // label: '已采数量',
  117. // slot: 'doneTotalCount',
  118. // headerSlot: 'doneTotalCount',
  119. // align: "center"
  120. //
  121. // },
  122. // {
  123. // width: 80,
  124. // prop: 'waitTotalCount',
  125. // label: '待采数量',
  126. // slot: 'waitTotalCount',
  127. // headerSlot: 'waitTotalCount',
  128. // align: "center"
  129. // },
  130. {
  131. minWidth: 80,
  132. prop: 'totalCount',
  133. label: '数量',
  134. align: "center",
  135. },
  136. {
  137. minWidth: 100,
  138. prop: 'weightUnit',
  139. label: '重量单位',
  140. align: "center",
  141. },
  142. {
  143. minWidth: 100,
  144. prop: 'measuringUnit',
  145. label: '计量单位',
  146. align: "center",
  147. },
  148. {
  149. minWidth: 140,
  150. prop: 'deliveryDeadline',
  151. label: this.type == 4 ? '客户期望交期' : '预计到货时间',
  152. align: "center",
  153. },
  154. ]
  155. },
  156. },
  157. methods: {
  158. async open(row, type) {
  159. this.type = type
  160. await this.getInquiryData(row, type);
  161. this.getSpanArr()
  162. },
  163. async getInquiryData(row, type = 1) {
  164. let arrName = this.arrName[type]
  165. let params = {
  166. productCode: row.productCode,
  167. relationType: type,
  168. taskId: row.taskId,
  169. batchNo: row.batchNo,
  170. relationIds: this.type != 5 ? (row[arrName] || []) : ([...row.requirementIds, ...row.planIds, ...row.inquiryIds, ...row.contractIds] || [])
  171. }
  172. this.loading = true;
  173. try {
  174. this.datasource = await getProductsNumberDetail(params);
  175. } catch {
  176. this.datasource = [];
  177. }
  178. this.loading = false;
  179. },
  180. objectSpanMethod({row, column, rowIndex, columnIndex}) {
  181. if (this.columns[columnIndex]?.isMerge) {
  182. const _row = this.spanArr[rowIndex]?.sourceCode || 0;
  183. const _col = _row > 0 ? 1 : 0;
  184. return {
  185. rowspan: _row,
  186. colspan: _col
  187. };
  188. }
  189. return {
  190. rowspan: 1,
  191. colspan: 1
  192. };
  193. },
  194. getSpanArr() {
  195. let pos = 0;
  196. this.spanArr = [];
  197. this.datasource.forEach((item, index) => {
  198. if (index === 0) {
  199. let obj = {}
  200. this.columns.forEach(col => {
  201. if (col.isMerge) {
  202. obj[col.prop] = 1
  203. }
  204. });
  205. this.spanArr.push(obj);
  206. } else {
  207. let nameSame = item.sourceCode === this.datasource[index - 1].sourceCode;
  208. if (nameSame) {
  209. this.spanArr[pos].sourceCode += 1;
  210. this.spanArr.push({
  211. relationType: 0,
  212. sourceCode: 0,
  213. sourceName: 0,
  214. });
  215. } else {
  216. pos = index;
  217. let obj = {}
  218. this.columns.forEach(col => {
  219. if (col.isMerge) {
  220. obj[col.prop] = 1
  221. }
  222. });
  223. this.spanArr.push(obj);
  224. }
  225. }
  226. });
  227. },
  228. cancel() {
  229. this.$emit("update:billDetailDialogFlag", false);
  230. },
  231. }
  232. }
  233. </script>
  234. <style scoped lang="scss">
  235. </style>