2020-01-02 17:01:11 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
|
2020-06-19 18:02:50 +08:00
|
|
|
<device-add ref="add" :project-code="projectCode" @reloadTable="reloadTable" />
|
|
|
|
<edit-config-gateway ref="editConfigGateway" @reloadTable="reloadTable" />
|
2020-01-02 17:01:11 +08:00
|
|
|
<edit-config ref="editConfig" @reloadTable="reloadTable" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { getProjectDeviceList, deleteProjectDevice } from '@/api/project';
|
2020-01-06 11:25:07 +08:00
|
|
|
import DeviceAdd from './add';
|
2020-06-19 18:02:50 +08:00
|
|
|
import EditConfigGateway from './editConfigGateway';
|
2020-01-02 17:01:11 +08:00
|
|
|
import EditConfig from './editConfig';
|
2020-06-19 18:02:50 +08:00
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
2020-01-02 17:01:11 +08:00
|
|
|
export default {
|
|
|
|
name: 'DeviceManage',
|
|
|
|
components: {
|
2020-01-06 11:25:07 +08:00
|
|
|
DeviceAdd,
|
2020-06-19 18:02:50 +08:00
|
|
|
EditConfigGateway,
|
2020-01-02 17:01:11 +08:00
|
|
|
EditConfig
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
examResultList: [],
|
|
|
|
pagerConfig: {
|
|
|
|
pageSize: 'pageSize',
|
|
|
|
pageIndex: 'pageNum'
|
|
|
|
},
|
2020-06-19 18:02:50 +08:00
|
|
|
deviceTypeList:[
|
|
|
|
{label: '道岔', value: 'SWITCH'},
|
|
|
|
{label: '信号机', value:'SIGNAL'},
|
|
|
|
{label: '屏蔽门', value: 'PSD'},
|
|
|
|
{label: 'IBP盘', value: 'IBP'},
|
|
|
|
{label: '车站', value: 'LW'}
|
|
|
|
],
|
2020-01-02 17:01:11 +08:00
|
|
|
projectList: [{label:'西铁院', value: 'XTY'}, {label: '贵州装备', value:'GZB'}],
|
2020-06-19 18:02:50 +08:00
|
|
|
projectMap: {
|
|
|
|
designxty: 'XTY',
|
|
|
|
designgzb: 'GZB'
|
|
|
|
},
|
2020-01-02 17:01:11 +08:00
|
|
|
queryForm: {
|
|
|
|
labelWidth: '120px',
|
|
|
|
reset: true,
|
2020-06-19 18:02:50 +08:00
|
|
|
beforeQuery: this.beforeQuery,
|
2020-01-02 17:01:11 +08:00
|
|
|
queryObject: {
|
|
|
|
code: {
|
|
|
|
type: 'text',
|
|
|
|
label: '设备编号'
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: 'select',
|
|
|
|
label: '设备类型',
|
|
|
|
config: {
|
|
|
|
data: [{label: '道岔', value: 'SWITCH'}, {label: '信号机', value:'SIGNAL'}, {label: '屏蔽门', value: 'PSD'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
queryList: {
|
|
|
|
query: getProjectDeviceList,
|
|
|
|
selectCheckShow: false,
|
|
|
|
indexShow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
title: '设备编号',
|
|
|
|
prop: 'code'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '项目名称',
|
|
|
|
prop: 'projectCode',
|
|
|
|
type: 'tag',
|
2020-06-19 18:02:50 +08:00
|
|
|
columnValue: (row) => { return this.$convertField(row.project, this.projectList, ['value', 'label']); },
|
2020-01-02 17:01:11 +08:00
|
|
|
tagType: (row) => { return 'success'; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '设备类型',
|
|
|
|
prop: 'type',
|
|
|
|
type: 'tag',
|
|
|
|
columnValue: (row) => { return this.$convertField(row.type, this.deviceTypeList, ['value', 'label']); },
|
|
|
|
tagType: (row) => { return 'success'; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '创建时间',
|
|
|
|
prop: 'createTime',
|
|
|
|
type: 'tag',
|
|
|
|
columnValue: (row) => { return this.handleTime(row.createTime); },
|
|
|
|
tagType: (row) => { return 'success'; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
title: this.$t('global.operate'),
|
|
|
|
width: '250',
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: '编辑配置',
|
|
|
|
handleClick: this.editConfig
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('global.delete'),
|
|
|
|
handleClick: this.handleDelete,
|
|
|
|
type: 'danger'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
actions: [
|
|
|
|
{ text: this.$t('global.add'), handler: this.createProjectDevice}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
currentModel: {}
|
|
|
|
};
|
|
|
|
},
|
2020-06-19 18:02:50 +08:00
|
|
|
computed: {
|
|
|
|
projectCode() {
|
|
|
|
return this.projectMap[getSessionStorage('project')];
|
|
|
|
}
|
|
|
|
},
|
2020-01-02 17:01:11 +08:00
|
|
|
created() {
|
|
|
|
},
|
|
|
|
methods: {
|
2020-06-19 18:02:50 +08:00
|
|
|
beforeQuery(params) {
|
|
|
|
params.projectCode = this.projectCode;
|
|
|
|
return params;
|
|
|
|
},
|
2020-01-02 17:01:11 +08:00
|
|
|
createProjectDevice() {
|
|
|
|
this.$refs.add.show();
|
|
|
|
},
|
|
|
|
computation(fieldValue, type) {
|
|
|
|
let list = [];
|
|
|
|
if (type === 'projectType') {
|
|
|
|
list = this.projectList;
|
|
|
|
} else if ( type === 'deviceType' ) {
|
|
|
|
list = this.deviceTypeList;
|
|
|
|
}
|
|
|
|
let value = '';
|
|
|
|
list.forEach((elem) => {
|
|
|
|
elem.label = fieldValue;
|
|
|
|
value = elem.value;
|
|
|
|
});
|
|
|
|
console.log(value, fieldValue, type);
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
handleTime(time) {
|
|
|
|
const timeList = time.split('T');
|
|
|
|
let newTime = '';
|
2020-01-03 17:00:33 +08:00
|
|
|
if (timeList.length > 1) {
|
|
|
|
newTime = timeList[0] + ' ' + timeList[1];
|
|
|
|
} else {
|
|
|
|
newTime = time;
|
|
|
|
}
|
2020-01-02 17:01:11 +08:00
|
|
|
return newTime;
|
|
|
|
},
|
|
|
|
// 删除
|
|
|
|
handleDelete(index, row) {
|
|
|
|
this.$confirm('此操作将删除该项目设备!', this.$t('global.tips'), {
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
deleteProjectDevice(row.id).then(response => {
|
|
|
|
this.$message.success(this.$t('system.deleteSuccess'));
|
|
|
|
this.reloadTable();
|
|
|
|
}).catch(() => {
|
|
|
|
this.reloadTable();
|
|
|
|
this.$messageBox(this.$t('error.deleteFailed'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
editConfig(index, row) {
|
2020-06-19 18:02:50 +08:00
|
|
|
if (row.type === 'LW' || row.type === 'IBP') {
|
|
|
|
this.$refs.editConfig.doShow(row);
|
|
|
|
} else {
|
|
|
|
this.$refs.editConfigGateway.doShow(row);
|
|
|
|
}
|
2020-01-02 17:01:11 +08:00
|
|
|
},
|
|
|
|
reloadTable() {
|
|
|
|
this.queryList.reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|