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