index.vue 5.4 KB

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