装备配置管理
This commit is contained in:
parent
6aaa754c62
commit
a2c5ceaf41
|
|
@ -10,6 +10,15 @@ export function listUser(query) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function selectConfigList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/material-mall/dept/selectConfigList',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 查询用户详细
|
// 查询用户详细
|
||||||
export function getUser(userId) {
|
export function getUser(userId) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,11 @@
|
||||||
@row-dblclick="handleRowDblClick"
|
@row-dblclick="handleRowDblClick"
|
||||||
:row-class-name="getRowClassName"
|
:row-class-name="getRowClassName"
|
||||||
>
|
>
|
||||||
<el-table-column label="装备分类" align="center" key="equipmentName" prop="equipmentName"
|
<el-table-column label="装备分类" align="center" key="equipmentName" prop="equipmentName"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="装备名称" align="center" key="equipmenttype" prop="equipmenttype"/>
|
<el-table-column label="装备名称" align="center" key="equipmenttype" prop="equipmenttype"/>
|
||||||
<el-table-column label="基本配置" prop="basicConfig" />
|
<el-table-column label="基本配置" align="center" prop="configStatus"/>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
|
|
@ -81,17 +81,44 @@
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="编辑基本配置"
|
title="编辑基本配置"
|
||||||
:visible.sync="inputDialogVisible"
|
:visible.sync="inputDialogVisible"
|
||||||
width="400px"
|
width="900px"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
>
|
>
|
||||||
<el-form ref="configForm" :model="configForm" :rules="configRules">
|
<el-form ref="configForm" :model="configForm" :rules="configRules">
|
||||||
<el-form-item prop="basicConfig">
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addConfig" style="margin-bottom:10px;">
|
||||||
<el-input
|
添加配置
|
||||||
v-model="configForm.basicConfig"
|
</el-button>
|
||||||
placeholder="请输入数字配置"
|
<div v-for="(item, index) in configForm.configs" :key="index"
|
||||||
clearable
|
style="border:1px solid #eee;padding:10px;margin-bottom:10px;"
|
||||||
/>
|
>
|
||||||
</el-form-item>
|
<el-form-item style="margin:auto" :prop="`configs.${index}.configurationType`">
|
||||||
|
<el-select v-model="item.configurationType" placeholder="请选择配置类型" clearable style="width: 180px">
|
||||||
|
<el-option v-for="dict in dict.type.config_type" :key="dict.value" :label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-input style="width: 180px;margin-left: 10px"
|
||||||
|
v-model="item.basicConfig"
|
||||||
|
placeholder="请输入数字配置"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
<el-input style="width: 180px ;margin-left: 10px"
|
||||||
|
v-model="item.configurationRate"
|
||||||
|
placeholder="请输入装备配置率"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
<el-input style="width: 180px ;margin-left: 10px"
|
||||||
|
v-model="item.configurationDescription"
|
||||||
|
placeholder="请输入配置说明"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
<el-button style="margin-left: 10px" type="danger" size="mini" @click="removeConfig(index)">删除</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="inputDialogVisible = false">取 消</el-button>
|
<el-button @click="inputDialogVisible = false">取 消</el-button>
|
||||||
|
|
@ -102,21 +129,22 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listUser, updateEquipmentConfig,deptTreeSelect } from '@/api/system/equipment'
|
import { listUser, updateEquipmentConfig, deptTreeSelect, selectConfigList } from '@/api/system/equipment'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'User',
|
name: 'User',
|
||||||
|
dicts: ['config_type'],
|
||||||
data() {
|
data() {
|
||||||
// 自定义数字验证规则
|
// 自定义数字验证规则
|
||||||
const validateNumber = (rule, value, callback) => {
|
const validateNumber = (rule, value, callback) => {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
callback(new Error('请输入配置值'));
|
callback(new Error('请输入配置值'))
|
||||||
} else if (isNaN(Number(value))) {
|
} else if (isNaN(Number(value))) {
|
||||||
callback(new Error('必须输入数字'));
|
callback(new Error('必须输入数字'))
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback()
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
|
|
@ -147,20 +175,42 @@ export default {
|
||||||
inputDialogVisible: false,
|
inputDialogVisible: false,
|
||||||
// 配置表单
|
// 配置表单
|
||||||
configForm: {
|
configForm: {
|
||||||
equipmentId: null, // 装备ID
|
equipmentId: null,
|
||||||
deptId: null, // 部门ID
|
deptId: null,
|
||||||
basicConfig: '' // 配置值
|
configs: []
|
||||||
},
|
},
|
||||||
// 配置表单验证规则
|
// 配置表单验证规则
|
||||||
configRules: {
|
configRules: {
|
||||||
basicConfig: [
|
configs: {
|
||||||
{ required: true, validator: validateNumber, trigger: 'blur' }
|
type: 'array',
|
||||||
]
|
required: true,
|
||||||
|
validator: (rule, value, callback) => {
|
||||||
|
if (!value || value.length === 0) {
|
||||||
|
return callback(new Error('请至少添加一个配置模块'))
|
||||||
|
}
|
||||||
|
for (const [i, item] of value.entries()) {
|
||||||
|
if (!item.configurationType) {
|
||||||
|
return callback(new Error(`第 ${i + 1} 个模块:配置类型不能为空`))
|
||||||
|
}
|
||||||
|
if (!item.basicConfig || isNaN(Number(item.basicConfig))) {
|
||||||
|
return callback(new Error(`第 ${i + 1} 个模块:数字配置必须是数字`))
|
||||||
|
}
|
||||||
|
if (!item.configurationRate) {
|
||||||
|
return callback(new Error(`第 ${i + 1} 个模块:装备配置率不能为空`))
|
||||||
|
}
|
||||||
|
if (!item.configurationDescription) {
|
||||||
|
return callback(new Error(`第 ${i + 1} 个模块:配置说明不能为空`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
},
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'label'
|
label: 'label'
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -173,8 +223,22 @@ export default {
|
||||||
this.getDeptTree()
|
this.getDeptTree()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
addConfig() {
|
||||||
|
this.configForm.configs.push({
|
||||||
|
configurationType: '',
|
||||||
|
basicConfig: '',
|
||||||
|
configurationRate: '',
|
||||||
|
configurationDescription: ''
|
||||||
|
})
|
||||||
|
},
|
||||||
|
removeConfig(index) {
|
||||||
|
this.configForm.configs.splice(index, 1)
|
||||||
|
},
|
||||||
/** 双击行事件 */
|
/** 双击行事件 */
|
||||||
handleRowDblClick(row) {
|
handleRowDblClick(row) {
|
||||||
|
this.configForm.deptId = this.currentDeptId;
|
||||||
|
this.configForm.equipmentId = row.equipmentId;
|
||||||
|
this.configForm.configs =[]
|
||||||
// 检查是否选择了部门
|
// 检查是否选择了部门
|
||||||
if (!this.currentDeptId) {
|
if (!this.currentDeptId) {
|
||||||
this.$message.warning('请先在左侧选择公司')
|
this.$message.warning('请先在左侧选择公司')
|
||||||
|
|
@ -182,16 +246,18 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否可编辑
|
// 检查是否可编辑
|
||||||
if (!this.checkSelectable(row)) return;
|
if (!this.checkSelectable(row)) return
|
||||||
|
selectConfigList({
|
||||||
// 填充表单数据
|
typeId: row.equipmentId,
|
||||||
this.configForm = {
|
deptId: this.currentDeptId
|
||||||
equipmentId: row.equipmentId, // 假设装备ID存储在userId字段
|
}).then(res => {
|
||||||
deptId: this.currentDeptId,
|
if (res.code === 200) {
|
||||||
basicConfig: row.basicConfig || ''
|
res.data.forEach(item => {
|
||||||
}
|
this.configForm.configs.push(item);
|
||||||
|
});
|
||||||
this.inputDialogVisible = true;
|
}
|
||||||
|
})
|
||||||
|
this.inputDialogVisible = true
|
||||||
|
|
||||||
// 清除验证
|
// 清除验证
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
@ -212,23 +278,25 @@ export default {
|
||||||
|
|
||||||
/** 保存配置到后端 */
|
/** 保存配置到后端 */
|
||||||
saveConfig() {
|
saveConfig() {
|
||||||
this.loading = true
|
/* console.log(this.configForm)
|
||||||
// 转换为数字类型
|
this.loading = true
|
||||||
const params = {
|
// 转换为数字类型
|
||||||
equipmentId: this.configForm.equipmentId,
|
const params = {
|
||||||
deptId: this.configForm.deptId,
|
equipmentId: this.configForm.equipmentId,
|
||||||
basicConfig: Number(this.configForm.basicConfig)
|
deptId: this.configForm.deptId,
|
||||||
}
|
basicConfig: Number(this.configForm.basicConfig)
|
||||||
|
|
||||||
updateEquipmentConfig(params).then(response => {
|
|
||||||
this.$message.success('配置保存成功')
|
|
||||||
|
|
||||||
// 更新前端显示
|
|
||||||
const index = this.userList.findIndex(item => item.equipmentId === params.equipmentId)
|
|
||||||
if (index !== -1) {
|
|
||||||
this.$set(this.userList[index], 'basicConfig', params.basicConfig)
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
updateEquipmentConfig(this.configForm).then(response => {
|
||||||
|
this.$message.success('配置保存成功')
|
||||||
|
this.getList()
|
||||||
|
/* // 更新前端显示
|
||||||
|
const index = this.userList.findIndex(item => item.equipmentId === params.equipmentId)
|
||||||
|
if (index !== -1) {
|
||||||
|
this.$set(this.userList[index], 'basicConfig', params.basicConfig)
|
||||||
|
}
|
||||||
|
*/
|
||||||
this.inputDialogVisible = false
|
this.inputDialogVisible = false
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
@ -240,88 +308,88 @@ export default {
|
||||||
|
|
||||||
/** 查询装备列表 */
|
/** 查询装备列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true
|
||||||
listUser(this.queryParams).then(response => {
|
listUser(this.queryParams).then(response => {
|
||||||
this.userList = (response.rows || []).map(item => {
|
this.userList = (response.rows || []).map(item => {
|
||||||
// 确保每行都有basicConfig属性
|
// 确保每行都有basicConfig属性
|
||||||
if (item.basicConfig === undefined) {
|
if (item.basicConfig === undefined) {
|
||||||
item.basicConfig = '';
|
item.basicConfig = ''
|
||||||
}
|
}
|
||||||
return item;
|
return item
|
||||||
});
|
})
|
||||||
this.total = response.total || 0;
|
this.total = response.total || 0
|
||||||
this.loading = false;
|
this.loading = false
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('获取装备列表失败:', error)
|
console.error('获取装备列表失败:', error)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
getDeptTree() {
|
getDeptTree() {
|
||||||
deptTreeSelect().then(response => {
|
deptTreeSelect().then(response => {
|
||||||
// 根据API实际响应结构处理
|
// 根据API实际响应结构处理
|
||||||
let treeData = response.data;
|
let treeData = response.data
|
||||||
|
|
||||||
// 如果API返回的是标准响应格式
|
// 如果API返回的是标准响应格式
|
||||||
if (response.code && response.data) {
|
if (response.code && response.data) {
|
||||||
treeData = response.data;
|
treeData = response.data
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deptOptions = treeData || [];
|
this.deptOptions = treeData || []
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('获取部门树失败:', error)
|
console.error('获取部门树失败:', error)
|
||||||
this.$message.error('获取部门树失败')
|
this.$message.error('获取部门树失败')
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 筛选节点
|
// 筛选节点
|
||||||
filterNode(value, data) {
|
filterNode(value, data) {
|
||||||
if (!value) return true;
|
if (!value) return true
|
||||||
return data.label.indexOf(value) !== -1;
|
return data.label.indexOf(value) !== -1
|
||||||
},
|
},
|
||||||
|
|
||||||
// 节点单击事件
|
// 节点单击事件
|
||||||
handleNodeClick(data) {
|
handleNodeClick(data) {
|
||||||
this.currentDeptId = data.id; // 保存当前选择的部门ID
|
this.currentDeptId = data.id // 保存当前选择的部门ID
|
||||||
this.currentDeptName = data.label; // 保存当前选择的部门名称
|
this.currentDeptName = data.label // 保存当前选择的部门名称
|
||||||
this.queryParams.deptId = data.id;
|
this.queryParams.deptId = data.id
|
||||||
this.handleQuery();
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.resetForm('queryForm');
|
this.resetForm('queryForm')
|
||||||
this.queryParams.equipmentName = undefined;
|
this.queryParams.equipmentName = undefined
|
||||||
this.queryParams.equipmenttype = undefined;
|
this.queryParams.equipmenttype = undefined
|
||||||
this.currentDeptId = null; // 重置部门ID
|
this.currentDeptId = null // 重置部门ID
|
||||||
this.currentDeptName = ''; // 重置部门名称
|
this.currentDeptName = '' // 重置部门名称
|
||||||
if (this.$refs.tree) {
|
if (this.$refs.tree) {
|
||||||
this.$refs.tree.setCurrentKey(null);
|
this.$refs.tree.setCurrentKey(null)
|
||||||
}
|
}
|
||||||
this.handleQuery();
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
|
|
||||||
// 检查行是否可编辑
|
// 检查行是否可编辑
|
||||||
checkSelectable(row) {
|
checkSelectable(row) {
|
||||||
// 这里保留原有的不可编辑逻辑
|
// 这里保留原有的不可编辑逻辑
|
||||||
return !(row.userId === 1 || row.isBuiltIn === '0' || this.hasSystemOrAuditrRole(row.roles));
|
return !(row.userId === 1 || row.isBuiltIn === '0' || this.hasSystemOrAuditrRole(row.roles))
|
||||||
},
|
},
|
||||||
|
|
||||||
hasSystemOrAuditrRole(roles) {
|
hasSystemOrAuditrRole(roles) {
|
||||||
if (!roles || !Array.isArray(roles)) return false;
|
if (!roles || !Array.isArray(roles)) return false
|
||||||
return roles.some(role => role.roleKey === 'systemAdmin' || role.roleKey === 'audit');
|
return roles.some(role => role.roleKey === 'systemAdmin' || role.roleKey === 'audit')
|
||||||
},
|
},
|
||||||
|
|
||||||
getRowClassName({ row }) {
|
getRowClassName({ row }) {
|
||||||
return !this.checkSelectable(row) ? 'disabled-row' : '';
|
return !this.checkSelectable(row) ? 'disabled-row' : ''
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue