提交 | 用户 | 时间
|
fb3b3e
|
1 |
<template> |
吴 |
2 |
<div class="app-container"> |
|
3 |
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
|
4 |
<el-form-item label="产品编码" prop="productCode"> |
|
5 |
<el-input |
|
6 |
v-model="queryParams.productCode" |
|
7 |
placeholder="请输入产品编码" |
|
8 |
clearable |
|
9 |
@keyup.enter.native="handleQuery" |
|
10 |
/> |
|
11 |
</el-form-item> |
|
12 |
<el-form-item label="产品名称" prop="productName"> |
|
13 |
<el-input |
|
14 |
v-model="queryParams.productName" |
|
15 |
placeholder="请输入产品名称" |
|
16 |
clearable |
|
17 |
@keyup.enter.native="handleQuery" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="配方编码" prop="formulaCode"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.formulaCode" |
|
23 |
placeholder="请输入配方编码" |
|
24 |
clearable |
|
25 |
@keyup.enter.native="handleQuery" |
|
26 |
/> |
|
27 |
</el-form-item> |
|
28 |
<el-form-item label="配方名称" prop="formulaName"> |
|
29 |
<el-input |
|
30 |
v-model="queryParams.formulaName" |
|
31 |
placeholder="请输入配方名称" |
|
32 |
clearable |
|
33 |
@keyup.enter.native="handleQuery" |
|
34 |
/> |
|
35 |
</el-form-item> |
|
36 |
<el-form-item label="状态" prop="status"> |
|
37 |
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable> |
|
38 |
<el-option |
|
39 |
v-for="dict in dict.type.open_status" |
|
40 |
:key="dict.value" |
|
41 |
:label="dict.label" |
|
42 |
:value="dict.value" |
|
43 |
/> |
|
44 |
</el-select> |
|
45 |
</el-form-item> |
|
46 |
<el-form-item style="float: right"> |
|
47 |
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
|
48 |
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
|
49 |
</el-form-item> |
|
50 |
</el-form> |
|
51 |
|
|
52 |
<el-row :gutter="10" class="mb8"> |
|
53 |
<el-col :span="1.5"> |
|
54 |
<el-button |
|
55 |
type="primary" |
|
56 |
plain |
|
57 |
icon="el-icon-plus" |
|
58 |
size="mini" |
|
59 |
@click="handleAdd" |
|
60 |
v-hasPermi="['main:info:add']" |
|
61 |
>新增</el-button> |
|
62 |
</el-col> |
|
63 |
<el-col :span="1.5"> |
|
64 |
<el-button |
|
65 |
type="success" |
|
66 |
plain |
|
67 |
icon="el-icon-edit" |
|
68 |
size="mini" |
|
69 |
:disabled="single" |
|
70 |
@click="handleUpdate" |
|
71 |
v-hasPermi="['main:info:edit']" |
|
72 |
>修改</el-button> |
|
73 |
</el-col> |
|
74 |
<el-col :span="1.5"> |
|
75 |
<el-button |
|
76 |
type="danger" |
|
77 |
plain |
|
78 |
icon="el-icon-delete" |
|
79 |
size="mini" |
|
80 |
:disabled="multiple" |
|
81 |
@click="handleDelete" |
|
82 |
v-hasPermi="['main:info:remove']" |
|
83 |
>删除</el-button> |
|
84 |
</el-col> |
|
85 |
<el-col :span="1.5"> |
|
86 |
<el-button |
|
87 |
type="warning" |
|
88 |
plain |
|
89 |
icon="el-icon-download" |
|
90 |
size="mini" |
|
91 |
@click="handleExport" |
|
92 |
v-hasPermi="['main:info:export']" |
|
93 |
>导出</el-button> |
|
94 |
</el-col> |
|
95 |
</el-row> |
|
96 |
|
|
97 |
<el-table border v-loading="loading" :data="infoList" @selection-change="handleSelectionChange"> |
|
98 |
<el-table-column type="selection" width="55" align="center" /> |
|
99 |
<el-table-column show-overflow-tooltip label="产品编码" align="center" prop="productCode" /> |
|
100 |
<el-table-column show-overflow-tooltip label="产品名称" align="center" prop="productName" /> |
|
101 |
<el-table-column show-overflow-tooltip label="配方编码" align="center" prop="formulaCode" > |
|
102 |
<template slot-scope="scope"> |
|
103 |
<router-link :to="{path: '/main/formula-data/index/', query: {formulaCode: scope.row.formulaCode} }" class="link-type"> |
|
104 |
<span>{{ scope.row.formulaCode }}</span> |
|
105 |
</router-link> |
|
106 |
</template> |
|
107 |
</el-table-column> |
|
108 |
<el-table-column show-overflow-tooltip label="配方名称" align="center" prop="formulaName" /> |
|
109 |
<el-table-column label="状态" align="center" prop="status"> |
|
110 |
<template slot-scope="scope"> |
|
111 |
<dict-tag :options="dict.type.open_status" :value="scope.row.status"/> |
|
112 |
</template> |
|
113 |
</el-table-column> |
|
114 |
<el-table-column label="备注" width="180px" show-overflow-tooltip align="center" prop="remark" /> |
|
115 |
<el-table-column show-overflow-tooltip label="更新用户" align="center" prop="updateBy" /> |
|
116 |
<el-table-column label="更新时间" align="center" prop="updateTime" width="180"> |
|
117 |
</el-table-column> |
|
118 |
</el-table> |
|
119 |
|
|
120 |
<pagination |
|
121 |
v-show="total>0" |
|
122 |
:total="total" |
|
123 |
:page.sync="queryParams.pageNum" |
|
124 |
:limit.sync="queryParams.pageSize" |
|
125 |
@pagination="getList" |
|
126 |
/> |
|
127 |
|
|
128 |
<!-- 添加或修改配方配置对话框 --> |
|
129 |
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
130 |
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
131 |
<el-form-item label="产品编码" prop="productCode"> |
|
132 |
<el-input v-model="form.productCode" placeholder="请输入产品编码" /> |
|
133 |
</el-form-item> |
|
134 |
<el-form-item label="产品名称" prop="productName"> |
|
135 |
<el-input v-model="form.productName" placeholder="请输入产品名称" /> |
|
136 |
</el-form-item> |
|
137 |
<el-form-item label="配方编码" prop="formulaCode"> |
|
138 |
<el-input v-model="form.formulaCode" placeholder="请输入配方编码" /> |
|
139 |
</el-form-item> |
|
140 |
<el-form-item label="配方名称" prop="formulaName"> |
|
141 |
<el-input v-model="form.formulaName" placeholder="请输入配方名称" /> |
|
142 |
</el-form-item> |
|
143 |
<el-form-item label="状态" prop="status"> |
|
144 |
<el-radio-group v-model="form.status"> |
|
145 |
<el-radio |
|
146 |
v-for="dict in dict.type.open_status" |
|
147 |
:key="dict.value" |
|
148 |
:label="dict.value" |
|
149 |
>{{dict.label}}</el-radio> |
|
150 |
</el-radio-group> |
|
151 |
</el-form-item> |
|
152 |
<el-form-item label="备注" prop="remark"> |
|
153 |
<el-input |
|
154 |
type="textarea" |
|
155 |
placeholder="请输入备注" |
|
156 |
v-model="form.remark" |
|
157 |
maxlength="30" |
|
158 |
show-word-limit |
|
159 |
> |
|
160 |
</el-input> |
|
161 |
</el-form-item> |
|
162 |
</el-form> |
|
163 |
<div slot="footer" class="dialog-footer"> |
|
164 |
<el-button type="primary" @click="submitForm">确 定</el-button> |
|
165 |
<el-button @click="cancel">取 消</el-button> |
|
166 |
</div> |
|
167 |
</el-dialog> |
|
168 |
</div> |
|
169 |
</template> |
|
170 |
|
|
171 |
<script> |
|
172 |
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/main/bs/formulaInfo"; |
|
173 |
|
|
174 |
export default { |
|
175 |
name: "Info", |
|
176 |
dicts: ['open_status'], |
|
177 |
data() { |
|
178 |
return { |
|
179 |
// 遮罩层 |
|
180 |
loading: true, |
|
181 |
// 选中数组 |
|
182 |
ids: [], |
|
183 |
// 非单个禁用 |
|
184 |
single: true, |
|
185 |
// 非多个禁用 |
|
186 |
multiple: true, |
|
187 |
// 显示搜索条件 |
|
188 |
showSearch: true, |
|
189 |
// 总条数 |
|
190 |
total: 0, |
|
191 |
// 配方配置表格数据 |
|
192 |
infoList: [], |
|
193 |
// 弹出层标题 |
|
194 |
title: "", |
|
195 |
// 是否显示弹出层 |
|
196 |
open: false, |
|
197 |
// 查询参数 |
|
198 |
queryParams: { |
|
199 |
pageNum: 1, |
|
200 |
pageSize: 10, |
|
201 |
productCode: null, |
|
202 |
productName: null, |
|
203 |
formulaCode: null, |
|
204 |
formulaName: null, |
|
205 |
status: null, |
|
206 |
}, |
|
207 |
// 表单参数 |
|
208 |
form: {}, |
|
209 |
// 表单校验 |
|
210 |
rules: { |
|
211 |
productCode: [ |
|
212 |
{ required: true, message: "产品编码不能为空", trigger: "blur" } |
|
213 |
], |
|
214 |
productName: [ |
|
215 |
{ required: true, message: "产品名称不能为空", trigger: "blur" } |
|
216 |
], |
|
217 |
formulaCode: [ |
|
218 |
{ required: true, message: "配方编码不能为空", trigger: "blur" } |
|
219 |
], |
|
220 |
formulaName: [ |
|
221 |
{ required: true, message: "配方名称不能为空", trigger: "blur" } |
|
222 |
], |
|
223 |
status: [ |
|
224 |
{ required: true, message: "状态不能为空", trigger: "change" } |
|
225 |
], |
|
226 |
} |
|
227 |
}; |
|
228 |
}, |
|
229 |
created() { |
|
230 |
this.getList(); |
|
231 |
}, |
|
232 |
methods: { |
|
233 |
/** 查询配方配置列表 */ |
|
234 |
getList() { |
|
235 |
this.loading = true; |
|
236 |
listInfo(this.queryParams).then(response => { |
|
237 |
this.infoList = response.rows; |
|
238 |
this.total = response.total; |
|
239 |
this.loading = false; |
|
240 |
}); |
|
241 |
}, |
|
242 |
// 取消按钮 |
|
243 |
cancel() { |
|
244 |
this.open = false; |
|
245 |
this.reset(); |
|
246 |
}, |
|
247 |
// 表单重置 |
|
248 |
reset() { |
|
249 |
this.form = { |
|
250 |
id: null, |
|
251 |
productCode: null, |
|
252 |
productName: null, |
|
253 |
formulaCode: null, |
|
254 |
formulaName: null, |
|
255 |
status: null, |
|
256 |
remark: null, |
|
257 |
createBy: null, |
|
258 |
createTime: null, |
|
259 |
updateBy: null, |
|
260 |
updateTime: null, |
|
261 |
delFlag: null |
|
262 |
}; |
|
263 |
this.resetForm("form"); |
|
264 |
}, |
|
265 |
/** 搜索按钮操作 */ |
|
266 |
handleQuery() { |
|
267 |
this.queryParams.pageNum = 1; |
|
268 |
this.getList(); |
|
269 |
}, |
|
270 |
/** 重置按钮操作 */ |
|
271 |
resetQuery() { |
|
272 |
this.resetForm("queryForm"); |
|
273 |
this.handleQuery(); |
|
274 |
}, |
|
275 |
// 多选框选中数据 |
|
276 |
handleSelectionChange(selection) { |
|
277 |
this.ids = selection.map(item => item.id) |
|
278 |
this.single = selection.length!==1 |
|
279 |
this.multiple = !selection.length |
|
280 |
}, |
|
281 |
/** 新增按钮操作 */ |
|
282 |
handleAdd() { |
|
283 |
this.reset(); |
|
284 |
this.open = true; |
|
285 |
this.title = "添加配方配置"; |
|
286 |
}, |
|
287 |
/** 修改按钮操作 */ |
|
288 |
handleUpdate(row) { |
|
289 |
this.reset(); |
|
290 |
const id = row.id || this.ids |
|
291 |
getInfo(id).then(response => { |
|
292 |
this.form = response.data; |
|
293 |
this.open = true; |
|
294 |
this.title = "修改配方配置"; |
|
295 |
}); |
|
296 |
}, |
|
297 |
/** 提交按钮 */ |
|
298 |
submitForm() { |
|
299 |
this.$refs["form"].validate(valid => { |
|
300 |
if (valid) { |
|
301 |
if (this.form.id != null) { |
|
302 |
updateInfo(this.form).then(response => { |
|
303 |
this.$modal.msgSuccess("修改成功"); |
|
304 |
this.open = false; |
|
305 |
this.getList(); |
|
306 |
}); |
|
307 |
} else { |
|
308 |
addInfo(this.form).then(response => { |
|
309 |
this.$modal.msgSuccess("新增成功"); |
|
310 |
this.open = false; |
|
311 |
this.getList(); |
|
312 |
}); |
|
313 |
} |
|
314 |
} |
|
315 |
}); |
|
316 |
}, |
|
317 |
/** 删除按钮操作 */ |
|
318 |
handleDelete(row) { |
|
319 |
const ids = row.id || this.ids; |
|
320 |
this.$modal.confirm('是否确认删除').then(function() { |
|
321 |
return delInfo(ids); |
|
322 |
}).then(() => { |
|
323 |
this.getList(); |
|
324 |
this.$modal.msgSuccess("删除成功"); |
|
325 |
}).catch(() => {}); |
|
326 |
}, |
|
327 |
/** 导出按钮操作 */ |
|
328 |
handleExport() { |
|
329 |
this.download('formulaInfo/export', { |
|
330 |
...this.queryParams |
|
331 |
}, `info_${new Date().getTime()}.xlsx`) |
|
332 |
} |
|
333 |
} |
|
334 |
}; |
|
335 |
</script> |