missExamUsers.vue 3.6 KB

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