提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible"> |
|
6 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"> |
|
7 |
<el-form-item label="名称" prop="energytypename"> |
|
8 |
<el-input v-model="dataForm.energytypename" placeholder="名称" maxlength="50" clearable></el-input> |
|
9 |
</el-form-item> |
|
10 |
</el-form> |
|
11 |
<span slot="footer" class="dialog-footer"> |
|
12 |
<el-button @click="visible = false">取消</el-button> |
|
13 |
<el-button type="primary" @click="dataFormSubmit()">确定</el-button> |
|
14 |
</span> |
|
15 |
</el-dialog> |
|
16 |
</template> |
|
17 |
|
|
18 |
<script> |
|
19 |
export default { |
|
20 |
data () { |
|
21 |
return { |
|
22 |
|
|
23 |
visible: false, |
|
24 |
roleList: [], |
|
25 |
dataForm: { |
|
26 |
id: 0, |
|
27 |
energytypename: '' |
|
28 |
}, |
|
29 |
dataRule: { |
|
30 |
energytypename: [ |
|
31 |
{ required: true, message: '名称不能为空', trigger: 'blur' } |
|
32 |
] |
|
33 |
} |
|
34 |
} |
|
35 |
}, |
|
36 |
methods: { |
|
37 |
init (id) { |
|
38 |
this.dataForm.id = id || 0 |
|
39 |
this.visible = true |
|
40 |
this.$nextTick(() => { |
|
41 |
this.$refs['dataForm'].resetFields() |
|
42 |
}) |
|
43 |
if (id) { |
|
44 |
this.$http({ |
|
45 |
url: `/iailab-ntt-model/mcs/schedule-energy-type/info/${this.dataForm.id}`, |
|
46 |
method: 'get', |
|
47 |
params: this.$http.adornParams() |
|
48 |
}).then(({data}) => { |
|
49 |
if (data && data.code === 0) { |
|
50 |
this.dataForm.energytypename = data.scheduleEnergyType.energytypename |
|
51 |
} |
|
52 |
}) |
|
53 |
} |
|
54 |
}, |
|
55 |
// 表单提交 |
|
56 |
dataFormSubmit () { |
|
57 |
this.$refs['dataForm'].validate((valid) => { |
|
58 |
if (valid) { |
|
59 |
this.$http({ |
|
60 |
url: `/iailab-ntt-model/mcs/schedule-energy-type/${!this.dataForm.id ? 'save' : 'update'}`, |
|
61 |
method: 'post', |
|
62 |
data: this.$http.adornData({ |
|
63 |
'id': this.dataForm.id || undefined, |
|
64 |
'energytypename': this.dataForm.energytypename |
|
65 |
}) |
|
66 |
}).then(({data}) => { |
|
67 |
if (data && data.code === 0) { |
|
68 |
this.$message({ |
|
69 |
message: '操作成功', |
|
70 |
type: 'success', |
|
71 |
duration: 1500, |
|
72 |
onClose: () => { |
|
73 |
this.visible = false |
|
74 |
this.$emit('refreshDataList') |
|
75 |
} |
|
76 |
}) |
|
77 |
} else { |
|
78 |
this.$message.error(data.msg) |
|
79 |
} |
|
80 |
}) |
|
81 |
} |
|
82 |
}) |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
</script> |