overdue.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="statistics-department-overdue-container layout-pd">
  3. <!-- 搜索 -->
  4. <el-card shadow="never">
  5. <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
  6. <el-form-item label="超期部门" prop="Keyword">
  7. <el-input v-model="state.queryParams.Keyword" placeholder="部门名称" clearable @keyup.enter="queryList" class="keyword-input" />
  8. </el-form-item>
  9. <el-form-item label="时间段" prop="crTime">
  10. <el-date-picker
  11. v-model="state.queryParams.crTime"
  12. type="daterange"
  13. unlink-panels
  14. range-separator="至"
  15. start-placeholder="开始时间"
  16. end-placeholder="结束时间"
  17. :shortcuts="shortcuts"
  18. @change="queryList"
  19. value-format="YYYY-MM-DD"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" @click="queryList" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
  24. <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
  25. <SvgIcon name="ele-Refresh" class="mr5" />重置
  26. </el-button>
  27. </el-form-item>
  28. </el-form>
  29. </el-card>
  30. <el-card shadow="never">
  31. <ProTable
  32. ref="proTableRef"
  33. :columns="columns"
  34. :data="state.tableData"
  35. @updateTable="queryList"
  36. :loading="state.loading"
  37. show-summary
  38. border
  39. @sort-change="sortChange"
  40. :total="state.total"
  41. v-model:page-index="state.queryParams.PageIndex"
  42. v-model:page-size="state.queryParams.PageSize"
  43. :summary-method="getSummaries"
  44. role-key="orgId"
  45. >
  46. </ProTable>
  47. </el-card>
  48. </div>
  49. </template>
  50. <script setup lang="tsx" name="statisticsDepartmentOverdue">
  51. import { onMounted, reactive, ref } from 'vue';
  52. import { ElButton, FormInstance } from 'element-plus';
  53. import { throttle } from '@/utils/tools';
  54. import { departmentList } from '@/api/statistics/department';
  55. import { shortcuts } from '@/utils/constants';
  56. import dayjs from 'dayjs';
  57. // 表格配置项
  58. const columns = ref<any[]>([
  59. { type: 'index', fixed: 'left', width: 55, label: '序号', align: 'center' },
  60. { prop: 'orgName', label: '超期部门', align: 'center' },
  61. { prop: 'handlerExtendedNum', label: '业务已办超期', align: 'center', sortable: 'custom' },
  62. { prop: 'counterHandlerExtendedNum', label: '会签已办超期', align: 'center', sortable: 'custom' },
  63. { prop: 'noHandlerExtendedNum', label: '业务待办超期', align: 'center', sortable: 'custom' },
  64. { prop: 'counterNoHandlerExtendedNum', label: '会签待办超期', align: 'center', sortable: 'custom' },
  65. { prop: 'subtotal', label: '小计', align: 'center' },
  66. ]);
  67. // 定义变量内容
  68. const ruleFormRef = ref<RefType>(); // 表单ref
  69. const state = reactive({
  70. queryParams: {
  71. // 查询条件
  72. PageIndex: 1,
  73. PageSize: 10,
  74. Keyword: null, // 关键词
  75. crTime: [dayjs().startOf('day').format('YYYY-MM-DD'), dayjs().endOf('day').format('YYYY-MM-DD')], // 时间默认今天开始到今天结束
  76. },
  77. tableData: [], //表单
  78. loading: false, // 加载
  79. total: 0, // 总数
  80. });
  81. /** 获取列表 */
  82. const queryList = throttle(() => {
  83. state.loading = true;
  84. let StartTime = null;
  85. let EndTime = null;
  86. if (state.queryParams?.crTime) {
  87. StartTime = state.queryParams?.crTime[0];
  88. EndTime = state.queryParams?.crTime[1];
  89. }
  90. const request = {
  91. StartTime,
  92. EndTime,
  93. DelayState: state.queryParams.DelayState,
  94. PageIndex: state.queryParams.PageIndex,
  95. PageSize: state.queryParams.PageSize,
  96. Keyword: state.queryParams.Keyword,
  97. SortField: state.queryParams.SortField,
  98. SortRule: state.queryParams.SortRule,
  99. };
  100. departmentList(request)
  101. .then((res: any) => {
  102. state.tableData = res.result?.items ?? [];
  103. state.total = res.result?.total ?? 0;
  104. state.loading = false;
  105. })
  106. .catch(() => {
  107. state.loading = false;
  108. });
  109. }, 300);
  110. // 排序
  111. const sortChange = (val: any) => {
  112. state.queryParams.SortField = val.order ? val.prop : null;
  113. // 0 升序 1 降序
  114. state.queryParams.SortRule = val.order ? (val.order == 'descending' ? 1 : 0) : null;
  115. queryList();
  116. };
  117. /** 重置按钮操作 */
  118. const resetQuery = throttle((formEl: FormInstance | undefined) => {
  119. if (!formEl) return;
  120. formEl.resetFields();
  121. queryList();
  122. }, 300);
  123. // 合计
  124. const getSummaries = (param: any) => {
  125. const { columns, data } = param;
  126. const sums: string[] = [];
  127. columns.forEach((column: { property: string }, index: number) => {
  128. if (index === 0) {
  129. sums[index] = '合计';
  130. return;
  131. }
  132. const values = data.map((item: { [x: string]: any }) => Number(item[column.property]));
  133. if (['orgName'].includes(column.property)) {
  134. //百分比不能计算
  135. sums[index] = '';
  136. return '';
  137. } else if (!values.every((value: unknown) => Number.isNaN(value))) {
  138. sums[index] = `${values.reduce((prev: any, curr: any) => {
  139. const value = Number(curr);
  140. if (!Number.isNaN(value)) {
  141. return prev + curr;
  142. } else {
  143. return prev;
  144. }
  145. }, 0)}`;
  146. } else {
  147. sums[index] = ' ';
  148. }
  149. });
  150. return sums;
  151. };
  152. onMounted(() => {
  153. queryList();
  154. });
  155. </script>