项目设备管理

This commit is contained in:
fan 2020-01-02 17:01:11 +08:00
parent ce5c87608a
commit 65b766e27f
7 changed files with 756 additions and 2 deletions

63
src/api/project.js Normal file
View File

@ -0,0 +1,63 @@
import request from '@/utils/request';
/** 新建项目设备*/
export function createDevice(data) {
return request({
url: `/api/project/device`,
method: 'post',
data: data
});
}
/** 项目设备编码是否已存在 */
export function deviceIsExist(projectCode, code) {
return request({
url: `/api/project/device/exist/${projectCode}/${code}`,
method: 'get'
});
}
/** 分页查询项目设备 */
export function getProjectDeviceList(params) {
return request({
url: `/api/project/device/paging`,
method: 'get',
params:params
});
}
/** 删除项目设备 */
export function deleteProjectDevice(id) {
return request({
url: `/api/project/device/${id}`,
method: 'delete'
});
}
/** 获取设备详情 */
export function getDeviceDetail(id) {
return request({
url: `/api/project/device/${id}`,
method: 'get'
});
}
/** 添加/修改屏蔽门设备网关映射配置 */
export function setPsdConfig(id, data) {
return request({
url: `/api/project/device/${id}/config/psd`,
method: 'put',
data: data
});
}
/** 添加/修改信号机设备网关映射配置 */
export function setSignalConfig(id, data) {
return request({
url: `/api/project/device/${id}/config/signal`,
method: 'put',
data: data
});
}
/** 添加/修改信号机设备网关映射配置 */
export function setSwitchConfig(id, data) {
return request({
url: `/api/project/device/${id}/config/switch`,
method: 'put',
data: data
});
}

View File

@ -71,5 +71,6 @@ export default {
subsystemGeneration: 'Subsystem generation',
newsBulletin: 'New bulletin',
commandDictionary: 'Command dictionary',
configLine: 'Line management'
configLine: 'Line management',
deviceManage: 'Device management'
};

View File

@ -72,5 +72,6 @@ export default {
subsystemGeneration: '子系统生成',
newsBulletin: '消息公告',
commandDictionary: '指令字典',
configLine: '线路管理'
configLine: '线路管理',
deviceManage: '设备管理'
};

View File

@ -104,6 +104,7 @@ const UserRulesDetail = () => import('@/views/orderauthor/rules/detail');
const LessonApproval = () => import('@/views/approval/lesson/index');
const ScriptApproval = () => import('@/views/approval/script/index');
const RunPlanApproval = () => import('@/views/approval/runPlan/index');
const DeviceManage = () => import('@/views/system/deviceManage/index');
import { loginInfo } from '@/scripts/ConstDic';
import { getSessionStorage } from '@/utils/auth';
@ -838,6 +839,13 @@ export const asyncRouter = [
meta: {
i18n: 'router.configLine'
}
},
{
path: 'deviceManage',
component: DeviceManage,
meta: {
i18n: 'router.deviceManage'
}
}
]
},

View File

@ -0,0 +1,108 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center :close-on-click-modal="false">
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { createDevice, deviceIsExist} from '@/api/project';
export default {
name: 'DeviceAdd',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
formModel: {
code: '',
type: '',
projectCode: ''
},
LessonList: [],
UserList: [],
UserLoading: false,
deviceTypeList:[{label: '道岔', value: 'SWITCH'}, {label: '信号机', value:'SIGNAL'}, {label: '屏蔽门', value: 'PSD'}],
projectList: [{label:'西铁院', value: 'XTY'}, {label: '贵州装备', value:'GZB'}],
gatewayList: []
};
},
computed: {
form() {
const form = {
labelWidth: '120px',
items: [
{ prop: 'code', label: '设备编码', type: 'text', required: true, placeholder: '请输入设备编码' },
{ prop: 'type', label: '设备类型', type: 'select', required: true, options: this.deviceTypeList, placeholder: '请选择设备类型' },
{ prop: 'projectCode', label: '所属项目', type: 'select', required: true, options: this.projectList, placeholder: '请选择设备所属项目'}
]
};
return form;
},
rules() {
const crules = {
code: [
{ required: true, message: '请输入设备编码', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择设备类型', trigger: 'change' }
],
projectCode: [
{ required: true, message: '请选择所属项目', trigger: 'change' }
]
};
return crules;
},
title() {
return '创建项目设备';
}
},
mounted() {
},
methods: {
show(data) {
this.dialogVisible = true;
},
doSave() {
const self = this;
this.$refs.dataform.validateForm(() => {
const params = {
code: this.formModel.code,
type: this.formModel.type,
projectCode: this.formModel.projectCode
};
deviceIsExist(params.projectCode, params.code).then(response => {
if (!response.data) {
createDevice(params).then(response => {
self.$message.success('创建项目设备成功!');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('error.addFailed') + error.message);
});
} else {
self.$message.error('已存在该设备编号,请修改设备编号后创建!');
}
});
});
},
handleClose(done) {
this.formModel = {
code: '',
type: '',
projectCode: ''
};
this.$refs.dataform.resetForm();
this.dialogVisible = false;
}
}
};
</script>

View File

@ -0,0 +1,397 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="60%" :before-close="handleClose" center :close-on-click-modal="false">
<data-form ref="datatop" :form="formTop" :form-model="formModel" :rules="topRules" />
<el-row :gutter="20">
<el-col :span="12">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>输入配置:</span>
</div>
<div style="margin-top: 20px">
<data-form ref="dataleft" :form="formLeft" :form-model="formModel" :rules="leftRules" />
</div>
</el-card>
</el-col>
<el-col :span="12">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>输出配置:</span>
</div>
<div style="margin-top: 20px">
<data-form ref="dataright" :form="formRight" :form-model="formModel" :rules="rightRules" />
</div>
</el-card>
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getDeviceDetail, setPsdConfig, setSignalConfig, setSwitchConfig } from '@/api/project';
export default {
name: 'EditConfig',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
formModel: {},
formLeft: {},
formRight: {},
leftRules: {},
rightRules: {},
gatewayList: [],
setDeviceConfigFunction: null,
data: null,
psdLeftValue: [
{label: '输入-是否关门位', value: 'i_c'},
{label: '输入-PSL关门按钮位', value: 'i_dc_b'},
{label: '输入-PSL开门按钮位', value: 'i_do_b'},
{label: '输入-互锁解除钥匙开关位', value: 'i_ir'},
{label: '输入-是否锁闭位', value: 'i_l'},
{label: '输入-PSL允许钥匙开关位', value: 'i_psl'},
{label: '输入-PSL试灯按钮位', value: 'i_ts_b'}
],
psdRightValue: [
{label: '输出-关门位', value: 'o_c'},
{label: '输出-关门信号灯控制位', value: 'o_dc_s'},
{label: '输出-关门且锁闭信号灯控制位', value: 'o_dcl_s'},
{label: '输出-开门信号灯控制位', value: 'o_do_s'},
{label: '输出-互锁解除信号灯控制位', value: 'o_ir_s'},
{label: '输出-锁闭位', value: 'o_l'},
{label: '输出-开门位', value: 'o_o'},
{label: '输出-PSL信号灯控制位', value: 'o_psl_s'}
],
switchLeftValue: [
{label: '输入-故障挤岔表示位', value: 'i_f'},
{label: '输入-定位表示位', value: 'i_n'},
{label: '输入-反位表示位', value: 'i_r'}
],
switchRightValue: [
{label: '输出-设置故障控制位', value: 'o_f'},
{label: '输出-定操控制位', value: 'o_n'},
{label: '输出-反操控制位', value: 'o_r'}
],
signalLeftValue: [
{label: '输入-故障表示位', value: 'i_f'},
{label: '输入-绿灯表示位', value: 'i_g'},
{label: '输入-红灯表示位', value: 'i_r'},
{label: '输入-黄灯表示位', value: 'i_y'}
],
signalRightValue: [
{label: '输出-故障控制位', value: 'o_f'},
{label: '输出-绿灯控制位', value: 'o_g'},
{label: '输出-红灯控制位', value: 'o_r'},
{label: '输出-黄灯控制位', value: 'o_y'}
]
};
},
computed: {
formTop() {
const form = {
labelWidth: '220px',
items: [
{ prop: 'gatewayCode', label: '网关编码:', type: 'select', required: true, options: this.gatewayList, placeholder: '请选择网关编码' }
]
};
return form;
},
topRules() {
const crules = {
gatewayCode: [
{ required: true, message: '请输入网关编码', trigger: 'change' }
]
};
return crules;
},
title() {
return '编辑设备配置';
}
},
methods: {
initForm(row) {
var validateDevice = (rule, value, callback) => {
console.log(value);
const list = [];
rule.list.forEach(item=> {
if (item.value !== rule.field && this.formModel[item.value] === value) {
list.push(item.label);
} else if (item.value === rule.field) {
list.push(item.label);
}
});
if (!value) {
callback(new Error(rule.messageEmpty));
} else if (list.length > 1) {
let repeatedValue = '';
list.forEach((item, index) => {
repeatedValue += item;
if (index !== list.length - 1) {
repeatedValue += '与';
}
});
callback(new Error(repeatedValue + '位置重复,请调整!'));
} else {
callback();
}
};
switch (row.type) {
case 'PSD': {
this.setDeviceConfigFunction = setPsdConfig;
this.formLeft = {
labelWidth: '220px',
items: [
{ prop:'i_addr', label:'输入网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'i_c', label: '输入-是否关门位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_dc_b', label: '输入-PSL关门按钮位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_do_b', label: '输入-PSL开门按钮位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_ir', label: '输入-互锁解除钥匙开关位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_l', label: '输入-是否锁闭位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_psl', label: '输入-PSL允许钥匙开关位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_ts_b', label: '输入-PSL试灯按钮位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.leftRules = {
i_addr: [
{ required: true, message: '请填写输入网关字地址', trigger: 'blur' }
],
i_c: [
{ validator: validateDevice, messageEmpty: '请填写输入-是否关门位', list: this.psdLeftValue, trigger: 'blur' }
],
i_dc_b: [
{validator: validateDevice, messageEmpty: '请填写输入-PSL关门按钮位', list: this.psdLeftValue, trigger: 'blur' }
],
i_do_b: [
{ validator: validateDevice, messageEmpty: '请填写输入-PSL开门按钮位', list: this.psdLeftValue, trigger: 'blur' }
],
i_ir: [
{ validator: validateDevice, messageEmpty: '请填写输入-互锁解除钥匙开关位', list: this.psdLeftValue, trigger: 'blur' }
],
i_l: [
{ validator: validateDevice, messageEmpty: '请填写输入-是否锁闭位', list: this.psdLeftValue, trigger: 'blur' }
],
i_psl: [
{ validator: validateDevice, messageEmpty: '请填写输入-PSL允许钥匙开关位', list: this.psdLeftValue, trigger: 'blur' }
],
i_ts_b: [
{ validator: validateDevice, messageEmpty: '请填写输入-PSL试灯按钮位', list: this.psdLeftValue, trigger: 'blur' }
]
};
this.formRight = {
labelWidth: '220px',
items: [
{ prop: 'o_addr', label: '输出网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'o_c', label: '输出-关门位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_dc_s', label: '输出-关门信号灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_dcl_s', label: '输出-关门且锁闭信号灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_do_s', label: '输出-开门信号灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_ir_s', label: '输出-互锁解除信号灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_l', label: '输出-锁闭位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_o', label: '输出-开门位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_psl_s', label: '输出-PSL信号灯控制位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.rightRules = {
o_addr: [
{ required: true, message: '请填写输出网关字地址', trigger: 'blur' }
],
o_c: [
{ validator: validateDevice, messageEmpty: '请填写输入-关门位', list: this.psdRightValue, trigger: 'blur' }
],
o_dc_s: [
{ validator: validateDevice, messageEmpty: '请填写输入-关门信号灯控制位', list: this.psdRightValue, trigger: 'blur' }
],
o_dcl_s: [
{ validator: validateDevice, messageEmpty: '请填写输入-关门且锁闭信号灯控制位', list: this.psdRightValue, trigger: 'blur' }
],
o_do_s: [
{ validator: validateDevice, messageEmpty: '请填写输入-开门信号灯控制位', list: this.psdRightValue, trigger: 'blur' }
],
o_ir_s: [
{ validator: validateDevice, messageEmpty: '请填写输入-互锁解除信号灯控制位', list: this.psdRightValue, trigger: 'blur' }
],
o_l: [
{ validator: validateDevice, messageEmpty: '请填写输入-锁闭位', list: this.psdRightValue, trigger: 'blur' }
],
o_o: [
{ validator: validateDevice, messageEmpty: '请填写输入-开门位', list: this.psdRightValue, trigger: 'blur' }
],
o_psl_s: [
{ validator: validateDevice, messageEmpty: '请填写输入-PSL信号灯控制位', list: this.psdRightValue, trigger: 'blur' }
]
};
break;
}
case 'SIGNAL': {
this.setDeviceConfigFunction = setSignalConfig;
this.formTop.labelWidth = '150px';
this.formLeft = {
labelWidth: '150px',
items: [
{ prop:'i_addr', label:'输入网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'i_f', label: '输入-故障表示位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_g', label: '输入-绿灯表示位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_r', label: '输入-红灯表示位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_y', label: '输入-黄灯表示位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.leftRules = {
i_addr: [
{ required: true, message: '请填写输入网关字地址', trigger: 'blur' }
],
i_f: [
{ validator: validateDevice, messageEmpty: '请填写输入-故障表示位', list: this.signalLeftValue, trigger: 'blur' }
],
i_g: [
{ validator: validateDevice, messageEmpty: '请填写输入-绿灯表示位', list: this.signalLeftValue, trigger: 'blur' }
],
i_r: [
{ validator: validateDevice, messageEmpty: '请填写输入-红灯表示位', list: this.signalLeftValue, trigger: 'blur' }
],
i_y: [
{ validator: validateDevice, messageEmpty: '请填写输入-黄灯表示位', list: this.signalLeftValue, trigger: 'blur' }
]
};
this.formRight = {
labelWidth: '150px',
size: 'mini',
items: [
{ prop: 'o_addr', label: '输出网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'o_f', label: '输出-故障控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_g', label: '输出-绿灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_r', label: '输出-红灯控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_y', label: '输出-黄灯控制位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.rightRules = {
o_addr: [
{ required: true, message: '请填写输出网关字地址', trigger: 'blur' }
],
o_f: [
{ validator: validateDevice, messageEmpty: '请填写输入-故障控制位', list: this.signalRightValue, trigger: 'blur' }
],
o_g: [
{ validator: validateDevice, messageEmpty: '请填写输入-绿灯控制位', list: this.signalRightValue, trigger: 'blur' }
],
o_r: [
{ validator: validateDevice, messageEmpty: '请填写输入-红灯控制位', list: this.signalRightValue, trigger: 'blur' }
],
o_y: [
{ validator: validateDevice, messageEmpty: '请填写输入-黄灯控制位', list: this.signalRightValue, trigger: 'blur' }
]
};
break;
}
case 'SWITCH': {
this.setDeviceConfigFunction = setSwitchConfig;
this.formTop.labelWidth = '160px';
this.formLeft = {
labelWidth: '160px',
items: [
{ prop:'i_addr', label:'输入网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'i_f', label: '输入-故障挤岔表示位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_n', label: '输入-定位表示位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'i_r', label: '输入-反位表示位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.leftRules = {
i_addr: [
{ required: true, message: '请填写输入网关字地址', trigger: 'blur' }
],
i_f: [
{ validator: validateDevice, messageEmpty: '请填写输入-故障挤岔表示位', list: this.switchLeftValue, trigger: 'blur' }
],
i_n: [
{ validator: validateDevice, messageEmpty: '请填写输入-定位表示位', list: this.switchLeftValue, trigger: 'blur' }
],
i_r: [
{ validator: validateDevice, messageEmpty: '请填写输入-反位表示位', list: this.switchLeftValue, trigger: 'blur' }
]
};
this.formRight = {
labelWidth: '160px',
items: [
{ prop: 'o_addr', label: '输出网关字地址:', type: 'number', min: 1, max: 20000, step: 1},
{ prop: 'o_f', label: '输出-故障挤岔控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_n', label: '输出-定操控制位:', type: 'number', min: 1, max: 16, step: 1},
{ prop: 'o_r', label: '输出-反操控制位:', type: 'number', min: 1, max: 16, step: 1}
]
};
this.rightRules = {
o_addr: [
{ required: true, message: '请填写输出网关字地址', trigger: 'blur' }
],
o_f: [
{ validator: validateDevice, messageEmpty: '请填写输出-故障挤岔控制位', list: this.switchRightValue, trigger: 'blur' }
],
o_n: [
{ validator: validateDevice, messageEmpty: '请填写输出-定操控制位', list: this.switchRightValue, trigger: 'blur' }
],
o_r: [
{ validator: validateDevice, messageEmpty: '请填写输出-反操控制位', list: this.switchRightValue, trigger: 'blur' }
]
};
break;
}
}
},
initData(row) {
getDeviceDetail(row.id).then(resp => {
if (resp.data.config) {
this.formModel = resp.data.config;
}
}).catch(()=> {
this.$message.error('获取项目设备详情失败!');
});
if (row.projectCode === 'XTY') {
this.gatewayList = [{lable:'XTY', value: 'XTY'}];
} else if (row.projectCode === 'GZB') {
this.gatewayList = [{label: 'GZB_1', value: 'GZB_1'}];
}
},
doShow(row) {
this.initData(row);
this.initForm(row);
this.dialogVisible = true;
this.data = row;
},
doSave() {
const self = this;
this.$refs.datatop.validateForm(() => {
self.$refs.dataleft.validateForm(()=> {
self.$refs.dataright.validateForm(()=> {
this.setDeviceConfigFunction(this.data.id, this.formModel).then(response => {
self.$message.success('设置设备网关映射配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
});
});
},
handleClose(done) {
this.formModel = {};
this.formLeft = {};
this.formRight = {};
this.leftRules = {};
this.rightRules = {};
this.gatewayList = [];
this.dialogVisible = false;
this.$refs.datatop.resetForm();
this.$refs.dataleft.resetForm();
this.$refs.dataright.resetForm();
}
}
};
</script>

View File

@ -0,0 +1,176 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<deivce-add ref="add" @reloadTable="reloadTable" />
<edit-config ref="editConfig" @reloadTable="reloadTable" />
</div>
</template>
<script>
import { getProjectDeviceList, deleteProjectDevice } from '@/api/project';
import DeivceAdd from './add';
import EditConfig from './editConfig';
export default {
name: 'DeviceManage',
components: {
DeivceAdd,
EditConfig
},
data() {
return {
examResultList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
deviceTypeList:[{label: '道岔', value: 'SWITCH'}, {label: '信号机', value:'SIGNAL'}, {label: '屏蔽门', value: 'PSD'}],
projectList: [{label:'西铁院', value: 'XTY'}, {label: '贵州装备', value:'GZB'}],
queryForm: {
labelWidth: '120px',
reset: true,
queryObject: {
projectCode: {
type: 'select',
label: '项目编码',
config: {
data: [{label:'西铁院', value: 'XTY'}, {label: '贵州装备', value:'GZB'}]
}
},
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',
columnValue: (row) => { return this.$convertField(row.projectCode, this.projectList, ['value', 'label']); },
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: this.$t('system.trainingUseTime'),
// prop: 'duration',
// type: 'tag',
// columnValue: (row) => { return this.computation(row.duration); },
// tagType: (row) => { return 'success'; }
// },
// {
// title: '',
// prop: 'config',
// columnValue: (row) => { return row.config; }
// },
{
title: '创建时间',
prop: 'createTime',
type: 'tag',
columnValue: (row) => { return this.handleTime(row.createTime); },
tagType: (row) => { return 'success'; }
},
// {
// title: '',
// prop: 'creator'
// },
{
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: {}
};
},
created() {
},
methods: {
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 = '';
timeList.forEach(elem => {
newTime += elem;
});
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) {
this.$refs.editConfig.doShow(row);
},
reloadTable() {
this.queryList.reload();
}
}
};
</script>