pointList.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="snapshot-statistics-point-list-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <vxe-grid v-bind="gridOptions" v-on="gridEvents" ref="gridRef">
  5. <template #form>
  6. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline :disabled="state.loading">
  7. <el-form-item prop="crTime">
  8. <statistical-time v-model="state.queryParams.crTime" @change="handleQuery" ref="statisticalTimeRef" :disabled="state.loading" />
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  12. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  13. <SvgIcon name="ele-Refresh" class="mr5" />重置
  14. </el-button>
  15. </el-form-item>
  16. </el-form>
  17. </template>
  18. </vxe-grid>
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="tsx" name="snapshotStatisticsPointList">
  23. import { defineAsyncComponent, onMounted, reactive, ref, computed } from 'vue';
  24. import { ElMessage, FormInstance } from 'element-plus';
  25. import Other from '@/utils/other';
  26. import { getSSPStatisticsIntegralArea, getSSPStatisticsIntegralAreaExport } from '@/api/snapshot/statistics';
  27. import { defaultDate } from '@/utils/constants';
  28. // 引入组件
  29. const StatisticalTime = defineAsyncComponent(() => import('@/components/StatisticalTime/index.vue')); // 日期类型选择组件
  30. // 定义变量内容
  31. const state = reactive<any>({
  32. queryParams: {
  33. // 查询条件
  34. SortField: null,
  35. SortRule: null,
  36. crTime: defaultDate,
  37. StartTime: null,
  38. EndTime: null,
  39. },
  40. tableData: [], //表单
  41. loading: false, // 加载
  42. });
  43. const requestParams = ref<EmptyObjectType>({});
  44. const gridOptions = reactive<any>({
  45. loading: false,
  46. border: true,
  47. showOverflow: true,
  48. columnConfig: {
  49. resizable: true,
  50. },
  51. scrollY: {
  52. enabled: true,
  53. gt: 100,
  54. },
  55. toolbarConfig: {
  56. zoom: true,
  57. custom: true,
  58. refresh: {
  59. queryMethod: () => {
  60. handleQuery();
  61. },
  62. },
  63. tools: [{ toolRender: { name: 'exportCurrent' } }, { toolRender: { name: 'exportAll' } }],
  64. },
  65. params: {
  66. exportMethod: getSSPStatisticsIntegralAreaExport,
  67. exportParams: requestParams,
  68. },
  69. customConfig: {
  70. storage: true,
  71. },
  72. id: 'snapshotStatisticsPointList',
  73. rowConfig: { isHover: true, height: 30, isCurrent: true, useKey: true },
  74. height: 'auto',
  75. columns: [
  76. { field: 'phoneNumber', title: '区域' },
  77. { field: 'totalPoints', title: '历史总积分' },
  78. { field: 'outPoints', title: '已兑换积分' },
  79. ],
  80. data: [],
  81. sortConfig: {
  82. remote: true,
  83. },
  84. });
  85. const gridEvents = {
  86. sortChange(val: any) {
  87. state.queryParams.SortField = val.order ? val.field : null;
  88. // 0 升序 1 降序
  89. state.queryParams.SortRule = val.order ? (val.order == 'desc' ? 1 : 0) : null;
  90. handleQuery();
  91. },
  92. };
  93. // 手动查询,将页码设置为1
  94. const handleQuery = () => {
  95. state.queryParams.PageIndex = 1;
  96. queryList();
  97. };
  98. // 改变页码
  99. const queryList = () => {
  100. return new Promise((resolve, reject) => {
  101. requestParams.value = Other.deepClone(state.queryParams);
  102. requestParams.value.StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0]; // 受理时间
  103. requestParams.value.EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  104. Reflect.deleteProperty(requestParams.value, 'crTime'); // 删除无用的参数
  105. state.loading = true;
  106. gridOptions.loading = true;
  107. getSSPStatisticsIntegralArea(requestParams.value)
  108. .then((response: any) => {
  109. gridOptions.data = response?.result ?? [];
  110. state.loading = false;
  111. gridOptions.loading = false;
  112. resolve(response);
  113. })
  114. .catch(() => {
  115. state.loading = false;
  116. gridOptions.loading = false;
  117. reject();
  118. });
  119. });
  120. };
  121. /** 重置按钮操作 */
  122. const ruleFormRef = ref<FormInstance>();
  123. const resetQuery = (formEl: FormInstance | undefined) => {
  124. if (!formEl) return;
  125. formEl.resetFields();
  126. queryList();
  127. };
  128. onMounted(() => {
  129. queryList();
  130. });
  131. </script>