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.
447 lines
14 KiB
447 lines
14 KiB
|
1 week ago
|
<script setup lang="ts">
|
||
|
|
import { onMounted, reactive, ref } from 'vue';
|
||
|
|
import { ElMessage } from 'element-plus';
|
||
|
|
import { getDicts } from '@/api/system/dict/data';
|
||
|
|
import {
|
||
|
|
listLawEnforcer,
|
||
|
|
listLawEnforcerDetails,
|
||
|
|
exportLawEnforcer,
|
||
|
|
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, // 执法人员关键字(接口参数名)
|
||
|
|
area: undefined as string | undefined,
|
||
|
|
field: undefined as string | undefined, // 所属领域名称
|
||
|
|
enforcementTime: '' as string, // 月度默认不传,用户选择月份后才传
|
||
|
|
orderByColumn: '' as string,
|
||
|
|
isAsc: '' as string
|
||
|
|
});
|
||
|
|
|
||
|
|
// 时段模式:year | quarter | month
|
||
|
|
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 quarterOptions = [
|
||
|
|
{ label: '第一季度', value: 1 },
|
||
|
|
{ label: '第二季度', value: 2 },
|
||
|
|
{ label: '第三季度', value: 3 },
|
||
|
|
{ label: '第四季度', value: 4 }
|
||
|
|
];
|
||
|
|
|
||
|
|
/** 年份选项(近 5 年) */
|
||
|
|
const yearOptions = (() => {
|
||
|
|
const curr = new Date().getFullYear();
|
||
|
|
return Array.from({ length: 5 }, (_, i) => String(curr - i));
|
||
|
|
})();
|
||
|
|
|
||
|
|
/** 同步 enforcementTime(年度 / 季度模式;月度由用户选月后赋值) */
|
||
|
|
const syncEnforcementTime = () => {
|
||
|
|
if (timeMode.value === 'year') {
|
||
|
|
queryParams.enforcementTime = selectedYear.value;
|
||
|
|
} else if (timeMode.value === 'quarter') {
|
||
|
|
queryParams.enforcementTime = `${selectedYear.value}-Q${selectedQuarter.value}`;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/** 时段模式变更 */
|
||
|
|
const handleTimeModeChange = () => {
|
||
|
|
if (timeMode.value === 'month') {
|
||
|
|
// 月度默认月份为空,用户主动选择后才传参数
|
||
|
|
queryParams.enforcementTime = '';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
syncEnforcementTime();
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleYearChange = () => syncEnforcementTime();
|
||
|
|
const handleQuarterChange = () => syncEnforcementTime();
|
||
|
|
const handleMonthChange = () => {
|
||
|
|
queryParams.enforcementTime = selectedMonth.value ? `${selectedMonth.value}-01` : '';
|
||
|
|
};
|
||
|
|
|
||
|
|
// ======================== 字典 ========================
|
||
|
|
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 {
|
||
|
|
// 接口字段:区 → districtName(下拉绑定的是 dictLabel),领域/单位 → bureauDeptName
|
||
|
|
const { area, field, ...rest } = queryParams;
|
||
|
|
const res = await listLawEnforcer({
|
||
|
|
...rest,
|
||
|
|
enforcementTime: rest.enforcementTime || undefined,
|
||
|
|
orderByColumn: rest.orderByColumn || undefined,
|
||
|
|
isAsc: rest.isAsc || undefined,
|
||
|
|
districtName: area,
|
||
|
|
bureauDeptName: field || undefined
|
||
|
|
});
|
||
|
|
tableData.value = (res as any)?.rows || [];
|
||
|
|
total.value = (res as any)?.total || 0;
|
||
|
|
} catch (e) {
|
||
|
|
console.warn('[scan-enforcer] 列表接口调用失败', e);
|
||
|
|
} finally {
|
||
|
|
loading.value = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleSearch = () => {
|
||
|
|
queryParams.pageNum = 1;
|
||
|
|
getList();
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleReset = () => {
|
||
|
|
const n = new Date();
|
||
|
|
queryParams.lawEnforcer = '';
|
||
|
|
queryParams.area = undefined;
|
||
|
|
queryParams.field = undefined;
|
||
|
|
queryParams.orderByColumn = '';
|
||
|
|
queryParams.isAsc = '';
|
||
|
|
queryParams.pageNum = 1;
|
||
|
|
queryParams.pageSize = 20;
|
||
|
|
timeMode.value = 'month';
|
||
|
|
selectedYear.value = String(n.getFullYear());
|
||
|
|
selectedQuarter.value = Math.ceil((n.getMonth() + 1) / 3);
|
||
|
|
selectedMonth.value = '';
|
||
|
|
queryParams.enforcementTime = '';
|
||
|
|
getList();
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleExport = async () => {
|
||
|
|
try {
|
||
|
|
const res = await exportLawEnforcer({
|
||
|
|
lawEnforcer: queryParams.lawEnforcer || undefined,
|
||
|
|
districtName: queryParams.area || undefined,
|
||
|
|
bureauDeptName: queryParams.field || undefined,
|
||
|
|
enforcementTime: queryParams.enforcementTime || undefined
|
||
|
|
});
|
||
|
|
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 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 = '';
|
||
|
|
queryParams.isAsc = '';
|
||
|
|
}
|
||
|
|
queryParams.pageNum = 1;
|
||
|
|
getList();
|
||
|
|
};
|
||
|
|
|
||
|
|
// ======================== 详情弹窗 ========================
|
||
|
|
const detailDialogVisible = ref(false);
|
||
|
|
const detailEnforcer = ref<EnforcerRow | null>(null);
|
||
|
|
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 listLawEnforcerDetails({
|
||
|
|
lawEnforcerId: detailEnforcer.value.lawEnforcerId,
|
||
|
|
enforcementTime: queryParams.enforcementTime || undefined,
|
||
|
|
pageNum: detailPage.value,
|
||
|
|
pageSize: detailPageSize.value
|
||
|
|
});
|
||
|
|
detailTableData.value = (res as any)?.rows || [];
|
||
|
|
detailTotal.value = (res as any)?.total || 0;
|
||
|
|
} catch (e) {
|
||
|
|
console.warn('[scan-enforcer] 详情接口调用失败', e);
|
||
|
|
} finally {
|
||
|
|
detailLoading.value = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleDetail = (row: EnforcerRow) => {
|
||
|
|
detailEnforcer.value = row;
|
||
|
|
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();
|
||
|
|
};
|
||
|
|
|
||
|
|
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.field"
|
||
|
|
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" @change="handleTimeModeChange">
|
||
|
|
<el-option label="年度" value="year" />
|
||
|
|
<el-option label="季度" value="quarter" />
|
||
|
|
<el-option label="月度" value="month" />
|
||
|
|
</el-select>
|
||
|
|
</el-form-item>
|
||
|
|
<el-form-item v-if="timeMode === 'year'">
|
||
|
|
<el-select v-model="selectedYear" class="period-select" @change="handleYearChange">
|
||
|
|
<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" @change="handleYearChange">
|
||
|
|
<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" @change="handleQuarterChange">
|
||
|
|
<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"
|
||
|
|
@change="handleMonthChange"
|
||
|
|
/>
|
||
|
|
</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" />
|
||
|
|
<el-table-column prop="lawEnforcer" label="执法人员" min-width="160" align="center" />
|
||
|
|
<el-table-column prop="zfcs" label="执法次数" width="140" align="center" sortable="custom" />
|
||
|
|
<el-table-column prop="bureauDeptName" 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
|
||
|
|
>
|
||
|
|
<el-table
|
||
|
|
v-loading="detailLoading"
|
||
|
|
:data="detailTableData"
|
||
|
|
border
|
||
|
|
stripe
|
||
|
|
style="width: 100%"
|
||
|
|
max-height="55vh"
|
||
|
|
>
|
||
|
|
<el-table-column label="序号" type="index" 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;
|
||
|
|
}
|
||
|
|
</style>
|