index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <script>
  2. import { dicts } from "./dicts";
  3. import { TableColumns, SearchColumns } from "./columns";
  4. import { LIST } from "@/api/business/purchase/catalogue";
  5. export default {
  6. name: "PuchaseCatalogue",
  7. dicts: dicts,
  8. components: {
  9. SeeButton: () => import("./see/index.vue"),
  10. InvButton: () => import("./invalid/index.vue"),
  11. EnaButton: () => import("./enable/index.vue"),
  12. ExpButton: () => import("./export/index.vue"),
  13. ElSuperTable: () => import("@/components/super-table/index.vue"),
  14. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  15. },
  16. data() {
  17. const params = this.$init.params(SearchColumns);
  18. return {
  19. size: "mini",
  20. loading: false,
  21. params: params,
  22. tableData: [],
  23. selectData: [],
  24. SearchColumns: SearchColumns,
  25. TableColumns: TableColumns,
  26. page: { pageNum: 1, pageSize: 10, total: 0 },
  27. };
  28. },
  29. computed: {},
  30. created() {
  31. this.useQuery(this.params, this.page);
  32. },
  33. methods: {
  34. //
  35. async fetchList(prop, page) {
  36. try {
  37. this.loading = true;
  38. const { pageNum, pageSize } = page;
  39. const { code, rows, total } = await LIST(
  40. { ...prop },
  41. { pageNum, pageSize }
  42. );
  43. if (code === 200) {
  44. this.tableData = rows.map((item, index) => ({
  45. ...item,
  46. $index: (pageNum - 1) * pageSize + index + 1,
  47. }));
  48. this.page.total = total;
  49. }
  50. } catch (err) {
  51. // catch
  52. } finally {
  53. // finally
  54. this.loading = false;
  55. }
  56. },
  57. // 查 询
  58. useQuery(prop, page) {
  59. this.selectData = [];
  60. this.fetchList(prop, page);
  61. },
  62. // 重 置
  63. useReset() {
  64. this.page.pageNum = 1;
  65. this.page.pageSize = 10;
  66. this.params = this.$init.params(SearchColumns);
  67. this.useQuery(this.params, this.page);
  68. },
  69. // 选 择
  70. useSelect(prop) {
  71. this.selectData = prop;
  72. },
  73. // 明 细
  74. async useSee(prop) {
  75. const { $index } = prop;
  76. const { open } = this.$refs.SeeButton;
  77. await open($index);
  78. },
  79. },
  80. };
  81. </script>
  82. <template>
  83. <el-card v-loading="loading" :body-style="{ padding: 0 }">
  84. <el-super-search
  85. v-model="params"
  86. :size="size"
  87. :dict="dict"
  88. :columns="SearchColumns"
  89. @reset="useReset"
  90. @submit="useQuery(params, page)"
  91. ></el-super-search>
  92. <div style="padding: 0 20px; text-align: right">
  93. <el-button-group>
  94. <ena-button
  95. :size="size"
  96. :select-data="selectData"
  97. status="Y"
  98. @success="useQuery(params, page)"
  99. ></ena-button>
  100. <ena-button
  101. :size="size"
  102. :select-data="selectData"
  103. status="N"
  104. @success="useQuery(params, page)"
  105. ></ena-button>
  106. </el-button-group>
  107. <el-button-group>
  108. <inv-button
  109. :size="size"
  110. :select-data="selectData"
  111. @success="useQuery(params, page)"
  112. ></inv-button>
  113. <see-button
  114. v-show="false"
  115. ref="SeeButton"
  116. :size="size"
  117. :dict="dict"
  118. :select-data="selectData"
  119. @success="useQuery(params, page)"
  120. ></see-button
  121. ></el-button-group>
  122. <el-button-group>
  123. <exp-button
  124. :size="size"
  125. :page="page"
  126. :data="params"
  127. @success="useQuery(params, page)"
  128. ></exp-button>
  129. </el-button-group>
  130. </div>
  131. <el-super-table
  132. v-model="tableData"
  133. :size="size"
  134. :dict="dict"
  135. :columns="TableColumns"
  136. stroage
  137. hideOperationColumns
  138. @row-dblclick="useSee"
  139. @selection-change="useSelect"
  140. >
  141. <el-table-column fixed width="55" align="center" type="selection">
  142. </el-table-column>
  143. </el-super-table>
  144. <pagination
  145. :total="page.total"
  146. :page.sync="page.pageNum"
  147. :limit.sync="page.pageSize"
  148. @pagination="useQuery(params, page)"
  149. style="margin: 20px"
  150. />
  151. </el-card>
  152. </template>
  153. <style scoped lang="scss">
  154. .el-card {
  155. width: calc(100% - 20px);
  156. height: 100%;
  157. margin: 10px;
  158. padding: 0 0 20px 0;
  159. }
  160. .el-button-group + .el-button-group {
  161. margin: 0 0 0 10px;
  162. }
  163. </style>