提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible" |
|
6 |
append-to-body |
|
7 |
> |
|
8 |
<el-form |
|
9 |
:model="dataForm" |
|
10 |
:rules="dataRule" |
|
11 |
ref="dataForm" |
|
12 |
@keyup.enter.native="dataFormSubmit()" |
|
13 |
label-width="100px" |
|
14 |
> |
|
15 |
<el-row :gutter="20"> |
|
16 |
<el-col :span="12"> |
|
17 |
<el-form-item label="服务名" prop="name"> |
|
18 |
<el-input v-model="dataForm.name" placeholder="服务名"></el-input> |
|
19 |
</el-form-item> |
|
20 |
</el-col> |
|
21 |
<el-col :span="12"> |
|
22 |
<el-form-item label="类型" prop="type"> |
|
23 |
<el-input v-model="dataForm.type" placeholder="类型"></el-input> |
|
24 |
</el-form-item> |
|
25 |
</el-col> |
|
26 |
</el-row> |
|
27 |
<el-row :gutter="20"> |
|
28 |
<el-col :span="12"> |
|
29 |
<el-form-item label="地址" prop="address"> |
|
30 |
<el-input v-model="dataForm.address" placeholder="地址" /> |
|
31 |
</el-form-item> |
|
32 |
</el-col> |
|
33 |
<el-col :span="12"> |
|
34 |
<el-form-item label="端口" prop="port"> |
|
35 |
<el-input v-model="dataForm.port" placeholder="端口" /> |
|
36 |
</el-form-item> |
|
37 |
</el-col> |
|
38 |
</el-row> |
|
39 |
<el-row :gutter="20"> |
|
40 |
<el-col :span="12"> |
|
41 |
<el-form-item |
|
42 |
label="设备不活动超时时间" |
|
43 |
prop="connectInactivityTimeout" |
|
44 |
><el-input-number |
|
45 |
:min=0 |
|
46 |
:max="1000000" |
|
47 |
v-model="dataForm.connectInactivityTimeout" |
|
48 |
placeholder="设备不活动超时时间" |
|
49 |
/> |
|
50 |
</el-form-item> |
|
51 |
</el-col> |
|
52 |
<el-col :span="12"> |
|
53 |
<el-form-item label="重连超时" prop="reconnectInterval" |
|
54 |
><el-input-number |
|
55 |
:min=0 |
|
56 |
:max="100000" |
|
57 |
v-model="dataForm.reconnectInterval" |
|
58 |
placeholder="重连超时" |
|
59 |
/> |
|
60 |
</el-form-item> |
|
61 |
</el-col> |
|
62 |
</el-row> |
|
63 |
<el-row :gutter="20"> |
|
64 |
<el-col :span="12"> |
|
65 |
<el-form-item label="读超时" prop="readTimeout"> |
|
66 |
<el-input-number |
|
67 |
:min=0 |
|
68 |
:max="100000" |
|
69 |
v-model="dataForm.readTimeout" |
|
70 |
placeholder="读超时" |
|
71 |
/> |
|
72 |
</el-form-item> |
|
73 |
</el-col> |
|
74 |
<el-col :span="12"> |
|
75 |
<el-form-item label="写超时" prop="writeTimeout"> |
|
76 |
<el-input-number |
|
77 |
:min=0 |
|
78 |
:max="100000" |
|
79 |
v-model="dataForm.writeTimeout" |
|
80 |
placeholder="读超时" |
|
81 |
/> |
|
82 |
</el-form-item> |
|
83 |
</el-col> |
|
84 |
</el-row> |
|
85 |
</el-form> |
|
86 |
<span slot="footer" class="dialog-footer"> |
|
87 |
<el-button @click="visible = false">取消</el-button> |
|
88 |
<el-button :loading="loading" type="primary" @click="dataFormSubmit()" |
|
89 |
>确定</el-button |
|
90 |
> |
|
91 |
</span> |
|
92 |
</el-dialog> |
|
93 |
</template> |
|
94 |
|
|
95 |
<script> |
|
96 |
import DictSelectTag from "@/components/dict/dict-select-tag"; |
|
97 |
export default { |
|
98 |
components: { |
|
99 |
DictSelectTag, |
|
100 |
}, |
|
101 |
data() { |
|
102 |
return { |
|
103 |
loading: false, |
|
104 |
visible: false, |
|
105 |
dataForm: { |
|
106 |
id: "", |
|
107 |
name: "", |
|
108 |
type: "", |
|
109 |
address: "", |
|
110 |
port: "", |
|
111 |
connectInactivityTimeout: "", |
|
112 |
reconnectInterval: "", |
|
113 |
readTimeout: "", |
|
114 |
writeTimeout: "", |
|
115 |
}, |
|
116 |
dataRule: { |
|
117 |
name: [{ required: true, message: "服务名不能为空", trigger: "blur" }], |
|
118 |
type: [{ required: true, message: "类型不能为空", trigger: "blur" }], |
|
119 |
address: [{ required: true, message: "地址不能为空", trigger: "blur" }], |
|
120 |
port: [{ required: true, message: "端口号不能为空", trigger: "blur" }], |
|
121 |
connectInactivityTimeout: [ |
|
122 |
{ |
|
123 |
required: true, |
|
124 |
message: "设备不活动超时时间不能为空", |
|
125 |
trigger: "blur", |
|
126 |
}, |
|
127 |
], |
|
128 |
reconnectInterval: [ |
|
129 |
{ required: true, message: "重连超时不能为空", trigger: "blur" }, |
|
130 |
], |
|
131 |
writeTimeout: [ |
|
132 |
{ |
|
133 |
required: true, |
|
134 |
message: "写超时", |
|
135 |
trigger: "blur", |
|
136 |
}, |
|
137 |
], |
|
138 |
readTimeout: [ |
|
139 |
{ |
|
140 |
required: true, |
|
141 |
message: "读超时", |
|
142 |
trigger: "blur", |
|
143 |
}, |
|
144 |
], |
|
145 |
}, |
|
146 |
showAuth: false, // 是否显示用户名、密码输入框 |
|
147 |
showCert: false, // 是否显示安全证书路径输入框 |
|
148 |
}; |
|
149 |
}, |
|
150 |
methods: { |
|
151 |
init(id) { |
|
152 |
this.dataForm.id = id || 0; |
|
153 |
this.visible = true; |
|
154 |
this.$nextTick(() => { |
|
155 |
this.$refs["dataForm"].resetFields(); |
|
156 |
if (this.dataForm.id) { |
|
157 |
this.$http({ |
|
158 |
url: `/data/channel/opcda/device/info/${this.dataForm.id}`, |
|
159 |
method: "get", |
|
160 |
params: this.$http.adornParams(), |
|
161 |
}).then(({ data }) => { |
|
162 |
if (data && data.code === 0) { |
|
163 |
this.dataForm.name = data.data.name; |
|
164 |
this.dataForm.type = data.data.type; |
|
165 |
this.dataForm.address = data.data.address; |
|
166 |
this.dataForm.port = data.data.port; |
|
167 |
this.dataForm.connectInactivityTimeout = |
|
168 |
data.data.connectInactivityTimeout; |
|
169 |
this.dataForm.reconnectInterval = data.data.reconnectInterval; |
|
170 |
this.dataForm.readTimeout = data.data.readTimeout; |
|
171 |
this.dataForm.writeTimeout = data.data.writeTimeout; |
|
172 |
} |
|
173 |
}); |
|
174 |
} |
|
175 |
}); |
|
176 |
}, |
|
177 |
// 表单提交 |
|
178 |
dataFormSubmit() { |
|
179 |
this.$refs["dataForm"].validate((valid) => { |
|
180 |
if (valid) { |
|
181 |
this.visible = true; |
|
182 |
this.$http({ |
|
183 |
headers: { |
|
184 |
"Content-Type": "application/json", |
|
185 |
}, |
|
186 |
url: `/data/channel/opcda/device/${ |
|
187 |
!this.dataForm.id ? "add" : "update" |
|
188 |
}`, |
|
189 |
method: "post", |
|
190 |
data: this.$http.adornData({ |
|
191 |
id: this.dataForm.id || undefined, |
|
192 |
name: this.dataForm.name, |
|
193 |
type: this.dataForm.type, |
|
194 |
address: this.dataForm.address, |
|
195 |
port: this.dataForm.port, |
|
196 |
reconnectInterval: this.dataForm.reconnectInterval, |
|
197 |
connectInactivityTimeout: this.dataForm.connectInactivityTimeout, |
|
198 |
readTimeout: this.dataForm.readTimeout, |
|
199 |
writeTimeout: this.dataForm.writeTimeout, |
|
200 |
}), |
|
201 |
}).then(({ data }) => { |
|
202 |
if (data && data.code === 0) { |
|
203 |
this.$message({ |
|
204 |
message: "操作成功", |
|
205 |
type: "success", |
|
206 |
duration: 1500, |
|
207 |
onClose: () => { |
|
208 |
this.loading = false; |
|
209 |
this.$emit("refreshDataList"); |
|
210 |
}, |
|
211 |
}); |
|
212 |
this.loading = false; |
|
213 |
} else { |
|
214 |
this.$message.error(data.msg); |
|
215 |
} |
|
216 |
}); |
|
217 |
} |
|
218 |
}); |
|
219 |
}, |
|
220 |
}, |
|
221 |
}; |
|
222 |
</script> |
|
223 |
<style> |
|
224 |
.el-select { |
|
225 |
width: 100%; |
|
226 |
} |
|
227 |
.el-input-group__append { |
|
228 |
padding: 0 5px 0 5px; |
|
229 |
} |
|
230 |
.el-input-group__prepend { |
|
231 |
padding: 0 5px 0 5px; |
|
232 |
} |
|
233 |
</style> |