懒羊羊
2024-03-21 995a733a26dd1856c0dd7286f2dcde5ca1434bca
提交 | 用户 | 时间
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-row>
15     <DvsubjectSelect ref="subjectSelect"  @onSelected="onSubjectSelected"></DvsubjectSelect>
c92f19 16     <el-table v-loading="loading" :data="checksubjectList" >
b5450a 17       <el-table-column label="项目编码" align="center" prop="itemsCode" />
H 18       <el-table-column label="项目名称" align="center" prop="itemsName" />
19       <el-table-column label="项目类型" align="center" prop="itemsType">
20         <template slot-scope="scope">
21           <dict-tag :options="dict.type.spotmaintenance" :value="scope.row.itemsType"/>
22         </template>
23       </el-table-column>
24       <el-table-column label="项目内容" align="center" width="300px" prop="itemsContent" />
25       <el-table-column label="标准" align="center" width="300px" prop="standard" />
c92f19 26       <el-table-column label="操作" align="center" >
H 27         <template slot-scope="scope">
28           <el-button
29             size="mini"
30             type="danger"
31             icon="el-icon-delete"
32             @click="deleteSelectedColumns(scope.row)"
33           >删除</el-button>
34         </template>
35       </el-table-column>
b5450a 36     </el-table>
H 37
38     <pagination
39       v-show="total>0"
40       :total="total"
41       :page.sync="queryParams.pageNum"
42       :limit.sync="queryParams.pageSize"
43       @pagination="getList"
44     />
45   </div>
46 </template>
47
48 <script>
49 import {listInspectionPlanItems,delInspectionPlanItems,addInspectionPlanItems} from "@/api/main/em/inspectionPlanItems/inspectionPlanItems";
50 import DvsubjectSelect from "@/components/inspectionPlanItems/index.vue"
51 export default {
52   name: "Checksubject",
53   props:{
54       planId: null,
55       optType: null
56   },
57   dicts: ['spotmaintenance'],
58   components:{DvsubjectSelect},
59   data() {
60     return {
61       // 遮罩层
62       loading: true,
63       // 选中数组
64       ids: [],
65         selectedRows: [],
66       // 非单个禁用
67       single: true,
68       // 非多个禁用
69       multiple: true,
70       // 显示搜索条件
71       showSearch: true,
72       // 总条数
73       total: 0,
74       // 点检项目表格数据
75       checksubjectList: [],
76       // 弹出层标题
77       title: "",
78       // 是否显示弹出层
79       open: false,
80       // 查询参数
81       queryParams: {
82         pageNum: 1,
83         pageSize: 10,
84         planId: this.planId,
85         itemsCode: null,
86         itemsName: null,
87         itemsType: null,
88         standard: null,
89         itemsContent: null,
90       },
91       // 表单参数
92       form: {}
93     };
94   },
95   created() {
96     this.getList();
97   },
98   methods: {
c92f19 99     deleteSelectedColumns(row) {
H 100       const index = this.checksubjectList.findIndex(item => item.id === row.id);
101       if (index !== -1) {
102         this.checksubjectList.splice(index, 1);
103       } else {
104         this.$message({
105           message: '未找到具有该ID的项目',
106           type: 'warning'
107         });
108       }
109       this.$emit('subSelected',this.checksubjectList);
110
111     },
b5450a 112     /** 查询点检项目列表 */
H 113     getList() {
114       this.loading = true;
115       listInspectionPlanItems(this.queryParams).then(response => {
c92f19 116         // this.checksubjectList = response.rows;
b5450a 117         this.total = response.total;
H 118         this.loading = false;
521803 119         // console.log(response.rows)
b5450a 120       });
H 121     },
122     /** 新增按钮操作 */
123     handleAdd() {
124         this.$refs.subjectSelect.showFlag = true;
125     },
c92f19 126     onSubjectSelected(selectedRows){
H 127       if(selectedRows !=null && selectedRows.length >0){
128         this.checksubjectList = selectedRows
129       }
130       this.$emit('subSelected',this.checksubjectList);
131       console.log(this.checksubjectList)
b5450a 132     },
H 133
134   }
135 };
136 </script>