Browse Source

Merge remote-tracking branch 'origin/dev-V1.2' into dev-V1.2

dev-V1.2
niujiyi 2 weeks ago
parent
commit
a822bd21e5
  1. 815
      zdxt-web-client/zdxt-admin-plus-ui/src/views/efcode/supervision_warning/risk-credit/components/CreditPane.vue
  2. 749
      zdxt-web-client/zdxt-admin-plus-ui/src/views/efcode/supervision_warning/risk-credit/index.vue

815
zdxt-web-client/zdxt-admin-plus-ui/src/views/efcode/supervision_warning/risk-credit/components/CreditPane.vue

@ -0,0 +1,815 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import * as echarts from 'echarts';
import { getDicts } from '@/api/system/dict/data';
import { getDomainInfo, type DashboardDomainVo } from '@/api/efcode/dashboard/area-info';
/** 维度:area=各区域 field=各领域 */
const props = defineProps<{
dimension: 'area' | 'field';
}>();
// ======================== 预警等级卡片 ========================
interface WarningCard {
level: string;
count: number;
desc: string;
color: string;
}
const warningCards = ref<WarningCard[]>([
{ level: 'A+级预警', count: 1, desc: '预警:不符合年度检查<=1次', color: '#cf1322' },
{ level: 'A级预警', count: 2, desc: '预警:不符合年度检查1~2次', color: '#52c41a' },
{ level: 'B级预警', count: 1, desc: '预警:不符合年度检查2~4次', color: '#fa8c16' },
{ level: 'C级预警', count: 1, desc: '预警:不符合 年度检查4~7次', color: '#fa541c' },
{ level: 'D级预警', count: 1, desc: '预警:不符合 年度检查7~10次', color: '#f5222d' },
{ level: 'E级预警', count: 1, desc: '预警:不符合年度检查10~20次', color: '#722ed1' }
]);
// ======================== 信用等级 / 阈值配置 ========================
const creditStyleMap: Record<string, { color: string; bg: string }> = {
'A+': { color: '#7b5cff', bg: 'rgba(123, 92, 255, 0.12)' },
A: { color: '#22b07d', bg: 'rgba(34, 176, 125, 0.12)' },
B: { color: '#2f7df6', bg: 'rgba(47, 125, 246, 0.12)' },
C: { color: '#f5a623', bg: 'rgba(245, 166, 35, 0.12)' },
D: { color: '#f54848', bg: 'rgba(245, 72, 72, 0.12)' },
E: { color: '#a259e6', bg: 'rgba(162, 89, 230, 0.12)' }
};
/** 信用等级 → 年度检查次数阈值(min~max 次) */
const creditThresholdMap: Record<string, { min: number; max: number; text: string }> = {
'A+': { min: 0, max: 1, text: '年度检查<=1次' },
A: { min: 1, max: 2, text: '年度检查1~2次' },
B: { min: 2, max: 4, text: '年度检查2~4次' },
C: { min: 4, max: 7, text: '年度检查4~7次' },
D: { min: 7, max: 10, text: '年度检查7~10次' },
E: { min: 10, max: 20, text: '年度检查10~20次' }
};
const creditOptions = Object.keys(creditStyleMap);
// ======================== 查询条件 ========================
const queryParams = reactive({
enterpriseName: '',
area: undefined as string | undefined, // 各区域页签使用
domain: undefined as string | undefined, // 各领域页签使用
creditLevel: undefined as string | undefined,
warningType: undefined as string | undefined,
warningLevel: undefined as string | undefined,
year: undefined as string | undefined
});
const warningTypeOptions = [
{ label: '检查超期', value: '检查超期' },
{ label: '检查不足', value: '检查不足' }
];
const warningLevelOptions = [
{ label: '高', value: '高' },
{ label: '中', value: '中' },
{ label: '低', value: '低' }
];
/** 年份选项(近 5 年) */
const yearOptions = (() => {
const curr = new Date().getFullYear();
return Array.from({ length: 5 }, (_, i) => String(curr - i));
})();
// ======================== 所属区 / 所属领域字典 ========================
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);
}
};
// ======================== 表格数据(Mock) ========================
interface WarningRow {
id: number;
enterpriseName: string;
districtName: string;
domainName: string;
creditLevel: string;
checkCount: number;
warningLevel: string;
}
const allRows: WarningRow[] = [
{
id: 1,
enterpriseName: '深圳市宝安区西乡健豹电子厂',
districtName: '宝安区',
domainName: '食品经营',
creditLevel: 'A+',
checkCount: 3,
warningLevel: '低'
},
{
id: 2,
enterpriseName: '深圳市黄金屋真空科技有限公司',
districtName: '福田区',
domainName: '产品质量',
creditLevel: 'B',
checkCount: 1,
warningLevel: '低'
},
{
id: 3,
enterpriseName: '深圳市蓝天新能源股份有限公司',
districtName: '南山区',
domainName: '特种设备',
creditLevel: 'C',
checkCount: 10,
warningLevel: '中'
},
{
id: 4,
enterpriseName: '深圳市华强电子科技有限公司',
districtName: '龙岗区',
domainName: '产品质量',
creditLevel: 'D',
checkCount: 6,
warningLevel: '低'
},
{
id: 5,
enterpriseName: '深圳市优鲜餐饮管理有限公司',
districtName: '龙华区',
domainName: '食品经营',
creditLevel: 'E',
checkCount: 29,
warningLevel: '高'
},
{
id: 6,
enterpriseName: '深圳市远祥物流有限公司',
districtName: '坪山区',
domainName: '网络交易',
creditLevel: 'A',
checkCount: 0,
warningLevel: '低'
},
{
id: 7,
enterpriseName: '深圳市金煌化工有限公司',
districtName: '龙岗区',
domainName: '特种设备',
creditLevel: 'A',
checkCount: 8,
warningLevel: '高'
}
];
const loading = ref(false);
const tableData = ref<WarningRow[]>([...allRows]);
const total = ref(658);
const currentPage = ref(52);
const pageSize = ref(20);
const selectedRows = ref<WarningRow[]>([]);
const tableHeight = ref<number | undefined>(undefined);
const tableRef = ref<HTMLElement>();
const calcTableHeight = () => {
if (!tableRef.value) return;
const rect = tableRef.value.getBoundingClientRect();
tableHeight.value = window.innerHeight - rect.top - 84;
};
/** 阈值文本 */
const thresholdText = (row: WarningRow) => creditThresholdMap[row.creditLevel]?.text ?? '-';
/** 检查次数颜色:0 次绿、超阈值红、低于阈值橙 */
const countColor = (row: WarningRow) => {
if (row.checkCount === 0) return '#22b07d';
const t = creditThresholdMap[row.creditLevel];
if (!t) return '#333';
if (row.checkCount > t.max) return '#f54848';
if (row.checkCount < t.min) return '#f5a623';
return '#f54848';
};
/** 预警类型:超阈值 → 检查超期;低于阈值 → 检查不足 */
const warningType = (row: WarningRow) => {
const t = creditThresholdMap[row.creditLevel];
if (t && row.checkCount < t.min) return '检查不足';
return '检查超期';
};
const warningTypeStyle = (type: string) =>
type === '检查超期' ? { color: '#f54848', bg: 'rgba(245, 72, 72, 0.1)' } : { color: '#f5a623', bg: 'rgba(245, 166, 35, 0.12)' };
const warningLevelColor = (level: string) => {
if (level === '高') return '#f54848';
if (level === '中') return '#f5a623';
return '#909399';
};
const getList = () => {
loading.value = true;
// Mock 本地过滤(接口接入后替换为远程请求)
const filtered = allRows.filter((row) => {
if (queryParams.enterpriseName && !row.enterpriseName.includes(queryParams.enterpriseName)) return false;
if (props.dimension === 'area' && queryParams.area) {
const item = areaOptions.value.find((i: any) => i.dictValue === queryParams.area);
if (item && row.districtName !== item.dictLabel) return false;
}
if (props.dimension === 'field' && queryParams.domain && row.domainName !== queryParams.domain) return false;
if (queryParams.creditLevel && row.creditLevel !== queryParams.creditLevel) return false;
if (queryParams.warningLevel && row.warningLevel !== queryParams.warningLevel) return false;
if (queryParams.warningType && warningType(row) !== queryParams.warningType) return false;
return true;
});
tableData.value = filtered;
total.value = filtered.length;
loading.value = false;
};
const handleSearch = () => {
currentPage.value = 1;
getList();
};
const handleReset = () => {
queryParams.enterpriseName = '';
queryParams.area = undefined;
queryParams.domain = undefined;
queryParams.creditLevel = undefined;
queryParams.warningType = undefined;
queryParams.warningLevel = undefined;
queryParams.year = undefined;
tableData.value = [...allRows];
total.value = 658;
currentPage.value = 52;
pageSize.value = 20;
};
const handleExport = () => {
ElMessage.info('导出功能待接口接入');
};
const handleSelectionChange = (selection: WarningRow[]) => {
selectedRows.value = selection;
};
const handleSizeChange = (size: number) => {
pageSize.value = size;
currentPage.value = 1;
getList();
};
const handlePageChange = (page: number) => {
currentPage.value = page;
getList();
};
// ======================== 详情弹窗 ========================
interface DetailRecord {
id: number;
time: string;
unit: string;
item: string;
type: string;
people: string;
}
interface DetailInfo {
name: string;
code: string;
creditLevel: string;
levelText: string;
district: string;
updateTime: string;
checkCount: number;
isOver: boolean;
diff: number;
thresholdText: string;
monthly: number[];
records: DetailRecord[];
}
const detailVisible = ref(false);
const detailInfo = ref<DetailInfo | null>(null);
const detailChartRef = ref<HTMLElement>();
let detailChart: echarts.ECharts | null = null;
/** 由行数据生成 Mock 详情(接口接入后替换为远程请求) */
const buildDetail = (row: WarningRow): DetailInfo => {
const t = creditThresholdMap[row.creditLevel];
const isOver = t ? row.checkCount > t.max : true;
const diff = t ? (isOver ? row.checkCount - t.max : t.min - row.checkCount) : 0;
const thresholdText = t ? t.text : '-';
// 月度分布 Mock:优先落在 2/4/5/6 月
const monthOrder = [2, 4, 5, 6, 1, 3, 7, 8, 9, 10, 11, 12];
const monthly = Array(12).fill(0);
for (let i = 0; i < row.checkCount; i++) monthly[monthOrder[i % 12] - 1] += 1;
const units = ['深圳市光明区卫生健康局', '深圳市市场监督管理局宝安监管局'];
const records: DetailRecord[] = Array.from({ length: row.checkCount }, (_, i) => {
const m = monthOrder[i % 12];
return {
id: i + 1,
time: `2026-${String(m).padStart(2, '0')}-${String(2 + i).padStart(2, '0')} 14:55:04`,
unit: units[i % units.length],
item: '信访投诉事项',
type: '行政检查',
people: '李强,宋佳佳'
};
});
return {
name: row.enterpriseName,
code: '91440300MA5F1234X1',
creditLevel: `${row.creditLevel}级`,
levelText: row.creditLevel,
district: row.districtName,
updateTime: '2026-10-30',
checkCount: row.checkCount,
isOver,
diff,
thresholdText,
monthly,
records
};
};
const renderDetailChart = () => {
if (!detailChartRef.value || !detailInfo.value) return;
if (!detailChart) detailChart = echarts.init(detailChartRef.value);
detailChart.setOption(
{
grid: { left: 36, right: 12, top: 24, bottom: 26 },
xAxis: {
type: 'category',
data: Array.from({ length: 12 }, (_, i) => `${i + 1}月`),
axisTick: { show: false },
axisLine: { lineStyle: { color: '#dcdfe6' } },
axisLabel: { color: '#909399', fontSize: 11 }
},
yAxis: {
type: 'value',
minInterval: 1,
splitLine: { lineStyle: { color: '#f0f2f5' } },
axisLabel: { color: '#909399', fontSize: 11 }
},
series: [
{
type: 'bar',
data: detailInfo.value.monthly,
barWidth: 14,
itemStyle: { color: '#2f7df6', borderRadius: [2, 2, 0, 0] },
label: { show: true, position: 'top', color: '#606266', fontSize: 11 }
}
]
},
true
);
detailChart.resize();
};
const handleDetail = (row: WarningRow) => {
detailInfo.value = buildDetail(row);
detailVisible.value = true;
};
const handleDetailClosed = () => {
detailChart?.dispose();
detailChart = null;
};
onMounted(() => {
loadAreaDict();
loadFieldDict();
nextTick(() => calcTableHeight());
window.addEventListener('resize', calcTableHeight);
});
onUnmounted(() => {
window.removeEventListener('resize', calcTableHeight);
});
defineExpose({ calcTableHeight });
</script>
<template>
<div class="credit-pane">
<!-- ==================== 预警等级卡片 ==================== -->
<div class="warning-cards">
<div v-for="card in warningCards" :key="card.level" class="warning-card">
<div class="card-title">{{ card.level }}</div>
<div class="card-count" :style="{ color: card.color }">
<span class="count-num">{{ card.count }}</span>
<span class="count-unit">家</span>
</div>
<div class="card-desc">{{ card.desc }}</div>
</div>
</div>
<!-- ==================== 搜索区域 ==================== -->
<div class="search-panel">
<el-form :inline="true" label-colon>
<el-form-item label="企业名称">
<el-input v-model="queryParams.enterpriseName" placeholder="请输入关键字" class="search-input" clearable @keyup.enter="handleSearch" />
</el-form-item>
<el-form-item v-if="dimension === 'area'" label="所属区">
<el-select v-model="queryParams.area" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in areaOptions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
</el-select>
</el-form-item>
<el-form-item v-else label="所属领域">
<el-select v-model="queryParams.domain" 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="queryParams.creditLevel" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in creditOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="预警类型">
<el-select v-model="queryParams.warningType" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in warningTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="预警级别">
<el-select v-model="queryParams.warningLevel" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in warningLevelOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="年份">
<el-select v-model="queryParams.year" placeholder="请选择" class="year-select" clearable>
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</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 ref="tableRef">
<el-table
v-loading="loading"
:data="tableData"
stripe
style="width: 100%"
:height="tableHeight"
:header-cell-style="{ background: '#f5f7fa', color: '#333', fontWeight: 600 }"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" width="80" align="center" type="index" />
<el-table-column prop="enterpriseName" label="企业名称" min-width="240" align="left" />
<el-table-column :label="dimension === 'area' ? '所属区' : '所属领域'" min-width="100" align="center">
<template #default="{ row }">
{{ dimension === 'area' ? row.districtName : row.domainName }}
</template>
</el-table-column>
<el-table-column label="信用等级" min-width="110" align="center">
<template #default="{ row }">
<span class="credit-tag" :style="{ color: creditStyleMap[row.creditLevel]?.color, background: creditStyleMap[row.creditLevel]?.bg }">
{{ row.creditLevel }}
</span>
</template>
</el-table-column>
<el-table-column label="年度检查次数" min-width="130" align="center">
<template #default="{ row }">
<span :style="{ color: countColor(row), fontWeight: 600 }">{{ row.checkCount }}次</span>
</template>
</el-table-column>
<el-table-column label="监管要求 / 阈值" min-width="160" align="center">
<template #default="{ row }">{{ thresholdText(row) }}</template>
</el-table-column>
<el-table-column label="预警类型" min-width="120" align="center">
<template #default="{ row }">
<span class="type-tag" :style="{ color: warningTypeStyle(warningType(row)).color, background: warningTypeStyle(warningType(row)).bg }">
{{ warningType(row) }}
</span>
</template>
</el-table-column>
<el-table-column label="预警级别" min-width="110" align="center">
<template #default="{ row }">
<span class="level-dot" :style="{ background: warningLevelColor(row.warningLevel) }"></span>
<span :style="{ color: warningLevelColor(row.warningLevel) }">{{ row.warningLevel }}</span>
</template>
</el-table-column>
<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="currentPage"
v-model:page-size="pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
class="mt-4"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
<!-- ==================== 企业预警详情弹窗 ==================== -->
<el-dialog v-model="detailVisible" width="860px" top="4vh" @opened="renderDetailChart" @closed="handleDetailClosed">
<template #header>
<div class="detail-header">
<div class="detail-title">{{ detailInfo?.name }}</div>
<div class="detail-code">统一社会信用代码:{{ detailInfo?.code }}</div>
</div>
</template>
<div v-if="detailInfo" class="detail-body">
<!-- 警告横幅 -->
<div class="warn-banner" :class="{ under: !detailInfo.isOver }">
<div class="warn-title">{{ detailInfo.isOver ? '检查次数超限警告' : '检查次数不足提醒' }}</div>
<div class="warn-desc">
本年度已检查{{ detailInfo.checkCount }}次,{{ detailInfo.levelText }}级企业年度检查次数{{ detailInfo.isOver ? '上限' : '下限' }}为
{{ detailInfo.isOver ? creditThresholdMap[detailInfo.levelText]?.max : creditThresholdMap[detailInfo.levelText]?.min }} 次,{{
detailInfo.isOver ? '超出' : '还差'
}}
{{ detailInfo.diff }} 次
</div>
</div>
<!-- 企业基本信息 -->
<div class="section-title">企业基本信息</div>
<div class="info-grid">
<div class="info-item">
<div class="info-label">企业名称</div>
<div class="info-value">{{ detailInfo.name }}</div>
</div>
<div class="info-item">
<div class="info-label">统一社会信用代码</div>
<div class="info-value">{{ detailInfo.code }}</div>
</div>
<div class="info-item">
<div class="info-label">信用等级</div>
<div class="info-value">{{ detailInfo.creditLevel }}</div>
</div>
<div class="info-item">
<div class="info-label">所属区域</div>
<div class="info-value">{{ detailInfo.district }}</div>
</div>
<div class="info-item">
<div class="info-label">数据更新时间</div>
<div class="info-value">{{ detailInfo.updateTime }}</div>
</div>
</div>
<!-- 年度检查次数统计 -->
<div class="section-title">年度检查次数统计</div>
<div ref="detailChartRef" class="detail-chart"></div>
<!-- 检查登记记录 -->
<div class="section-title">检查登记记录(共{{ detailInfo.records.length }}条)</div>
<el-table :data="detailInfo.records" style="width: 100%" :header-cell-style="{ color: '#909399', fontWeight: 400, background: '#fff' }">
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="time" label="执法时间" min-width="160" align="center" />
<el-table-column prop="unit" label="执法单位" min-width="220" align="center" show-overflow-tooltip />
<el-table-column prop="item" label="执法事项" min-width="120" align="center" />
<el-table-column prop="type" label="执法类型" min-width="100" align="center" />
<el-table-column prop="people" label="执法人员" min-width="120" align="center" />
</el-table>
</div>
</el-dialog>
</div>
</template>
<style scoped lang="scss">
.credit-pane {
box-sizing: border-box;
}
/* ==================== 预警卡片 ==================== */
.warning-cards {
display: flex;
gap: 12px;
margin-bottom: 16px;
}
.warning-card {
flex: 1;
min-width: 0;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 14px 16px;
box-sizing: border-box;
.card-title {
font-size: 13px;
font-weight: 600;
color: #333;
line-height: 1.5;
}
.card-count {
margin-top: 6px;
line-height: 1.2;
.count-num {
font-size: 22px;
font-weight: 700;
}
.count-unit {
margin-left: 2px;
font-size: 13px;
font-weight: 600;
}
}
.card-desc {
margin-top: 6px;
font-size: 12px;
color: #909399;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
/* ==================== 搜索区域 ==================== */
.search-panel {
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: 180px;
}
.search-select {
width: 160px;
}
.year-select {
width: 120px;
}
}
/* ==================== 表格区域 ==================== */
.table-panel {
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 16px 20px;
box-sizing: border-box;
}
.credit-tag {
display: inline-block;
min-width: 30px;
padding: 2px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
line-height: 1.4;
}
.type-tag {
display: inline-block;
padding: 2px 10px;
border-radius: 4px;
font-size: 12px;
line-height: 1.5;
}
.level-dot {
display: inline-block;
width: 8px;
height: 8px;
margin-right: 6px;
border-radius: 50%;
vertical-align: middle;
}
.mt-4 {
margin-top: 16px;
justify-content: flex-end;
}
/* ==================== 详情弹窗 ==================== */
.detail-header {
.detail-title {
font-size: 16px;
font-weight: 600;
color: #303133;
line-height: 1.4;
}
.detail-code {
margin-top: 4px;
font-size: 12px;
font-weight: 400;
color: #909399;
}
}
.detail-body {
padding-top: 4px;
}
.warn-banner {
padding: 12px 16px;
background: #fef0f0;
border-radius: 4px;
.warn-title {
font-size: 13px;
font-weight: 600;
color: #f56c6c;
line-height: 1.5;
}
.warn-desc {
margin-top: 4px;
font-size: 12px;
color: #f56c6c;
line-height: 1.5;
}
&.under {
background: #fdf6ec;
.warn-title,
.warn-desc {
color: #e6a23c;
}
}
}
.section-title {
display: flex;
align-items: center;
margin: 20px 0 12px;
font-size: 14px;
font-weight: 600;
color: #303133;
&::before {
content: '';
width: 4px;
height: 14px;
margin-right: 8px;
background: #2f7df6;
border-radius: 2px;
}
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px 24px;
.info-label {
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.info-value {
margin-top: 4px;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 1.5;
}
}
.detail-chart {
width: 100%;
height: 180px;
}
</style>

749
zdxt-web-client/zdxt-admin-plus-ui/src/views/efcode/supervision_warning/risk-credit/index.vue

@ -1,534 +1,28 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import * as echarts from 'echarts';
import { getDicts } from '@/api/system/dict/data';
import { nextTick, ref } from 'vue';
import CreditPane from './components/CreditPane.vue';
// ======================== 预警等级卡片 ========================
interface WarningCard {
level: string;
count: number;
desc: string;
color: string;
}
const warningCards = ref<WarningCard[]>([
{ level: 'A+级预警', count: 1, desc: '预警:不符合年度检查<=1次', color: '#cf1322' },
{ level: 'A级预警', count: 2, desc: '预警:不符合年度检查1~2次', color: '#52c41a' },
{ level: 'B级预警', count: 1, desc: '预警:不符合年度检查2~4次', color: '#fa8c16' },
{ level: 'C级预警', count: 1, desc: '预警:不符合 年度检查4~7次', color: '#fa541c' },
{ level: 'D级预警', count: 1, desc: '预警:不符合 年度检查7~10次', color: '#f5222d' },
{ level: 'E级预警', count: 1, desc: '预警:不符合年度检查10~20次', color: '#722ed1' }
]);
// ======================== 信用等级 / 阈值配置 ========================
const creditStyleMap: Record<string, { color: string; bg: string }> = {
'A+': { color: '#7b5cff', bg: 'rgba(123, 92, 255, 0.12)' },
A: { color: '#22b07d', bg: 'rgba(34, 176, 125, 0.12)' },
B: { color: '#2f7df6', bg: 'rgba(47, 125, 246, 0.12)' },
C: { color: '#f5a623', bg: 'rgba(245, 166, 35, 0.12)' },
D: { color: '#f54848', bg: 'rgba(245, 72, 72, 0.12)' },
E: { color: '#a259e6', bg: 'rgba(162, 89, 230, 0.12)' }
};
/** 信用等级 → 年度检查次数阈值(min~max 次) */
const creditThresholdMap: Record<string, { min: number; max: number; text: string }> = {
'A+': { min: 0, max: 1, text: '年度检查<=1次' },
A: { min: 1, max: 2, text: '年度检查1~2次' },
B: { min: 2, max: 4, text: '年度检查2~4次' },
C: { min: 4, max: 7, text: '年度检查4~7次' },
D: { min: 7, max: 10, text: '年度检查7~10次' },
E: { min: 10, max: 20, text: '年度检查10~20次' }
};
const creditOptions = Object.keys(creditStyleMap);
// ======================== 查询条件 ========================
const queryParams = reactive({
enterpriseName: '',
area: undefined as string | undefined,
creditLevel: undefined as string | undefined,
warningType: undefined as string | undefined,
warningLevel: undefined as string | undefined,
year: undefined as string | undefined
});
const warningTypeOptions = [
{ label: '检查超期', value: '检查超期' },
{ label: '检查不足', value: '检查不足' }
];
const warningLevelOptions = [
{ label: '高', value: '高' },
{ label: '中', value: '中' },
{ label: '低', value: '低' }
];
/** 年份选项(近 5 年) */
const yearOptions = (() => {
const curr = new Date().getFullYear();
return Array.from({ length: 5 }, (_, i) => String(curr - i));
})();
// ======================== 所属区字典 ========================
const areaOptions = ref<any[]>([]);
const loadAreaDict = async () => {
try {
const res = await getDicts('address_type');
areaOptions.value = res.data || [];
} catch (e) {
console.error('加载所属区字典失败', e);
}
};
// ======================== 表格数据(Mock) ========================
interface WarningRow {
id: number;
enterpriseName: string;
districtName: string;
creditLevel: string;
checkCount: number;
warningLevel: string;
}
const allRows: WarningRow[] = [
{ id: 1, enterpriseName: '深圳市宝安区西乡健豹电子厂', districtName: '宝安区', creditLevel: 'A+', checkCount: 3, warningLevel: '低' },
{ id: 2, enterpriseName: '深圳市黄金屋真空科技有限公司', districtName: '福田区', creditLevel: 'B', checkCount: 1, warningLevel: '低' },
{ id: 3, enterpriseName: '深圳市蓝天新能源股份有限公司', districtName: '南山区', creditLevel: 'C', checkCount: 10, warningLevel: '中' },
{ id: 4, enterpriseName: '深圳市华强电子科技有限公司', districtName: '龙岗区', creditLevel: 'D', checkCount: 6, warningLevel: '低' },
{ id: 5, enterpriseName: '深圳市优鲜餐饮管理有限公司', districtName: '龙华区', creditLevel: 'E', checkCount: 29, warningLevel: '高' },
{ id: 6, enterpriseName: '深圳市远祥物流有限公司', districtName: '坪山区', creditLevel: 'A', checkCount: 0, warningLevel: '低' },
{ id: 7, enterpriseName: '深圳市金煌化工有限公司', districtName: '龙岗区', creditLevel: 'A', checkCount: 8, warningLevel: '高' }
];
const loading = ref(false);
const tableData = ref<WarningRow[]>([...allRows]);
const total = ref(658);
const currentPage = ref(52);
const pageSize = ref(20);
const selectedRows = ref<WarningRow[]>([]);
const tableHeight = ref<number | undefined>(undefined);
const tableRef = ref<HTMLElement>();
const calcTableHeight = () => {
if (!tableRef.value) return;
const rect = tableRef.value.getBoundingClientRect();
tableHeight.value = window.innerHeight - rect.top - 84;
};
/** 阈值文本 */
const thresholdText = (row: WarningRow) => creditThresholdMap[row.creditLevel]?.text ?? '-';
/** 检查次数颜色:0 次绿、超阈值红、低于阈值橙 */
const countColor = (row: WarningRow) => {
if (row.checkCount === 0) return '#22b07d';
const t = creditThresholdMap[row.creditLevel];
if (!t) return '#333';
if (row.checkCount > t.max) return '#f54848';
if (row.checkCount < t.min) return '#f5a623';
return '#f54848';
};
/** 预警类型:超阈值 → 检查超期;低于阈值 → 检查不足 */
const warningType = (row: WarningRow) => {
const t = creditThresholdMap[row.creditLevel];
if (t && row.checkCount < t.min) return '检查不足';
return '检查超期';
};
const warningTypeStyle = (type: string) =>
type === '检查超期'
? { color: '#f54848', bg: 'rgba(245, 72, 72, 0.1)' }
: { color: '#f5a623', bg: 'rgba(245, 166, 35, 0.12)' };
const warningLevelColor = (level: string) => {
if (level === '高') return '#f54848';
if (level === '中') return '#f5a623';
return '#909399';
};
const getList = () => {
loading.value = true;
// Mock 本地过滤(接口接入后替换为远程请求)
const filtered = allRows.filter((row) => {
if (queryParams.enterpriseName && !row.enterpriseName.includes(queryParams.enterpriseName)) return false;
if (queryParams.area) {
const item = areaOptions.value.find((i: any) => i.dictValue === queryParams.area);
if (item && row.districtName !== item.dictLabel) return false;
}
if (queryParams.creditLevel && row.creditLevel !== queryParams.creditLevel) return false;
if (queryParams.warningLevel && row.warningLevel !== queryParams.warningLevel) return false;
if (queryParams.warningType && warningType(row) !== queryParams.warningType) return false;
return true;
});
tableData.value = filtered;
total.value = filtered.length;
loading.value = false;
};
const handleSearch = () => {
currentPage.value = 1;
getList();
};
const handleReset = () => {
queryParams.enterpriseName = '';
queryParams.area = undefined;
queryParams.creditLevel = undefined;
queryParams.warningType = undefined;
queryParams.warningLevel = undefined;
queryParams.year = undefined;
tableData.value = [...allRows];
total.value = 658;
currentPage.value = 52;
pageSize.value = 20;
};
const handleExport = () => {
ElMessage.info('导出功能待接口接入');
};
const handleSelectionChange = (selection: WarningRow[]) => {
selectedRows.value = selection;
};
const handleSizeChange = (size: number) => {
pageSize.value = size;
currentPage.value = 1;
getList();
};
// area=各区域 field=各领域
const activeTab = ref<'area' | 'field'>('area');
const handlePageChange = (page: number) => {
currentPage.value = page;
getList();
};
// ======================== 详情弹窗 ========================
interface DetailRecord {
id: number;
time: string;
unit: string;
item: string;
type: string;
people: string;
}
interface DetailInfo {
name: string;
code: string;
creditLevel: string;
levelText: string;
district: string;
updateTime: string;
checkCount: number;
isOver: boolean;
diff: number;
thresholdText: string;
monthly: number[];
records: DetailRecord[];
}
const detailVisible = ref(false);
const detailInfo = ref<DetailInfo | null>(null);
const detailChartRef = ref<HTMLElement>();
let detailChart: echarts.ECharts | null = null;
/** 由行数据生成 Mock 详情(接口接入后替换为远程请求) */
const buildDetail = (row: WarningRow): DetailInfo => {
const t = creditThresholdMap[row.creditLevel];
const isOver = t ? row.checkCount > t.max : true;
const diff = t ? (isOver ? row.checkCount - t.max : t.min - row.checkCount) : 0;
const thresholdText = t ? t.text : '-';
// 月度分布 Mock:优先落在 2/4/5/6 月
const monthOrder = [2, 4, 5, 6, 1, 3, 7, 8, 9, 10, 11, 12];
const monthly = Array(12).fill(0);
for (let i = 0; i < row.checkCount; i++) monthly[monthOrder[i % 12] - 1] += 1;
const units = ['深圳市光明区卫生健康局', '深圳市市场监督管理局宝安监管局'];
const records: DetailRecord[] = Array.from({ length: row.checkCount }, (_, i) => {
const m = monthOrder[i % 12];
return {
id: i + 1,
time: `2026-${String(m).padStart(2, '0')}-${String(2 + i).padStart(2, '0')} 14:55:04`,
unit: units[i % units.length],
item: '信访投诉事项',
type: '行政检查',
people: '李强,宋佳佳'
};
/** 页签切换后通知表格重新计算高度(懒加载页签中的尺寸需要重算) */
const handleTabChange = () => {
nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
return {
name: row.enterpriseName,
code: '91440300MA5F1234X1',
creditLevel: `${row.creditLevel}级`,
levelText: row.creditLevel,
district: row.districtName,
updateTime: '2026-10-30',
checkCount: row.checkCount,
isOver,
diff,
thresholdText,
monthly,
records
};
};
const renderDetailChart = () => {
if (!detailChartRef.value || !detailInfo.value) return;
if (!detailChart) detailChart = echarts.init(detailChartRef.value);
detailChart.setOption(
{
grid: { left: 36, right: 12, top: 24, bottom: 26 },
xAxis: {
type: 'category',
data: Array.from({ length: 12 }, (_, i) => `${i + 1}月`),
axisTick: { show: false },
axisLine: { lineStyle: { color: '#dcdfe6' } },
axisLabel: { color: '#909399', fontSize: 11 }
},
yAxis: {
type: 'value',
minInterval: 1,
splitLine: { lineStyle: { color: '#f0f2f5' } },
axisLabel: { color: '#909399', fontSize: 11 }
},
series: [
{
type: 'bar',
data: detailInfo.value.monthly,
barWidth: 14,
itemStyle: { color: '#2f7df6', borderRadius: [2, 2, 0, 0] },
label: { show: true, position: 'top', color: '#606266', fontSize: 11 }
}
]
},
true
);
detailChart.resize();
};
const handleDetail = (row: WarningRow) => {
detailInfo.value = buildDetail(row);
detailVisible.value = true;
};
const handleDetailClosed = () => {
detailChart?.dispose();
detailChart = null;
};
onMounted(() => {
loadAreaDict();
nextTick(() => calcTableHeight());
window.addEventListener('resize', calcTableHeight);
});
onUnmounted(() => {
window.removeEventListener('resize', calcTableHeight);
});
</script>
<template>
<div class="app-container">
<!-- ==================== 预警等级卡片 ==================== -->
<div class="warning-cards">
<div v-for="card in warningCards" :key="card.level" class="warning-card">
<div class="card-title">{{ card.level }}</div>
<div class="card-count" :style="{ color: card.color }">
<span class="count-num">{{ card.count }}</span>
<span class="count-unit">家</span>
</div>
<div class="card-desc">{{ card.desc }}</div>
</div>
</div>
<!-- ==================== 搜索区域 ==================== -->
<div class="search-panel">
<el-form :inline="true" label-colon>
<el-form-item label="企业名称">
<el-input
v-model="queryParams.enterpriseName"
placeholder="请输入关键字"
class="search-input"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="所属区">
<el-select v-model="queryParams.area" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in areaOptions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
</el-select>
</el-form-item>
<el-form-item label="信用等级">
<el-select v-model="queryParams.creditLevel" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in creditOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="预警类型">
<el-select v-model="queryParams.warningType" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in warningTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="预警级别">
<el-select v-model="queryParams.warningLevel" placeholder="请选择" class="search-select" clearable>
<el-option v-for="item in warningLevelOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="年份">
<el-select v-model="queryParams.year" placeholder="请选择" class="year-select" clearable>
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
</el-select>
</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 ref="tableRef">
<el-table
v-loading="loading"
:data="tableData"
stripe
style="width: 100%"
:height="tableHeight"
:header-cell-style="{ background: '#f5f7fa', color: '#333', fontWeight: 600 }"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" width="80" align="center" type="index" />
<el-table-column prop="enterpriseName" label="企业名称" min-width="240" align="left" />
<el-table-column prop="districtName" label="所属区" min-width="100" align="center" />
<el-table-column label="信用等级" min-width="110" align="center">
<template #default="{ row }">
<span
class="credit-tag"
:style="{ color: creditStyleMap[row.creditLevel]?.color, background: creditStyleMap[row.creditLevel]?.bg }"
>
{{ row.creditLevel }}
</span>
</template>
</el-table-column>
<el-table-column label="年度检查次数" min-width="130" align="center">
<template #default="{ row }">
<span :style="{ color: countColor(row), fontWeight: 600 }">{{ row.checkCount }}次</span>
</template>
</el-table-column>
<el-table-column label="监管要求 / 阈值" min-width="160" align="center">
<template #default="{ row }">{{ thresholdText(row) }}</template>
</el-table-column>
<el-table-column label="预警类型" min-width="120" align="center">
<template #default="{ row }">
<span class="type-tag" :style="{ color: warningTypeStyle(warningType(row)).color, background: warningTypeStyle(warningType(row)).bg }">
{{ warningType(row) }}
</span>
</template>
</el-table-column>
<el-table-column label="预警级别" min-width="110" align="center">
<template #default="{ row }">
<span class="level-dot" :style="{ background: warningLevelColor(row.warningLevel) }"></span>
<span :style="{ color: warningLevelColor(row.warningLevel) }">{{ row.warningLevel }}</span>
</template>
</el-table-column>
<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="currentPage"
v-model:page-size="pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
class="mt-4"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
<!-- ==================== 企业预警详情弹窗 ==================== -->
<el-dialog
v-model="detailVisible"
width="860px"
top="4vh"
@opened="renderDetailChart"
@closed="handleDetailClosed"
>
<template #header>
<div class="detail-header">
<div class="detail-title">{{ detailInfo?.name }}</div>
<div class="detail-code">统一社会信用代码:{{ detailInfo?.code }}</div>
</div>
</template>
<div v-if="detailInfo" class="detail-body">
<!-- 警告横幅 -->
<div class="warn-banner" :class="{ under: !detailInfo.isOver }">
<div class="warn-title">{{ detailInfo.isOver ? '检查次数超限警告' : '检查次数不足提醒' }}</div>
<div class="warn-desc">
本年度已检查{{ detailInfo.checkCount }}次,{{ detailInfo.levelText }}级企业年度检查次数{{
detailInfo.isOver ? '上限' : '下限'
}}为 {{ detailInfo.isOver ? creditThresholdMap[detailInfo.levelText]?.max : creditThresholdMap[detailInfo.levelText]?.min }} 次,{{
detailInfo.isOver ? '超出' : '还差'
}} {{ detailInfo.diff }} 次
</div>
</div>
<!-- 企业基本信息 -->
<div class="section-title">企业基本信息</div>
<div class="info-grid">
<div class="info-item">
<div class="info-label">企业名称</div>
<div class="info-value">{{ detailInfo.name }}</div>
</div>
<div class="info-item">
<div class="info-label">统一社会信用代码</div>
<div class="info-value">{{ detailInfo.code }}</div>
</div>
<div class="info-item">
<div class="info-label">信用等级</div>
<div class="info-value">{{ detailInfo.creditLevel }}</div>
</div>
<div class="info-item">
<div class="info-label">所属区域</div>
<div class="info-value">{{ detailInfo.district }}</div>
</div>
<div class="info-item">
<div class="info-label">数据更新时间</div>
<div class="info-value">{{ detailInfo.updateTime }}</div>
</div>
</div>
<!-- 年度检查次数统计 -->
<div class="section-title">年度检查次数统计</div>
<div ref="detailChartRef" class="detail-chart"></div>
<!-- 检查登记记录 -->
<div class="section-title">检查登记记录(共{{ detailInfo.records.length }}条)</div>
<el-table
:data="detailInfo.records"
style="width: 100%"
:header-cell-style="{ color: '#909399', fontWeight: 400, background: '#fff' }"
>
<el-table-column type="index" label="序号" width="70" align="center" />
<el-table-column prop="time" label="执法时间" min-width="160" align="center" />
<el-table-column prop="unit" label="执法单位" min-width="220" align="center" show-overflow-tooltip />
<el-table-column prop="item" label="执法事项" min-width="120" align="center" />
<el-table-column prop="type" label="执法类型" min-width="100" align="center" />
<el-table-column prop="people" label="执法人员" min-width="120" align="center" />
</el-table>
</div>
</el-dialog>
<el-tabs v-model="activeTab" type="border-card" @tab-change="handleTabChange">
<el-tab-pane label="各区域" name="area" lazy>
<CreditPane dimension="area" />
</el-tab-pane>
<el-tab-pane label="各领域" name="field" lazy>
<CreditPane dimension="field" />
</el-tab-pane>
</el-tabs>
</div>
</template>
@ -536,216 +30,11 @@ onUnmounted(() => {
.app-container {
padding: 16px;
box-sizing: border-box;
background: #f0f2f5;
min-height: calc(100vh - 84px);
}
/* ==================== 预警卡片 ==================== */
.warning-cards {
display: flex;
gap: 12px;
margin-bottom: 16px;
}
.warning-card {
flex: 1;
min-width: 0;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 14px 16px;
box-sizing: border-box;
.card-title {
font-size: 13px;
font-weight: 600;
color: #333;
line-height: 1.5;
}
.card-count {
margin-top: 6px;
line-height: 1.2;
.count-num {
font-size: 22px;
font-weight: 700;
}
.count-unit {
margin-left: 2px;
font-size: 13px;
font-weight: 600;
}
}
.card-desc {
margin-top: 6px;
font-size: 12px;
color: #909399;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
/* ==================== 搜索区域 ==================== */
.search-panel {
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: 180px;
}
.search-select {
width: 160px;
}
.year-select {
width: 120px;
}
}
/* ==================== 表格区域 ==================== */
.table-panel {
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 16px 20px;
box-sizing: border-box;
}
.credit-tag {
display: inline-block;
min-width: 30px;
padding: 2px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
line-height: 1.4;
}
.type-tag {
display: inline-block;
padding: 2px 10px;
border-radius: 4px;
font-size: 12px;
line-height: 1.5;
}
.level-dot {
display: inline-block;
width: 8px;
height: 8px;
margin-right: 6px;
border-radius: 50%;
vertical-align: middle;
}
.mt-4 {
margin-top: 16px;
justify-content: flex-end;
}
/* ==================== 详情弹窗 ==================== */
.detail-header {
.detail-title {
font-size: 16px;
font-weight: 600;
color: #303133;
line-height: 1.4;
}
.detail-code {
margin-top: 4px;
font-size: 12px;
font-weight: 400;
color: #909399;
}
}
.detail-body {
padding-top: 4px;
}
.warn-banner {
padding: 12px 16px;
background: #fef0f0;
border-radius: 4px;
.warn-title {
font-size: 13px;
font-weight: 600;
color: #f56c6c;
line-height: 1.5;
}
.warn-desc {
margin-top: 4px;
font-size: 12px;
color: #f56c6c;
line-height: 1.5;
}
&.under {
background: #fdf6ec;
.warn-title,
.warn-desc {
color: #e6a23c;
}
}
}
.section-title {
display: flex;
align-items: center;
margin: 20px 0 12px;
font-size: 14px;
font-weight: 600;
color: #303133;
&::before {
content: '';
width: 4px;
height: 14px;
margin-right: 8px;
background: #2f7df6;
border-radius: 2px;
}
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px 24px;
.info-label {
font-size: 12px;
color: #909399;
line-height: 1.5;
}
.info-value {
margin-top: 4px;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 1.5;
}
}
.detail-chart {
width: 100%;
height: 180px;
/* 卡片式页签(与 efcode/report/registration/index.vue、inspection-registration/index.vue 保持一致) */
:deep(.el-tabs--border-card) {
box-shadow: none;
}
</style>

Loading…
Cancel
Save