rt-sim-training-client/src/views/system/commandDictionary/index.vue

186 lines
6.9 KiB
Vue
Raw Normal View History

2019-11-15 16:31:48 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</div>
</template>
<script>
import { getCommandList, delCommand } from '@/api/management/dictionary';
2019-11-18 14:29:43 +08:00
import { getLineCodeList } from '@/api/management/mapline';
2019-11-15 16:31:48 +08:00
export default {
name: 'CommandDictionary',
components: {
},
data() {
return {
taskStatusList: [],
2019-11-18 14:29:43 +08:00
deviceTypeList: [
{ label: '区段', value: 'section' },
{ label: '道岔', value: 'switch' },
{ label: '信号机', value: 'signal' },
{ label: '站台', value: 'station' },
{ label: '控制模式', value: 'stationConter' },
{ label: '临时全线限速', value: 'limitConter' }
],
2019-11-15 16:31:48 +08:00
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
reset: true,
queryObject: {
lineCode: {
type: 'select',
label: this.$t('system.lineCode'),
config: {
data: []
}
},
2019-11-18 14:29:43 +08:00
operateObject: {
2019-11-15 16:31:48 +08:00
type: 'select',
label: this.$t('system.deviceType'),
config: {
data: []
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
2019-11-18 14:29:43 +08:00
title: this.$t('system.lineCode'), // 线路编号
prop: 'lineCode',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.lineCode, this.taskStatusList, ['code', 'name']); },
tagType: (row) => { return 'success'; }
2019-11-15 16:31:48 +08:00
},
{
2019-11-18 14:29:43 +08:00
title: this.$t('system.controlMode'), // 控制模式
prop: 'controlMode',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.controlMode, this.$ConstSelect.controlMode, ['value', 'label']); },
tagType: (row) => { return 'success'; }
2019-11-15 16:31:48 +08:00
},
{
2019-11-18 14:29:43 +08:00
title: this.$t('system.simulationRole'), // 仿真角色
prop: 'simulationRole',
2019-11-15 16:31:48 +08:00
type: 'tag',
2019-11-18 14:29:43 +08:00
columnValue: (row) => { return this.$convertField(row.simulationRole, this.$ConstSelect.simulationRole, ['value', 'label']); },
2019-11-15 16:31:48 +08:00
tagType: (row) => { return 'success'; }
},
{
2019-11-18 14:29:43 +08:00
title: this.$t('system.deviceType'), // 设备类型
prop: 'operateObject',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.operateObject, this.deviceTypeList, ['value', 'label']); },
tagType: (row) => { return 'success'; }
2019-11-15 16:31:48 +08:00
},
{
title: this.$t('system.instructionType'), // 指令类型
2019-11-18 14:29:43 +08:00
prop: 'operate'
},
{
title: this.$t('system.parameterName'), // 指令参数名称
prop: 'paramList',
type: 'tagMore',
columnValue: (row) => { return this.replace(row.paramList); },
tagType: (row) => { return 'success'; }
2019-11-15 16:31:48 +08:00
},
{
type: 'button',
title: this.$t('global.operate'),
width: '250',
buttons: [
{
name: this.$t('global.edit'),
handleClick: this.handleEdit
},
{
name: this.$t('global.delete'),
handleClick: this.handleDelete,
type: 'danger'
}
]
}
],
actions: [
{ text: this.$t('global.add'), handler: this.handleAdd }
]
},
currentModel: {}
};
},
mounted () {
this.loadInitData();
},
methods: {
async loadInitData() {
try {
this.taskStatusList = [];
this.mapList = [];
2019-11-18 14:29:43 +08:00
const list = await getLineCodeList();
2019-11-15 16:31:48 +08:00
this.taskStatusList = list.data;
list.data.forEach(elem => {
2019-11-18 14:29:43 +08:00
this.queryForm.queryObject.lineCode.config.data.push({ value: elem.code, label: elem.name });
});
this.deviceTypeList.forEach(elem => {
this.queryForm.queryObject.operateObject.config.data.push(elem);
2019-11-15 16:31:48 +08:00
});
} catch (error) {
console.log(error);
}
},
queryFunction(params) {
if (!params['lineCode']) {
params['lineCode'] = '';
}
return getCommandList(params);
},
2019-11-18 14:29:43 +08:00
replace(fieldValue) {
const arr = [];
if (fieldValue && fieldValue.length) {
fieldValue.forEach((v, j) => {
if (v.name) {
arr.push(v.name);
}
});
}
return arr;
2019-11-15 16:31:48 +08:00
},
handleEdit(index, row) {
2019-11-18 14:29:43 +08:00
this.$router.push({ path: `/system/commands/Detail`, query: { type: 'edit', id: row.id } });
2019-11-15 16:31:48 +08:00
},
handleAdd() {
2019-11-18 14:29:43 +08:00
this.$router.push({ path: `/system/commands/Detail`, query: { type: 'add' } });
2019-11-15 16:31:48 +08:00
},
handleDelete(index, row) {
this.$confirm(this.$t('system.wellDelType'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
delCommand(row.id).then(response => {
this.$message.success(this.$t('system.deleteSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.deleteFailed'));
});
});
},
reloadTable() {
this.queryList.reload();
}
}
};
</script>