提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? `新增` : '编辑'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible"> |
|
6 |
<el-form label-position="left" :rules="dataRule" @keyup.enter.native="dataFormSubmit()" ref="dataForm" label-width="80px" :model="dataForm"> |
|
7 |
<el-row> |
|
8 |
<el-col :span="12"> |
|
9 |
<el-form-item label="指标编码"> |
|
10 |
<el-input v-model="dataForm.code"></el-input> |
|
11 |
</el-form-item> |
|
12 |
</el-col> |
|
13 |
<el-col :span="12"> |
|
14 |
<el-form-item label="指标名称"> |
|
15 |
<el-input v-model="dataForm.evaluateIndex"></el-input> |
|
16 |
</el-form-item> |
|
17 |
</el-col> |
|
18 |
</el-row> |
|
19 |
</el-form> |
|
20 |
<span slot="footer" class="dialog-footer"> |
|
21 |
<el-button @click="visible = false" :loading="uploadLoading">取消</el-button> |
|
22 |
<el-button type="primary" @click="dataFormSubmit()" :loading="uploadLoading">确定</el-button> |
|
23 |
</span> |
|
24 |
</el-dialog> |
|
25 |
</template> |
|
26 |
|
|
27 |
<script> |
|
28 |
import DictSelectTag from "@/components/dict/dict-select-tag"; |
|
29 |
export default { |
|
30 |
components: { |
|
31 |
DictSelectTag |
|
32 |
}, |
|
33 |
data () { |
|
34 |
return { |
|
35 |
visible: false, |
|
36 |
dataForm: { |
|
37 |
id:"", |
|
38 |
pid:"", |
|
39 |
code: "", |
|
40 |
evaluateIndex: "", |
|
41 |
weight:"0" |
|
42 |
}, |
|
43 |
uploadLoading: false, |
|
44 |
dataRule: { |
|
45 |
code: [ |
|
46 |
{ required: true, message: "设备名称不能为空", trigger: "blur" }, |
|
47 |
], |
|
48 |
evaluateIndex: [ |
|
49 |
{ required: true, message: "IP地址不能为空", trigger: "blur" }, |
|
50 |
] |
|
51 |
} |
|
52 |
} |
|
53 |
}, |
|
54 |
methods: { |
|
55 |
init(pid,id) { |
|
56 |
console.log(pid,id) |
|
57 |
this.visible = true; |
|
58 |
this.$nextTick(() => { |
|
59 |
this.dataForm=[]; |
|
60 |
this.dataForm.pid = pid |
|
61 |
if (id) { |
|
62 |
this.dataForm.id = id |
|
63 |
this.$http.get(`/iailab-ntt-model/index/evaluate/${this.dataForm.id}`).then(({ data }) => { |
|
64 |
if (data && data.code === 0) { |
|
65 |
this.dataForm=data.data; |
|
66 |
} |
|
67 |
}); |
|
68 |
} |
|
69 |
}); |
|
70 |
}, |
|
71 |
// 表单提交 |
|
72 |
dataFormSubmit() { |
|
73 |
this.$refs["dataForm"].validate((valid) => { |
|
74 |
if (valid) { |
|
75 |
this.uploadLoading = true; |
|
76 |
this.$http[!this.dataForm.id ? "post" : "put"]( |
|
77 |
"/iailab-ntt-model/index/evaluate", |
|
78 |
{ |
|
79 |
...this.dataForm, |
|
80 |
} |
|
81 |
).then(({data: res}) => { |
|
82 |
if (res.code !== 0) { |
|
83 |
return this.$message.error(res.msg); |
|
84 |
} |
|
85 |
this.$message({ |
|
86 |
message: this.$t("prompt.success"), |
|
87 |
type: "success", |
|
88 |
duration: 500, |
|
89 |
onClose: () => { |
|
90 |
this.visible = false; |
|
91 |
this.$emit("refreshDataList"); |
|
92 |
}, |
|
93 |
}); |
|
94 |
this.uploadLoading = false |
|
95 |
}) |
|
96 |
.catch(() => { |
|
97 |
}); |
|
98 |
} |
|
99 |
}); |
|
100 |
}, |
|
101 |
beforeCloseHandle(done) { |
|
102 |
this.dataList = []; |
|
103 |
done(); |
|
104 |
}, |
|
105 |
}, |
|
106 |
}; |
|
107 |
</script> |