billDetailDialog.vue 5.7 KB

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