2019-11-15 16:31:48 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
|
2019-11-19 13:00:36 +08:00
|
|
|
<show-condition ref="showCondition" />
|
2019-11-15 16:31:48 +08:00
|
|
|
</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-19 13:00:36 +08:00
|
|
|
import ShowCondition from './showCondition';
|
|
|
|
import Commands from '@/scripts/plugin/Commands';
|
2019-11-15 16:31:48 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'CommandDictionary',
|
|
|
|
components: {
|
2019-11-19 13:00:36 +08:00
|
|
|
ShowCondition
|
2019-11-15 16:31:48 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
taskStatusList: [],
|
2019-11-19 13:00:36 +08:00
|
|
|
operateList: [],
|
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-19 13:00:36 +08:00
|
|
|
title: this.$t('system.deviceType'), // 操作对象
|
2019-11-18 14:29:43 +08:00
|
|
|
prop: 'operateObject',
|
|
|
|
type: 'tag',
|
2019-11-19 13:00:36 +08:00
|
|
|
columnValue: (row) => { return this.$convertField(row.operateObject, this.$ConstSelect.deviceTypeList, ['value', 'label']); },
|
2019-11-18 14:29:43 +08:00
|
|
|
tagType: (row) => { return 'success'; }
|
2019-11-15 16:31:48 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('system.instructionType'), // 指令类型
|
2019-11-19 13:00:36 +08:00
|
|
|
prop: 'operate',
|
|
|
|
type: 'tag',
|
|
|
|
columnValue: (row) => { return this.convertField(row.operate, row.operateObject, ['value', 'label']); },
|
|
|
|
tagType: (row) => { return 'success'; }
|
2019-11-18 14:29:43 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
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'),
|
2019-11-19 13:00:36 +08:00
|
|
|
width: '350',
|
2019-11-15 16:31:48 +08:00
|
|
|
buttons: [
|
2019-11-19 13:00:36 +08:00
|
|
|
{
|
|
|
|
name: '查看条件参数',
|
|
|
|
handleClick: this.showCondition
|
|
|
|
},
|
2019-11-15 16:31:48 +08:00
|
|
|
{
|
|
|
|
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 });
|
|
|
|
});
|
2019-11-19 13:00:36 +08:00
|
|
|
this.$ConstSelect.deviceTypeList.forEach(elem => {
|
2019-11-18 14:29:43 +08:00
|
|
|
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-19 13:00:36 +08:00
|
|
|
convertField(fieldValue, operateObject, converFormat) {
|
|
|
|
if (Commands) {
|
|
|
|
// debugger;
|
|
|
|
const enumList = Object.values(Commands[operateObject]);
|
|
|
|
if (enumList && converFormat && converFormat.length >= 2) {
|
|
|
|
const value = converFormat[0];
|
|
|
|
const label = converFormat[1];
|
|
|
|
for (let i = 0; i < enumList.length; i++) {
|
|
|
|
if (fieldValue == enumList[i][value]) {
|
|
|
|
return enumList[i][label];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
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
|
|
|
},
|
2019-11-19 13:00:36 +08:00
|
|
|
// 显示条件参数
|
|
|
|
showCondition(index, row) {
|
|
|
|
this.$refs.showCondition.doShow(row.conditionList);
|
|
|
|
},
|
|
|
|
// 编辑
|
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
|
|
|
},
|
2019-11-19 13:00:36 +08:00
|
|
|
// 新增指令
|
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>
|