hdy
2024-03-19 5218032b30db4a1e19ac6bb243b71900a600da28
提交 | 用户 | 时间
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     <DvsubjectSelect ref="subjectSelect"  @onSelected="onSubjectSelected"></DvsubjectSelect>
27     <el-table v-loading="loading" :data="checksubjectList" @selection-change="handleSelectionChange">
28       <el-table-column type="selection" width="55" align="center" />
29       <el-table-column label="项目编码" align="center" prop="itemsCode" />
30       <el-table-column label="项目名称" align="center" prop="itemsName" />
31       <el-table-column label="项目类型" align="center" prop="itemsType">
32         <template slot-scope="scope">
33           <dict-tag :options="dict.type.spotmaintenance" :value="scope.row.itemsType"/>
34         </template>
35       </el-table-column>
36       <el-table-column label="项目内容" align="center" width="300px" prop="itemsContent" />
37       <el-table-column label="标准" align="center" width="300px" prop="standard" />
38     </el-table>
39
40     <pagination
41       v-show="total>0"
42       :total="total"
43       :page.sync="queryParams.pageNum"
44       :limit.sync="queryParams.pageSize"
45       @pagination="getList"
46     />
47   </div>
48 </template>
49
50 <script>
51 import {listInspectionPlanItems,delInspectionPlanItems,addInspectionPlanItems} from "@/api/main/em/inspectionPlanItems/inspectionPlanItems";
52 import DvsubjectSelect from "@/components/inspectionPlanItems/index.vue"
53 export default {
54   name: "Checksubject",
55   props:{
56       planId: null,
57       optType: null
58   },
59   dicts: ['spotmaintenance'],
60   components:{DvsubjectSelect},
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     this.getList();
99   },
100   methods: {
101     /** 查询点检项目列表 */
102     getList() {
103       this.loading = true;
104       listInspectionPlanItems(this.queryParams).then(response => {
105         this.checksubjectList = response.rows;
106         this.total = response.total;
107         this.loading = false;
521803 108         // console.log(response.rows)
b5450a 109       });
H 110     },
111     // 多选框选中数据
112     handleSelectionChange(selection) {
113       this.ids = selection.map(item => item.recordId)
114       this.single = selection.length!==1
115       this.multiple = !selection.length
116     },
117     /** 新增按钮操作 */
118     handleAdd() {
119         this.$refs.subjectSelect.showFlag = true;
120     },
121     onSubjectSelected(rows){
122         if(rows != null && rows.length >0){
123             rows.forEach(row => {
124                 row.planId= this.planId;
125               addInspectionPlanItems(row).then(response => {
126                     this.getList();
127                 });
128             });
129         }
130     },
131     /** 删除按钮操作 */
132     handleDelete(row) {
133       const recordIds = row.recordId || this.ids;
134       this.$modal.confirm('是否确认删除点检项目编号为"' + recordIds + '"的数据项?').then(function() {
135         return delInspectionPlanItems(recordIds);
136       }).then(() => {
137         this.getList();
138         this.$modal.msgSuccess("删除成功");
139       }).catch(() => {});
140     },
141
142   }
143 };
144 </script>