213 lines
6.3 KiB
Vue
213 lines
6.3 KiB
Vue
<template>
|
|
<div>
|
|
<div>
|
|
<el-dialog title="新建网关" :visible.sync="outerVisible" width="382px" v-loading="loading">
|
|
<el-form :model="formData" :rules="rules" ref="formData" label-width="85px" class="demo-ruleForm">
|
|
<el-form-item label="网关名称:" prop="wgpz_wgmc">
|
|
<el-select v-model="formData.wgpz_wgmc" placeholder="请选择" style="width: 200px">
|
|
<el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="网关ID:" prop="wgpz_wgid">
|
|
<el-select v-model="formData.wgpz_wgid" placeholder="请选择" style="width: 200px">
|
|
<el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="网关类型:" prop="wgpz_wglx">
|
|
<el-select v-model="formData.wgpz_wglx" placeholder="请选择" style="width: 200px">
|
|
<el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<el-dialog width="382px" title="系统提示" :visible.sync="innerVisible" append-to-body>
|
|
<p class="inner_content" style="color: #fff !important">
|
|
请确认选择的网关类型与网关实体一致:否则该工程无法下载至实体网关
|
|
</p>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" @click="innerConfirm('formData')">确定</el-button>
|
|
<el-button @click="innerVisible = false">取 消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
<div slot="footer" class="dialog-footer-outer">
|
|
<el-button type="primary" @click="saveInfo('formData')">保存</el-button>
|
|
<el-button @click="outerVisible = false">取 消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { SaveUserAnswer, GetUserAnswer } from "@/api/user";
|
|
export default {
|
|
name: "DataAcquire",
|
|
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
user_id: "",
|
|
options1: [
|
|
{
|
|
value: "有线区网关1",
|
|
label: "有线区网关1",
|
|
},
|
|
{
|
|
value: "无线区网关1",
|
|
label: "无线区网关1",
|
|
},
|
|
],
|
|
options2: [
|
|
{
|
|
value: "LAN-BOX1",
|
|
label: "LAN-BOX1",
|
|
},
|
|
{
|
|
value: "WLAN-BOX1",
|
|
label: "WLAN-BOX1",
|
|
},
|
|
],
|
|
options3: [
|
|
{
|
|
value: "loT Lite网关",
|
|
label: "loT Lite网关",
|
|
},
|
|
{
|
|
value: "MODBUS网关",
|
|
label: "MODBUS网关",
|
|
},
|
|
{
|
|
value: "BACNET网关",
|
|
label: "BACNET网关",
|
|
},
|
|
{
|
|
value: "OPC UA网关",
|
|
label: "OPC UA网关",
|
|
},
|
|
{
|
|
value: "OPC DA网关",
|
|
label: "OPC DA网关",
|
|
},
|
|
{
|
|
value: "loT网关",
|
|
label: "loT网关",
|
|
},
|
|
],
|
|
value: "",
|
|
formData: {
|
|
wgpz_wgmc: "",
|
|
wgpz_wgid: "",
|
|
wgpz_wglx: "",
|
|
},
|
|
rules: {
|
|
wgpz_wgmc: [
|
|
{ required: true, message: "请选择网关名称", trigger: "blur" },
|
|
],
|
|
wgpz_wgid: [
|
|
{ required: true, message: "请选择网关id", trigger: "blur" },
|
|
],
|
|
wgpz_wglx: [
|
|
{ required: true, message: "请选择网关类型", trigger: "blur" },
|
|
],
|
|
},
|
|
outerVisible: true,
|
|
innerVisible: false,
|
|
};
|
|
},
|
|
methods: {
|
|
getParameter(data) {
|
|
console.log(data);
|
|
this.user_id = data;
|
|
},
|
|
saveInfo(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
// console.log('submit!');
|
|
this.innerVisible = true;
|
|
} else {
|
|
console.log("error submit!!");
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
async innerConfirm() {
|
|
this.outerVisible = false;
|
|
this.innerVisible = false;
|
|
let datas = sessionStorage.getItem("DB-IotLite_wx");
|
|
console.log(JSON.parse(datas));
|
|
this.formdata = { ...JSON.parse(datas), ...this.formdata };
|
|
// console.log(this.formdata);
|
|
let res = await SaveUserAnswer({
|
|
mark: "DB-IotLite_wx",
|
|
user_id: this.user_id,
|
|
mark_value: JSON.stringify(this.formdata),
|
|
});
|
|
if (res.data.state) {
|
|
this.$message({
|
|
message: "保存成功",
|
|
type: "success",
|
|
});
|
|
sessionStorage.setItem("DB-IotLite_wx", JSON.stringify(this.formdata));
|
|
this.$router.replace(`/dbcollectserial?user_id=${this.user_id}`);
|
|
} else {
|
|
this.$message({
|
|
message: "保存失败",
|
|
type: "error",
|
|
});
|
|
}
|
|
// console.log(res);
|
|
// console.log(JSON.parse(res.data.data.mark_value));
|
|
},
|
|
async getUserAnswer() {
|
|
this.loading = true;
|
|
let res2 = await GetUserAnswer({
|
|
mark: "DB-IotLite_yx",
|
|
user_id: this.user_id,
|
|
});
|
|
this.loading = false;
|
|
if (res2.data.data && res2.data.state) {
|
|
if (res2.data.data.step == 1) {
|
|
this.$router.push(`/dbcollectserial?user_id=${this.user_id}`)
|
|
} else if (res2.data.data.step == 2) {
|
|
this.$router.push(`/dbserialdevice?user_id=${this.user_id}`)
|
|
} else if (res2.data.data.step == 3) {
|
|
this.$router.push(`/dbcollect?user_id=${this.user_id}`)
|
|
} else {
|
|
console.log(res2);
|
|
let res3 = JSON.parse(res2.data.data.mark_value);
|
|
if (res3.wgpz_wgid) {
|
|
this.formData.wgpz_wgid = res3.wgpz_wgid;
|
|
console.log(this.formData.wgpz_wgid);
|
|
this.formData.wgpz_wgmc = res3.wgpz_wgmc;
|
|
this.formData.wgpz_wglx = res3.wgpz_wglx;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
let that = this;
|
|
window.getParameter = that.getParameter;
|
|
this.getUserAnswer();
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.data_acquire {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.inner_content {
|
|
margin-left: 30px;
|
|
width: 280px;
|
|
height: 40px;
|
|
// color: rgba(255, 255, 255, 0);
|
|
font-size: 14px;
|
|
text-align: left;
|
|
font-family: "SourceHanSansSC-regular";
|
|
}
|
|
</style>
|