提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" title="设置值" :close-on-click-modal="false" |
|
3 |
:close-on-press-escape="false"> |
|
4 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" |
|
5 |
label-width="120px"> |
|
6 |
<el-row> |
|
7 |
<el-col :span="12"> |
|
8 |
<el-form-item prop="pointName" :label="$t('point.pointName')"> |
|
9 |
<el-input v-model="dataForm.pointName" :placeholder="$t('point.pointName')" readonly></el-input> |
|
10 |
</el-form-item> |
|
11 |
</el-col> |
|
12 |
<el-col :span="12"> |
|
13 |
<el-form-item prop="defaultValue" label="值"> |
|
14 |
<el-input v-model="dataForm.defaultValue" placeholder="值"></el-input> |
|
15 |
</el-form-item> |
|
16 |
</el-col> |
|
17 |
</el-row> |
|
18 |
</el-form> |
|
19 |
<template slot="footer"> |
|
20 |
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|
21 |
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|
22 |
</template> |
|
23 |
</el-dialog> |
|
24 |
</template> |
|
25 |
<script> |
|
26 |
import debounce from 'lodash/debounce' |
|
27 |
|
|
28 |
export default { |
|
29 |
data() { |
|
30 |
return { |
|
31 |
visible: false, |
|
32 |
dataForm: { |
|
33 |
id: '', |
|
34 |
pointNo: '', |
|
35 |
pointName: '', |
|
36 |
defaultValue: '' |
|
37 |
} |
|
38 |
} |
|
39 |
}, |
|
40 |
computed: { |
|
41 |
dataRule() { |
|
42 |
return { |
|
43 |
pointNo: [ |
|
44 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
45 |
], |
|
46 |
defaultValue: [ |
|
47 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
48 |
], |
|
49 |
} |
|
50 |
} |
|
51 |
}, |
|
52 |
methods: { |
|
53 |
init(row) { |
|
54 |
this.visible = true |
|
55 |
this.dataForm.id = row.id |
|
56 |
this.dataForm.pointNo = row.pointNo |
|
57 |
this.dataForm.pointName = row.pointName |
|
58 |
}, |
|
59 |
// 表单提交 |
|
60 |
dataFormSubmitHandle: debounce(function () { |
|
61 |
this.$refs['dataForm'].validate((valid) => { |
|
62 |
if (!valid) { |
|
63 |
return false |
|
64 |
} |
|
65 |
this.$http['put']('/mcs/da-point/setPointValue', { |
|
66 |
...this.dataForm |
|
67 |
}).then(({data: res}) => { |
|
68 |
if (res.code !== 0) { |
|
69 |
return this.$message.error(res.msg) |
|
70 |
} |
|
71 |
this.$message({ |
|
72 |
message: this.$t('prompt.success'), |
|
73 |
type: 'success', |
|
74 |
duration: 500, |
|
75 |
onClose: () => { |
|
76 |
this.visible = false |
|
77 |
this.$emit('refreshDataList') |
|
78 |
} |
|
79 |
}) |
|
80 |
}).catch(() => { |
|
81 |
}) |
|
82 |
}) |
|
83 |
}, 1000, {'leading': true, 'trailing': false}) |
|
84 |
} |
|
85 |
} |
|
86 |
</script> |