index.vue
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!--
* @Author: panda
* @Date: 2021-09-27 13:40:37
* @LastEditTime: 2021-09-27 17:04:20
* @LastEditors: Please set LastEditors
* @Description: 参数缺省设置
* @FilePath: /fanxing_new/src/views/resource/publicConfig/index.vue
-->
<template>
<div class="config-box">
<div class="switch-box">
<el-radio v-model="radio" label="defaultConfig">正常配置</el-radio>
<el-radio v-model="radio" label="illegalStopDefaultConfig">违停配置</el-radio>
</div>
<el-row>
<el-col :span="3" class="search-box">
<el-input placeholder="请输入内容" v-model="paramsval" class="input-with-select">
<el-button
slot="append"
icon="el-icon-search"
@click="$refs.iframeconfig.contentWindow.clickButton(paramsval)"
></el-button>
</el-input>
</el-col>
</el-row>
<el-row>
<el-col :span="20" class="content-box">
<iframe
id="iframeconfig"
ref="iframeconfig"
src="./dynamicParameters.html"
frameborder="0"
width="100%"
height="600"
scrolling="no"
></iframe>
</el-col>
<el-col :span="1" :offset="19">
<el-button type="primary" @click="saveConfig" class="save-btn">保存</el-button>
</el-col>
</el-row>
</div>
</template>
<script>
import xml from './baseConfig.js'
export default {
data() {
return {
paramsval:'',
radio: 'defaultConfig',
config:'',
configid:''
}
},
watch:{
radio(val){
this.getbaseConf(val)
}
},
methods:{
xmlInit: function(obj) {
this.$refs.iframeconfig.contentWindow.loadParameterTree(
obj.content,
'<?xml version="1.0" encoding="GBK"?><root></root>'
);
},
getbaseConf(type){
this.$api.device.getConfig(type).then(res => {
this.config = res.data.content
this.configid = res.data.id
this.xmlInit(res.data)
})
},
saveConfig(){
this.$refs.iframeconfig.contentWindow.submit();
//ifram 传递回来的饿xml
let XMLStr = this.$refs.iframeconfig.contentWindow.xmlStr;
if(!XMLStr) {
XMLStr = this.config
}
this.$api.device.saveConfig(this.configid,{content:XMLStr}).then(res => {
if(res.ecode == 200) {
this.$message({
type: "success",
message: '保存成功!'
});
} else {
this.$message({
type: "error",
message: '保存失败!'
});
}
})
},
},
mounted(){
setTimeout(() => {
this.getbaseConf('defaultConfig')
}, 2000);
}
}
</script>
<style>
.config-box{
margin:10px;
background: #fff;
overflow: hidden;
}
.switch-box{
margin:10px 0 0 10px
}
.search-box,.content-box{
margin:10px;
}
.save-btn{
float: right;
margin-bottom: 20px;
}
</style>