懒羊羊
2024-03-22 640ff86be676ef7ef5a2ef12d0af34a46962c17e
提交 | 用户 | 时间
4ca735 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-row>
15     <MachinerySelect ref="machinerySelect" @onSelected="onMachineryAdd" ></MachinerySelect>
16     <el-table v-loading="loading" :data="checkmachineryList" >
17       <el-table-column label="设备编码" align="center" prop="equipmentCode" />
18       <el-table-column label="设备名称" align="center" prop="equipmentName" />
19       <el-table-column label="品牌" align="center" prop="equipmentBrand" />
20       <el-table-column label="规格型号" align="center" prop="equipmentSpec" />
21       <el-table-column label="备注" align="center" prop="remark" />
22       <el-table-column label="操作" align="center" >
23         <template slot-scope="scope">
24           <el-button
25             size="mini"
26             type="danger"
27             icon="el-icon-delete"
28             @click="deleteSelectedColumns(scope.row)"
29           >删除</el-button>
30         </template>
31       </el-table-column>
32     </el-table>
33
34     <pagination
35       v-show="total>0"
36       :total="total"
37       :page.sync="queryParams.pageNum"
38       :limit.sync="queryParams.pageSize"
39       @pagination="getList"
40     />
41   </div>
42 </template>
43
44 <script>
45 import { listInspectionPlanInfo, getInspectionPlanInfo, delInspectionPlanInfo, addInspectionPlanInfo, updateInspectionPlanInfo } from "@/api/main/em/inspectionPlanInfo/inspectionPlanInfo";
46 import MachinerySelect from "@/components/inspectionPlanArchives/index.vue";
47 export default {
48   name: "Checkmachinery",
49   components:{MachinerySelect},
50   props:{
51     id: null,
52     optType: null
53   },
54   data() {
55     return {
56       // 遮罩层
57       loading: true,
58
59       // 选中数组
60       ids: [],
61       // 非单个禁用
62       single: true,
63       // 非多个禁用
64       multiple: true,
65       // 显示搜索条件
66       showSearch: true,
67       // 总条数
68       total: 0,
69       // 点检设备表格数据
70       checkmachineryList: [],
71         // 弹出层标题
72       title: "",
73       // 是否显示弹出层
74       open: false,
75       // 查询参数
76       queryParams: {
77         pageNum: 1,
78         pageSize: 10,
79         equipmentId: null,
80         equipmentCode: null,
81         equipmentName: null,
82         equipmentBrand: null,
83         equipmentSpec: null,
84       },
85       // 表单参数
86       form: {},
87     };
88   },
89   created() {
90     if(this.optType === 'add'){
91       this.getList();
92     }
93     if(this.optType === 'edit'){
94       this.getListedit();
95     }
96     console.log(this.planCode)
97   },
98   methods: {
99
100     deleteSelectedColumns(row) {
101       const index = this.checkmachineryList.findIndex(item => item.id === row.id);
102       if (index !== -1) {
103         this.checkmachineryList.splice(index, 1);
104       } else {
105         this.$message({
106           message: '未找到具有该ID的项目',
107           type: 'warning'
108         });
109       }
110       this.$emit('inSelected',this.checkmachineryList);
111
112     },
113   /** 查询点检设备列表 */
114     getList() {
115       this.loading = true;
116       this.queryParams.spareField1 = '设备清单'
117     listInspectionPlanInfo(this.queryParams).then(response => {
118         // this.checkmachineryList = response.rows;
119         this.total = response.total;
120         this.loading = false;
121       });
122     },
123     getListedit() {
124       this.loading = true;
125       this.queryParams.spareField1 = '设备清单'
126       this.queryParams.spareField2 = this.id;
127       listInspectionPlanInfo(this.queryParams).then(response => {
128         this.checkmachineryList = response.rows;
129         this.total = response.total;
130         this.loading = false;
131       });
132     },
133
134
135     /** 新增按钮操作 */
136     handleAdd() {
137       this.$refs.machinerySelect.showFlag = true;
138     },
139       //设备资源选择回调
140     // onMachineryAdd(rows){
141     //   if(rows !=null && rows.length >0){
142     //      rows.forEach(row => {
143     //         row.planId = this.planId;
144     //        addInspectionPlanArchives(row).then(response =>{
145     //           this.getList();
146     //         });
147     //      });
148     //   }
149     // },
150     onMachineryAdd(selectedRows){
151       if(selectedRows !=null && selectedRows.length >0){
152         this.checkmachineryList = selectedRows
153       }
154       this.$emit('inSelected',this.checkmachineryList);
155     },
156
157   }
158 };
159 </script>