装备配置管理
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) {
|
||||
return request({
|
||||
|
|
|
|||
|
|
@ -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, // 假设装备ID存储在userId字段
|
||||
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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue