<template>
|
<el-container direction="vertical">
|
<app-header title="交通统计报表审核系统 - 规则管理"></app-header>
|
<el-container>
|
<el-aside width="200px">
|
<el-menu router default-active="/rules">
|
<el-menu-item index="/dashboard">工作台</el-menu-item>
|
<el-menu-item index="/import">数据导入</el-menu-item>
|
<el-menu-item index="/data">数据查看</el-menu-item>
|
<el-menu-item index="/explain">企业解释</el-menu-item>
|
<el-menu-item index="/audit">审核结果</el-menu-item>
|
<el-menu-item index="/report">报表生成</el-menu-item>
|
<el-menu-item index="/rules">规则管理</el-menu-item>
|
<el-menu-item index="/users">用户管理</el-menu-item>
|
</el-menu>
|
</el-aside>
|
<el-main>
|
<h3>审核规则管理</h3>
|
<el-form :inline="true">
|
<el-form-item label="报表类型">
|
<el-radio-group v-model="reportType" @change="loadRules">
|
<el-radio label="H2032">货运月报</el-radio>
|
<el-radio label="H2031">旅客月报</el-radio>
|
<el-radio label="CITY_BUS">城市公交月报</el-radio>
|
<el-radio label="CITY_TAXI">巡游出租月报</el-radio>
|
<el-radio label="INVEST">投资月报</el-radio>
|
<el-radio label="H204">能耗季报</el-radio>
|
|
|
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="loadRules" :loading="loading">刷新</el-button>
|
</el-form-item>
|
</el-form>
|
<div class="table-area">
|
<el-table :data="rules" border v-loading="loading" size="small" style="width:100%" height="100%">
|
<el-table-column prop="ruleCode" label="规则编码" width="120"></el-table-column>
|
<el-table-column prop="ruleName" label="规则名称" min-width="180"></el-table-column>
|
<el-table-column prop="description" label="规则说明" min-width="260" show-overflow-tooltip></el-table-column>
|
<el-table-column label="比较方式" width="130">
|
<template slot-scope="scope">{{ typeLabel(scope.row.compareType) }}</template>
|
</el-table-column>
|
<el-table-column label="阈值" width="130">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.threshold" size="mini" placeholder="阈值" @change="saveThreshold(scope.row)"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="等级" width="110">
|
<template slot-scope="scope">
|
<el-select v-model="scope.row.alertLevel" size="mini" @change="saveThreshold(scope.row)">
|
<el-option label="红 (RED)" value="RED"></el-option>
|
<el-option label="黄 (YELLOW)" value="YELLOW"></el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column label="启用" width="80">
|
<template slot-scope="scope">
|
<el-switch v-model="scope.row.isEnabled" :active-value="1" :inactive-value="0"
|
@change="toggleRule(scope.row)"></el-switch>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</el-main>
|
</el-container>
|
</el-container>
|
</template>
|
<script>
|
import api from '@/api'
|
import AppHeader from '@/components/AppHeader.vue'
|
const TYPE_CN = {
|
DIFF: '差值对比', RATIO: '比例对比', MOM: '环比新增', NULL_CHECK: '必填/一致性',
|
OUT_RANGE: '范围检查', MOM_EQ_ZERO: '环比为0', MOM_PCT: '环比百分比',
|
MOM_EQ: '等于上月', EXISTENCE: '存在性', CROSS_DIFF: '跨表对比',
|
EXISTENCE_AUTH: '运政缺失', EXISTENCE_SYS: '系统缺失', CROSS_DIFF_PCT: '跨表百分比',
|
TREND_CONSISTENCY: '趋势一致', RATIO_CHANGE: '占比变化', AVG_DIST_CHANGE: '平均运距变化',
|
PAX_PER_TRIP_CHANGE: '单车次载客人数变化', LOADED_RATIO_DIFF: '载货里程占比对比',
|
FUEL_RANGE: '单耗超范围', FUEL_MOM: '单耗环比', FREIGHT_VS_H2032: '与货运月报对比',
|
AVG_DIST_VS_H2032: '平均运距对比', LOADED_TON_RATIO: '载货吨位比值'
|
}
|
export default {
|
components: { AppHeader },
|
name: 'RuleManage',
|
data() {
|
return { reportType: 'H2032', rules: [], loading: false }
|
},
|
methods: {
|
typeLabel(t) { return TYPE_CN[t] || t },
|
loadRules() {
|
this.loading = true
|
api.get('/rules/list', { params: { reportType: this.reportType } })
|
.then(res => { this.rules = res.data || [] })
|
.catch(e => { if (e && e._toast) return; this.$message.error('规则加载失败') })
|
.finally(() => { this.loading = false })
|
},
|
toggleRule(row) {
|
api.post('/rules/toggle', null, { params: { id: row.id, enabled: row.isEnabled } })
|
.then(() => { this.$message.success((row.isEnabled ? '已启用:' : '已停用:') + row.ruleCode) })
|
.catch(e => { if (e && e._toast) return; row.isEnabled = row.isEnabled ? 0 : 1; this.$message.error('操作失败') })
|
},
|
saveThreshold(row) {
|
api.post('/rules/update', {
|
id: row.id, threshold: row.threshold, alertLevel: row.alertLevel
|
}).then(() => { this.$message.success('已保存:' + row.ruleCode) })
|
.catch(e => { if (e && e._toast) return; this.$message.error('保存失败') })
|
}
|
},
|
mounted() { this.loadRules() }
|
}
|
</script>
|