<template>
|
<div class="app-container">
|
<el-form style="margin-left :20px" :model="queryParams" ref="queryForm" size="small" :inline="true"
|
v-show="showSearch" label-width="68px">
|
<el-form-item label="考核类型" prop="examineCategory">
|
<el-select v-model="queryParams.examineCategory" placeholder="考核类型" clearable @change="handleQuery">
|
<el-option
|
v-for="dict in dict.type.platform_examine_category"
|
:key="dict.value"
|
:label="dict.label"
|
:value="parseInt(dict.value)"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="考核标签" prop="examineTag">
|
<el-select v-model="queryParams.examineTag" placeholder="考核标签" clearable @change="handleQuery">
|
<el-option
|
v-for="dict in dict.type.platform_examine_tag"
|
:key="parseInt(dict.value)"
|
:label="dict.label"
|
:value="parseInt(dict.value)"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
|
<el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" style="margin-left :15px">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
>新增
|
</el-button>
|
</el-col>
|
<!-- <el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="el-icon-edit"
|
size="mini"
|
:disabled="single"
|
@click="handleUpdate"
|
>修改</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="mini"
|
:disabled="multiple"
|
@click="handleDelete"
|
>删除</el-button>
|
</el-col> -->
|
<!-- <el-col :span="1.5">-->
|
<!-- <el-button-->
|
<!-- type="warning"-->
|
<!-- plain-->
|
<!-- icon="el-icon-download"-->
|
<!-- size="mini"-->
|
<!-- @click="handleExport"-->
|
<!-- >导出</el-button>-->
|
<!-- </el-col>-->
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
<div class="card-container">
|
<el-card class="box-card" v-for="item in checkTemplateList" :key="item">
|
<div class="text item">模板名称:{{ item.templateName }}</div>
|
<div class="text item">考核标签:{{
|
item.examineTag === 0 ? '省厅考核' :
|
item.examineTag === 1 ? '区县考核' :
|
item.examineTag === 2 ? '公安部考核' : '未知'
|
}}
|
</div>
|
<div class="text item" style="display: flex">
|
<span>考核类型:</span>
|
<dict-tag :options="dict.type.platform_examine_category" :value="item.examineCategory"/>
|
</div>
|
<!-- <div class="text item">考核频率:{{ item.frequency == 0 ? '月度考核' : '季度考核' }}</div> -->
|
<div class="text item" style="display: flex">
|
<span>考核对象:</span>
|
<el-tooltip effect="dark" :content="translateDeptIdList(item.deptId)" placement="top">
|
<div class="item" style="margin-bottom: 0" v-for="(deptId,index) in item.deptId" :key=index>
|
{{ translateDeptIdList(item.deptId) }}
|
</div>
|
</el-tooltip>
|
</div>
|
<div class="text item" style="display: flex">
|
<span style="padding: 3px 0;">使用状态:</span>
|
<dict-tag :options="dict.type.platform_use_state" :value="item.status"/>
|
</div>
|
<div class="bottom clearfix">
|
<el-button type="text" class="button" @click="handleStatus(item)" v-show="item.status == 1">启用</el-button>
|
<el-button type="text" class="button" @click="handleStatus(item)" v-show="item.status == 0">停用</el-button>
|
<el-button type="text" class="button" @click="handleCopy(item)">复制</el-button>
|
<el-button type="text" class="button" @click="handleUpdate(item)">修改</el-button>
|
<el-button type="text" class="button" @click="handleDelete(item)">删除</el-button>
|
</div>
|
</el-card>
|
</div>
|
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
|
<!-- 添加或修改考核模板对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form-item label="模板名称" prop="templateName">
|
<el-input v-model="form.templateName" placeholder="请输入模板名称"/>
|
</el-form-item>
|
<el-form-item label="考核标签" prop="examineTag">
|
<el-select v-model="form.examineTag" placeholder="考核类型">
|
<el-option
|
v-for="dict in dict.type.platform_examine_tag"
|
:key="dict.value"
|
:label="dict.label"
|
:value="parseInt(dict.value)"
|
/>
|
</el-select>
|
</el-form-item>
|
<!-- <el-form-item label="考核频率" prop="frequency">-->
|
<!-- <el-select v-model="form.frequency" placeholder="考核频率">-->
|
<!-- <el-option-->
|
<!-- v-for="dict in dict.type.platform_examine_frequency"-->
|
<!-- :key="dict.value"-->
|
<!-- :label="dict.label"-->
|
<!-- :value="parseInt(dict.value)"-->
|
<!-- />-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<el-form-item label="考核对象" prop="deptId">
|
<el-select v-model="form.deptId" multiple placeholder="请选择">
|
<el-option
|
v-for="item in areaList"
|
:key="item.id"
|
:label="item.value"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="考核类型" prop="examineCategory">
|
<el-select v-model="form.examineCategory" placeholder="考核类型" :disabled="tempRuleFormList.length > 0">
|
<el-option
|
v-for="dict in dict.type.platform_examine_category"
|
:key="dict.value"
|
:label="dict.label"
|
:value="parseInt(dict.value)"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="考核规则" prop="tempRuleFormList">
|
<div class="row-warp">
|
<div class="row" v-for="(form) in tempRuleFormList">
|
<div class="row-left">
|
<div>规则</div>
|
<div class="margin-5">
|
<el-select v-model="form.ruleId" placeholder="请选择">
|
<el-option
|
v-for="item in currentRuleList"
|
:key="item.id"
|
:label="item.ruleName"
|
:value="item.id"
|
:disabled="isRuleDisabled(item.id, index)"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="row-right">
|
<div>权重</div>
|
<div class="margin-5">
|
<el-input type="number" v-model.number="form.weight"/>
|
</div>
|
</div>
|
<div class="item-op">
|
<el-button @click="removeRule(form)" type="danger" icon="el-icon-delete" circle></el-button>
|
</div>
|
</div>
|
<div style="margin-top: 25px">
|
<el-button type="success" @click="nextAdd()" size="mini" plain>添加</el-button>
|
</div>
|
</div>
|
</el-form-item>
|
<el-form-item label="报警分数" prop="alarmScore">
|
<el-input v-model="form.alarmScore" placeholder="请输入报警分数"/>
|
</el-form-item>
|
<el-form-item label="调整系数" prop="adjustCoefficient">
|
<el-input v-model="form.adjustCoefficient" placeholder="请输入系数值"/>
|
</el-form-item>
|
<el-form-item label="调整方式" prop="adjustWay">
|
<el-select v-model="form.adjustWay" placeholder="请选择调整系数计算方式">
|
<el-option
|
label="乘"
|
value="*">
|
</el-option>
|
<el-option
|
label="除"
|
value="/">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="规则描述" prop="description">
|
<el-input v-model="form.description" type="textarea" :autosize="{ minRows: 4, maxRows: 6}"
|
placeholder="请输入规则描述"/>
|
</el-form-item>
|
<el-form-item label="状态" prop="status">
|
<el-radio v-model="form.status" label="0">启用</el-radio>
|
<el-radio v-model="form.status" label="1">停用</el-radio>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="cancel">取 消</el-button>
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import {
|
listCheckTemplate,
|
getCheckTemplate,
|
delCheckTemplate,
|
addCheckTemplate,
|
updateCheckTemplate,
|
copyCheckTemplate
|
} from "@/api/platform/check-template";
|
import {areaSelect} from '@/api/system/dept'
|
import {listCheckRule} from "../../../../api/platform/check-rule";
|
|
export default {
|
name: "CheckTemplate",
|
dicts: ['platform_use_state', 'platform_examine_category', 'platform_rule_category', 'platform_examine_frequency', 'platform_examine_tag'],
|
data() {
|
return {
|
props: {multiple: true},
|
value: [],
|
areaList: [],
|
ruleList: [],
|
unitList: [],
|
selectedRuleIds: [],
|
examineCategory: null,
|
isExamineCategoryDisabled: false,
|
// 临时规则表单列表
|
tempRuleFormList: [],
|
// 最终
|
ruleFormList: [],
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 考核模板表格数据
|
checkTemplateList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 状态时间范围
|
daterangeCreateTime: [],
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
examineCategory: null,
|
examineTag: null
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
templateName: [
|
{required: true, message: "模板名称不能为空", trigger: "blur"}
|
],
|
examineTag: [
|
{required: true, message: "请选择考核标签", trigger: "change"}
|
],
|
frequency: [
|
{required: true, message: "请选择状态考核频率", trigger: "change"}
|
],
|
deptId: [
|
{required: true, message: "请至少选择一个考核对象", trigger: "change"}
|
],
|
examineCategory: [
|
{required: true, message: "请选择考核类型", trigger: "change"}
|
],
|
adjustCoefficient: [
|
{required: true, message: "调整系数不能为空", trigger: "blur"}
|
],
|
adjustWay: [
|
{required: true, message: "请选择调整方式", trigger: "change"}
|
],
|
status: [
|
{required: true, message: "请选择状态", trigger: "change"}
|
],
|
},
|
};
|
},
|
computed: {
|
formattedDeptIds() {
|
// 使用map将数组元素转换为字符串,然后用join方法连接它们
|
return this.item.deptId.map(deptId => deptId.toString()).join(', ');
|
},
|
currentRuleList() {
|
// 根据当前考核类型返回相应的规则列表
|
const ruleListKey = this.form.examineCategory;
|
// 有三个不同的规则列表
|
const videoRules = this.ruleList['videoRules']; // 视频相关的规则集合
|
const carRules = this.ruleList['carRules']; // 汽车相关的规则集合
|
const faceRules = this.ruleList['faceRules']; // 人脸相关的规则集合
|
|
// 使用条件语句来选择规则列表
|
if (ruleListKey == 2) {
|
return carRules;
|
} else if (ruleListKey == 3) {
|
return faceRules;
|
} else if (ruleListKey == 1) {
|
return videoRules;
|
} else {
|
// 默认返回一个空数组或备选方案
|
return [];
|
}
|
}
|
},
|
created() {
|
this.getList();
|
this.areaSelect();
|
this.selectCheckRule();
|
if (typeof this.form.deptId === 'string' && this.form.deptId.length > 0) {
|
this.form.deptId = this.form.deptId.split(',').map(Number); // 假设deptId的值是以逗号分隔的数字字符串
|
}
|
},
|
methods: {
|
isRuleDisabled(ruleId, index) {
|
// 检查规则是否已被添加到 tempRuleFormList 中并且不是当前遍历的项
|
return this.tempRuleFormList.some(item => item.ruleId === ruleId && item !== this.tempRuleFormList[index]);
|
},
|
removeRule(form) {
|
console.log(form)
|
this.ruleFormList = this.ruleFormList.filter(item => item !== form);
|
this.tempRuleFormList = this.tempRuleFormList.filter(item => item !== form)
|
},
|
nextAdd() {
|
this.tempRuleFormList.push({"ruleId": null, "weight": null});
|
},
|
handleChange(value) {
|
console.log(value);
|
},
|
// 考核规则下拉数据
|
selectCheckRule() {
|
listCheckRule().then(res => {
|
this.ruleList = res.data;
|
})
|
},
|
// 区域下拉数据
|
areaSelect() {
|
areaSelect().then(res => {
|
this.areaList = res.data;
|
})
|
},
|
translateDeptId(deptId) {
|
const department = this.areaList.find(dept => dept.id === deptId);
|
return department ? department.value : '未知';
|
},
|
translateDeptIdList(deptNames) {
|
return deptNames.map(this.translateDeptId).join(', ');
|
},
|
/** 查询考核模板列表 */
|
getList() {
|
this.loading = true;
|
console.log(this.queryParams)
|
listCheckTemplate(this.queryParams).then(response => {
|
this.checkTemplateList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
templateName: null,
|
examineTag: null,
|
frequency: null,
|
deptId: [],
|
examineCategory: null,
|
alarmScore: null,
|
adjustCoefficient: null,
|
adjustWay: null,
|
status: null,
|
description: null,
|
createTime: null,
|
updateTime: null,
|
deleted: null
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.daterangeCreateTime = [];
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map(item => item.id)
|
this.single = selection.length !== 1
|
this.multiple = !selection.length
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.selectedRuleIds = [];
|
this.tempRuleFormList = [];
|
this.open = true;
|
this.title = "添加考核模板";
|
},
|
/** 复制按钮操作 */
|
handleCopy(row) {
|
copyCheckTemplate(row).then(response => {
|
this.$modal.msgSuccess("复制成功");
|
this.open = false;
|
this.getList();
|
});
|
},
|
handleStatus(row) {
|
let text = row.status == 1 ? '启用' : '停用';
|
const templateName = row.templateName;
|
this.$modal.confirm('是否确认' + text + '考核名为"' + templateName + '"的数据项?').then(function () {
|
row.status = row.status == 1 ? "0" : "1";
|
return updateCheckTemplate(row);
|
}).then(() => {
|
this.getList();
|
this.$modal.msgSuccess(text + "成功");
|
}).catch(() => {
|
});
|
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const id = row.id || this.ids
|
getCheckTemplate(id).then(response => {
|
this.form = response.data;
|
this.tempRuleFormList = this.form.ruleFormList;
|
this.ruleFormList = this.form.ruleFormList;
|
this.open = true;
|
this.title = "修改考核模板";
|
});
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate(valid => {
|
if (valid) {
|
// 遍历表单中的每个权重字段
|
for (let i = 0; i < this.tempRuleFormList.length; i++) {
|
const weight = this.tempRuleFormList[i].weight;
|
const ruleId = this.tempRuleFormList[i].ruleId;
|
// 如果权重为空,则显示错误提示,并阻止提交
|
if (!weight || !ruleId) {
|
this.$message.error('规则或权重不能为空');
|
return;
|
}
|
}
|
this.form.ruleFormList = this.tempRuleFormList;
|
if (this.form.id != null) {
|
updateCheckTemplate(this.form).then(response => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addCheckTemplate(this.form).then(response => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const id = row.id
|
this.$modal.confirm('是否确认删除考核模板名为"' + row.templateName + '"的数据项?').then(function () {
|
return delCheckTemplate(id);
|
}).then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
}).catch(() => {
|
});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download('system/checkTemplate/export', {
|
...this.queryParams
|
}, `checkTemplate_${new Date().getTime()}.xlsx`)
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.margin-5 {
|
margin-left: 5px;
|
}
|
|
.row-warp {
|
display: flex;
|
flex-direction: column;
|
}
|
|
.row {
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
justify-content: center;
|
margin: 5px 0;
|
}
|
|
.row-left {
|
flex: 1;
|
display: flex;
|
flex-direction: row;
|
}
|
|
.row-right {
|
flex: 1;
|
display: flex;
|
flex-direction: row;
|
}
|
|
.text {
|
font-size: 14px;
|
}
|
|
.item {
|
margin-bottom: 15px;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
|
.box-card {
|
width: 20%;
|
|
margin-right: 50px;
|
margin-bottom: 30px;
|
}
|
|
.card-container {
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: flex-start;
|
align-items: stretch;
|
margin-top: 20px;
|
padding: 0 20px;
|
}
|
</style>
|