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" />
|
2020-07-07 17:37:45 +08:00
|
|
|
<edit-config-screen ref="editConfigScreen" @reloadTable="reloadTable" />
|
2020-06-23 15:18:44 +08:00
|
|
|
<input id="device-manage-url" v-model="url" style="opacity: 0;">
|
2020-01-02 17:01:11 +08:00
|
|
|
</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-07-07 17:37:45 +08:00
|
|
|
import EditConfigScreen from './editConfigScreen';
|
2020-06-19 18:02:50 +08:00
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
2020-07-07 16:30:06 +08:00
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
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-07-07 17:37:45 +08:00
|
|
|
EditConfig,
|
|
|
|
EditConfigScreen
|
2020-01-02 17:01:11 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
examResultList: [],
|
2020-06-23 15:18:44 +08:00
|
|
|
url: '',
|
2020-01-02 17:01:11 +08:00
|
|
|
pagerConfig: {
|
|
|
|
pageSize: 'pageSize',
|
|
|
|
pageIndex: 'pageNum'
|
|
|
|
},
|
2020-07-07 16:30:06 +08:00
|
|
|
deviceTypeList:ConstConfig.ConstSelect.projectDeviceTypeList,
|
2020-07-07 15:42:56 +08:00
|
|
|
projectList: [{label:'西铁院', value: 'XTY'}, {label: '贵州装备', value:'GZB'}, {label: '盈达科技', value:'HYD'}],
|
2020-06-19 18:02:50 +08:00
|
|
|
projectMap: {
|
|
|
|
designxty: 'XTY',
|
2020-07-07 15:42:56 +08:00
|
|
|
designgzb: 'GZB',
|
|
|
|
designhyd: 'HYD'
|
2020-06-19 18:02:50 +08:00
|
|
|
},
|
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: {
|
2020-07-07 16:30:06 +08:00
|
|
|
data: ConstConfig.ConstSelect.projectDeviceTypeList
|
2020-01-02 17:01:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
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'),
|
2020-06-23 15:18:44 +08:00
|
|
|
width: '300',
|
2020-01-02 17:01:11 +08:00
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: '编辑配置',
|
|
|
|
handleClick: this.editConfig
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('global.delete'),
|
|
|
|
handleClick: this.handleDelete,
|
|
|
|
type: 'danger'
|
2020-06-23 15:18:44 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '登录路径',
|
|
|
|
handleClick: this.getPath,
|
2020-06-24 18:40:48 +08:00
|
|
|
showControl: (row) => { return row.type !== 'SWITCH' && row.type !== 'SIGNAL' && row.type !== 'PSD'; }
|
2020-01-02 17:01:11 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
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-07-07 18:22:54 +08:00
|
|
|
if (row.type === 'LW' || row.type === 'IBP' || row.type === 'ISCS_LW' || row.type === 'ISCS_CW') {
|
2020-06-19 18:02:50 +08:00
|
|
|
this.$refs.editConfig.doShow(row);
|
2020-06-24 18:40:48 +08:00
|
|
|
} else if (row.type === 'SWITCH' || row.type === 'SIGNAL' || row.type === 'PSD') {
|
2020-06-19 18:02:50 +08:00
|
|
|
this.$refs.editConfigGateway.doShow(row);
|
2020-07-07 17:37:45 +08:00
|
|
|
} else if (row.type == 'LSW' || row.type == 'CCTV') {
|
|
|
|
this.$refs.editConfigScreen.doShow(row);
|
2020-06-24 18:40:48 +08:00
|
|
|
} else {
|
|
|
|
this.$messageBox('暂无配置内容');
|
2020-06-19 18:02:50 +08:00
|
|
|
}
|
2020-01-02 17:01:11 +08:00
|
|
|
},
|
|
|
|
reloadTable() {
|
|
|
|
this.queryList.reload();
|
2020-06-23 15:18:44 +08:00
|
|
|
},
|
|
|
|
getPath(index, row) {
|
|
|
|
let url = '';
|
2020-07-07 18:22:54 +08:00
|
|
|
url = `${window.location.protocol}//${window.location.host}/login?project=${this.projectCode.toLowerCase()}&projectDevice=${row.code}&type=${row.type}`;
|
2020-06-23 15:18:44 +08:00
|
|
|
this.url = url;
|
|
|
|
this.$messageBox();
|
|
|
|
this.$confirm(`登录路径:${url}`, '登录路径', {
|
|
|
|
confirmButtonText: '复制路径',
|
|
|
|
cancelButtonText: '关闭',
|
|
|
|
type: 'success'
|
|
|
|
}).then(() => {
|
|
|
|
const inputText = document.getElementById('device-manage-url');
|
|
|
|
inputText.select(); // 选择对象
|
|
|
|
document.execCommand('Copy'); // 执行浏览器复制命令
|
|
|
|
this.$message.success('登录路径已经复制到粘贴板');
|
|
|
|
});
|
2020-01-02 17:01:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|