InternetCompetition/src/components/CollectionWifi.vue

1355 lines
43 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 采集点配置-有线 -->
<template>
<div>
<!-- <div v-click-outside="closeMenu"> -->
<!-- 设置树形控件 -->
<!-- <el-button type="info" plain @click="dialogVisible = true">采集点设置</el-button> -->
<div v-show="dialogVisible" class="tree_menu">
<el-tree :data="trees" node-key="id" :props="defaultProps" default-expand-all @node-contextmenu="rightClick"
@node-click="treeNodeClick" ref="tree">
<!-- <span class="custom-tree-node" slot-scope="{ node, data }">
<template v-if="data.editing == 1 && flag">
<el-input style="width: 260px;" v-model="gateway" @change="changeInput"></el-input>
</template>
<template v-else>{{ data.label }}</template>
</span> -->
</el-tree>
<!-- 树形控件右键组件 -->
<div v-show="menuShow" class="tree_rightmenu" :style="{ ...rightMenu }">
<el-menu class="el-menu-vertical-demo" @select="selectMenuNode" default-active="#0078FE">
<el-menu-item id="menuitem" index="1" style="font-size: 12px">
<span slot="title">{{$t('edit')}}</span>
</el-menu-item>
<el-menu-item index="2" style="font-size: 12px">
<span slot="title">{{$t('del')}}</span>
</el-menu-item>
<el-menu-item index="3" style="font-size: 12px">
<span slot="title">{{$t('cancel')}}</span>
</el-menu-item>
</el-menu>
</div>
</div>
<!-- </div> -->
<div class="pas_params" v-show="add_passage">
<div>
<el-button type="primary" plain @click="handleSelect">{{$t('save')}}</el-button>
<!-- <el-menu class="el-menu-demo" mode="horizontal" @select="handleSelect"> -->
<!-- 添加时只支持一条,不能多次添加 -->
<!-- <el-menu-item index="1">保存</el-menu-item> -->
<!-- </el-menu> -->
</div>
<el-table ref="singleTable" :data="tableData" style="width: 100%" v-loading="loading">
<el-table-column type="index"> </el-table-column>
<el-table-column property="cjdpz_tagid" label="TagID">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_tagid" placeholder="">
<el-option v-for="(option, index) in options1" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_mc" label="名称">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_mc" placeholder="">
<el-option v-for="(option, index) in options2" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_sjq" :label="$t('dbcollect.dataArea')">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_sjq" placeholder="">
<el-option v-for="(option, index) in options3" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_jcqdz" :label="$t('dbcollect.registerAddress')" width="150px">
<template slot-scope="scope">
<el-input v-model="scope.row.cjdpz_jcqdz" placeholder="1-9999"></el-input>
</template>
</el-table-column>
<el-table-column property="cjdpz_cjsjlx" :label="$t('dbcollect.type')">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_cjsjlx" placeholder="">
<el-option v-for="(option, index) in options5" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_zjx" :label="$t('dbcollect.byteOrder')">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_zjx" placeholder="">
<el-option v-for="(option, index) in options6" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_dxsx" :label="$t('dbcollect.readWrite')">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_dxsx" placeholder="">
<el-option v-for="(option, index) in options7" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column property="cjdpz_beilv" :label="$t('dbcollect.Multiplier')">
<template slot-scope="scope">
<el-select v-model="scope.row.cjdpz_beilv" placeholder="">
<el-option v-for="(option, index) in options8" :key="index" :label="option.label"
:value="option.value"></el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</div>
<div class="dev_attribute">
<el-dialog :title="$t('configuration.deviceProperties')" :visible.sync="edit_device" width="382px" v-loading="loading">
<el-form :model="tableData[0]" :label-position="labelPosition" :rules="rules" ref="formdata">
<el-row>
<el-col :span="24">
<el-form-item :label="$t('configuration.deviceID')" :label-width="formLabelWidth" prop="sbpz_sbid">
<el-select v-model="tableData[0].sbpz_sbid" placeholder="" style="width: 200px; height: 30px">
<el-option v-for="(item, index) in options9" :key="index" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item :label="$t('configuration.deviceName')" :label-width="formLabelWidth" prop="sbpz_sbmc">
<el-select v-model="tableData[0].sbpz_sbmc" placeholder="" style="width: 200px; height: 30px">
<el-option v-for="(item, index) in options10" :key="index" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item :label="$t('configuration.deviceAddress')" :label-width="formLabelWidth" prop="sbpz_sbdz">
<el-input v-model="tableData[0].sbpz_sbdz" placeholder="" style="width: 200px; height: 30px"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item>
<!-- 需要修改的地方 -->
<el-checkbox v-model="tableData[0].sbpz_jysb">{{ $t('configuration.disableDevice') }}</el-checkbox>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item :label="$t('configuration.addressSelection')">
<span class="one">1</span>
<el-switch v-model="tableData[0].sbpz_jdzxz"> </el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">{{ $t('save') }}</el-button>
<el-button @click="edit_device = false">{{ $t('cancel') }}</el-button>
</span>
</el-dialog>
</div>
<div class="gateway">
<el-dialog :title="$t('ntconfig.createGateway')" :visible.sync="outerVisible" width="382px">
<el-form :model="tableData[0]" :rules="rulesGate" ref="gateWay" :label-width="this.$i18n.locale==='zh'?'130px':'85px'" class="demo-ruleForm">
<el-form-item :label="$t('ntconfig.gatewayName')" prop="wgpz_wgmc">
<el-select v-model="tableData[0].wgpz_wgmc" :placeholder="$t('select')" style="width: 200px">
<el-option v-for="item in opts1" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('ntconfig.gatewayId')" prop="wgpz_wgid">
<el-select v-model="tableData[0].wgpz_wgid" :placeholder="$t('select')" style="width: 200px">
<el-option v-for="item in opts2" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('ntconfig.gatewayType')" prop="wgpz_wglx">
<el-select v-model="tableData[0].wgpz_wglx" :placeholder="$t('select')" style="width: 200px">
<el-option v-for="item in opts3" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer-outer">
<el-button type="primary" @click="submitGate">{{$t('save')}}</el-button>
<el-button @click="outerVisible = false">{{$t('cancel')}}</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import {SaveUserAnswer, GetUserAnswer, GetTree, SendTree, getQueryAnswer} from "@/api/user";
export default {
name: "CollectionWifi",
data() {
return {
loading: false,
flag: false,
gateway: "",
user_id: "",
trees: [],
nodekey: "",
tableData: [
{
ippz_lwfs: "",
// ippz_wangkou: "",
ippz_zwym: "",
ippz_mrwg: "",
ippz_dns_sx: "",
ippz_dns_by: "",
ippz_ip: "",
ippz_mac: "",
ippz_wifi_ssid: "",
ippz_wifi_mm: "",
wgpz_wgmc: "",
wgpz_wgid: "",
wgpz_wglx: "",
tdpz_tdmc: "",
tdpz_td: "",
tdpz_qdmc: "",
tdpz_chuankou: "",
tdpz_btl: "",
tdpz_sjw: "",
tdpz_tzw: "",
tdpz_jojy: "",
tdpz_cgsj: "",
tdpz_jgsj: "",
tdpz_lxsj: "",
tdpz_cfcs: "",
tdpz_watchtime: "",
tdpz_cjsylxdz: "",
tdpz_dxzkb: "",
tdpz_050F: "",
tdpz_0610: "",
sbpz_sbid: "",
sbpz_sbmc: "",
sbpz_sbdz: "",
sbpz_jysb: false,
sbpz_jdzxz: true,
cjdpz_tagid: "",
cjdpz_mc: "",
cjdpz_sjq: "",
cjdpz_jcqdz: "",
cjdpz_cjsjlx: "",
cjdpz_zjx: "",
cjdpz_dxsx: "",
cjdpz_beilv: "",
mqtt_qiyong: "",
mqtt_ip: "",
mqtt_port: "",
mqtt_wgsn: "",
mqtt_sssjfbzt: "",
mqtt_qos: "",
mqtt_scms: "",
mqtt_sczq: "",
mqtt_sjgl: "",
mqtt_cjd_sbmc: "",
mqtt_cjd_tagid: "",
// mqtt_retained: "",
},
],
options1: [
{
value: "MachinePamHID909",
label: "MachinePamHID909",
},
{
value: "MachinePamHID910",
label: "MachinePamHID910",
},
{
value: "MachinePamHID911",
label: "MachinePamHID911",
},
{
value: "MachinePamHID912",
label: "MachinePamHID912",
},
{
value: "MachinePamHID913",
label: "MachinePamHID913",
},
{
value: "MachinePamHID914",
label: "MachinePamHID914",
},
{
value: "MachinePamHID915",
label: "MachinePamHID915",
},
{
value: "MachinePamHID916",
label: "MachinePamHID916",
},
{
value: "MachinePamHID917",
label: "MachinePamHID917",
},
{
value: "MachinePamHID918",
label: "MachinePamHID918",
},
{
value: "MachinePamHID919",
label: "MachinePamHID919",
},
{
value: "MachinePamHID920",
label: "MachinePamHID920",
},
{
value: "MachinePamHID921",
label: "MachinePamHID921",
},
{
value: "MachinePamHID922",
label: "MachinePamHID922",
},
{
value: "MachinePamHID923",
label: "MachinePamHID923",
},
{
value: "MachinePamHID924",
label: "MachinePamHID924",
},
{
value: "MachinePamHID925",
label: "MachinePamHID925",
},
{
value: "MachinePamHID926",
label: "MachinePamHID926",
},
{
value: "MachinePamHID927",
label: "MachinePamHID927",
},
{
value: "MachinePamHID928",
label: "MachinePamHID928",
},
{
value: "MachinePamHID929",
label: "MachinePamHID929",
},
{
value: "MachinePamHID930",
label: "MachinePamHID930",
},
{
value: "MachinePamHID931",
label: "MachinePamHID931",
},
{
value: "MachinePamHID932",
label: "MachinePamHID932",
},
{
value: "MachinePamHID933",
label: "MachinePamHID933",
},
{
value: "MachinePamHID934",
label: "MachinePamHID934",
},
{
value: "MachinePamHID935",
label: "MachinePamHID935",
},
{
value: "MachinePamHID936",
label: "MachinePamHID936",
},
{
value: "MachinePamHID937",
label: "MachinePamHID937",
},
{
value: "MachinePamHID938",
label: "MachinePamHID938",
},
],
options2: [
{
value: "急停状态",
label: "急停状态",
},
{
value: "产量",
label: "产量",
},
{
value: "相对位置X",
label: "相对位置X",
},
{
value: "相对位置Y",
label: "相对位置Y",
},
{
value: "相对位置Z",
label: "相对位置Z",
},
{
value: "实际位置X",
label: "实际位置X",
},
{
value: "实际位置Y",
label: "实际位置Y",
},
{
value: "实际位置Z",
label: "实际位置Z",
},
{
value: "主轴转速",
label: "主轴转速",
},
{
value: "当前刀具",
label: "当前刀具",
},
{
value: "预选刀具",
label: "预选刀具",
},
{
value: "报警信息",
label: "报警信息",
},
{
value: "驱动单元电流",
label: "驱动单元电流",
},
{
value: "负载电流",
label: "负载电流",
},
{
value: "额定电流",
label: "额定电流",
},
{
value: "运行时间",
label: "运行时间",
},
{
value: "加工产品用时",
label: "加工产品用时",
},
{
value: "工作模式",
label: "工作模式",
},
{
value: "切削速度",
label: "切削速度",
},
{
value: "任务信息",
label: "任务信息",
},
{
value: "使能状态",
label: "使能状态",
},
{
value: "系统状态",
label: "系统状态",
},
{
value: "执行任务信息",
label: "执行任务信息",
},
{
value: "进给倍军",
label: "进给倍军",
},
{
value: "轴速度",
label: "轴速度",
},
{
value: "轴角度",
label: "轴角度",
},
{
value: "进给速度",
label: "进给速度",
},
],
options3: [
{
value: "0X (Coil Status)",
label: "0X (Coil Status)",
},
{
value: "1X (Input Status)",
label: "1X (Input Status)",
},
{
value: "3X (Input Registers)",
label: "3X (Input Registers)",
},
{
value: "4X (Holding Register)",
label: "4X (Holding Register)",
},
],
options5: [
{
value: " bool",
label: "bool",
},
{
value: "bit",
label: "bit",
},
{
value: "uint16",
label: "uint16",
},
{
value: "int16",
label: "int16",
},
{
value: "uint32",
label: "uint32",
},
{
value: "int32",
label: "int32",
},
{
value: "float",
label: "float",
},
{
value: "double",
label: "double",
},
],
options6: [
{
value: "Null",
label: "Null",
},
{
value: "Big-endian4321",
label: "Big-endian4321",
},
{
value: "Little-endian1234",
label: "Little-endian1234",
},
{
value: "Big-endian byte swap2143",
label: "Big-endian byte swap2143",
},
{
value: "Little-endian byte swap3412",
label: "Little-endian byte swap3412",
},
],
options7: this.$t('dbcollect.options7'),
options8: [
{
value: " 0.1",
label: "0.1",
},
{
value: "1",
label: "1",
},
{
value: "10",
label: "10",
},
{
value: "100",
label: "100",
},
],
options9:this.$t('configuration.options1'),
options10: this.$t('configuration.options2'),
labelPosition: "left",
formLabelWidth: "116px",
add_passage: true,
edit_device: false,
rightMenu: "",
dialogVisible: true,
menuShow: false,
// formdata: {
// sbpz_sbid: "",
// sbpz_sbmc: "",
// sbpz_mac: "3C:2D:50:20:30:3D",
// sbpz_jysb: false,
// sbpz_jdzxz: true,
// },
selectlabel: "",
datas: [
{
label: "Gateway",
children: [
{
label: "数据采集",
children: [
{
label: "I/O点",
},
{
label: "用户点",
},
{
label: "计算点",
},
{
label: "系统点",
},
],
},
{
label: "数据服务",
children: [
{
label: "Modbus",
},
],
},
{
label: "IOT",
children: [
{
label: "Mqtt Client",
},
{
label: "Alink",
},
{
label: "Tlink",
},
{
label: "loTDDC",
},
{
label: "Ulink",
},
],
},
],
},
],
defaultProps: {
children: "children",
label: "label",
},
rules: {
sbpz_sbid: [
{ required: true, message: this.$t('configuration.rules.sbpz_sbid'), trigger: "blur" },
],
sbpz_sbmc: [
{ required: true, message: this.$t('configuration.rules.sbpz_sbmc'), trigger: "blur" },
],
sbpz_sbdz: [
{ required: true, message: this.$t('configuration.rules.sbpz_sbdz'), trigger: "blur" },
],
},
// 网关配置
outerVisible: false,
// gateWay: {
// wgpz_wgmc: "",
// wgpz_wgid: "",
// wgpz_wglx: "",
// },
rulesGate: {
wgpz_wgmc: [
{ required: true, message: this.$t('dbcollectiongate.rules.wgpz_wgmc'), trigger: "blur" },
],
wgpz_wgid: [
{ required: true, message: this.$t('dbcollectiongate.rules.wgpz_wgid'), trigger: "blur" },
],
wgpz_wglx: [
{ required: true, message: this.$t('dbcollectiongate.rules.wgpz_wglx'), trigger: "blur" },
],
},
opts1: this.$t('dbcollectiongate.options1'),
opts2: [
{
value: "LAN-BOX1",
label: "LAN-BOX1",
},
{
value: "WLAN-BOX1",
label: "WLAN-BOX1",
},
],
opts3: this.$t('dbcollectiongate.options3'),
};
},
methods: {
// 提交时校验
submitForm() {
this.$refs["formdata"].validate((valid) => {
if (valid) {
this.saveDevice();
} else {
console.log("error submit!!");
return false;
}
});
},
async rightClick(e, data, node) {
console.log(node);
if (data.editing) {
this.outerVisible = true;
this.add_passage = false;
this.GetUserAnswer();
this.trees[0].label =this.tableData[0].wgpz_wgid;
}
if (node.level == 5) {
this.menuShow = false;
this.menuShow = true;
this.nodekey = data.id;
console.log(data.label);
this.selectlabel = data.label;
// console.log(node);
e.preventDefault(); //关闭浏览器右键默认事件
this.rightMenu = { top: e.pageY + "px", left: e.pageX + "px" };
document.addEventListener("click", (ev) => {
ev.stopImmediatePropagation();
if (ev.target !== document.querySelector(".el-menu-item.is-active")) {
this.foo();
}
});
}
},
// 点击时候的判断,判断是否为编辑
async selectMenuNode(index, indexPath) {
console.log(index);
if (index == 1) {
// this.GetUserAnswer();
this.edit_device = true;
let answer = await GetUserAnswer({
mark: "DB-IotLite_wx",
// user_id: "USER202307301114011710",
user_id: this.user_id,
})
this.add_passage = false;
console.log(answer);
let obj = JSON.parse(answer.data.data.mark_value);
console.log(obj);
if (obj.sbpz_sbid) {
this.tableData[0].sbpz_sbid = obj.sbpz_sbid;
this.tableData[0].sbpz_jdzxz = Boolean(Number(obj.sbpz_jdzxz));
this.tableData[0].sbpz_jysb = Boolean(Number(obj.sbpz_jysb));
this.tableData[0].sbpz_sbmc = obj.sbpz_sbmc;
this.tableData[0].sbpz_sbdz = obj.sbpz_sbdz;
}
this.tableData[0].cjdpz_tagid = obj.cjdpz_tagid;
this.tableData[0].cjdpz_mc = obj.cjdpz_mc;
this.tableData[0].cjdpz_sjq = obj.cjdpz_sjq;
this.tableData[0].cjdpz_jcqdz = obj.cjdpz_jcqdz;
this.tableData[0].cjdpz_cjsjlx = obj.cjdpz_cjsjlx;
this.tableData[0].cjdpz_zjx = obj.cjdpz_zjx;
this.tableData[0].cjdpz_dxsx = obj.cjdpz_dxsx;
this.tableData[0].cjdpz_beilv = obj.cjdpz_beilv;
// this.tableData[0].ippz_wangkou = obj.ippz_wangkou;
this.tableData[0].ippz_lwfs = obj.ippz_lwfs;
this.tableData[0].ippz_zwym = obj.ippz_zwym;
this.tableData[0].ippz_ip = obj.ippz_ip;
this.tableData[0].ippz_mrwg = obj.ippz_mrwg;
this.tableData[0].tdpz_watchtime = obj.tdpz_watchtime;
this.tableData[0].tdpz_cjsylxdz = obj.tdpz_cjsylxdz;
this.tableData[0].ippz_dns_sx = obj.ippz_dns_sx;
this.tableData[0].ippz_dns_by = obj.ippz_dns_by;
this.tableData[0].ippz_mac = obj.ippz_mac;
this.tableData[0].ippz_wifi_ssid = obj.ippz_wifi_ssid;
this.tableData[0].ippz_wifi_mm = obj.ippz_wifi_mm;
this.tableData[0].tdpz_tdmc = obj.tdpz_tdmc;
this.tableData[0].tdpz_td = obj.tdpz_td;
this.tableData[0].tdpz_qdmc = obj.tdpz_qdmc;
this.tableData[0].tdpz_chuankou = obj.tdpz_chuankou;
this.tableData[0].tdpz_btl = obj.tdpz_btl;
this.tableData[0].tdpz_sjw = obj.tdpz_sjw;
this.tableData[0].tdpz_tzw = obj.tdpz_tzw;
this.tableData[0].tdpz_jojy = obj.tdpz_jojy;
this.tableData[0].tdpz_port = obj.tdpz_port;
this.tableData[0].tdpz_cgsj = obj.tdpz_cgsj;
this.tableData[0].tdpz_jgsj = obj.tdpz_jgsj;
this.tableData[0].tdpz_lxsj = obj.tdpz_lxsj;
this.tableData[0].tdpz_cfcs = obj.tdpz_cfcs;
this.tableData[0].tdpz_050F = obj.tdpz_050F;
this.tableData[0].tdpz_0610 = obj.tdpz_0610;
this.tableData[0].tdpz_dxzkb = obj.tdpz_dxzkb;
this.tableData[0].mqtt_qiyong = obj.mqtt_qiyong;
this.tableData[0].mqtt_ip = obj.mqtt_ip;
this.tableData[0].mqtt_port = obj.mqtt_port;
this.tableData[0].mqtt_wgsn = obj.mqtt_wgsn;
this.tableData[0].mqtt_sssjfbzt = obj.mqtt_sssjfbzt;
this.tableData[0].mqtt_qos = obj.mqtt_qos;
this.tableData[0].mqtt_scms = obj.mqtt_scms;
this.tableData[0].mqtt_sczq = obj.mqtt_sczq;
this.tableData[0].mqtt_sjgl = obj.mqtt_sjgl;
this.tableData[0].mqtt_cjd_sbmc = obj.mqtt_cjd_sbmc;
this.tableData[0].mqtt_cjd_tagid = obj.mqtt_cjd_tagid;
// this.tableData[0].mqtt_retained = obj.mqtt_retained;
} else if (index == 2) {
this.$refs["tree"].remove(this.nodekey);
this.sendTree();
this.$message({
message: "删除成功",
type: "success",
});
var obj = {
sbpz_sbid: "",
sbpz_jdzxz: "",
sbpz_jysb: "",
sbpz_sbmc: "",
sbpz_sbdzc: "",
cjdpz_tagid: "",
cjdpz_mc: "",
cjdpz_sjq: "",
cjdpz_jcqdz: "",
cjdpz_cjsjlx: "",
cjdpz_zjx: "",
cjdpz_dxsx: "",
cjdpz_beilv: "",
// ippz_wangkou: this.tableData[0].ippz_wangkou,
ippz_lwfs: this.tableData[0].ippz_lwfs,
ippz_zwym: this.tableData[0].ippz_zwym,
ippz_ip: this.tableData[0].ippz_ip,
ippz_mrwg: this.tableData[0].ippz_mrwg,
wgpz_wgmc: this.tableData[0].wgpz_wgmc,
wgpz_wgid: this.tableData[0].wgpz_wgid,
wgpz_wglx: this.tableData[0].wgpz_wglx,
tdpz_watchtime: this.tableData[0].tdpz_watchtime,
tdpz_cjsylxdz: this.tableData[0].tdpz_cjsylxdz,
ippz_dns_sx: this.tableData[0].ippz_dns_sx,
ippz_dns_by: this.tableData[0].ippz_dns_by,
ippz_mac: this.tableData[0].ippz_mac,
ippz_wifi_ssid: this.tableData[0].ippz_wifi_ssid,
ippz_wifi_mm: this.tableData[0].ippz_wifi_mm,
tdpz_tdmc: this.tableData[0].tdpz_tdmc,
tdpz_td: this.tableData[0].tdpz_td,
tdpz_qdmc: this.tableData[0].tdpz_qdmc,
tdpz_chuankou: this.tableData[0].tdpz_chuankou,
tdpz_btl: this.tableData[0].tdpz_btl,
tdpz_sjw: this.tableData[0].tdpz_sjw,
tdpz_tzw: this.tableData[0].tdpz_tzw,
tdpz_jojy: this.tableData[0].tdpz_jojy,
tdpz_port: this.tableData[0].tdpz_port,
tdpz_cgsj: this.tableData[0].tdpz_cgsj,
tdpz_jgsj: this.tableData[0].tdpz_jgsj,
tdpz_lxsj: this.tableData[0].tdpz_lxsj,
tdpz_cfcs: this.tableData[0].tdpz_cfcs,
tdpz_050F: this.tableData[0].tdpz_050F,
tdpz_0610: this.tableData[0].tdpz_0610,
tdpz_dxzkb: this.tableData[0].tdpz_dxzkb,
mqtt_qiyong: this.tableData[0].mqtt_qiyong,
mqtt_ip: this.tableData[0].mqtt_ip,
mqtt_port: this.tableData[0].mqtt_port,
mqtt_wgsn: this.tableData[0].mqtt_wgsn,
mqtt_sssjfbzt: this.tableData[0].mqtt_sssjfbzt,
mqtt_qos: this.tableData[0].mqtt_qos,
mqtt_scms: this.tableData[0].mqtt_scms,
mqtt_sczq: this.tableData[0].mqtt_sczq,
mqtt_sjgl: this.tableData[0].mqtt_sjgl,
mqtt_cjd_sbmc: this.tableData[0].mqtt_cjd_sbmc,
mqtt_cjd_tagid: this.tableData[0].mqtt_cjd_tagid,
}
let res = await SaveUserAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id,
mark_value: JSON.stringify(obj),
step: "2",
});
this.$router.push(`/dbserialdevice?user_id=${this.user_id}`);
}
},
foo() {
// 取消鼠标监听事件 菜单栏
this.menuShow = false;
document.removeEventListener("click", this.foo); // 关掉监听,
},
treeNodeClick(key, keyPath) {
console.log(key);
console.log(keyPath);
// if (keyPath.id == 10 || key.label == "Mqtt Client") {
// this.$router.push("./mqttconfig")
// }
this.add_passage = true;
},
getDriveName() {
this.diag_drive = true;
},
// 保存表单
async handleSelect() {
// console.log(this.tableData);
// let datas = sessionStorage.getItem("DB-IotLite_yx");
// this.tableData = { ...JSON.parse(datas), ...this.tableData[0] };
let res = await SaveUserAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id,
// user_id: "USER202307301114011710",
mark_value: JSON.stringify(this.tableData[0]),
step: "3",
});
console.log(this.tableData[0])
if (res.data.state) {
this.$message({
message: "保存成功",
type: "success",
});
console.log(res);
sessionStorage.setItem(
"DB-IotLite_wx",
JSON.stringify(this.tableData[0])
);
// console.log(this.tableData);
} else {
this.$message({
message: `保存失败`,
type: "error",
});
}
// }
},
closeMenu(ev) {
console.log({ ev });
this.dialogVisible = false;
},
async GetUserAnswer() {
let answer = await GetUserAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id,
// user_id: "USER202307301114011710",
});
if(!answer.data.state){
getQueryAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id
}).then(res => {
let obj = JSON.parse(res.data.data.r3);
if (obj.cjdpz_tagid) {
this.tableData[0].cjdpz_tagid = obj.cjdpz_tagid;
this.tableData[0].cjdpz_mc = obj.cjdpz_mc;
this.tableData[0].cjdpz_sjq = obj.cjdpz_sjq;
this.tableData[0].cjdpz_jcqdz = obj.cjdpz_jcqdz;
this.tableData[0].cjdpz_cjsjlx = obj.cjdpz_cjsjlx;
this.tableData[0].cjdpz_zjx = obj.cjdpz_zjx;
this.tableData[0].cjdpz_dxsx = obj.cjdpz_dxsx;
this.tableData[0].cjdpz_beilv = obj.cjdpz_beilv;
}
// this.tableData[0].ippz_wangkou = obj.ippz_wangkou;
this.tableData[0].ippz_lwfs = obj.ippz_lwfs;
this.tableData[0].ippz_zwym = obj.ippz_zwym;
this.tableData[0].ippz_ip = obj.ippz_ip;
this.tableData[0].ippz_mrwg = obj.ippz_mrwg;
this.tableData[0].wgpz_wgmc = obj.wgpz_wgmc;
this.tableData[0].wgpz_wgid = obj.wgpz_wgid;
this.tableData[0].wgpz_wglx = obj.wgpz_wglx;
this.tableData[0].tdpz_watchtime = obj.tdpz_watchtime;
this.tableData[0].tdpz_cjsylxdz = obj.tdpz_cjsylxdz;
this.tableData[0].ippz_dns_sx = obj.ippz_dns_sx;
this.tableData[0].ippz_dns_by = obj.ippz_dns_by;
this.tableData[0].ippz_mac = obj.ippz_mac;
this.tableData[0].ippz_wifi_ssid = obj.ippz_wifi_ssid;
this.tableData[0].ippz_wifi_mm = obj.ippz_wifi_mm;
this.tableData[0].tdpz_tdmc = obj.tdpz_tdmc;
this.tableData[0].tdpz_td = obj.tdpz_td;
this.tableData[0].tdpz_qdmc = obj.tdpz_qdmc;
this.tableData[0].tdpz_chuankou = obj.tdpz_chuankou;
this.tableData[0].tdpz_btl = obj.tdpz_btl;
this.tableData[0].tdpz_sjw = obj.tdpz_sjw;
this.tableData[0].tdpz_tzw = obj.tdpz_tzw;
this.tableData[0].tdpz_jojy = obj.tdpz_jojy;
this.tableData[0].tdpz_port = obj.tdpz_port;
this.tableData[0].tdpz_cgsj = obj.tdpz_cgsj;
this.tableData[0].tdpz_jgsj = obj.tdpz_jgsj;
this.tableData[0].tdpz_lxsj = obj.tdpz_lxsj;
this.tableData[0].tdpz_cfcs = obj.tdpz_cfcs;
this.tableData[0].tdpz_050F = obj.tdpz_050F;
this.tableData[0].tdpz_0610 = obj.tdpz_0610;
this.tableData[0].tdpz_dxzkb = obj.tdpz_dxzkb;
this.tableData[0].sbpz_sbid = obj.sbpz_sbid;
this.tableData[0].sbpz_sbmc = obj.sbpz_sbmc;
this.tableData[0].sbpz_sbdz = obj.sbpz_sbdz;
this.tableData[0].sbpz_jysb = obj.sbpz_jysb;
this.tableData[0].sbpz_jdzxz = obj.sbpz_jdzxz;
this.tableData[0].mqtt_qiyong = obj.mqtt_qiyong;
this.tableData[0].mqtt_ip = obj.mqtt_ip;
this.tableData[0].mqtt_port = obj.mqtt_port;
this.tableData[0].mqtt_wgsn = obj.mqtt_wgsn;
this.tableData[0].mqtt_sssjfbzt = obj.mqtt_sssjfbzt;
this.tableData[0].mqtt_qos = obj.mqtt_qos;
this.tableData[0].mqtt_scms = obj.mqtt_scms;
this.tableData[0].mqtt_sczq = obj.mqtt_sczq;
this.tableData[0].mqtt_sjgl = obj.mqtt_sjgl;
this.tableData[0].mqtt_cjd_sbmc = obj.mqtt_cjd_sbmc;
this.tableData[0].mqtt_cjd_tagid = obj.mqtt_cjd_tagid;
})
}
if (answer.data.state && answer.data.data) {
console.log(answer);
let obj = JSON.parse(answer.data.data.mark_value);
console.log(obj);
if (obj.cjdpz_tagid) {
this.tableData[0].cjdpz_tagid = obj.cjdpz_tagid;
this.tableData[0].cjdpz_mc = obj.cjdpz_mc;
this.tableData[0].cjdpz_sjq = obj.cjdpz_sjq;
this.tableData[0].cjdpz_jcqdz = obj.cjdpz_jcqdz;
this.tableData[0].cjdpz_cjsjlx = obj.cjdpz_cjsjlx;
this.tableData[0].cjdpz_zjx = obj.cjdpz_zjx;
this.tableData[0].cjdpz_dxsx = obj.cjdpz_dxsx;
this.tableData[0].cjdpz_beilv = obj.cjdpz_beilv;
}
// this.tableData[0].ippz_wangkou = obj.ippz_wangkou;
this.tableData[0].ippz_lwfs = obj.ippz_lwfs;
this.tableData[0].ippz_zwym = obj.ippz_zwym;
this.tableData[0].ippz_ip = obj.ippz_ip;
this.tableData[0].ippz_mrwg = obj.ippz_mrwg;
this.tableData[0].wgpz_wgmc = obj.wgpz_wgmc;
this.tableData[0].wgpz_wgid = obj.wgpz_wgid;
this.tableData[0].wgpz_wglx = obj.wgpz_wglx;
this.tableData[0].tdpz_watchtime = obj.tdpz_watchtime;
this.tableData[0].tdpz_cjsylxdz = obj.tdpz_cjsylxdz;
this.tableData[0].ippz_dns_sx = obj.ippz_dns_sx;
this.tableData[0].ippz_dns_by = obj.ippz_dns_by;
this.tableData[0].ippz_mac = obj.ippz_mac;
this.tableData[0].ippz_wifi_ssid = obj.ippz_wifi_ssid;
this.tableData[0].ippz_wifi_mm = obj.ippz_wifi_mm;
this.tableData[0].tdpz_tdmc = obj.tdpz_tdmc;
this.tableData[0].tdpz_td = obj.tdpz_td;
this.tableData[0].tdpz_qdmc = obj.tdpz_qdmc;
this.tableData[0].tdpz_chuankou = obj.tdpz_chuankou;
this.tableData[0].tdpz_btl = obj.tdpz_btl;
this.tableData[0].tdpz_sjw = obj.tdpz_sjw;
this.tableData[0].tdpz_tzw = obj.tdpz_tzw;
this.tableData[0].tdpz_jojy = obj.tdpz_jojy;
this.tableData[0].tdpz_port = obj.tdpz_port;
this.tableData[0].tdpz_cgsj = obj.tdpz_cgsj;
this.tableData[0].tdpz_jgsj = obj.tdpz_jgsj;
this.tableData[0].tdpz_lxsj = obj.tdpz_lxsj;
this.tableData[0].tdpz_cfcs = obj.tdpz_cfcs;
this.tableData[0].tdpz_050F = obj.tdpz_050F;
this.tableData[0].tdpz_0610 = obj.tdpz_0610;
this.tableData[0].tdpz_dxzkb = obj.tdpz_dxzkb;
this.tableData[0].sbpz_sbid = obj.sbpz_sbid;
this.tableData[0].sbpz_sbmc = obj.sbpz_sbmc;
this.tableData[0].sbpz_sbdz = obj.sbpz_sbdz;
this.tableData[0].sbpz_jysb = obj.sbpz_jysb;
this.tableData[0].sbpz_jdzxz = obj.sbpz_jdzxz;
this.tableData[0].mqtt_qiyong = obj.mqtt_qiyong;
this.tableData[0].mqtt_ip = obj.mqtt_ip;
this.tableData[0].mqtt_port = obj.mqtt_port;
this.tableData[0].mqtt_wgsn = obj.mqtt_wgsn;
this.tableData[0].mqtt_sssjfbzt = obj.mqtt_sssjfbzt;
this.tableData[0].mqtt_qos = obj.mqtt_qos;
this.tableData[0].mqtt_scms = obj.mqtt_scms;
this.tableData[0].mqtt_sczq = obj.mqtt_sczq;
this.tableData[0].mqtt_sjgl = obj.mqtt_sjgl;
this.tableData[0].mqtt_cjd_sbmc = obj.mqtt_cjd_sbmc;
this.tableData[0].mqtt_cjd_tagid = obj.mqtt_cjd_tagid;
// this.tableData[0].mqtt_retained = obj.mqtt_retained;
}
},
async sendTree() {
let result = await SendTree({
user_id: this.user_id,
// user_id: "USER202307301114011710",
data: JSON.stringify(this.trees),
type: "2",
});
console.log(result);
},
// 保存设备的属性
async saveDevice() {
var obj = {
sbpz_sbid: this.tableData[0].sbpz_sbid,
sbpz_sbmc: this.tableData[0].sbpz_sbmc,
sbpz_sbdz: this.tableData[0].sbpz_sbdz,
sbpz_jysb: String(Number(this.tableData[0].sbpz_jysb)),
sbpz_jdzxz: String(Number(this.tableData[0].sbpz_jdzxz)),
};
let datas = { ...this.tableData[0], ...obj };
console.log(datas);
this.add_passage = false;
let res4 = await SaveUserAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id,
// user_id: "USER202307301114011710",
mark_value: JSON.stringify(datas),
step: "3",
});
if (res4.data.state) {
// console.log(res4.data.state);
this.$message({
message: "更改成功",
type: "success",
});
sessionStorage.setItem("DB-IotLite_wx", JSON.stringify(datas));
this.updateLabelById(this.nodekey, this.tableData[0].sbpz_sbmc);
this.sendTree();
} else {
this.$message({
message: `更改失败,原因是${res4.data.message}`,
type: "error",
});
}
},
// 修改树形控件的名字
findNodeById(nodes, targetId) {
let foundNode = null;
const findNode = (nodes) => {
for (const node of nodes) {
if (node.id === targetId) {
// 找到节点
foundNode = node;
return;
}
if (node.children) {
findNode(node.children);
}
}
};
findNode(nodes);
return foundNode;
},
updateLabelById(targetId, newLabel) {
const targetNode = this.findNodeById(this.trees, targetId);
// console.log(targetId);
// console.log(targetNode);
// console.log(newLabel);
if (targetNode) {
// 找到节点更新label值
// console.log(targetNode);
// console.log(newLabel);
this.$set(targetNode, "label", newLabel);
// 强制更新视图
this.$forceUpdate();
// this.getTree();
}
},
async getTree() {
let res = await GetTree({
user_id: this.user_id,
// user_id: "USER202307301114011710",
type: "2",
});
if(this.$i18n.locale==='zh'){
this.trees = JSON.parse(res.data.data.r2);
}else{
this.trees = JSON.parse(res.data.data.data);
}
},
//网关信息配置
async submitGate() {
this.$refs["gateWay"].validate((valid) => {
if (valid) {
// console.log('submit!');
this.saveGates();
} else {
console.log("error submit!!");
return false;
}
});
},
async saveGates() {
this.outerVisible = false;
// this.innerVisible = false;
// let datas = sessionStorage.getItem("DB-IotLite_yx");
// console.log(JSON.parse(datas));
// datas = { ...JSON.parse(datas), ...this.gateWay };
// console.log(datas);
let res = await SaveUserAnswer({
mark: "DB-IotLite_wx",
user_id: this.user_id,
// user_id: "USER202307301114011710",
mark_value: JSON.stringify(this.tableData[0]),
step: "3",
});
if (res.data.state) {
this.$message({
message: "修改成功",
type: "success",
});
this.trees[0].label = this.tableData[0].wgpz_wgid;
this.sendTree();
sessionStorage.setItem(
"DB-IotLite_wx",
JSON.stringify(this.tableData[0])
);
} else {
this.$message({
message: `保存失败,原因是${res.data.message}`,
type: "error",
});
}
console.log(res);
},
},
created() {
console.log(this.$route.query.user_id);
this.user_id = this.$route.query.user_id;
if(this.user_id!="undefined"){
this.getTree();
}
this.loading = true;
this.GetUserAnswer();
this.loading = false;
},
};
</script>
<style lang="less" scoped>
.tree_menu {
position: absolute;
width: 286px;
height: 753px;
left: 64px;
top: 104px;
width: 286px;
height: 753px;
line-height: 20px;
border-radius: 3px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
border: 1px solid rgba(220, 220, 220, 1);
}
.tree_rightmenu {
position: fixed;
width: 120px;
border: 1px solid rgba(0, 0, 0, 0.15);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
z-index: 1000;
}
/deep/ .pas_params {
position: absolute;
left: 362px;
top: 125px;
width: 1066px;
height: 716px;
line-height: 20px;
border-radius: 3px;
background-color: rgba(255, 255, 255, 1);
// text-align: center;
border: 1px solid rgba(220, 220, 220, 1);
.el-button {
width: 80px;
height: 30px;
line-height: 0.5;
}
.el-col-12:last-child {
padding-right: 150px;
}
.el-col-12:first-child {
padding-right: 54px;
}
.el-row {
height: 40px;
display: flex;
align-items: flex-start;
.el-col-1 {
text-align: center;
line-height: 20px;
height: 20px;
}
.el-col-9 {
padding-left: 30px;
}
}
.el-input__inner {
height: 30px;
text-align: left;
padding: 0px 8px;
}
.content {
position: absolute;
left: 377px;
top: 69px;
width: 1220px;
height: 836px;
line-height: 20px;
padding-left: 36px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
font-size: 14px;
border: 1px solid rgba(187, 187, 187, 1);
display: flex;
justify-content: flex-start;
align-items: flex-start;
.el-form-item {
margin-bottom: 0px;
}
/deep/ .con_left {
.el-con-5 {
width: 43px;
}
}
.con_left {
width: 709px;
position: relative;
.con_left_footer {
position: absolute;
left: 499px;
top: 777px;
}
}
.con_right {
width: 480px;
.dialog-footer {
.el-button {
width: 80px;
height: 30px;
line-height: 0.5;
}
}
}
}
}
.one {
z-index: 10000;
position: absolute;
left: 95px;
top: 0px;
}
</style>