index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <script>
  2. import { TableColumns, SearchColumns } from "./column";
  3. import { LIST } from "@/api/business/purchase/catalogue";
  4. import { initPage, initLayout, initPageSizes, initParams } from "@/utils/init";
  5. export default {
  6. name: "PuchaseCatalogue",
  7. components: {
  8. // AddDrawer: () => import("./add/index.vue"),
  9. // SeeDrawer: () => 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() {
  55. this.fetchList(this.params, this.page);
  56. },
  57. // 重置操作
  58. resetList() {
  59. this.page = initPage();
  60. this.params = initParams(SearchColumns);
  61. this.fetchList(this.params, this.page);
  62. },
  63. // 页大小变
  64. sizeChange(prop) {
  65. this.page.pageSize = prop;
  66. this.fetchList(this.params, this.page);
  67. },
  68. // 当前页变
  69. currentChange(prop) {
  70. this.page.pageNum = prop;
  71. this.fetchList(this.params, this.page);
  72. },
  73. // 打开编辑dialog
  74. async openEditDialog(prop) {
  75. return;
  76. const { open } = this.$refs.Editdialog;
  77. await open(prop);
  78. },
  79. },
  80. };
  81. </script>
  82. <template>
  83. <el-card
  84. v-loading="loading"
  85. style="width: calc(100% - 24px); height: 100%; margin: 10px"
  86. :body-style="{ padding: 0 }"
  87. >
  88. <!-- <see-drawer ref="SeeDrawerFef"></see-drawer> -->
  89. <!-- <add-drawer ref="AddDrawerFef" @close="resetList"></add-drawer> -->
  90. <edit-dialog ref="Editdialog" @submit-success="resetList"></edit-dialog>
  91. <el-form
  92. :size="size"
  93. :model="params"
  94. label-width="auto"
  95. label-position="right"
  96. style="padding: 20px 0 0"
  97. >
  98. <el-row style="display: flex; flex-wrap: wrap">
  99. <el-col :span="22">
  100. <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
  101. <el-col
  102. v-for="column in searchColumns"
  103. :key="column.title"
  104. :span="column.span || 6"
  105. >
  106. <el-form-item :prop="column.key" :label="column.title">
  107. <el-input
  108. v-if="column.inputType === 'Input'"
  109. v-model="params[column.key]"
  110. :placeholder="column.placeholder"
  111. style="width: 100%"
  112. ></el-input>
  113. <el-switch
  114. v-if="column.inputType === 'Switch'"
  115. v-model="params[column.key]"
  116. active-value="1"
  117. inactive-value="0"
  118. >
  119. </el-switch>
  120. <dr-popover-select
  121. v-if="column.inputType === 'PopoverSelect'"
  122. v-model="params[column.key]"
  123. :size="size"
  124. :source.sync="params"
  125. :title="column.title"
  126. :type="column.referName"
  127. :multiple="column.multiple"
  128. :readonly="column.readonly"
  129. :value-key="column.valueKey"
  130. :placeholder="column.placeholder"
  131. :data-mapping="column.dataMapping"
  132. >
  133. </dr-popover-select>
  134. </el-form-item>
  135. </el-col>
  136. </el-row>
  137. </el-col>
  138. <el-col :span="1" :offset="1">
  139. <el-row style="display: flex; flex-wrap: wrap">
  140. <el-col :span="24" style="margin-bottom: 20px">
  141. <el-button
  142. circle
  143. :size="size"
  144. icon="el-icon-search"
  145. @click="queryList(params, page)"
  146. ></el-button>
  147. </el-col>
  148. <el-col :span="24">
  149. <el-button
  150. circle
  151. :size="size"
  152. icon="el-icon-refresh"
  153. @click="resetList"
  154. ></el-button>
  155. </el-col>
  156. </el-row>
  157. </el-col>
  158. </el-row>
  159. </el-form>
  160. <el-table
  161. @row-dblclick="openEditDialog"
  162. :data="tableData"
  163. :size="size"
  164. style="width: 100%; margin: 20px 0 0 0"
  165. >
  166. <el-table-column
  167. v-for="(column, index) in tableColumns"
  168. :key="index"
  169. :prop="column.key"
  170. :label="column.title"
  171. :width="column.width || 180"
  172. :show-overflow-tooltip="column.showOverflowTooltip || true"
  173. >
  174. </el-table-column>
  175. </el-table>
  176. <el-pagination
  177. @size-change="sizeChange"
  178. @current-change="currentChange"
  179. :total="page.total"
  180. :page-sizes="pageSizes"
  181. :page-size="page.pageSize"
  182. :current-page="page.pageNum"
  183. :layout="layout"
  184. style="margin: 16px 0"
  185. >
  186. </el-pagination>
  187. </el-card>
  188. </template>