懒羊羊
2024-03-15 7f6f725ad67e017c0bbae2a4de01952b88352af0
提交 | 用户 | 时间
b5450a 1 <template>
H 2   <div class="app-container">
3     <el-row :gutter="10" class="mb8">
4       <el-col :span="1.5">
5         <el-button
6           type="primary"
7           plain
8           icon="el-icon-plus"
9           size="mini"
10           @click="handleAdd"
11           v-hasPermi="['mes:dv:checkplan:add']"
12         >新增</el-button>
13       </el-col>
14       <el-col :span="1.5">
15         <el-button
16           type="danger"
17           plain
18           icon="el-icon-delete"
19           size="mini"
20           :disabled="multiple"
21           @click="handleDelete"
22           v-hasPermi="['mes:dv:checkplan:remove']"
23         >删除</el-button>
24       </el-col>
25     </el-row>
26     <MachinerySelect ref="machinerySelect" @onSelected="onMachineryAdd"></MachinerySelect>
27     <el-table v-loading="loading" :data="checkmachineryList" @selection-change="handleSelectionChange">
28       <el-table-column type="selection" width="55" align="center" />
29       <el-table-column label="设备编码" align="center" prop="equipmentCode" />
30       <el-table-column label="设备名称" align="center" prop="equipmentName" />
31       <el-table-column label="品牌" align="center" prop="equipmentBrand" />
32       <el-table-column label="规格型号" align="center" prop="equipmentSpec" />
33       <el-table-column label="备注" align="center" prop="remark" />
34     </el-table>
35
36     <pagination
37       v-show="total>0"
38       :total="total"
39       :page.sync="queryParams.pageNum"
40       :limit.sync="queryParams.pageSize"
41       @pagination="getList"
42     />
43   </div>
44 </template>
45
46 <script>
47 import { listInspectionPlanArchives, delInspectionPlanArchives, addInspectionPlanArchives} from "@/api/main/em/inspectionPlanArchives/inspectionPlanArchives";
48 import MachinerySelect from "@/components/inspectionPlanArchives/index.vue";
49 export default {
50   name: "Checkmachinery",
51   components:{MachinerySelect},
52   props:{
53     planId: null,
54     optType: null
55   },
56   data() {
57     return {
58       // 遮罩层
59       loading: true,
60
61       // 选中数组
62       ids: [],
63       // 非单个禁用
64       single: true,
65       // 非多个禁用
66       multiple: true,
67       // 显示搜索条件
68       showSearch: true,
69       // 总条数
70       total: 0,
71       // 点检设备表格数据
72       checkmachineryList: [],
73       // 弹出层标题
74       title: "",
75       // 是否显示弹出层
76       open: false,
77       // 查询参数
78       queryParams: {
79         pageNum: 1,
80         pageSize: 10,
81         planId: this.planId,
82         equipmentId: null,
83         equipmentCode: null,
84         equipmentName: null,
85         equipmentBrand: null,
86         equipmentSpec: null,
87       },
88       // 表单参数
89       form: {},
90     };
91   },
92   created() {
93     this.getList();
94   },
95   methods: {
96     /** 查询点检设备列表 */
97     getList() {
98       this.loading = true;
99       listInspectionPlanArchives(this.queryParams).then(response => {
100         this.checkmachineryList = response.rows;
101         this.total = response.total;
102         this.loading = false;
103       });
104     },
105
106     // 多选框选中数据
107     handleSelectionChange(selection) {
108       this.ids = selection.map(item => item.recordId)
109       this.single = selection.length!==1
110       this.multiple = !selection.length
111     },
112     /** 新增按钮操作 */
113     handleAdd() {
114       this.$refs.machinerySelect.showFlag = true;
115     },
116       //设备资源选择回调
117     onMachineryAdd(rows){
118       if(rows !=null && rows.length >0){
119          rows.forEach(row => {
120             row.planId = this.planId;
121            addInspectionPlanArchives(row).then(response =>{
122               this.getList();
123             });
124          });
125       }
126     },
127     /** 删除按钮操作 */
128     handleDelete(row) {
129       const recordIds = row.recordId || this.ids;
130       this.$modal.confirm('是否确认删除点检设备编号为"' + recordIds + '"的数据项?').then(function() {
131         return delInspectionPlanArchives(recordIds);
132       }).then(() => {
133         this.getList();
134         this.$modal.msgSuccess("删除成功");
135       }).catch(() => {});
136     }
137   }
138 };
139 </script>