123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <div class="statistics-department-overdue-container layout-pd">
- <!-- 搜索 -->
- <el-card shadow="never">
- <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
- <el-form-item label="超期部门" prop="Keyword">
- <el-input v-model="state.queryParams.Keyword" placeholder="部门名称" clearable @keyup.enter="queryList" class="keyword-input" />
- </el-form-item>
- <el-form-item label="时间段" prop="crTime">
- <el-date-picker
- v-model="state.queryParams.crTime"
- type="daterange"
- unlink-panels
- range-separator="至"
- start-placeholder="开始时间"
- end-placeholder="结束时间"
- :shortcuts="shortcuts"
- @change="queryList"
- value-format="YYYY-MM-DD"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="queryList" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
- <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
- <SvgIcon name="ele-Refresh" class="mr5" />重置
- </el-button>
- </el-form-item>
- </el-form>
- </el-card>
- <el-card shadow="never">
- <ProTable
- ref="proTableRef"
- :columns="columns"
- :data="state.tableData"
- @updateTable="queryList"
- :loading="state.loading"
- show-summary
- border
- @sort-change="sortChange"
- :total="state.total"
- v-model:page-index="state.queryParams.PageIndex"
- v-model:page-size="state.queryParams.PageSize"
- :summary-method="getSummaries"
- role-key="orgId"
- >
- </ProTable>
- </el-card>
- </div>
- </template>
- <script setup lang="tsx" name="statisticsDepartmentOverdue">
- import { onMounted, reactive, ref } from 'vue';
- import { ElButton, FormInstance } from 'element-plus';
- import { throttle } from '@/utils/tools';
- import { departmentList } from '@/api/statistics/department';
- import { shortcuts } from '@/utils/constants';
- import dayjs from 'dayjs';
- // 表格配置项
- const columns = ref<any[]>([
- { type: 'index', fixed: 'left', width: 55, label: '序号', align: 'center' },
- { prop: 'orgName', label: '超期部门', align: 'center' },
- { prop: 'handlerExtendedNum', label: '业务已办超期', align: 'center', sortable: 'custom' },
- { prop: 'counterHandlerExtendedNum', label: '会签已办超期', align: 'center', sortable: 'custom' },
- { prop: 'noHandlerExtendedNum', label: '业务待办超期', align: 'center', sortable: 'custom' },
- { prop: 'counterNoHandlerExtendedNum', label: '会签待办超期', align: 'center', sortable: 'custom' },
- { prop: 'subtotal', label: '小计', align: 'center' },
- ]);
- // 定义变量内容
- const ruleFormRef = ref<RefType>(); // 表单ref
- const state = reactive({
- queryParams: {
- // 查询条件
- PageIndex: 1,
- PageSize: 10,
- Keyword: null, // 关键词
- crTime: [dayjs().startOf('day').format('YYYY-MM-DD'), dayjs().endOf('day').format('YYYY-MM-DD')], // 时间默认今天开始到今天结束
- },
- tableData: [], //表单
- loading: false, // 加载
- total: 0, // 总数
- });
- /** 获取列表 */
- const queryList = throttle(() => {
- state.loading = true;
- let StartTime = null;
- let EndTime = null;
- if (state.queryParams?.crTime) {
- StartTime = state.queryParams?.crTime[0];
- EndTime = state.queryParams?.crTime[1];
- }
- const request = {
- StartTime,
- EndTime,
- DelayState: state.queryParams.DelayState,
- PageIndex: state.queryParams.PageIndex,
- PageSize: state.queryParams.PageSize,
- Keyword: state.queryParams.Keyword,
- SortField: state.queryParams.SortField,
- SortRule: state.queryParams.SortRule,
- };
- departmentList(request)
- .then((res: any) => {
- state.tableData = res.result?.items ?? [];
- state.total = res.result?.total ?? 0;
- state.loading = false;
- })
- .catch(() => {
- state.loading = false;
- });
- }, 300);
- // 排序
- const sortChange = (val: any) => {
- state.queryParams.SortField = val.order ? val.prop : null;
- // 0 升序 1 降序
- state.queryParams.SortRule = val.order ? (val.order == 'descending' ? 1 : 0) : null;
- queryList();
- };
- /** 重置按钮操作 */
- const resetQuery = throttle((formEl: FormInstance | undefined) => {
- if (!formEl) return;
- formEl.resetFields();
- queryList();
- }, 300);
- // 合计
- const getSummaries = (param: any) => {
- const { columns, data } = param;
- const sums: string[] = [];
- columns.forEach((column: { property: string }, index: number) => {
- if (index === 0) {
- sums[index] = '合计';
- return;
- }
- const values = data.map((item: { [x: string]: any }) => Number(item[column.property]));
- if (['orgName'].includes(column.property)) {
- //百分比不能计算
- sums[index] = '';
- return '';
- } else if (!values.every((value: unknown) => Number.isNaN(value))) {
- sums[index] = `${values.reduce((prev: any, curr: any) => {
- const value = Number(curr);
- if (!Number.isNaN(value)) {
- return prev + curr;
- } else {
- return prev;
- }
- }, 0)}`;
- } else {
- sums[index] = ' ';
- }
- });
- return sums;
- };
- onMounted(() => {
- queryList();
- });
- </script>
|