装备配置管理

This commit is contained in:
jiang 2025-07-01 16:24:49 +08:00
parent 6aaa754c62
commit a2c5ceaf41
2 changed files with 157 additions and 80 deletions

View File

@ -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) {
return request({

View File

@ -52,11 +52,11 @@
@row-dblclick="handleRowDblClick"
:row-class-name="getRowClassName"
>
<el-table-column label="装备分类" align="center" key="equipmentName" prop="equipmentName"
:show-overflow-tooltip="true"
/>
<el-table-column label="装备分类" align="center" key="equipmentName" prop="equipmentName"
:show-overflow-tooltip="true"
/>
<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">
<template slot-scope="scope">
<el-button
@ -81,17 +81,44 @@
<el-dialog
title="编辑基本配置"
:visible.sync="inputDialogVisible"
width="400px"
width="900px"
:close-on-click-modal="false"
>
<el-form ref="configForm" :model="configForm" :rules="configRules">
<el-form-item prop="basicConfig">
<el-input
v-model="configForm.basicConfig"
placeholder="请输入数字配置"
clearable
/>
</el-form-item>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addConfig" style="margin-bottom:10px;">
添加配置
</el-button>
<div v-for="(item, index) in configForm.configs" :key="index"
style="border:1px solid #eee;padding:10px;margin-bottom:10px;"
>
<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>
<span slot="footer" class="dialog-footer">
<el-button @click="inputDialogVisible = false"> </el-button>
@ -102,21 +129,22 @@
</template>
<script>
import { listUser, updateEquipmentConfig,deptTreeSelect } from '@/api/system/equipment'
import { listUser, updateEquipmentConfig, deptTreeSelect, selectConfigList } from '@/api/system/equipment'
export default {
name: 'User',
dicts: ['config_type'],
data() {
//
const validateNumber = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入配置值'));
callback(new Error('请输入配置值'))
} else if (isNaN(Number(value))) {
callback(new Error('必须输入数字'));
callback(new Error('必须输入数字'))
} else {
callback();
callback()
}
};
}
return {
//
@ -147,20 +175,42 @@ export default {
inputDialogVisible: false,
//
configForm: {
equipmentId: null, // ID
deptId: null, // ID
basicConfig: '' //
equipmentId: null,
deptId: null,
configs: []
},
//
configRules: {
basicConfig: [
{ required: true, validator: validateNumber, trigger: 'blur' }
]
configs: {
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: {
children: 'children',
label: 'label'
},
}
}
},
watch: {
@ -173,8 +223,22 @@ export default {
this.getDeptTree()
},
methods: {
addConfig() {
this.configForm.configs.push({
configurationType: '',
basicConfig: '',
configurationRate: '',
configurationDescription: ''
})
},
removeConfig(index) {
this.configForm.configs.splice(index, 1)
},
/** 双击行事件 */
handleRowDblClick(row) {
this.configForm.deptId = this.currentDeptId;
this.configForm.equipmentId = row.equipmentId;
this.configForm.configs =[]
//
if (!this.currentDeptId) {
this.$message.warning('请先在左侧选择公司')
@ -182,16 +246,18 @@ export default {
}
//
if (!this.checkSelectable(row)) return;
//
this.configForm = {
equipmentId: row.equipmentId, // IDuserId
deptId: this.currentDeptId,
basicConfig: row.basicConfig || ''
}
this.inputDialogVisible = true;
if (!this.checkSelectable(row)) return
selectConfigList({
typeId: row.equipmentId,
deptId: this.currentDeptId
}).then(res => {
if (res.code === 200) {
res.data.forEach(item => {
this.configForm.configs.push(item);
});
}
})
this.inputDialogVisible = true
//
this.$nextTick(() => {
@ -212,23 +278,25 @@ export default {
/** 保存配置到后端 */
saveConfig() {
this.loading = true
//
const params = {
equipmentId: this.configForm.equipmentId,
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)
/* console.log(this.configForm)
this.loading = true
//
const params = {
equipmentId: this.configForm.equipmentId,
deptId: this.configForm.deptId,
basicConfig: Number(this.configForm.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.loading = false
}).catch(error => {
@ -240,88 +308,88 @@ export default {
/** 查询装备列表 */
getList() {
this.loading = true;
this.loading = true
listUser(this.queryParams).then(response => {
this.userList = (response.rows || []).map(item => {
// basicConfig
if (item.basicConfig === undefined) {
item.basicConfig = '';
item.basicConfig = ''
}
return item;
});
this.total = response.total || 0;
this.loading = false;
return item
})
this.total = response.total || 0
this.loading = false
}).catch(error => {
console.error('获取装备列表失败:', error)
this.loading = false
});
})
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
// API
let treeData = response.data;
let treeData = response.data
// API
if (response.code && response.data) {
treeData = response.data;
treeData = response.data
}
this.deptOptions = treeData || [];
this.deptOptions = treeData || []
}).catch(error => {
console.error('获取部门树失败:', error)
this.$message.error('获取部门树失败')
});
})
},
//
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
if (!value) return true
return data.label.indexOf(value) !== -1
},
//
handleNodeClick(data) {
this.currentDeptId = data.id; // ID
this.currentDeptName = data.label; //
this.queryParams.deptId = data.id;
this.handleQuery();
this.currentDeptId = data.id // ID
this.currentDeptName = data.label //
this.queryParams.deptId = data.id
this.handleQuery()
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.queryParams.equipmentName = undefined;
this.queryParams.equipmenttype = undefined;
this.currentDeptId = null; // ID
this.currentDeptName = ''; //
this.resetForm('queryForm')
this.queryParams.equipmentName = undefined
this.queryParams.equipmenttype = undefined
this.currentDeptId = null // ID
this.currentDeptName = '' //
if (this.$refs.tree) {
this.$refs.tree.setCurrentKey(null);
this.$refs.tree.setCurrentKey(null)
}
this.handleQuery();
this.handleQuery()
},
//
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) {
if (!roles || !Array.isArray(roles)) return false;
return roles.some(role => role.roleKey === 'systemAdmin' || role.roleKey === 'audit');
if (!roles || !Array.isArray(roles)) return false
return roles.some(role => role.roleKey === 'systemAdmin' || role.roleKey === 'audit')
},
getRowClassName({ row }) {
return !this.checkSelectable(row) ? 'disabled-row' : '';
},
return !this.checkSelectable(row) ? 'disabled-row' : ''
}
}
}
</script>