billDetailDialog.vue 5.6 KB

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