index.vue 5.3 KB

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