index.vue 5.1 KB

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