index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <script>
  2. import { dicts } from "./dicts";
  3. import useColumns 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 { TableColumns, SearchColumns } = useColumns();
  18. const params = this.$init.params(SearchColumns);
  19. return {
  20. size: "mini",
  21. loading: false,
  22. params: params,
  23. tableData: [],
  24. selectData: [],
  25. TableColumns: TableColumns,
  26. SearchColumns: SearchColumns,
  27. page: { pageNum: 1, pageSize: 20, total: 0 },
  28. };
  29. },
  30. computed: {},
  31. created() {
  32. this.useQuery(this.params, this.page);
  33. },
  34. methods: {
  35. //
  36. async fetchList(prop, page) {
  37. try {
  38. this.loading = true;
  39. const { pageNum, pageSize } = page;
  40. const { code, rows, total } = await LIST(
  41. { ...prop },
  42. { pageNum, pageSize }
  43. );
  44. if (code === 200) {
  45. this.tableData = rows.map((item, index) => ({
  46. ...item,
  47. $index: (pageNum - 1) * pageSize + index + 1,
  48. }));
  49. this.page.total = total;
  50. }
  51. } catch (err) {
  52. // catch
  53. } finally {
  54. // finally
  55. this.loading = false;
  56. }
  57. },
  58. // 查 询
  59. useQuery(prop, page) {
  60. const { invalid, createTime } = prop;
  61. const [invalidStart, invalidEnd] = invalid || [];
  62. const [createTimeStart, createTimeEnd] = createTime || [];
  63. this.fetchList(
  64. {
  65. ...prop,
  66. invalidStart,
  67. invalidEnd,
  68. createTimeStart,
  69. createTimeEnd,
  70. invalid: null,
  71. createTime: null,
  72. },
  73. page
  74. );
  75. },
  76. // 重 置
  77. useReset() {
  78. this.page.pageNum = 1;
  79. this.page.pageSize = 10;
  80. this.params = this.$init.params(this.SearchColumns);
  81. this.useQuery(this.params, this.page);
  82. },
  83. // 选 择
  84. useSelect(prop) {
  85. this.selectData = prop;
  86. },
  87. // 明 细
  88. async useSee(prop) {
  89. const { open } = this.$refs.SeeButton;
  90. await open([prop]);
  91. },
  92. },
  93. };
  94. </script>
  95. <template>
  96. <el-card
  97. v-loading="loading"
  98. :body-style="{
  99. height: '100%',
  100. padding: 0,
  101. display: 'flex',
  102. 'flex-direction': 'column',
  103. }"
  104. >
  105. <el-super-search
  106. v-model="params"
  107. :size="size"
  108. :dict="dict"
  109. :columns="SearchColumns"
  110. @reset="useReset"
  111. @submit="useQuery(params, page)"
  112. ></el-super-search>
  113. <div class="my-4" style="text-align: right">
  114. <el-button-group>
  115. <ena-button
  116. :size="size"
  117. :select-data="selectData"
  118. status="Y"
  119. @success="useQuery(params, page)"
  120. ></ena-button>
  121. <ena-button
  122. :size="size"
  123. :select-data="selectData"
  124. status="N"
  125. @success="useQuery(params, page)"
  126. ></ena-button>
  127. </el-button-group>
  128. <el-button-group>
  129. <inv-button
  130. ref="InvButton"
  131. :size="size"
  132. :select-data="selectData"
  133. @success="useQuery(params, page)"
  134. ></inv-button>
  135. <see-button
  136. v-show="false"
  137. ref="SeeButton"
  138. :size="size"
  139. :dict="dict"
  140. :select-data="selectData"
  141. @success="useQuery(params, page)"
  142. ></see-button
  143. ></el-button-group>
  144. <el-button-group>
  145. <exp-button
  146. :size="size"
  147. :select-data="selectData"
  148. @success="useQuery(params, page)"
  149. ></exp-button>
  150. </el-button-group>
  151. </div>
  152. <el-super-table
  153. v-model="tableData"
  154. :size="size"
  155. :dict="dict"
  156. :page="page"
  157. :columns="TableColumns"
  158. index
  159. checkbox
  160. pagination
  161. convenitentOperation
  162. storage-key="PuchaseCatalogueSuperTable1"
  163. @row-dblclick="useSee"
  164. @selection-change="useSelect"
  165. @pagination="useQuery(params, page)"
  166. >
  167. </el-super-table>
  168. </el-card>
  169. </template>
  170. <style scoped lang="scss">
  171. .el-card {
  172. width: calc(100% - 32px);
  173. height: calc(100vh - 32px);
  174. margin: 16px;
  175. padding: 16px;
  176. border-radius: 8px;
  177. }
  178. .el-button-group + .el-button-group {
  179. margin: 0 0 0 10px;
  180. }
  181. </style>