You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
487 lines
16 KiB
487 lines
16 KiB
<script setup lang="ts">
|
|
import { onMounted, reactive, ref } from 'vue';
|
|
import { ElMessage } from 'element-plus';
|
|
import { getDicts } from '@/api/system/dict/data';
|
|
import {
|
|
listLawEnforcerDomain,
|
|
listLawEnforcerDomainDetails,
|
|
exportLawEnforcerDomain,
|
|
exportLawEnforcerDomainDetails,
|
|
type EnforcerRow,
|
|
type LawEnforcerDetailRow
|
|
} from '@/api/efcode/report/law-enforcer';
|
|
import { getDomainInfo, type DashboardDomainVo } from '@/api/efcode/dashboard/area-info';
|
|
|
|
// ======================== 查询条件 ========================
|
|
const queryParams = reactive({
|
|
pageNum: 1,
|
|
pageSize: 20,
|
|
lawEnforcer: '' as string, // 执法人员关键字
|
|
domainName: undefined as string | undefined, // 所属领域名称(直接作为接口参数)
|
|
orderByColumn: 'enforce_count' as string, // 默认执法次数降序
|
|
isAsc: 'desc' as string
|
|
});
|
|
|
|
// 时段模式:year | quarter | month | custom
|
|
const timeMode = ref('month');
|
|
const selectedYear = ref<string>(String(new Date().getFullYear()));
|
|
const selectedQuarter = ref<number>(Math.ceil((new Date().getMonth() + 1) / 3));
|
|
const selectedMonth = ref<string>('');
|
|
const customRange = ref<string[]>([]); // 自定义时段 [beginTime, endTime]
|
|
|
|
// 季度选项
|
|
const quarterOptions = [
|
|
{ label: '第一季度', value: 1 },
|
|
{ label: '第二季度', value: 2 },
|
|
{ label: '第三季度', value: 3 },
|
|
{ label: '第四季度', value: 4 }
|
|
];
|
|
|
|
/** 年份选项(从 2024 年开始,因为 2024 年才开始有数据) */
|
|
const yearOptions = (() => {
|
|
const curr = new Date().getFullYear();
|
|
const startYear = 2024;
|
|
const years: string[] = [];
|
|
for (let y = curr; y >= startYear; y--) {
|
|
years.push(String(y));
|
|
}
|
|
return years.length > 0 ? years : [String(curr)];
|
|
})();
|
|
|
|
/** 时段 → beginTime/endTime(后端 enforcementTime 为 Date,年/季度无法直接表达,改用日期区间) */
|
|
const buildTimeParams = () => {
|
|
if (timeMode.value === 'year') {
|
|
const year = selectedYear.value;
|
|
return { beginTime: `${year}-01-01`, endTime: `${year}-12-31` };
|
|
}
|
|
if (timeMode.value === 'quarter') {
|
|
const year = selectedYear.value;
|
|
const startMonth = (selectedQuarter.value - 1) * 3 + 1;
|
|
const endMonth = selectedQuarter.value * 3;
|
|
const endDay = new Date(Number(year), endMonth, 0).getDate();
|
|
return {
|
|
beginTime: `${year}-${String(startMonth).padStart(2, '0')}-01`,
|
|
endTime: `${year}-${String(endMonth).padStart(2, '0')}-${String(endDay).padStart(2, '0')}`
|
|
};
|
|
}
|
|
if (timeMode.value === 'custom') {
|
|
if (!customRange.value || customRange.value.length !== 2) {
|
|
return { beginTime: undefined, endTime: undefined };
|
|
}
|
|
return {
|
|
beginTime: customRange.value[0],
|
|
endTime: customRange.value[1]
|
|
};
|
|
}
|
|
// 月度:未选月份则不按时间过滤
|
|
if (!selectedMonth.value) {
|
|
return { beginTime: undefined, endTime: undefined };
|
|
}
|
|
const [year, month] = selectedMonth.value.split('-');
|
|
const endDay = new Date(Number(year), Number(month), 0).getDate();
|
|
return {
|
|
beginTime: `${year}-${month}-01`,
|
|
endTime: `${year}-${month}-${String(endDay).padStart(2, '0')}`
|
|
};
|
|
};
|
|
|
|
// ======================== 字典 ========================
|
|
const areaOptions = ref<any[]>([]);
|
|
const fieldOptions = ref<DashboardDomainVo[]>([]);
|
|
|
|
const loadAreaDict = async () => {
|
|
try {
|
|
const res = await getDicts('address_type');
|
|
areaOptions.value = res.data || [];
|
|
} catch (e) {
|
|
console.error('加载所属区字典失败', e);
|
|
}
|
|
};
|
|
|
|
const loadFieldDict = async () => {
|
|
try {
|
|
const res = await getDomainInfo();
|
|
fieldOptions.value = res.data || [];
|
|
} catch (e) {
|
|
console.error('加载所属领域字典失败', e);
|
|
}
|
|
};
|
|
|
|
// ======================== 表格数据 ========================
|
|
const loading = ref(false);
|
|
const tableData = ref<EnforcerRow[]>([]);
|
|
const total = ref(0);
|
|
const selectedRows = ref<EnforcerRow[]>([]);
|
|
|
|
const getList = async () => {
|
|
loading.value = true;
|
|
try {
|
|
const { domainName, ...rest } = queryParams;
|
|
const res = await listLawEnforcerDomain({
|
|
...rest,
|
|
...buildTimeParams(),
|
|
orderByColumn: rest.orderByColumn || undefined,
|
|
isAsc: rest.isAsc || undefined,
|
|
domainName: domainName || undefined
|
|
});
|
|
tableData.value = (res as any)?.rows || [];
|
|
total.value = (res as any)?.total || 0;
|
|
} catch (e) {
|
|
console.warn('[scan-domain] 列表接口调用失败', e);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
|
|
const handleSearch = () => {
|
|
queryParams.pageNum = 1;
|
|
getList();
|
|
};
|
|
|
|
const handleReset = () => {
|
|
const n = new Date();
|
|
queryParams.lawEnforcer = '';
|
|
queryParams.domainName = undefined;
|
|
queryParams.orderByColumn = 'enforce_count';
|
|
queryParams.isAsc = 'desc';
|
|
queryParams.pageNum = 1;
|
|
queryParams.pageSize = 20;
|
|
timeMode.value = 'month';
|
|
selectedYear.value = String(n.getFullYear());
|
|
selectedQuarter.value = Math.ceil((n.getMonth() + 1) / 3);
|
|
selectedMonth.value = '';
|
|
customRange.value = [];
|
|
getList();
|
|
};
|
|
|
|
const handleExport = async () => {
|
|
try {
|
|
const res = await exportLawEnforcerDomain({
|
|
lawEnforcer: queryParams.lawEnforcer || undefined,
|
|
domainName: queryParams.domainName || undefined,
|
|
...buildTimeParams()
|
|
});
|
|
const blob = new Blob([res as any], {
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
});
|
|
const url = window.URL.createObjectURL(blob);
|
|
const link = document.createElement('a');
|
|
link.href = url;
|
|
link.download = '执法人员-领域报表.xlsx';
|
|
link.click();
|
|
window.URL.revokeObjectURL(url);
|
|
} catch (e) {
|
|
ElMessage.error('导出失败');
|
|
}
|
|
};
|
|
|
|
const handleSelectionChange = (selection: EnforcerRow[]) => {
|
|
selectedRows.value = selection;
|
|
};
|
|
|
|
/** 序号:跨页累加 */
|
|
const indexMethod = (index: number) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1;
|
|
|
|
/** 详情序号:跨页累加 */
|
|
const detailIndexMethod = (index: number) => (detailPage.value - 1) * detailPageSize.value + index + 1;
|
|
|
|
/** 执法次数列排序 */
|
|
const handleSortChange = (sortObj: { prop: string; order: 'ascending' | 'descending' | null }) => {
|
|
if (sortObj.prop === 'zfcs' && sortObj.order) {
|
|
queryParams.orderByColumn = 'enforce_count';
|
|
queryParams.isAsc = sortObj.order === 'ascending' ? 'asc' : 'desc';
|
|
} else {
|
|
// 非执法次数列排序(或取消排序),回退到默认执法次数降序
|
|
queryParams.orderByColumn = 'enforce_count';
|
|
queryParams.isAsc = 'desc';
|
|
}
|
|
queryParams.pageNum = 1;
|
|
getList();
|
|
};
|
|
|
|
// ======================== 详情弹窗 ========================
|
|
const detailDialogVisible = ref(false);
|
|
const detailEnforcer = ref<EnforcerRow | null>(null);
|
|
const detailDomainName = ref<string | undefined>(undefined);
|
|
const detailLoading = ref(false);
|
|
const detailTableData = ref<LawEnforcerDetailRow[]>([]);
|
|
const detailTotal = ref(0);
|
|
const detailPage = ref(1);
|
|
const detailPageSize = ref(20);
|
|
|
|
const getDetailList = async () => {
|
|
detailLoading.value = true;
|
|
try {
|
|
if (!detailEnforcer.value?.lawEnforcerId) return;
|
|
const res = await listLawEnforcerDomainDetails({
|
|
lawEnforcerId: detailEnforcer.value.lawEnforcerId,
|
|
domainName: detailDomainName.value,
|
|
...buildTimeParams(),
|
|
pageNum: detailPage.value,
|
|
pageSize: detailPageSize.value
|
|
});
|
|
detailTableData.value = (res as any)?.rows || [];
|
|
detailTotal.value = (res as any)?.total || 0;
|
|
} catch (e) {
|
|
console.warn('[scan-domain] 详情接口调用失败', e);
|
|
} finally {
|
|
detailLoading.value = false;
|
|
}
|
|
};
|
|
|
|
const handleDetail = (row: EnforcerRow) => {
|
|
detailEnforcer.value = row;
|
|
detailDomainName.value = queryParams.domainName;
|
|
detailPage.value = 1;
|
|
detailDialogVisible.value = true;
|
|
getDetailList();
|
|
};
|
|
|
|
const handleDetailSizeChange = (size: number) => {
|
|
detailPageSize.value = size;
|
|
detailPage.value = 1;
|
|
getDetailList();
|
|
};
|
|
|
|
const handleDetailPageChange = (page: number) => {
|
|
detailPage.value = page;
|
|
getDetailList();
|
|
};
|
|
|
|
const detailExporting = ref(false);
|
|
|
|
/** 详情导出 */
|
|
const handleDetailExport = async () => {
|
|
if (!detailEnforcer.value?.lawEnforcerId) return;
|
|
detailExporting.value = true;
|
|
try {
|
|
const res = await exportLawEnforcerDomainDetails({
|
|
lawEnforcerId: detailEnforcer.value.lawEnforcerId,
|
|
domainName: detailDomainName.value,
|
|
...buildTimeParams()
|
|
});
|
|
const blob = new Blob([res as any], {
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
});
|
|
const url = window.URL.createObjectURL(blob);
|
|
const link = document.createElement('a');
|
|
link.href = url;
|
|
link.download = `执法详情-${detailEnforcer.value.lawEnforcer || ''}.xlsx`;
|
|
link.click();
|
|
window.URL.revokeObjectURL(url);
|
|
} catch (e) {
|
|
ElMessage.error('导出失败');
|
|
} finally {
|
|
detailExporting.value = false;
|
|
}
|
|
};
|
|
|
|
onMounted(() => {
|
|
loadAreaDict();
|
|
loadFieldDict();
|
|
// 月份默认为空、不传时段参数,但仍加载列表
|
|
getList();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="app-container">
|
|
<div class="page-card">
|
|
<!-- ==================== 搜索区域 ==================== -->
|
|
<div class="search-panel">
|
|
<el-form :inline="true" label-colon>
|
|
<el-form-item label="执法人员">
|
|
<el-input v-model="queryParams.lawEnforcer" placeholder="请输入关键字" class="search-input" clearable @keyup.enter="handleSearch" />
|
|
</el-form-item>
|
|
<el-form-item label="所属领域">
|
|
<el-select v-model="queryParams.domainName" placeholder="请选择" class="search-select" clearable>
|
|
<el-option v-for="item in fieldOptions" :key="item.domainId" :label="item.domainName" :value="item.domainName" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="时段">
|
|
<el-select v-model="timeMode" style="width: 100px">
|
|
<el-option label="年度" value="year" />
|
|
<el-option label="季度" value="quarter" />
|
|
<el-option label="月度" value="month" />
|
|
<el-option label="自定义" value="custom" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="timeMode === 'year'">
|
|
<el-select v-model="selectedYear" class="period-select">
|
|
<el-option v-for="y in yearOptions" :key="y" :label="`${y}年`" :value="y" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="timeMode === 'quarter'">
|
|
<el-select v-model="selectedYear" class="period-select">
|
|
<el-option v-for="y in yearOptions" :key="y" :label="`${y}年`" :value="y" />
|
|
</el-select>
|
|
<el-select v-model="selectedQuarter" style="width: 110px; margin-left: 4px">
|
|
<el-option v-for="q in quarterOptions" :key="q.value" :label="q.label" :value="q.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="timeMode === 'month'">
|
|
<el-date-picker v-model="selectedMonth" type="month" placeholder="选择月份" value-format="YYYY-MM" style="width: 150px" />
|
|
</el-form-item>
|
|
<el-form-item v-if="timeMode === 'custom'">
|
|
<el-date-picker
|
|
v-model="customRange"
|
|
type="daterange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期"
|
|
value-format="YYYY-MM-DD"
|
|
style="width: 260px"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
|
<el-button type="primary" @click="handleReset">重置</el-button>
|
|
<el-button @click="handleExport">导出</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
|
|
<!-- ==================== 表格区域 ==================== -->
|
|
<div class="table-panel">
|
|
<div class="table-wrapper">
|
|
<el-table
|
|
v-loading="loading"
|
|
:data="tableData"
|
|
border
|
|
stripe
|
|
style="width: 100%"
|
|
height="100%"
|
|
@selection-change="handleSelectionChange"
|
|
@sort-change="handleSortChange"
|
|
>
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
<el-table-column label="序号" width="90" align="center" type="index" :index="indexMethod" />
|
|
<el-table-column prop="lawEnforcer" label="执法人员" min-width="160" align="center" />
|
|
<el-table-column prop="zfcs" label="执法次数" width="140" align="center" sortable="custom" :default-sort="{ prop: 'zfcs', order: 'descending' }" />
|
|
<el-table-column prop="domainName" label="所属领域" min-width="260" align="center" show-overflow-tooltip />
|
|
<el-table-column label="操作" width="90" align="center" fixed="right">
|
|
<template #default="{ row }">
|
|
<el-button type="primary" link size="small" @click="handleDetail(row)">详情</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
|
|
<el-pagination
|
|
v-model:current-page="queryParams.pageNum"
|
|
v-model:page-size="queryParams.pageSize"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
:total="total"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
class="mt-4"
|
|
@size-change="getList"
|
|
@current-change="getList"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ==================== 执法详情弹窗 ==================== -->
|
|
<el-dialog v-model="detailDialogVisible" width="1100px" title="执法详情" append-to-body top="5vh" destroy-on-close>
|
|
<div class="detail-toolbar">
|
|
<el-button type="primary" :loading="detailExporting" @click="handleDetailExport">导出</el-button>
|
|
</div>
|
|
|
|
<el-table v-loading="detailLoading" :data="detailTableData" border stripe style="width: 100%" max-height="55vh">
|
|
<el-table-column label="序号" type="index" :index="detailIndexMethod" width="80" align="center" />
|
|
<el-table-column label="执法单位" prop="bureauDeptName" min-width="220" align="center" show-overflow-tooltip />
|
|
<el-table-column label="执法人员" prop="lawEnforcer" min-width="160" align="center" />
|
|
<el-table-column label="执法时间" prop="enforcementTime" min-width="180" align="center" />
|
|
<el-table-column label="被执法企业名称" prop="enterpriseName" min-width="260" align="center" show-overflow-tooltip />
|
|
<el-table-column label="执法事项" prop="lawEnforcementItemText" width="120" align="center" />
|
|
</el-table>
|
|
|
|
<el-pagination
|
|
v-model:current-page="detailPage"
|
|
v-model:page-size="detailPageSize"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
:total="detailTotal"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
class="mt-4"
|
|
@size-change="handleDetailSizeChange"
|
|
@current-change="handleDetailPageChange"
|
|
/>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped lang="scss">
|
|
.app-container {
|
|
height: 100%;
|
|
padding: 16px;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.page-card {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: #fff;
|
|
border-radius: 4px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.search-panel {
|
|
flex: none;
|
|
background: #fff;
|
|
border: 1px solid #e4e7ed;
|
|
border-radius: 4px;
|
|
padding: 18px 20px 0;
|
|
margin-bottom: 16px;
|
|
|
|
:deep(.el-form-item__label) {
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.search-input {
|
|
width: 210px;
|
|
}
|
|
|
|
.search-select {
|
|
width: 220px;
|
|
}
|
|
|
|
.period-select {
|
|
width: 110px;
|
|
}
|
|
}
|
|
|
|
.table-panel {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: #fff;
|
|
border: 1px solid #e4e7ed;
|
|
border-radius: 4px;
|
|
padding: 16px 20px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.table-wrapper {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.mt-4 {
|
|
flex: none;
|
|
margin-top: 16px;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.detail-toolbar {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|