index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div class="snapshot-config-industry-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <vxe-grid v-bind="gridOptions" ref="gridRef">
  5. <template #form>
  6. <el-form :model="state.queryParams" ref="ruleFormRef" inline @submit.native.prevent :disabled="gridOptions.loading">
  7. <el-form-item label="行业名称" prop="Name">
  8. <el-input v-model="state.queryParams.Name" placeholder="请填写行业名称" clearable @keyup.enter="handleQuery" class="keyword-input" />
  9. </el-form-item>
  10. <el-form-item label="审批部门" prop="ApproveOrgName">
  11. <el-input v-model="state.queryParams.ApproveOrgName" placeholder="请填写审批部门" clearable @keyup.enter="handleQuery" class="keyword-input" />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  15. <el-button @click="resetQuery(ruleFormRef)" class="default-button"> <SvgIcon name="ele-Refresh" class="mr5" />重置 </el-button>
  16. </el-form-item>
  17. </el-form>
  18. </template>
  19. <template #toolbar_buttons>
  20. <el-button type="primary" @click="addIndustry" v-auth="'snapshot:config:industry:add'">
  21. <SvgIcon name="ele-Plus" class="mr5" />新增行业
  22. </el-button>
  23. </template>
  24. <template #action="{row}">
  25. <el-button link type="primary" @click="editIndustry(row)" v-auth="'snapshot:config:industry:edit'" title="编辑行业"> 编辑 </el-button>
  26. </template>
  27. <template #pager>
  28. <pagination
  29. @pagination="queryList"
  30. :total="state.total"
  31. v-model:current-page="state.queryParams.PageIndex"
  32. v-model:page-size="state.queryParams.PageSize"
  33. :disabled="state.loading"
  34. />
  35. </template>
  36. </vxe-grid>
  37. </div>
  38. <!-- 行业新增 -->
  39. <industry-add ref="industryAddRef" @updateList="queryList" />
  40. <!-- 行业编辑 -->
  41. <industry-edit ref="industryEditRef" @updateList="queryList" />
  42. </div>
  43. </template>
  44. <script lang="tsx" setup name="snapshotConfigIndustry">
  45. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  46. import { FormInstance } from 'element-plus';
  47. import { getIndustryList } from '@/api/snapshot/config';
  48. // 引入组件
  49. const IndustryAdd = defineAsyncComponent(() => import('@/views/snapshot/config/industry/components/Industry-add.vue')); // 行业新增
  50. const IndustryEdit = defineAsyncComponent(() => import('@/views/snapshot/config/industry/components/Industry-edit.vue')); // 行业修改
  51. const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
  52. // 定义变量内容
  53. const state = reactive<any>({
  54. loading: false,
  55. queryParams: {
  56. // 查询参数
  57. PageIndex: 1,
  58. PageSize: 20,
  59. Name: null, // 行业名称
  60. ApproveOrgName: null, // 审批部门名称
  61. },
  62. total: 0, // 总条数
  63. });
  64. const gridOptions = reactive<any>({
  65. loading: false,
  66. border: true,
  67. showOverflow: true,
  68. columnConfig: {
  69. resizable: true,
  70. },
  71. scrollY: {
  72. enabled: true,
  73. gt: 100,
  74. },
  75. toolbarConfig: {
  76. zoom: true,
  77. custom: true,
  78. refresh: {
  79. queryMethod: () => {
  80. handleQuery();
  81. },
  82. },
  83. slots: {
  84. buttons: 'toolbar_buttons',
  85. },
  86. },
  87. customConfig: {
  88. storage: true,
  89. },
  90. id: 'snapshotConfigIndustry',
  91. rowConfig: { isHover: true, height: 30, isCurrent: true, useKey: true },
  92. height: 'auto',
  93. columns: [
  94. {
  95. field: 'name',
  96. title: '行业名称',
  97. },
  98. {
  99. field: 'approveOrgName',
  100. title: '审批部门',
  101. },
  102. {
  103. field: 'citizenReadPackAmount',
  104. title: '市民红包',
  105. }, {
  106. field: 'guiderReadPackAmount',
  107. title: '网格员红包',
  108. },
  109. {
  110. field: 'isEnable',
  111. title: '启用状态',
  112. width: 100,
  113. slots: {
  114. default: ({ row }: any) => {
  115. return row.isEnable ? '启用' : '禁用';
  116. },
  117. },
  118. },
  119. {
  120. field: 'acceptType',
  121. title: '关联受理类型',
  122. },
  123. {
  124. field: 'titleSuffix',
  125. title: '标题追加信息',
  126. },
  127. {
  128. field: 'pageUrl',
  129. title: '页面URL',
  130. },
  131. {
  132. field: 'txtRemarks',
  133. title: '帮助说明',
  134. },
  135. {
  136. field: 'displayOrder',
  137. title: '排序',
  138. },
  139. {
  140. field: 'txtCareRemarks',
  141. title: '备注',
  142. },
  143. { title: '操作', width: 90, fixed: 'right', align: 'center', slots: { default: 'action' } },
  144. ],
  145. data: [],
  146. });
  147. const ruleFormRef = ref<any>(null); // 表单ref
  148. /** 搜索按钮操作 节流操作 */
  149. const handleQuery = () => {
  150. state.queryParams.PageIndex = 1;
  151. queryList();
  152. };
  153. // 获取参数列表
  154. const queryList = () => {
  155. state.loading = true;
  156. gridOptions.loading = true;
  157. getIndustryList(state.queryParams)
  158. .then((res) => {
  159. state.loading = false;
  160. gridOptions.data = res.result.items ?? [];
  161. state.total = res.result.total ?? 0;
  162. gridOptions.loading = false;
  163. })
  164. .finally(() => {
  165. state.loading = false;
  166. gridOptions.loading = false;
  167. });
  168. };
  169. // 重置表单
  170. const resetQuery = (formEl: FormInstance | undefined) => {
  171. if (!formEl) return;
  172. formEl.resetFields();
  173. queryList();
  174. };
  175. // 参数行业
  176. const industryAddRef = ref<RefType>(); // 参数行业
  177. const addIndustry = () => {
  178. industryAddRef.value.openDialog();
  179. };
  180. // 编辑行业
  181. const industryEditRef = ref<RefType>();
  182. const editIndustry = (row: any) => {
  183. industryEditRef.value.openDialog(row.id);
  184. };
  185. // 页面加载时
  186. onMounted(() => {
  187. queryList();
  188. });
  189. </script>