index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <script>
  2. import { TableColumns, SearchColumns } from "./column";
  3. import { LIST, REMOVE } from "@/api/business/purchase/apply";
  4. import { initPage, initLayout, initPageSizes, initParams } from "@/utils/init";
  5. export default {
  6. name: "PuchaseApply",
  7. components: {
  8. AddDialog: () => import("./add/index.vue"),
  9. SeeDialog: () => import("./see/index.vue"),
  10. // Editdialog: () => import("./edit/index.vue"),
  11. },
  12. data() {
  13. return {
  14. size: "mini",
  15. loading: false,
  16. searchColumns: SearchColumns,
  17. params: initParams(SearchColumns),
  18. tableData: [],
  19. tableColumns: TableColumns,
  20. page: initPage(),
  21. layout: initLayout(),
  22. pageSizes: initPageSizes(),
  23. };
  24. },
  25. computed: {},
  26. created() {
  27. this.queryList(this.params, this.page);
  28. },
  29. methods: {
  30. //
  31. async fetchList(prop, page) {
  32. try {
  33. this.loading = true;
  34. const { pageNum, pageSize } = page;
  35. const { code, msg, rows, total } = await LIST({
  36. pageNum,
  37. pageSize,
  38. ...prop,
  39. });
  40. if (code === 200) {
  41. this.tableData = rows;
  42. this.page.total = total;
  43. this.$notify.success({ title: msg });
  44. } else {
  45. this.$notify.warning({ title: msg });
  46. }
  47. } catch (err) {
  48. //
  49. } finally {
  50. this.loading = false;
  51. }
  52. },
  53. // 查询操作
  54. queryList(prop, page) {
  55. this.fetchList(prop, page);
  56. },
  57. // 重置操作
  58. resetList() {
  59. this.page = initPage();
  60. this.params = initParams(SearchColumns);
  61. this.queryList(this.params, this.page);
  62. },
  63. // 删除操作
  64. async deleteItem(prop) {
  65. try {
  66. this.loading = true;
  67. const { id } = prop;
  68. const { code, msg } = await REMOVE(id);
  69. if (code === 200) {
  70. this.$notify.success({ title: msg });
  71. this.queryList(this.params, this.page);
  72. } else {
  73. this.$notify.warning({ title: msg });
  74. }
  75. } catch (err) {
  76. //
  77. } finally {
  78. this.loading = false;
  79. }
  80. },
  81. // 页大小变
  82. sizeChange(prop) {
  83. this.page.pageSize = prop;
  84. this.queryList(this.params, this.page);
  85. },
  86. // 当前页变
  87. currentChange(prop) {
  88. this.page.pageNum = prop;
  89. this.queryList(this.params, this.page);
  90. },
  91. // 打开新增dialog
  92. async openAddDialog(prop) {
  93. const { open } = this.$refs.AddDialog;
  94. await open(prop);
  95. },
  96. // 打开查看dialog
  97. async openSeeDialog(prop) {
  98. const { id } = prop;
  99. const { open } = this.$refs.SeeDialog;
  100. await open(id);
  101. },
  102. // 打开编辑dialog
  103. async openEditDialog(prop) {
  104. const { id } = prop;
  105. const { setVisible, fetchItem } = this.$refs.EditdialogFef;
  106. await setVisible(true);
  107. await fetchItem(id);
  108. },
  109. },
  110. };
  111. </script>
  112. <template>
  113. <el-card
  114. v-loading="loading"
  115. style="width: calc(100% - 24px); height: 100%; margin: 10px"
  116. :body-style="{ padding: 0 }"
  117. >
  118. <see-dialog ref="SeeDialog"></see-dialog>
  119. <add-dialog ref="AddDialog" @submit-success="resetList"></add-dialog>
  120. <!-- <edit-dialog ref="EditdialogFef" @close="resetList"></edit-dialog> -->
  121. <el-form
  122. :size="size"
  123. :model="params"
  124. label-width="75px"
  125. label-position="right"
  126. style="padding: 20px 20px 0"
  127. >
  128. <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
  129. <el-col
  130. v-for="column in searchColumns"
  131. :key="column.title"
  132. :span="column.span || 6"
  133. >
  134. <el-form-item :prop="column.key" :label="column.title">
  135. <el-input
  136. v-model="params[column.key]"
  137. :placeholder="column.placeholder"
  138. ></el-input>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="8">
  142. <el-form-item label-width="0">
  143. <el-button
  144. circle
  145. :size="size"
  146. icon="el-icon-search"
  147. @click="queryList(params, page)"
  148. ></el-button>
  149. <el-button
  150. circle
  151. :size="size"
  152. icon="el-icon-refresh"
  153. @click="resetList"
  154. ></el-button>
  155. </el-form-item>
  156. </el-col>
  157. </el-row>
  158. </el-form>
  159. <el-table
  160. :size="size"
  161. :data="tableData"
  162. @row-dblclick="openSeeDialog"
  163. style="width: 100%; margin: 20px 0 0 0"
  164. >
  165. <el-table-column
  166. v-for="(column, index) in tableColumns"
  167. :key="index"
  168. :prop="column.key"
  169. :label="column.title"
  170. :width="column.width || 180"
  171. :show-overflow-tooltip="column.showOverflowTooltip || true"
  172. >
  173. </el-table-column>
  174. <el-table-column fixed="right" label="操作" width="200">
  175. <template slot-scope="scope">
  176. <el-button
  177. @click.native.prevent="openAddDialog(scope.row)"
  178. type="text"
  179. size="small"
  180. >
  181. 复 制
  182. </el-button>
  183. <el-button
  184. @click.native.prevent="editItem(scope.row)"
  185. type="text"
  186. size="small"
  187. >
  188. 编 辑
  189. </el-button>
  190. <el-button
  191. @click.native.prevent="deleteItem(scope.row)"
  192. type="text"
  193. size="small"
  194. >
  195. 删 除
  196. </el-button>
  197. </template>
  198. </el-table-column>
  199. </el-table>
  200. <el-pagination
  201. @size-change="sizeChange"
  202. @current-change="currentChange"
  203. :total="page.total"
  204. :page-sizes="pageSizes"
  205. :page-size="page.pageSize"
  206. :current-page="page.pageNum"
  207. :layout="layout"
  208. style="margin: 16px 0"
  209. >
  210. </el-pagination>
  211. </el-card>
  212. </template>