装备配置管理

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) { export function getUser(userId) {
return request({ return request({

View File

@ -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, // IDuserId }).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>