<template>
|
<div>
|
<FYTable @search="onSearch" :pagination="false" ref="tableRef" :expandChange="expandChange">
|
<template #options>
|
<!-- 区县 -->
|
<!-- <FYOptionLocation
|
:allOption="false"
|
:level="3"
|
:checkStrictly="false"
|
v-model:value="formSearch.locations"
|
></FYOptionLocation> -->
|
</template>
|
<template #table-column>
|
<el-table-column align="center" type="expand">
|
<template v-slot="scope">
|
<el-table :data="scope.row.children" table-layout="fixed">
|
<el-table-column
|
prop="itemname"
|
label="名称"
|
width="200"
|
:show-overflow-tooltip="true"
|
></el-table-column>
|
<el-table-column prop="itemdescription" label="描述"></el-table-column>
|
<el-table-column prop="maxscore" label="最高分"></el-table-column>
|
<el-table-column prop="minscore" label="最低分"></el-table-column>
|
<el-table-column prop="defaultvalue" label="默认值"></el-table-column>
|
<el-table-column
|
prop="ertype"
|
label="评分规则类型"
|
width="150"
|
:formatter="formatSubRuleType"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="extension1"
|
label="评分类型"
|
width="150"
|
:formatter="formatScoreMode"
|
></el-table-column>
|
<el-table-column
|
prop="extension2"
|
label="得分模式"
|
width="150"
|
:formatter="formatScoreMode"
|
></el-table-column>
|
<el-table-column
|
prop="extension3"
|
label="选择模式"
|
width="150"
|
:formatter="formatScoreMode"
|
></el-table-column>
|
<!-- <el-table-column
|
prop="usedanalyse"
|
label="是否分析"
|
width="100"
|
:formatter="formatBoolean"
|
>
|
</el-table-column> -->
|
<el-table-column
|
prop="remark"
|
label="备注"
|
:show-overflow-tooltip="true"
|
></el-table-column>
|
<el-table-column v-slot="scope" prop="操作" label="操作" width="150">
|
<el-button link type="primary" @click="editSubRule(scope.row, 1)">查看</el-button>
|
<el-button link type="primary" @click="editSubRule(scope.row, 2)">修改</el-button>
|
<el-popconfirm title="确认删除?" @confirm="deleteSubRule(scope.row)">
|
<template #reference>
|
<el-button link type="danger">删除</el-button>
|
</template>
|
</el-popconfirm>
|
</el-table-column>
|
</el-table>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="rulename"
|
label="规则名称"
|
width="350"
|
:show-overflow-tooltip="true"
|
></el-table-column>
|
<el-table-column
|
prop="ruletype"
|
label="规则类型"
|
:formatter="formatRuleType"
|
></el-table-column>
|
<el-table-column prop="tasktype" label="任务类型"></el-table-column>
|
<el-table-column prop="scensetype" label="场景类型"></el-table-column>
|
<el-table-column prop="provincename" label="省份名称"></el-table-column>
|
<el-table-column prop="cityname" label="城市名称"></el-table-column>
|
<el-table-column prop="districtname" label="区县名称"></el-table-column>
|
<el-table-column
|
prop="suitable"
|
label="是否适用"
|
:formatter="formatBoolean"
|
></el-table-column>
|
<el-table-column prop="isuse" label="是否启用" :formatter="formatBoolean"></el-table-column>
|
<el-table-column v-slot="scope" prop="操作" label="操作" width="160">
|
<el-button link type="primary" @click="editRule(scope.row, 1)">查看</el-button>
|
<el-button link type="primary" @click="editRule(scope.row, 2)">修改</el-button>
|
<el-popconfirm title="确认删除?" @confirm="deleteRule(scope.row)">
|
<template #reference>
|
<el-button link type="danger">删除</el-button>
|
</template>
|
</el-popconfirm>
|
</el-table-column>
|
</template>
|
</FYTable>
|
<!-- 父节点的修改页面 -->
|
<el-dialog title="修改" width="80%" v-model="evalutionRuleVisible">
|
<CompEvalutionRuleUpd
|
v-if="evalutionRuleVisible"
|
:before-close="beforeEvalutionRuleDialogClose"
|
:evalutionRule="currEvalutionRule"
|
:readonly="parentReadOnly"
|
@updated="onEvalutionRuleUpdated"
|
/>
|
</el-dialog>
|
<!-- 子节点的修改页面 -->
|
<el-dialog title="修改" width="80%" v-model="evalutionSubRuleVisible">
|
<CompEvalutionSubRuleUpd
|
v-if="evalutionSubRuleVisible"
|
:before-close="beforeEvalutionSubRuleDialogClose"
|
:evalutionSubRule="currEvalutionSubRule"
|
:readonly="subReadOnly"
|
@updated="onEvalutionSubRuleUpdated"
|
/>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import evaluateApi from '@/api/fysp/evaluateApi';
|
import CompEvalutionRuleUpd from './components/evalution/CompEvalutionRuleUpd.vue';
|
import CompEvalutionSubRuleUpd from './components/evalution/CompEvalutionSubRuleUpd.vue';
|
import { ElMessage } from 'element-plus';
|
export default {
|
watch: {
|
expandKeyId: {
|
handler(newObj, oldObj) {
|
console.log('expandKeyId', this.expandKeyId);
|
},
|
deep: true
|
}
|
},
|
components: {
|
CompEvalutionRuleUpd,
|
CompEvalutionSubRuleUpd
|
},
|
mounted() {},
|
methods: {
|
// 评分规则子节点修改页面相关
|
deleteSubRule(row) {
|
evaluateApi.deleteSubRuleById(row.guid).then((res) => {
|
if (res == 1) {
|
ElMessage({
|
message: '删除成功',
|
type: 'success'
|
});
|
this.refreshTableData();
|
}
|
});
|
},
|
editSubRule(row, type) {
|
this.subReadOnly = (type == 1);
|
this.currEvalutionSubRule = row;
|
this.evalutionSubRuleVisible = true;
|
},
|
onEvalutionSubRuleUpdated(isOk) {
|
this.beforeEvalutionSubRuleDialogClose();
|
if (!isOk) {
|
return;
|
}
|
this.refreshTableData();
|
},
|
beforeEvalutionSubRuleDialogClose() {
|
this.evalutionSubRuleVisible = false;
|
},
|
// 评分规则父节点修改页面相关
|
deleteRule(row) {
|
evaluateApi.deleteParentRuleById(row.guid).then((res) => {
|
if (res == 1) {
|
ElMessage({
|
message: '删除成功',
|
type: 'success'
|
});
|
this.refreshTableData();
|
}
|
});
|
},
|
editRule(row, type) {
|
this.parentReadOnly = (type == 1);
|
this.currEvalutionRule = row;
|
this.evalutionRuleVisible = true;
|
},
|
onEvalutionRuleUpdated(isOk) {
|
this.beforeEvalutionRuleDialogClose();
|
if (!isOk) {
|
return;
|
}
|
this.refreshTableData();
|
},
|
beforeEvalutionRuleDialogClose() {
|
this.evalutionRuleVisible = false;
|
},
|
// 刷新列表数据
|
refreshTableData() {
|
setTimeout(() => {
|
this.$refs.tableRef.onSearch();
|
}, 1000);
|
},
|
|
onSearch(page, func) {
|
evaluateApi.getAllParentRules().then((res) => {
|
this.expandData = [];
|
this.expandKeyId = [];
|
res.forEach((element) => {
|
element.hasChildren = true;
|
// 获取子节点列表
|
evaluateApi.getSubRules(element.guid).then((res) => {
|
element.children = res.data;
|
});
|
});
|
func({ data: res });
|
});
|
},
|
// 加载子节点
|
load(row) {
|
var topId = row.guid;
|
evaluateApi.getSubRules(topId).then((res) => {
|
return res.data;
|
});
|
},
|
// 列表展示内容键值对的映射方法
|
formatBoolean(row, column, cellValue) {
|
if (cellValue == null || cellValue == undefined) {
|
return '';
|
}
|
return cellValue ? '是' : '否';
|
},
|
formatRuleType(row, column, cellValue) {
|
for (let index = 0; index < this.ruleTypes.length; index++) {
|
const item = this.ruleTypes[index];
|
if (item.value == cellValue) {
|
return item.label;
|
}
|
}
|
return '';
|
},
|
formatSubRuleType(row, column, cellValue) {
|
for (let index = 0; index < this.subRuleTypes.length; index++) {
|
const item = this.subRuleTypes[index];
|
if (item.value == cellValue) {
|
return item.label;
|
}
|
}
|
return '';
|
},
|
// 分数模式
|
formatScoreMode(row, column, cellValue) {
|
for (let index = 0; index < this.scoreTypes.length; index++) {
|
const item = this.scoreTypes[index];
|
if (item.value == cellValue) {
|
return item.label;
|
}
|
}
|
return '';
|
},
|
// 刷新数据时保存行的展开状态
|
saveExpandedRowsStatus() {
|
this.tableData.forEach((item) => {
|
if (item.guid == this.expandKeyId) {
|
this.$refs.table.toggleRowExpansion(item, true);
|
}
|
});
|
},
|
// 扩展每次只能打开一个
|
expandChange(row, expandedRows) {
|
this.expandData = expandedRows;
|
if (expandedRows.length == 1) {
|
if (!this.expandKeyId) {
|
this.expandKeyId = row.guid;
|
}
|
this.load(row);
|
} else if (expandedRows.length >= 2) {
|
//已经展开一行
|
this.expandKeyId = expandedRows[expandedRows.length - 1].guid; //获取最后一个点开的rowID
|
//遍历表格数据,关闭其他的展开行
|
this.tableData.map((item) => {
|
if (item.guid != this.expandKeyId) {
|
this.$refs.table.toggleRowExpansion(item, false);
|
}
|
});
|
} else {
|
//关闭
|
this.expandKeyId = undefined;
|
this.expandData = [];
|
}
|
}
|
},
|
data() {
|
return {
|
subReadOnly: false,
|
parentReadOnly: false,
|
// 当前展开的行
|
expandKeyId: [],
|
expandData: [],
|
// 评分规则子节点修改页面相关
|
currEvalutionSubRule: {},
|
evalutionSubRuleVisible: false,
|
// 评分规则父节点修改页面相关
|
currEvalutionRule: {},
|
evalutionRuleVisible: false,
|
|
tableData: [],
|
ruleTypes: [
|
{ label: '规范性', value: '1' },
|
{ label: '评分', value: '2' }
|
],
|
subRuleTypes: [
|
{ label: '规范考核项', value: 1 },
|
{ label: '评分大项', value: 2 },
|
{ label: '评分小项', value: 3 },
|
{ label: '最小评分项', value: 4 }
|
],
|
scoreTypes: [
|
{ label: '基础分', value: 'basic_score' },
|
{ label: '附加分', value: 'addition_score' },
|
{ label: '减分模式', value: 'minus_mode' },
|
{ label: '加分模式', value: 'add_mode' },
|
{ label: '单选模式', value: 'single_mode' },
|
{ label: '多选模式', value: 'multi_mode' },
|
{ label: '空', value: 'null' }
|
],
|
formSearch: {}
|
};
|
}
|
};
|
</script>
|
<style scoped></style>
|