提交 | 用户 | 时间
|
1308d4
|
1 |
<template> |
W |
2 |
<!-- 添加或修改IQC检验项目对话框 --> |
|
3 |
<el-dialog |
|
4 |
:title="title" |
|
5 |
:visible.sync="open" |
|
6 |
width="750px" |
|
7 |
custom-class="madelClass" |
|
8 |
:destroyOnClose="true" |
|
9 |
> |
|
10 |
<div class="contbox"> |
|
11 |
<el-form |
|
12 |
ref="form" |
|
13 |
v-if="open" |
|
14 |
:model="form" |
|
15 |
:rules="rules" |
|
16 |
:disabled="isCheck" |
|
17 |
> |
|
18 |
<el-form-item |
|
19 |
v-for="(item, index) in formItem" |
|
20 |
:key="index" |
|
21 |
:label="item.label" |
|
22 |
:prop="item.prop" |
|
23 |
label-width="120px" |
|
24 |
:class="item.component == 'inputNumber' ? 'itemFixed' : ''" |
|
25 |
> |
|
26 |
<template v-if="item.component == 'input'"> |
|
27 |
<el-input |
|
28 |
v-model="form[item.prop]" |
|
29 |
:readonly="item.readonly" |
|
30 |
:placeholder=" |
|
31 |
item.prop == 'checkItemNo' ? '自动生成' : '请输入' + item.label |
|
32 |
" |
|
33 |
/> |
|
34 |
</template> |
|
35 |
<template v-if="item.component == 'inputNumber'"> |
|
36 |
<el-input-number |
|
37 |
v-model="form[item.prop]" |
|
38 |
:label="'请输入' + item.label" |
|
39 |
></el-input-number> |
|
40 |
</template> |
|
41 |
<template v-if="item.component == 'textarea'"> |
|
42 |
<el-input |
|
43 |
type="textarea" |
|
44 |
:rows="2" |
|
45 |
:placeholder="'请输入' + item.label" |
|
46 |
v-model="form[item.prop]" |
|
47 |
> |
|
48 |
</el-input> |
|
49 |
</template> |
|
50 |
<template v-if="item.component == 'select'"> |
|
51 |
<template v-if="item.prop == 'werks'"> |
|
52 |
<el-select |
|
53 |
v-model="form[item.prop]" |
|
54 |
:placeholder="'请选择' + item.label" |
|
55 |
v-if="item.prop == 'werks'" |
|
56 |
style="width: 100%" |
|
57 |
> |
|
58 |
<el-option |
|
59 |
v-for="dict in werksList" |
|
60 |
:key="dict.werks" |
|
61 |
:label="dict.werksName" |
|
62 |
:value="dict.werks" |
|
63 |
> |
|
64 |
</el-option> |
|
65 |
</el-select> |
|
66 |
</template> |
|
67 |
|
|
68 |
<template v-if="item.prop == 'type'"> |
|
69 |
<el-select |
|
70 |
v-model="form[item.prop]" |
|
71 |
:placeholder="'请选择' + item.label" |
|
72 |
v-if="item.prop == 'type'" |
|
73 |
style="width: 100%" |
|
74 |
> |
|
75 |
<el-option |
|
76 |
v-for="dict in werksList" |
|
77 |
:key="dict.werks" |
|
78 |
:label="dict.werksName" |
|
79 |
:value="dict.werks" |
|
80 |
> |
|
81 |
</el-option> |
|
82 |
</el-select> |
|
83 |
</template> |
|
84 |
|
|
85 |
<template v-if="item.prop == 'isUseLocation'"> |
|
86 |
<el-select |
|
87 |
v-model="form[item.prop]" |
|
88 |
:placeholder="'请选择' + item.label" |
|
89 |
v-if="item.prop == 'isUseLocation'" |
|
90 |
style="width: 100%" |
|
91 |
> |
|
92 |
<el-option |
|
93 |
v-for="dict in dict.type.isenable" |
|
94 |
:key="dict.value" |
|
95 |
:label="dict.label" |
|
96 |
:value="dict.value" |
|
97 |
> |
|
98 |
</el-option> |
|
99 |
</el-select> |
|
100 |
</template> |
|
101 |
</template> |
|
102 |
</el-form-item> |
|
103 |
</el-form> |
|
104 |
</div> |
|
105 |
|
|
106 |
<div slot="footer" class="dialog-footer"> |
|
107 |
<el-button |
|
108 |
v-if="!isCheck" |
|
109 |
:loading="buttonLoading" |
|
110 |
type="primary" |
|
111 |
@click="submitForm" |
|
112 |
>确 定</el-button |
|
113 |
> |
|
114 |
<el-button @click="cancel">取 消</el-button> |
|
115 |
</div> |
|
116 |
</el-dialog> |
|
117 |
</template> |
|
118 |
|
|
119 |
<script> |
|
120 |
import { formatData, formrRquired, formatDataItem } from "./info.data"; |
|
121 |
import { getWarehouse, addWarehouse, updateWarehouse } from "@/api/basicData/warehouse"; |
|
122 |
import { listwerkshouse } from "@/api/basicData/location"; |
|
123 |
export default { |
|
124 |
name: "checkItemAdd", |
|
125 |
components: {}, |
|
126 |
dicts: ["isenable"], |
|
127 |
data() { |
|
128 |
return { |
|
129 |
form: JSON.parse(JSON.stringify(formatData)), |
|
130 |
rules: formrRquired, |
|
131 |
open: false, |
|
132 |
title: "", |
|
133 |
buttonLoading: false, |
|
134 |
isCheck: false, |
|
135 |
werksList: [], |
|
136 |
}; |
|
137 |
}, |
|
138 |
|
|
139 |
computed: { |
|
140 |
formItem() { |
|
141 |
return formatDataItem; |
|
142 |
}, |
|
143 |
}, |
|
144 |
watch:{ |
|
145 |
open(val){ |
|
146 |
if(!val){ |
|
147 |
this.$refs["form"].resetFields(); |
|
148 |
|
|
149 |
} |
|
150 |
|
|
151 |
} |
|
152 |
}, |
|
153 |
mounted() { |
|
154 |
listwerkshouse({ |
|
155 |
pageNum: 1, |
|
156 |
pageSize: 99, |
|
157 |
}).then(res =>{ |
|
158 |
console.log(res, '工厂'); |
|
159 |
this.werksList = res.rows; |
|
160 |
}) |
|
161 |
}, |
|
162 |
methods: { |
|
163 |
/** 提交按钮 */ |
|
164 |
submitForm() { |
|
165 |
this.$refs["form"].validate((valid) => { |
|
166 |
if (valid) { |
|
167 |
this.buttonLoading = true; |
|
168 |
if (this.form.warehouseId != null) { |
|
169 |
updateWarehouse(this.form) |
|
170 |
.then((response) => { |
|
171 |
this.$modal.msgSuccess("修改成功"); |
|
172 |
this.open = false; |
|
173 |
this.$emit("getList"); |
|
174 |
}) |
|
175 |
.finally(() => { |
|
176 |
this.buttonLoading = false; |
|
177 |
}); |
|
178 |
} else { |
|
179 |
addWarehouse(this.form) |
|
180 |
.then((response) => { |
|
181 |
this.$modal.msgSuccess("新增成功"); |
|
182 |
this.open = false; |
|
183 |
this.$emit("getList"); |
|
184 |
}) |
|
185 |
.finally(() => { |
|
186 |
this.buttonLoading = false; |
|
187 |
}); |
|
188 |
} |
|
189 |
} |
|
190 |
}); |
|
191 |
}, |
|
192 |
// 取消按钮 |
|
193 |
cancel() { |
|
194 |
this.reset(); |
|
195 |
}, |
|
196 |
reset() { |
|
197 |
this.$refs["form"].resetFields(); |
|
198 |
this.open = false; |
|
199 |
this.isCheck = false; |
|
200 |
}, |
|
201 |
elDialogShow(type, info = "") { |
|
202 |
this.open = true; |
|
203 |
if (type == 1) { |
|
204 |
this.title = "检测项目添加"; |
|
205 |
this.isCheck = false; |
|
206 |
} else if (type == 2) { |
|
207 |
this.isCheck = false; |
|
208 |
this.getDetailse(info); |
|
209 |
this.title = "检测项目编辑"; |
|
210 |
} else { |
|
211 |
this.title = "检测项目查看"; |
|
212 |
this.isCheck = true; |
|
213 |
this.getDetailse(info); |
|
214 |
} |
|
215 |
this.$nextTick(()=>{ |
|
216 |
|
|
217 |
}) |
|
218 |
}, |
|
219 |
getDetailse(id) { |
|
220 |
getWarehouse(id).then((res) => { |
|
221 |
if (res.code === 200) { |
|
222 |
this.form = res.data; |
|
223 |
} |
|
224 |
}); |
|
225 |
}, |
|
226 |
}, |
|
227 |
}; |
|
228 |
</script> |
|
229 |
|
|
230 |
<style lang="less" scoped> |
|
231 |
.contbox { |
|
232 |
max-height: 60vh !important; |
|
233 |
overflow: auto; |
|
234 |
box-sizing: border-box; |
|
235 |
padding: 0 20px; |
|
236 |
} |
|
237 |
.itemFixed { |
|
238 |
display: inline-block !important; |
|
239 |
} |
|
240 |
.itemFixed:first-child { |
|
241 |
display: block !important; |
|
242 |
} |
|
243 |
::v-deep .is-disabled .el-input__inner { |
|
244 |
color: #606266 !important; |
|
245 |
} |
|
246 |
// ::v-deep .el-input.is-disabled .el-input__inner |
|
247 |
</style> |