|
|
|
@ -32,54 +32,57 @@
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus"
|
|
|
|
|
@click="dialogVisible = true; resetForm()">新增要素</el-button>
|
|
|
|
|
|
|
|
|
|
<!-- 渲染所有要素 -->
|
|
|
|
|
<div v-for="(element, elementIndex) in tableData" :key="elementIndex" class="tablebox">
|
|
|
|
|
<div class="boxheader">
|
|
|
|
|
<div class="headerone">
|
|
|
|
|
<div>{{ element.type == 1 ? '关键要素' : '重要要素' }}:</div>
|
|
|
|
|
<div>{{ element.name }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="headertwo">
|
|
|
|
|
<el-button type="primary" icon="el-icon-edit" size="mini"
|
|
|
|
|
@click="handleDeleteElement(element, elementIndex)">删除要素</el-button>
|
|
|
|
|
<el-button type="primary" icon="el-icon-edit" size="mini"
|
|
|
|
|
@click="handleUpdate(element)">编辑要素</el-button>
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus"
|
|
|
|
|
@click="showAddIndicatorDialog(element)">新增指标</el-button>
|
|
|
|
|
<!-- 要素列表渲染 -->
|
|
|
|
|
<div v-if="tableData.length > 0" class="tablebox" style="margin: .5rem;">
|
|
|
|
|
<div v-for="(element, elementIndex) in tableData" :key="elementIndex" class="tablebox">
|
|
|
|
|
<div class="boxheader">
|
|
|
|
|
<div class="headerone">
|
|
|
|
|
<div>{{ element.type == 1 ? '关键要素' : '重要要素' }}:</div>
|
|
|
|
|
<div>{{ element.name }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="headertwo">
|
|
|
|
|
<el-button type="primary" icon="el-icon-delete" size="mini"
|
|
|
|
|
@click="handleDeleteElement(element, elementIndex)">删除要素</el-button>
|
|
|
|
|
<el-button type="primary" icon="el-icon-edit" size="mini"
|
|
|
|
|
@click="handleUpdate(element)">编辑要素</el-button>
|
|
|
|
|
<el-button type="primary" icon="el-icon-plus"
|
|
|
|
|
@click="showAddIndicatorDialog(element)">新增指标</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table :data="element.list" style="width: 100%" border>
|
|
|
|
|
<el-table-column label="序号" width="80" align="center">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
{{ scope.$index + 1 }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="jtzb" label="具体指标" width="180"></el-table-column>
|
|
|
|
|
<el-table-column prop="xxyq" label="详细要求" min-width="300"></el-table-column>
|
|
|
|
|
<el-table-column label="操作" width="180" align="center">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button size="mini" type="text"
|
|
|
|
|
@click="handleUpdateIndicator(element, scope.row)">编辑</el-button>
|
|
|
|
|
<el-button size="mini" type="text" style="color: #F56C6C;"
|
|
|
|
|
@click="handleDeleteIndicator(element, scope.row, elementIndex, scope.$index)">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table :data="element.list" style="width: 100%">
|
|
|
|
|
<el-table-column label="序号" width="180">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
{{ scope.$index + 1 }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="jtzb" label="具体指标" width="180"></el-table-column>
|
|
|
|
|
<el-table-column prop="xxyq" label="详细要求" width="950"></el-table-column>
|
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button size="mini" type="text"
|
|
|
|
|
@click="handleUpdateIndicator(element, scope.row)">编辑指标</el-button>
|
|
|
|
|
<el-button size="mini" type="text"
|
|
|
|
|
@click="handleDelete(element, scope.row, elementIndex, scope.$index)"
|
|
|
|
|
style="color: #F25353;">删除指标</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else style="text-align: center; margin: 1rem;">暂无数据</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 新增/编辑要素弹窗 -->
|
|
|
|
|
<el-dialog :title="form.id ? '编辑要素' : '新增要素'" :visible.sync="dialogVisible" width="30%">
|
|
|
|
|
<el-form :model="form" :rules="rules" ref="elementForm" label-width="80px">
|
|
|
|
|
<el-form-item label="类型" prop="type">
|
|
|
|
|
<el-select v-model="form.type" placeholder="请选择类型">
|
|
|
|
|
<!-- 要素新增对话框 -->
|
|
|
|
|
<el-dialog title="新增要素" :visible.sync="dialogVisible" width="500px">
|
|
|
|
|
<el-form :model="form" :rules="formRules" ref="elementForm" label-width="80px">
|
|
|
|
|
<el-form-item label="要素类型" prop="type">
|
|
|
|
|
<el-select v-model="form.type" placeholder="请选择类型" style="width: 100%">
|
|
|
|
|
<el-option v-for="dict in dict.type.yslx" :key="dict.value" :label="dict.label"
|
|
|
|
|
:value="dict.value"></el-option>
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
|
|
<el-input v-model="form.name" placeholder="请输入名称"></el-input>
|
|
|
|
|
<el-form-item label="要素名称" prop="name">
|
|
|
|
|
<el-input v-model="form.name" placeholder="请输入要素名称"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
@ -88,14 +91,35 @@
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 新增/编辑指标弹窗 -->
|
|
|
|
|
<el-dialog :title="indicatorForm.id ? '编辑指标' : '新增指标'" :visible.sync="indicatorDialogVisible" width="30%">
|
|
|
|
|
<el-form :model="indicatorForm" :rules="rules" ref="indicatorForm" label-width="80px">
|
|
|
|
|
<!-- 编辑要素对话框 -->
|
|
|
|
|
<el-dialog title="编辑要素" :visible.sync="editDialogVisible" width="500px">
|
|
|
|
|
<el-form :model="editForm" :rules="formRules" ref="editElementForm" label-width="80px">
|
|
|
|
|
<el-form-item label="要素类型" prop="type">
|
|
|
|
|
<el-select v-model="editForm.type" placeholder="请选择类型" style="width: 100%">
|
|
|
|
|
<el-option v-for="dict in dict.type.yslx" :key="dict.value" :label="dict.label"
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="要素名称" prop="name">
|
|
|
|
|
<el-input v-model="editForm.name" placeholder="请输入要素名称"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="editDialogVisible = false">取 消</el-button>
|
|
|
|
|
<el-button type="primary" @click="submitEditElementForm">确 定</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 指标编辑/新增对话框 -->
|
|
|
|
|
<el-dialog :title="indicatorForm.id ? '编辑指标' : '新增指标'" :visible.sync="indicatorDialogVisible" width="500px">
|
|
|
|
|
<el-form :model="indicatorForm" :rules="indicatorRules" ref="indicatorForm" label-width="80px">
|
|
|
|
|
<el-form-item label="具体指标" prop="jtzb">
|
|
|
|
|
<el-input v-model="indicatorForm.jtzb" placeholder="请输入具体指标"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="详细要求" prop="xxyq">
|
|
|
|
|
<el-input v-model="indicatorForm.xxyq" placeholder="请输入详细要求"></el-input>
|
|
|
|
|
<el-input type="textarea" :rows="3" v-model="indicatorForm.xxyq"
|
|
|
|
|
placeholder="请输入详细要求"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
@ -104,6 +128,7 @@
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 企业端 -->
|
|
|
|
|
<div v-if="showCompanySection">
|
|
|
|
|
<tianbao />
|
|
|
|
@ -112,43 +137,89 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { addElement, getAllElements, editElemention, deleteElemention } from '@/api/ManageApi/index';
|
|
|
|
|
import {
|
|
|
|
|
addElement,
|
|
|
|
|
getAllElements,
|
|
|
|
|
editElemention,
|
|
|
|
|
deleteElemention,
|
|
|
|
|
updateYsElement,
|
|
|
|
|
deleteYsElement
|
|
|
|
|
} from '@/api/ManageApi/index';
|
|
|
|
|
import { checkPermi, checkRole } from "@/utils/permission";
|
|
|
|
|
import tianbao from '@/views/components/tianbao/tianbao.vue'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'ElementManagement',
|
|
|
|
|
dicts: ['yslx'],
|
|
|
|
|
components: { tianbao },
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
// 搜索表单
|
|
|
|
|
searchForm: {
|
|
|
|
|
name: '',
|
|
|
|
|
jtzb: ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 表格数据
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
|
|
|
|
// 对话框控制
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
editDialogVisible: false,
|
|
|
|
|
indicatorDialogVisible: false,
|
|
|
|
|
|
|
|
|
|
// 新增表单数据
|
|
|
|
|
form: {
|
|
|
|
|
type: '',
|
|
|
|
|
name: ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 编辑表单数据
|
|
|
|
|
editForm: {
|
|
|
|
|
id: 0,
|
|
|
|
|
type: '',
|
|
|
|
|
name: '',
|
|
|
|
|
oldName: '',
|
|
|
|
|
oldType: ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 指标表单数据
|
|
|
|
|
indicatorForm: {
|
|
|
|
|
id: 0,
|
|
|
|
|
jtzb: '',
|
|
|
|
|
xxyq: '',
|
|
|
|
|
elementId: 0
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 当前操作的要素
|
|
|
|
|
currentElement: null,
|
|
|
|
|
currentElementIndex: -1,
|
|
|
|
|
rules: {
|
|
|
|
|
|
|
|
|
|
// 验证规则
|
|
|
|
|
formRules: {
|
|
|
|
|
type: [{ required: true, message: '请选择要素类型', trigger: 'change' }],
|
|
|
|
|
name: [{ required: true, message: '请输入要素名称', trigger: 'blur' }],
|
|
|
|
|
name: [{ required: true, message: '请输入要素名称', trigger: 'blur' }]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
indicatorRules: {
|
|
|
|
|
jtzb: [{ required: true, message: '请输入具体指标', trigger: 'blur' }],
|
|
|
|
|
xxyq: [{ required: true, message: '请输入详细要求', trigger: 'blur' }]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 接口版本控制
|
|
|
|
|
useNewApi: true
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
showCompanySection() {
|
|
|
|
|
const isCompany = this.checkRole(['company']);
|
|
|
|
|
const isCommon = this.checkRole(['common']);
|
|
|
|
|
return isCompany && !isCommon;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
checkPermi,
|
|
|
|
|
checkRole,
|
|
|
|
@ -163,9 +234,14 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 查询要素
|
|
|
|
|
// 获取要素列表
|
|
|
|
|
fetchElements() {
|
|
|
|
|
getAllElements(this.searchForm).then(response => {
|
|
|
|
|
const params = {
|
|
|
|
|
name: this.searchForm.name,
|
|
|
|
|
jtzb: this.searchForm.jtzb
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getAllElements(params).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.tableData = response.data.map(item => ({
|
|
|
|
|
...item,
|
|
|
|
@ -179,7 +255,7 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 重置查询表单
|
|
|
|
|
// 重置搜索表单
|
|
|
|
|
resetSearchForm() {
|
|
|
|
|
this.searchForm = {
|
|
|
|
|
name: '',
|
|
|
|
@ -188,10 +264,9 @@ export default {
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 重置要素表单
|
|
|
|
|
// 重置新增要素表单
|
|
|
|
|
resetForm() {
|
|
|
|
|
this.form = {
|
|
|
|
|
id: 0,
|
|
|
|
|
type: '',
|
|
|
|
|
name: ''
|
|
|
|
|
};
|
|
|
|
@ -217,13 +292,20 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 提交要素表单
|
|
|
|
|
// 提交新增要素表单
|
|
|
|
|
submitElementForm() {
|
|
|
|
|
this.$refs.elementForm.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.handleAddElement();
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 提交编辑要素表单
|
|
|
|
|
submitEditElementForm() {
|
|
|
|
|
this.$refs.editElementForm.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.handleEditElement();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -232,14 +314,16 @@ export default {
|
|
|
|
|
submitIndicatorForm() {
|
|
|
|
|
this.$refs.indicatorForm.validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
this.handleAddIndicator();
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
if (this.indicatorForm.id) {
|
|
|
|
|
this.handleEditIndicator();
|
|
|
|
|
} else {
|
|
|
|
|
this.handleAddIndicator();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
|
// 新增要素
|
|
|
|
|
handleAddElement() {
|
|
|
|
|
const user = this.getUserInfo();
|
|
|
|
|
const payload = {
|
|
|
|
@ -247,64 +331,76 @@ export default {
|
|
|
|
|
createBy: user.userName,
|
|
|
|
|
createId: user.userId,
|
|
|
|
|
updateBy: user.userName,
|
|
|
|
|
updateId: user.userId,
|
|
|
|
|
updateId: user.userId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const api = this.form.id ? editElemention : addElement;
|
|
|
|
|
api(payload).then(response => {
|
|
|
|
|
addElement(payload).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success(this.form.id ? '要素编辑成功' : '要素新增成功');
|
|
|
|
|
this.$message.success('新增成功');
|
|
|
|
|
this.dialogVisible = false;
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
} else {}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '新增失败');
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
this.$message.error('新增失败: ' + (error.message || '未知错误'));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 编辑要素
|
|
|
|
|
handleEditElement() {
|
|
|
|
|
const payload = {
|
|
|
|
|
newName: this.editForm.name,
|
|
|
|
|
newType: this.editForm.type,
|
|
|
|
|
oldName: this.editForm.oldName,
|
|
|
|
|
oldType: this.editForm.oldType
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateYsElement(payload).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success('编辑成功');
|
|
|
|
|
this.editDialogVisible = false;
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '编辑失败');
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
this.$message.error('编辑失败: ' + (error.message || '未知错误'));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 准备编辑要素
|
|
|
|
|
handleUpdate(element) {
|
|
|
|
|
this.currentElement = element;
|
|
|
|
|
this.form = {
|
|
|
|
|
type: element.type,
|
|
|
|
|
name: element.name
|
|
|
|
|
this.editForm = {
|
|
|
|
|
id: element.id,
|
|
|
|
|
type: element.type.toString(),
|
|
|
|
|
name: element.name,
|
|
|
|
|
oldName: element.name,
|
|
|
|
|
oldType: element.type.toString()
|
|
|
|
|
};
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
this.editDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除要素
|
|
|
|
|
// 删除要素
|
|
|
|
|
handleDeleteElement(element, elementIndex) {
|
|
|
|
|
this.$confirm(`确定删除要素"${element.name}"及其所有指标吗?`, '警告', {
|
|
|
|
|
this.$confirm(`确定删除要素"${element.name}"吗?`, '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
// 构造要删除的ID列表(要素ID + 所有指标ID)
|
|
|
|
|
const idList = [element.id];
|
|
|
|
|
if (element.list && element.list.length > 0) {
|
|
|
|
|
element.list.forEach(indicator => {
|
|
|
|
|
if (indicator.id) { // 确保指标有ID
|
|
|
|
|
idList.push(indicator.id);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打印调试信息
|
|
|
|
|
console.log('删除要素请求参数:', {
|
|
|
|
|
idList: idList.join(','),
|
|
|
|
|
elementIndex
|
|
|
|
|
});
|
|
|
|
|
const deletePromise = this.useNewApi
|
|
|
|
|
? deleteYsElement({ name: element.name, lx: element.type })
|
|
|
|
|
: deleteElemention([element.id]);
|
|
|
|
|
|
|
|
|
|
// 调用API删除
|
|
|
|
|
deleteElemention(idList).then(response => {
|
|
|
|
|
deletePromise.then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success('删除成功');
|
|
|
|
|
// 从前端数组中移除该要素
|
|
|
|
|
this.tableData.splice(elementIndex, 1);
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '删除失败');
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.error('删除失败:', error);
|
|
|
|
|
this.$message.error('删除失败: ' + (error.message || '未知错误'));
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {
|
|
|
|
@ -312,7 +408,7 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 显示新增指标弹窗
|
|
|
|
|
// 显示新增指标对话框
|
|
|
|
|
showAddIndicatorDialog(element) {
|
|
|
|
|
this.currentElement = element;
|
|
|
|
|
this.resetIndicatorForm();
|
|
|
|
@ -320,7 +416,7 @@ export default {
|
|
|
|
|
this.indicatorDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 新增或编辑指标
|
|
|
|
|
// 新增指标
|
|
|
|
|
handleAddIndicator() {
|
|
|
|
|
const user = this.getUserInfo();
|
|
|
|
|
const payload = {
|
|
|
|
@ -333,22 +429,44 @@ export default {
|
|
|
|
|
updateId: user.userId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const api = this.indicatorForm.id ? editElemention : addElement;
|
|
|
|
|
|
|
|
|
|
api(payload).then(response => {
|
|
|
|
|
addElement(payload).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success(this.indicatorForm.id ? '指标编辑成功' : '指标新增成功');
|
|
|
|
|
this.$message.success('新增成功');
|
|
|
|
|
this.indicatorDialogVisible = false;
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '操作失败');
|
|
|
|
|
this.$message.error(response.msg || '新增失败');
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
this.$message.error('操作失败: ' + (error.message || '未知错误'));
|
|
|
|
|
this.$message.error('新增失败: ' + (error.message || '未知错误'));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 编辑指标
|
|
|
|
|
handleEditIndicator() {
|
|
|
|
|
const user = this.getUserInfo();
|
|
|
|
|
const payload = {
|
|
|
|
|
...this.indicatorForm,
|
|
|
|
|
name: this.currentElement.name,
|
|
|
|
|
type: this.currentElement.type,
|
|
|
|
|
updateBy: user.userName,
|
|
|
|
|
updateId: user.userId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
editElemention(payload).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success('编辑成功');
|
|
|
|
|
this.indicatorDialogVisible = false;
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '编辑失败');
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
this.$message.error('编辑失败: ' + (error.message || '未知错误'));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 准备编辑指标
|
|
|
|
|
handleUpdateIndicator(element, indicator) {
|
|
|
|
|
this.currentElement = element;
|
|
|
|
|
this.indicatorForm = {
|
|
|
|
@ -359,22 +477,15 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 删除指标
|
|
|
|
|
handleDelete(element, indicator, elementIndex, indicatorIndex) {
|
|
|
|
|
this.$confirm('确定删除该指标吗?', '警告', {
|
|
|
|
|
handleDeleteIndicator(element, indicator, elementIndex, indicatorIndex) {
|
|
|
|
|
this.$confirm('确定删除该指标吗?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
console.log('删除指标请求参数:', {
|
|
|
|
|
idList: [indicator.id].join(','),
|
|
|
|
|
elementIndex,
|
|
|
|
|
indicatorIndex
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
deleteElemention([indicator.id]).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message.success('删除成功');
|
|
|
|
|
// 根据索引从要素的list中移除指标
|
|
|
|
|
this.tableData[elementIndex].list.splice(indicatorIndex, 1);
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg || '删除失败');
|
|
|
|
@ -386,16 +497,6 @@ export default {
|
|
|
|
|
this.$message.info('已取消删除');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
showCompanySection() {
|
|
|
|
|
const isCompany = this.checkRole(['company']);
|
|
|
|
|
const isCommon = this.checkRole(['common']);
|
|
|
|
|
return isCompany && !isCommon;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.fetchElements();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|