zhibiaoAdd.vue
10.3 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<template>
<div>
<el-dialog
:title="title"
:visible.sync="open"
v-if="open"
width="1000px"
append-to-body
top="10vh"
custom-class="new_dialog"
>
<div>
<el-form
:model="dynamicValidateForm"
ref="dynamicValidateForm"
label-width="100px"
class="demo-dynamic"
:rules="rules"
>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="预警编号" prop="baseNo" label-width="120px">
<el-input
v-model="dynamicValidateForm.baseNo"
placeholder="请输入预警编号"
:disabled="true"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="预警名称"
prop="baseName"
label-width="120px"
>
<el-input
v-model="dynamicValidateForm.baseName"
placeholder="请输入预警名称"
:disabled="disabled"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item
label="预警指标类型"
prop="baseType"
label-width="120px"
>
<el-select
v-model="dynamicValidateForm.baseType"
placeholder="预警指标类型"
clearable
size="small"
:disabled="disabled"
>
<el-option
v-for="(item, index) in dict.type.index_type_list"
:key="index"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="指标说明" prop="note" label-width="120px">
<el-input
v-model="dynamicValidateForm.note"
type="textarea"
placeholder="请输入指标说明"
show-word-limit
:disabled="disabled"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="监控预警详细" label-width="120px">
</el-form-item>
</el-col>
</el-row>
<div
style="
display: flex;
justify-content: space-between;
width: 90%;
margin: auto;
"
>
<div>注:在新增监控指标项时,需要技术提供sql</div>
<el-button type="text" :disabled="disabled" @click="guize">添加</el-button>
</div>
<el-table
:data="tableData"
border
style="width: 95%; margin: auto; margin-bottom: 20px"
>
<el-table-column
label="序号"
type="index"
width="55"
align="center"
/>
<el-table-column prop="name" label="监控指标项" align="center" />
<el-table-column
prop="baseSql"
label="监控指标sql"
align="center"
/>
<el-table-column fixed="right" label="操作" align="center">
<template slot-scope="scope">
<el-button
@click="handleClick(scope.row, scope.$index)"
type="text"
size="small"
:disabled="disabled"
>编辑</el-button
>
<el-button
type="text"
size="small"
:disabled="disabled"
@click.native.prevent="deleteRow(scope.$index, tableData)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-form>
<div
slot="footer"
class="dialog-footer"
style="margin-left: 83%"
v-if="!disabled"
>
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</div>
</el-dialog>
<el-dialog
title="新增规则"
:visible.sync="dialogFormVisible"
v-if="dialogFormVisible"
>
<el-form ref="formAdd" :model="formAdd" :rules="rules2">
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="监控指标项" prop="name" label-width="120px">
<el-input v-model="formAdd.name" placeholder="请输入监控指标项" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="监控指标sql"
prop="baseSql"
label-width="120px"
>
<el-input
v-model="formAdd.baseSql"
placeholder="请输入监控指标sql"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="tableUp">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getEarlylNo,
earlyBaseSave,
earlyBaseModifier,
} from "@/api/postList/list";
export default {
name: "addMobile",
dicts: ["sys_normal_disable", "name_roll_type", "index_type_list"],
props: [],
data() {
return {
imageUrl: "",
labelProduct: [],
checkList: [],
open: false,
// 弹出层标题
title: "",
// 表单参数
dialogFormVisible: false,
formLabelWidth: "120px",
dynamicValidateForm: {
baseNo: "",
},
disabled: false,
rules: {
baseNo: [
{ required: true, message: "预警编号不能为空", trigger: "blur" },
],
baseName: [
{ required: true, message: "预警名称不能为空", trigger: "blur" },
],
baseType: [
{ required: true, message: "请选择预警指标", trigger: "change" },
],
},
rules2: {
name: [
{ required: true, message: "监控指标项不能为空", trigger: "blur" },
],
baseSql: [
{ required: true, message: "监控指标sql不能为空", trigger: "blur" },
],
},
tableData: [],
formAdd: {},
fileList: [],
id: "",
addBtn: 1,
indexNum: "",
};
},
methods: {
// 取消按钮
cancel() {
this.open = false;
},
add() {
this.open = true;
this.id = "";
this.dynamicValidateForm = {
baseNo: "",
baseType: "",
note: "",
};
this.tableData = [];
this.openGetEarlylNo();
},
edit(res) {
this.open = true;
this.id = res.id;
this.dynamicValidateForm = res;
this.tableData = res.earlyBaseSqls;
},
see(res) {
this.open = true;
},
openGetEarlylNo() {
getEarlylNo().then((response) => {
this.dynamicValidateForm.baseNo = response.msg;
});
},
submitForm(formName) {
this.$refs["dynamicValidateForm"].validate((valid) => {
if (valid) {
if (this.id) {
let list = {
...this.dynamicValidateForm,
earlyBaseSqls: this.tableData,
id:this.id
};
// console.log(list)
earlyBaseModifier(list).then((response) => {
if (response.code == 200) {
this.$modal.msgSuccess(response.msg);
this.open = false;
this.$emit("getList");
} else {
this.$modal.msgSuccess(response.msg);
this.open = false;
}
});
} else {
let list = {
...this.dynamicValidateForm,
earlyBaseSqls: this.tableData,
};
// console.log(list)
earlyBaseSave(list).then((response) => {
if (response.code == 200) {
this.$modal.msgSuccess(response.msg);
this.open = false;
this.$emit("getList");
} else {
this.$modal.msgSuccess(response.msg);
this.open = false;
}
});
}
}
});
},
guize() {
this.dialogFormVisible = true;
this.formAdd = {};
this.addBtn = 1;
},
tableUp() {
this.$refs["formAdd"].validate((valid) => {
if (valid) {
if (this.addBtn == 1) {
this.tableData.push(this.formAdd);
this.dialogFormVisible = false;
} else {
this.tableData.splice(this.indexNum, 1);
this.tableData.push(this.formAdd);
this.dialogFormVisible = false;
console.log(this.formAdd);
}
}
});
},
deleteRow(index, rows) {
rows.splice(index, 1);
},
handleClick(row, index) {
console.log(row, index);
this.addBtn = 2;
this.dialogFormVisible = true;
this.formAdd = row;
this.indexNum = index;
},
removeDomain(item) {
var index = this.dynamicValidateForm.domains.indexOf(item);
if (index !== -1) {
this.dynamicValidateForm.domains.splice(index, 1);
}
},
},
};
</script>
<style lang="scss" scoped>
.box1 {
display: flex;
justify-content: space-around;
width: 100%;
}
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
.new_dialog {
height: 70%;
overflow: hidden;
overflow-y: scroll;
}
</style>