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