missExamUsers.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="snapshot-statistics-grid-handle-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" @submit.native.prevent inline :disabled="gridOptions.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. <template #pager>
  19. <pagination
  20. @pagination="queryList"
  21. :total="state.total"
  22. v-model:current-page="state.queryParams.PageIndex"
  23. v-model:page-size="state.queryParams.PageSize"
  24. :disabled="state.loading"
  25. />
  26. </template>
  27. </vxe-grid>
  28. </div>
  29. </div>
  30. </template>
  31. <script lang="tsx" setup name="examTrainExamStatisticsMissExamUsers">
  32. import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  33. import { FormInstance } from 'element-plus';
  34. import { defaultDate } from '@/utils/constants';
  35. import { getMissExamUsersData, getMissExamUsersExport } from '@/api/examTrain/statistics';
  36. import Other from '@/utils/other';
  37. // 引入组件
  38. const StatisticalTime = defineAsyncComponent(() => import('@/components/StatisticalTime/index.vue')); // 日期类型选择组件
  39. const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
  40. // 定义变量内容
  41. const state = reactive<any>({
  42. loading: false,
  43. total: 0, // 总数
  44. queryParams: {
  45. // 查询参数
  46. PageIndex: 1,
  47. PageSize: 20,
  48. crTime: defaultDate, // 时间默认今天开始到今天结束
  49. startTime: null,
  50. endTime: null,
  51. anlysisType: 3,
  52. },
  53. });
  54. const requestParams = ref<EmptyObjectType>({});
  55. const gridOptions = reactive<any>({
  56. loading: false,
  57. border: true,
  58. showOverflow: true,
  59. columnConfig: {
  60. resizable: true,
  61. },
  62. scrollY: {
  63. enabled: true,
  64. gt: 100,
  65. },
  66. toolbarConfig: {
  67. zoom: true,
  68. custom: true,
  69. refresh: {
  70. queryMethod: () => {
  71. handleQuery();
  72. },
  73. },
  74. tools: [{ toolRender: { name: 'exportCurrent' } }, { toolRender: { name: 'exportAll' } }],
  75. },
  76. params: {
  77. exportMethod: getMissExamUsersExport,
  78. exportParams: requestParams,
  79. },
  80. customConfig: {
  81. storage: true,
  82. },
  83. id: 'examTrainExamStatisticsMissExamUsers',
  84. rowConfig: { isHover: true, height: 30, isCurrent: true, useKey: true },
  85. height: 'auto',
  86. align: 'center',
  87. columns: [
  88. {
  89. field: 'userName',
  90. title: '缺考人员',
  91. width: 200,
  92. fixed: 'left',
  93. },
  94. {
  95. field: 'orgName',
  96. title: '部门名称',
  97. fixed: 'left',
  98. width: 300,
  99. },
  100. {
  101. field: 'examName',
  102. title: '考试题目',
  103. fixed: 'left',
  104. minWidth: 300,
  105. },
  106. ],
  107. data: [],
  108. });
  109. /** 搜索按钮操作 节流操作 */
  110. const handleQuery = () => {
  111. state.queryParams.PageIndex = 1;
  112. queryList();
  113. };
  114. // 获取参数列表
  115. const queryList = () => {
  116. state.loading = true;
  117. gridOptions.loading = true;
  118. requestParams.value = Other.deepClone(state.queryParams);
  119. requestParams.value.startTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0]; // 受理时间
  120. requestParams.value.endTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
  121. Reflect.deleteProperty(requestParams.value, 'crTime'); // 删除无用的参数
  122. getMissExamUsersData(requestParams.value)
  123. .then((res) => {
  124. state.loading = false;
  125. gridOptions.data = res.result.items ?? [];
  126. state.total = res?.result.pagination.totalCount ?? 0;
  127. gridOptions.loading = false;
  128. })
  129. .finally(() => {
  130. state.loading = false;
  131. gridOptions.loading = false;
  132. });
  133. };
  134. // 重置表单
  135. const ruleFormRef = ref<any>(null); // 表单ref
  136. const statisticalTimeRef = ref<RefType>();
  137. const resetQuery = (formEl: FormInstance | undefined) => {
  138. if (!formEl) return;
  139. formEl.resetFields();
  140. statisticalTimeRef.value.reset();
  141. queryList();
  142. };
  143. // 页面加载时
  144. onMounted(() => {
  145. queryList();
  146. });
  147. </script>