新建上级级联平台时自动填入本级平台参数

This commit is contained in:
Lawrence 2020-12-17 14:50:49 +08:00
parent 8a82a71ded
commit 273ece96b5

View File

@ -1,11 +1,18 @@
<template>
<div id="addlatform" v-loading="isLoging">
<el-dialog title="添加平台" width="70%" top="2rem" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()">
<div id="shared" style="text-align: right; margin-top: 1rem;">
<div id="addlatform" v-loading="isLoging">
<el-dialog
title="添加平台"
width="70%"
top="2rem"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
@close="close()"
>
<div id="shared" style="text-align: right; margin-top: 1rem">
<el-row :gutter="24">
<el-col :span="11">
<el-form ref="platform1" :rules="rules" :model="platform" label-width="160px" >
<el-form ref="platform1" :rules="rules" :model="platform" label-width="160px">
<el-form-item label="名称" prop="name">
<el-input v-model="platform.name"></el-input>
</el-form-item>
@ -30,7 +37,6 @@
<el-form-item label="本地端口" prop="devicePort">
<el-input v-model="platform.devicePort" :disabled="true"></el-input>
</el-form-item>
</el-form>
</el-col>
<el-col :span="12">
@ -48,24 +54,34 @@
<el-input v-model="platform.keepTimeout"></el-input>
</el-form-item>
<el-form-item label="信令传输" prop="transport">
<el-select v-model="platform.transport" style="width:100%" placeholder="请选择信令传输方式">
<el-select
v-model="platform.transport"
style="width: 100%"
placeholder="请选择信令传输方式"
>
<el-option label="UDP" value="UDP"></el-option>
<el-option label="TCP" value="TCP"></el-option>
</el-select>
</el-form-item>
<el-form-item label="字符集" prop="characterSet">
<el-select v-model="platform.characterSet" style="width:100%" placeholder="请选择字符集">
<el-select
v-model="platform.characterSet"
style="width: 100%"
placeholder="请选择字符集"
>
<el-option label="GB2312" value="GB2312"></el-option>
<el-option label="UTF-8" value="UTF-8"></el-option>
</el-select>
</el-form-item>
<el-form-item label="其他选项" >
<el-checkbox label="启用" v-model="platform.enable" ></el-checkbox>
<el-form-item label="其他选项">
<el-checkbox label="启用" v-model="platform.enable"></el-checkbox>
<el-checkbox label="云台控制" v-model="platform.PTZEnable"></el-checkbox>
<el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">{{onSubmit_text}}</el-button>
<el-button type="primary" @click="onSubmit">{{
onSubmit_text
}}</el-button>
<el-button @click="close">取消</el-button>
</el-form-item>
</el-form>
@ -73,30 +89,28 @@
</el-row>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
name: 'platformEdit',
name: "platformEdit",
props: {},
computed: {
},
computed: {},
created() {},
data() {
var deviceGBIdRules = async (rule, value, callback) => {
console.log(value)
if (value === '') {
callback(new Error('请输入设备国标编号'));
console.log(value);
if (value === "") {
callback(new Error("请输入设备国标编号"));
} else {
var exit = await this.deviceGBIdExit(value);
console.log(exit)
console.log(exit == "true")
console.log(exit === "true")
console.log(exit);
console.log(exit == "true");
console.log(exit === "true");
if (exit) {
callback(new Error('设备国标编号已存在'));
}else {
callback(new Error("设备国标编号已存在"));
} else {
callback();
}
}
@ -105,7 +119,7 @@ export default {
listChangeCallback: null,
showDialog: false,
isLoging: false,
onSubmit_text:"立即创建",
onSubmit_text: "立即创建",
// platform: {
// enable: false,
// PTZEnable: true,
@ -145,71 +159,66 @@ export default {
characterSet: "GB2312",
},
rules: {
name: [
{ required: true, message:"请输入平台名称", trigger: 'blur' }
],
name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
serverGBId: [
{ required: true, message:"请输入SIP服务国标编码", trigger: 'blur' }
{ required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
],
serverGBDomain: [
{ required: true, message:"请输入SIP服务国标域", trigger: 'blur' }
{ required: true, message: "请输入SIP服务国标域", trigger: "blur" },
],
serverIP: [
{ required: true, message:"请输入SIP服务IP", trigger: 'blur' }
],
serverPort: [
{ required: true, message:"请输入SIP服务端口", trigger: 'blur' }
],
deviceGBId: [
{validator: deviceGBIdRules, trigger: 'blur' }
],
username: [
{ required: false, message:"请输入SIP认证用户名", trigger: 'blur' }
],
password: [
{ required: false, message:"请输入SIP认证密码", trigger: 'blur' }
],
expires: [
{ required: true, message:"请输入注册周期", trigger: 'blur' }
],
keepTimeout: [
{ required: true, message:"请输入心跳周期", trigger: 'blur' }
],
transport: [
{ required: true, message:"请选择信令传输", trigger: 'blur' }
],
characterSet: [
{ required: true, message:"请选择编码字符集", trigger: 'blur' }
]
}
serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }],
},
};
},
methods: {
openDialog: function (platform, callback) {
var that = this;
this.$axios
.get(`/api/platforms/serverconfig`)
.then(function (res) {
console.log(res);
that.platform.deviceGBId = res.data.username;
that.platform.deviceIp = res.data.deviceIp;
that.platform.devicePort = res.data.devicePort;
that.platform.username = res.data.username;
that.platform.password = res.data.password;
})
.catch(function (error) {
console.log(error);
});
this.showDialog = true;
this.listChangeCallback = callback;
if (platform != null) {
this.platform = platform;
this.onSubmit_text = "保存"
this.onSubmit_text = "保存";
} else {
}
},
onSubmit: function () {
console.log('onSubmit');
console.log("onSubmit");
var that = this;
that.$axios.post(`/api/platforms/save`, that.platform)
that.$axios
.post(`/api/platforms/save`, that.platform)
.then(function (res) {
console.log(res)
console.log(res.data == "success")
console.log(res);
console.log(res.data == "success");
if (res.data == "success") {
that.$message({
showClose: true,
message: '保存成功',
type: 'success'
message: "保存成功",
type: "success",
});
that.showDialog = false;
if (that.listChangeCallback != null) {
that.listChangeCallback()
that.listChangeCallback();
}
}
})
@ -218,15 +227,16 @@ export default {
});
},
close: function () {
console.log('关闭添加视频平台');
console.log("关闭添加视频平台");
this.showDialog = false;
this.$refs.platform1.resetFields();
this.$refs.platform2.resetFields();
},
deviceGBIdExit: async function (deviceGbId) {
var result = false;
var that = this
await that.$axios.post(`/api/platforms/exit/${deviceGbId}`)
var that = this;
await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`)
.then(function (res) {
result = res.data;
})
@ -234,10 +244,8 @@ export default {
console.log(error);
});
return result;
}
}
},
},
};
</script>