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

pull/14/head
Lawrence 2020-12-17 14:50:49 +08:00
parent 8a82a71ded
commit 273ece96b5
1 changed files with 335 additions and 327 deletions

View File

@ -1,8 +1,15 @@
<template> <template>
<div id="addlatform" v-loading="isLoging"> <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()"> <el-dialog
<div id="shared" style="text-align: right; margin-top: 1rem;"> 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-row :gutter="24">
<el-col :span="11"> <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">
@ -30,7 +37,6 @@
<el-form-item label="本地端口" prop="devicePort"> <el-form-item label="本地端口" prop="devicePort">
<el-input v-model="platform.devicePort" :disabled="true"></el-input> <el-input v-model="platform.devicePort" :disabled="true"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -48,13 +54,21 @@
<el-input v-model="platform.keepTimeout"></el-input> <el-input v-model="platform.keepTimeout"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="信令传输" prop="transport"> <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="UDP" value="UDP"></el-option>
<el-option label="TCP" value="TCP"></el-option> <el-option label="TCP" value="TCP"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="字符集" prop="characterSet"> <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="GB2312" value="GB2312"></el-option>
<el-option label="UTF-8" value="UTF-8"></el-option> <el-option label="UTF-8" value="UTF-8"></el-option>
</el-select> </el-select>
@ -65,7 +79,9 @@
<el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox> <el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox>
</el-form-item> </el-form-item>
<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-button @click="close"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -78,24 +94,22 @@
<script> <script>
export default { export default {
name: 'platformEdit', name: "platformEdit",
props: {}, props: {},
computed: { computed: {},
},
created() {}, created() {},
data() { data() {
var deviceGBIdRules = async (rule, value, callback) => { var deviceGBIdRules = async (rule, value, callback) => {
console.log(value) console.log(value);
if (value === '') { if (value === "") {
callback(new Error('请输入设备国标编号')); callback(new Error("请输入设备国标编号"));
} else { } else {
var exit = await this.deviceGBIdExit(value); var exit = await this.deviceGBIdExit(value);
console.log(exit) console.log(exit);
console.log(exit == "true") console.log(exit == "true");
console.log(exit === "true") console.log(exit === "true");
if (exit) { if (exit) {
callback(new Error('设备国标编号已存在')); callback(new Error("设备国标编号已存在"));
} else { } else {
callback(); callback();
} }
@ -145,71 +159,66 @@ export default {
characterSet: "GB2312", characterSet: "GB2312",
}, },
rules: { rules: {
name: [ name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
{ required: true, message:"请输入平台名称", trigger: 'blur' }
],
serverGBId: [ serverGBId: [
{ required: true, message:"请输入SIP服务国标编码", trigger: 'blur' } { required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
], ],
serverGBDomain: [ serverGBDomain: [
{ required: true, message:"请输入SIP服务国标域", trigger: 'blur' } { required: true, message: "请输入SIP服务国标域", trigger: "blur" },
], ],
serverIP: [ serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
{ required: true, message:"请输入SIP服务IP", trigger: 'blur' } serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
], deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
serverPort: [ username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
{ required: true, message:"请输入SIP服务端口", trigger: 'blur' } password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
], expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
deviceGBId: [ keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
{validator: deviceGBIdRules, trigger: 'blur' } transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
], characterSet: [{ required: true, message: "请选择编码字符集", 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: { methods: {
openDialog: function (platform, callback) { 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.showDialog = true;
this.listChangeCallback = callback; this.listChangeCallback = callback;
if (platform != null) { if (platform != null) {
this.platform = platform; this.platform = platform;
this.onSubmit_text = "保存" this.onSubmit_text = "保存";
} else {
} }
}, },
onSubmit: function () { onSubmit: function () {
console.log('onSubmit'); console.log("onSubmit");
var that = this; var that = this;
that.$axios.post(`/api/platforms/save`, that.platform) that.$axios
.post(`/api/platforms/save`, that.platform)
.then(function (res) { .then(function (res) {
console.log(res) console.log(res);
console.log(res.data == "success") console.log(res.data == "success");
if (res.data == "success") { if (res.data == "success") {
that.$message({ that.$message({
showClose: true, showClose: true,
message: '保存成功', message: "保存成功",
type: 'success' type: "success",
}); });
that.showDialog = false; that.showDialog = false;
if (that.listChangeCallback != null) { if (that.listChangeCallback != null) {
that.listChangeCallback() that.listChangeCallback();
} }
} }
}) })
@ -218,15 +227,16 @@ export default {
}); });
}, },
close: function () { close: function () {
console.log('关闭添加视频平台'); console.log("关闭添加视频平台");
this.showDialog = false; this.showDialog = false;
this.$refs.platform1.resetFields(); this.$refs.platform1.resetFields();
this.$refs.platform2.resetFields(); this.$refs.platform2.resetFields();
}, },
deviceGBIdExit: async function (deviceGbId) { deviceGBIdExit: async function (deviceGbId) {
var result = false; var result = false;
var that = this var that = this;
await that.$axios.post(`/api/platforms/exit/${deviceGbId}`) await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`)
.then(function (res) { .then(function (res) {
result = res.data; result = res.data;
}) })
@ -234,10 +244,8 @@ export default {
console.log(error); console.log(error);
}); });
return result; return result;
},
} },
}
}; };
</script> </script>