hdy
2024-03-22 4ca73594828312fba2fd60afaae3928981ca6701
提交 | 用户 | 时间
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     <DvsubjectSelect ref="subjectSelect"  @onSelected="onSubjectSelected"></DvsubjectSelect>
16     <el-table v-loading="loading" :data="checksubjectList" >
17       <el-table-column label="项目编码" align="center" prop="itemsCode" />
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" />
26       <el-table-column label="操作" align="center" >
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>
36     </el-table>
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 { listInspectionPlanInfo, getInspectionPlanInfo, delInspectionPlanInfo, addInspectionPlanInfo, updateInspectionPlanInfo } from "@/api/main/em/inspectionPlanInfo/inspectionPlanInfo";
50 import DvsubjectSelect from "@/components/inspectionPlanItems/index.vue"
51 export default {
52   name: "Checksubject",
53   components:{DvsubjectSelect},
54   dicts: ['spotmaintenance'],
55   props:{
56       id: null,
57       optType: null
58   },
59
60
61   data() {
62     return {
63       // 遮罩层
64       loading: true,
65       // 选中数组
66       ids: [],
67         selectedRows: [],
68       // 非单个禁用
69       single: true,
70       // 非多个禁用
71       multiple: true,
72       // 显示搜索条件
73       showSearch: true,
74       // 总条数
75       total: 0,
76       // 点检项目表格数据
77       checksubjectList: [],
78       // 弹出层标题
79       title: "",
80       // 是否显示弹出层
81       open: false,
82       // 查询参数
83       queryParams: {
84         pageNum: 1,
85         pageSize: 10,
86         planId: this.planId,
87         itemsCode: null,
88         itemsName: null,
89         itemsType: null,
90         standard: null,
91         itemsContent: null,
92       },
93       // 表单参数
94       form: {}
95     };
96   },
97   created() {
98     if(this.optType === 'add'){
99       this.getList();
100     }
101     if(this.optType === 'edit'){
102       this.getListedit();
103     }
104   },
105   methods: {
106     deleteSelectedColumns(row) {
107       const index = this.checksubjectList.findIndex(item => item.id === row.id);
108       if (index !== -1) {
109         this.checksubjectList.splice(index, 1);
110       } else {
111         this.$message({
112           message: '未找到具有该ID的项目',
113           type: 'warning'
114         });
115       }
116       this.$emit('subSelected',this.checksubjectList);
117
118     },
119     /** 查询点检项目列表 */
120     getList() {
121       this.loading = true;
122       listInspectionPlanInfo(this.queryParams).then(response => {
123         // this.checksubjectList = response.rows;
124         this.total = response.total;
125         this.loading = false;
126         // console.log(response.rows)
127       });
128     },
129     getListedit() {
130       this.loading = true;
131       this.queryParams.spareField1 = '项目清单'
132       this.queryParams.spareField2 = this.id;
133       listInspectionPlanInfo(this.queryParams).then(response => {
134         this.checksubjectList = response.rows;
135         this.total = response.total;
136         this.loading = false;
137       });
138     },
139     /** 新增按钮操作 */
140     handleAdd() {
141         this.$refs.subjectSelect.showFlag = true;
142     },
143     onSubjectSelected(selectedRows){
144       if(selectedRows !=null && selectedRows.length >0){
145         this.checksubjectList = selectedRows
146       }
147       this.$emit('subSelected',this.checksubjectList);
148     },
149
150   }
151 };
152 </script>