提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :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="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|
6 |
<el-row> |
|
7 |
<el-col :span="12"> |
|
8 |
<el-form-item label="设备分类编码" prop="classNo"> |
|
9 |
<el-input v-model="dataForm.classNo" placeholder="设备分类编码"></el-input> |
|
10 |
</el-form-item> |
|
11 |
</el-col> |
|
12 |
<el-col :span="12"> |
|
13 |
<el-form-item label="设备分类名称" prop="className"> |
|
14 |
<el-input v-model="dataForm.className" placeholder="设备分类名称"></el-input> |
|
15 |
</el-form-item> |
|
16 |
</el-col> |
|
17 |
</el-row> |
|
18 |
<el-row> |
|
19 |
<el-col :span="12"> |
|
20 |
<el-form-item label="评价指标" prop="indexType"> |
|
21 |
<dict-select-tag style="width: 100%;" v-model="dataForm.indexType" dictCode="health_index_type"></dict-select-tag> |
|
22 |
</el-form-item> |
|
23 |
</el-col> |
|
24 |
<el-col :span="12"> |
|
25 |
<el-form-item label="故障类型" prop="faultType"> |
|
26 |
<dict-select-tag style="width: 100%;" v-model="dataForm.faultType" dictCode="health_fault_type"></dict-select-tag> |
|
27 |
</el-form-item> |
|
28 |
</el-col> |
|
29 |
</el-row> |
|
30 |
<el-row> |
|
31 |
<el-col :span="12"> |
|
32 |
<el-form-item label="故障码" prop="faultCode"> |
|
33 |
<el-input v-model="dataForm.faultCode" placeholder="故障码"></el-input> |
|
34 |
</el-form-item> |
|
35 |
</el-col> |
|
36 |
<el-col :span="12"> |
|
37 |
<el-form-item label="排序" prop="sort"> |
|
38 |
<el-input v-model="dataForm.sort" placeholder="排序"></el-input> |
|
39 |
</el-form-item> |
|
40 |
</el-col> |
|
41 |
</el-row> |
|
42 |
<el-row> |
|
43 |
<el-col :span="24"> |
|
44 |
<el-form-item label="处理对策" prop="solution"> |
|
45 |
<el-input v-model="dataForm.solution" type = "textarea" rows="3" placeholder="处理对策"></el-input> |
|
46 |
</el-form-item> |
|
47 |
</el-col> |
|
48 |
</el-row> |
|
49 |
</el-form> |
|
50 |
<template slot="footer"> |
|
51 |
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|
52 |
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|
53 |
</template> |
|
54 |
</el-dialog> |
|
55 |
</template> |
|
56 |
|
|
57 |
<script> |
|
58 |
import debounce from 'lodash/debounce' |
|
59 |
import DictSelectTag from "@/components/dict/dict-select-tag.vue"; |
|
60 |
|
|
61 |
export default { |
|
62 |
components: {DictSelectTag}, |
|
63 |
data() { |
|
64 |
return { |
|
65 |
visible: false, |
|
66 |
dataForm: { |
|
67 |
id: '', |
|
68 |
classNo: '', |
|
69 |
className: '', |
|
70 |
indexType: '', |
|
71 |
faultType: '', |
|
72 |
faultCode: '', |
|
73 |
solution: '', |
|
74 |
sort: '' |
|
75 |
} |
|
76 |
} |
|
77 |
}, |
|
78 |
computed: { |
|
79 |
dataRule() { |
|
80 |
return { |
|
81 |
classNo: [ |
|
82 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
83 |
], |
|
84 |
className: [ |
|
85 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
86 |
], |
|
87 |
indexType: [ |
|
88 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
89 |
], |
|
90 |
faultType: [ |
|
91 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
92 |
], |
|
93 |
faultCode: [ |
|
94 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
95 |
], |
|
96 |
solution: [ |
|
97 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
98 |
] |
|
99 |
} |
|
100 |
} |
|
101 |
}, |
|
102 |
methods: { |
|
103 |
init() { |
|
104 |
this.visible = true |
|
105 |
this.$nextTick(() => { |
|
106 |
this.$refs['dataForm'].resetFields() |
|
107 |
if (this.dataForm.id) { |
|
108 |
this.getInfo() |
|
109 |
} |
|
110 |
}) |
|
111 |
}, |
|
112 |
// 获取信息 |
|
113 |
getInfo() { |
|
114 |
this.$http.get(`/iailab-ntt-model/device/device-fault/${this.dataForm.id}`).then(({data: res}) => { |
|
115 |
if (res.code !== 0) { |
|
116 |
return this.$message.error(res.msg) |
|
117 |
} |
|
118 |
this.dataForm = { |
|
119 |
...this.dataForm, |
|
120 |
...res.data |
|
121 |
} |
|
122 |
}).catch(() => { |
|
123 |
}) |
|
124 |
}, |
|
125 |
// 表单提交 |
|
126 |
dataFormSubmitHandle: debounce(function () { |
|
127 |
this.$refs['dataForm'].validate((valid) => { |
|
128 |
if (!valid) { |
|
129 |
return false |
|
130 |
} |
|
131 |
this.$http[!this.dataForm.id ? 'post' : 'put']('/iailab-ntt-model/device/device-fault/', this.dataForm).then(({data: res}) => { |
|
132 |
if (res.code !== 0) { |
|
133 |
return this.$message.error(res.msg) |
|
134 |
} |
|
135 |
this.$message({ |
|
136 |
message: this.$t('prompt.success'), |
|
137 |
type: 'success', |
|
138 |
duration: 500, |
|
139 |
onClose: () => { |
|
140 |
this.visible = false |
|
141 |
this.$emit('refreshDataList') |
|
142 |
} |
|
143 |
}) |
|
144 |
}).catch(() => { |
|
145 |
}) |
|
146 |
}) |
|
147 |
}, 1000, {'leading': true, 'trailing': false}) |
|
148 |
} |
|
149 |
} |
|
150 |
</script> |