设备管理配置调整

This commit is contained in:
fan 2023-03-01 15:51:05 +08:00
parent 710dd576d4
commit 8e7b653bd3

View File

@ -43,29 +43,6 @@
<!--</el-form-item>--> <!--</el-form-item>-->
<!--</el-form>--> <!--</el-form>-->
<el-input v-model="jsonConfig" autosize type="textarea" /> <el-input v-model="jsonConfig" autosize type="textarea" />
<el-form v-show="['PIS_STAND','PIS_TRAIN'].includes(data.type)" ref="formPis" :model="formPis" label-width="100px" :rules="rulesPis" style="margin-top:10px">
<!-- -->
<el-form-item label="关联角色:" prop="roleCode">
<el-select v-model="formPis.roleCode" placeholder="请选择" size="small">
<el-option
v-for="item in roleList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="关联客户端:" prop="client">
<el-select v-model="formPis.client" placeholder="请选择" size="small">
<el-option
v-for="item in clientList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button> <el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button> <el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
@ -77,9 +54,8 @@
import { setDeviceConfig, getDeviceDetail } from '@/api/project'; import { setDeviceConfig, getDeviceDetail } from '@/api/project';
import ConstConfig from '@/scripts/ConstConfig'; import ConstConfig from '@/scripts/ConstConfig';
// getAllMapOnline, getStationListNeedAttendant, getPsdListByStandCode, getStandListByStationCode // getAllMapOnline, getStationListNeedAttendant, getPsdListByStandCode, getStandListByStationCode
import {querySimulationMemberByMapId, querySimulationStationsByMapId } from '@/api/jmap/map'; // import {querySimulationMemberByMapId, querySimulationStationsByMapId } from '@/api/jmap/map';
import { getBackProjectConfigByCode } from '@/api/projectConfig'; // import { getMapFunctioById } from '@/api/trainingPlatform';
import { getMapFunctioById } from '@/api/trainingPlatform';
export default { export default {
name: 'EditConfigGateway', name: 'EditConfigGateway',
@ -95,10 +71,6 @@ export default {
// setDeviceConfigFunction: null, // setDeviceConfigFunction: null,
clientList: ConstConfig.ConstSelect.clientList, clientList: ConstConfig.ConstSelect.clientList,
data: {}, data: {},
formPis:{
roleCode:'',
client:''
},
titleMap: { titleMap: {
SWITCH: '道岔', SWITCH: '道岔',
PSD:'屏蔽门', PSD:'屏蔽门',
@ -119,15 +91,7 @@ export default {
// standList: [], // standList: [],
// standCode: '', // standCode: '',
// psdList: [], // psdList: [],
jsonConfig: '', jsonConfig: ''
rulesPis: {
roleCode: [
{ required: true, message: '请选择关联角色', trigger: 'change'}
],
client: [
{ required: true, message: '请选择关联客户端', trigger: 'change'}
]
}
}; };
}, },
computed: { computed: {
@ -146,30 +110,12 @@ export default {
initData(row) { initData(row) {
this.jsonConfig = '{}'; this.jsonConfig = '{}';
getDeviceDetail(row.id).then(resp => { getDeviceDetail(row.id).then(resp => {
this.formPis = {roleCode:'', client:''};
if (resp.data.config) { if (resp.data.config) {
// this.formModel = JSON.parse(resp.data.config); // this.formModel = JSON.parse(resp.data.config);
const config = JSON.parse(resp.data.config); this.jsonConfig = JSON.stringify(JSON.parse(resp.data.config), null, 4);
const jsonConfig = Object.assign({}, config);
delete jsonConfig.roleCode;
delete jsonConfig.client;
this.jsonConfig = JSON.stringify(jsonConfig, null, 4);
if (['PIS_STAND', 'PIS_TRAIN'].includes(row.type)) {
getBackProjectConfigByCode(row.project).then(res=>{
const data = res.data;
this.dialogVisible = true;
this.roleList = [];
if (config.roleCode) { this.formPis.roleCode = config.roleCode; }
if (config.client) { this.formPis.client = config.client; }
if (data.functionId) {
if (data.mapId) { this.mapIdChange(data.mapId, data.functionId); }
} else {
this.$message.error('请先配置项目信息');
}
});
}
} }
}).catch((e)=> { }).catch((e)=> {
console.error(e, '======');
this.$message.error('获取项目设备详情失败!'); this.$message.error('获取项目设备详情失败!');
}); });
// if (row.type === 'PSL' || row.type === 'PSC') { // if (row.type === 'PSL' || row.type === 'PSC') {
@ -193,13 +139,7 @@ export default {
}, },
doSave() { doSave() {
const self = this; const self = this;
let flag = true; const flag = true;
if (this.$refs.formPis) {
this.$refs.formPis.validate((valid) => {
flag = valid;
this.jsonConfig = JSON.stringify(Object.assign(JSON.parse(this.jsonConfig), this.formPis));
});
}
// const form = JSON.parse(this.jsonConfig); // const form = JSON.parse(this.jsonConfig);
// if (this.data.type === 'PSC' || this.data.type === 'PSL') { // if (this.data.type === 'PSC' || this.data.type === 'PSL') {
// form.psdCode = this.formModel.psdCode; // form.psdCode = this.formModel.psdCode;
@ -234,44 +174,44 @@ export default {
this.dialogVisible = false; this.dialogVisible = false;
this.$refs.form && this.$refs.form.resetFields(); this.$refs.form && this.$refs.form.resetFields();
}, },
mapIdChange(mapId, functionId) { // mapIdChange(mapId, functionId) {
if (mapId) { // if (mapId) {
querySimulationStationsByMapId(mapId).then(resp => { // querySimulationStationsByMapId(mapId).then(resp => {
if (resp.data && resp.data.length) { // if (resp.data && resp.data.length) {
this.stationList = resp.data; // this.stationList = resp.data;
} // }
}).catch(() => { // }).catch(() => {
this.$message.error('获取车站列表失败'); // this.$message.error('');
}); // });
querySimulationMemberByMapId(mapId).then(resp => { // querySimulationMemberByMapId(mapId).then(resp => {
if (resp.data) { // if (resp.data) {
getMapFunctioById(functionId).then(response=>{ // getMapFunctioById(functionId).then(response=>{
if (resp.data) { // if (resp.data) {
const roleList = resp.data[response.data.simType]; // const roleList = resp.data[response.data.simType];
const covertRoleList = []; // const covertRoleList = [];
roleList.forEach(member => { // roleList.forEach(member => {
const data = this.handleMember(member, this.stationList); // const data = this.handleMember(member, this.stationList);
covertRoleList.push(data); // covertRoleList.push(data);
}); // });
this.roleList = covertRoleList; // this.roleList = covertRoleList;
} // }
}); // });
} // }
}).catch(() => { // }).catch(() => {
this.$message.error('获取角色列表失败'); // this.$message.error('');
}); // });
} // }
// this.stationList = []; // // this.stationList = [];
// if (mapId) { // // if (mapId) {
// getStationListNeedAttendant(mapId).then(resp => { // // getStationListNeedAttendant(mapId).then(resp => {
// if (resp.data && resp.data.length) { // // if (resp.data && resp.data.length) {
// this.stationList = resp.data; // // this.stationList = resp.data;
// } // // }
// }).catch(() => { // // }).catch(() => {
// this.$message.error(''); // // this.$message.error('');
// }); // // });
// } // // }
}, // },
// stationCodeChange(stationCode) { // stationCodeChange(stationCode) {
// this.standList = []; // this.standList = [];
// if (stationCode) { // if (stationCode) {