houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div>
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.jxlb" placeholder="检修类别" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-button @click="searchDataList()">查询</el-button>
10           <el-button v-if="$hasPermission('coal:preventive-plan:add')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
11           <el-button v-if="$hasPermission('coal:preventive-plan:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
12         </el-form-item>
13       </el-form>
14       <el-table
15               :data="dataList"
16               border
17               v-loading="dataListLoading"
18               @selection-change="selectionChangeHandle"
19               style="width: 100%;">
20         <el-table-column
21                 type="selection"
22                 header-align="center"
23                 align="center"
24                 width="50">
25         </el-table-column>
26         <el-table-column
27                 type="index"
28                 align="center"
29                 width="50"
30                 label="序号">
31         </el-table-column>
32         <el-table-column
33                 prop="jxlb"
34                 header-align="center"
35                 align="center"
36                 width="200"
37                 label="检修类别">
38         </el-table-column>
39         <el-table-column
40                 prop="jxyy"
41                 header-align="center"
42                 align="center"
43                 width="100"
44                 label="检修原因">
45         </el-table-column>
46         <el-table-column
47                 prop="jxnr"
48                 header-align="center"
49                 align="center"
50                 width="100"
51                 label="检修内容">
52         </el-table-column>
53         <el-table-column
54                 prop="jxfzr"
55                 header-align="center"
56                 align="center"
57                 width="200"
58                 label="检修负责人">
59         </el-table-column>
60         <el-table-column
61                 prop="jxdw"
62                 header-align="center"
63                 align="center"
64                 width="200"
65                 label="检修队伍">
66         </el-table-column>
67         <el-table-column
68                 prop="sbbm"
69                 header-align="center"
70                 align="center"
71                 min-width="100"
72                 label="设备编码">
73         </el-table-column>
74         <el-table-column
75                 prop="sbmc"
76                 header-align="center"
77                 align="center"
78                 width="100"
79                 label="设备名称">
80         </el-table-column>
81         <el-table-column
82                 prop="kssj"
83                 header-align="center"
84                 align="center"
85                 width="120"
86                 label="开始时间">
87         </el-table-column>
88         <el-table-column
89                 prop="jssj"
90                 header-align="center"
91                 align="center"
92                 width="120"
93                 label="结束时间">
94         </el-table-column>
95         <el-table-column
96                 prop="bz"
97                 header-align="center"
98                 align="center"
99                 width="100"
100                 label="备注">
101         </el-table-column>
102         <el-table-column
103                 v-if="$hasPermission('coal:preventive-plan:edit')"
104                 fixed="right"
105                 header-align="center"
106                 align="center"
107                 width="100"
108                 label="操作">
109           <template slot-scope="scope">
110             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
111           </template>
112         </el-table-column>
113       </el-table>
114       <el-pagination
115               @size-change="sizeChangeHandle"
116               @current-change="currentChangeHandle"
117               :current-page="pageIndex"
118               :page-sizes="[10, 20, 50, 100]"
119               :page-size="pageSize"
120               :total="totalPage"
121               layout="total, sizes, prev, pager, next, jumper">
122       </el-pagination>
123       <!-- 弹窗, 新增 / 修改 -->
124       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
125     </div>
126   </el-card>
127 </template>
128
129 <script>
130   import AddOrUpdate from './preventive-plan-add-or-update'
131
132   export default {
133     data () {
134       return {
135         dataForm: {
136           jxlb: ''
137         },
138         dataList: [],
139         pageIndex: 1,
140         pageSize: 10,
141         totalPage: 0,
142         dataListLoading: false,
143         dataListSelections: [],
144         addOrUpdateVisible: false
145       }
146     },
147     components: {
148       AddOrUpdate
149     },
150     mounted () {
151       this.getDataList()
152     },
153     methods: {
154       searchDataList () {
155         this.pageIndex = 1
156         this.getDataList()
157       },
158       // 获取数据列表
159       getDataList () {
160         this.dataListLoading = true
161         this.$http({
162           url: '/data/coal/preventive-plan/list',
163           method: 'get',
164           params: this.$http.adornParams({
165             'page': this.pageIndex,
166             'limit': this.pageSize,
167             'jxlb': this.dataForm.jxlb
168           })
169         }).then(({data}) => {
170           if (data && data.code === 0) {
171             this.dataList = data.page.list
172             this.totalPage = data.page.totalCount
173           } else {
174             this.dataList = []
175             this.totalPage = 0
176           }
177           this.dataListLoading = false
178         })
179       },
180       // 每页数
181       sizeChangeHandle (val) {
182         this.pageSize = val
183         this.pageIndex = 1
184         this.getDataList()
185       },
186       // 当前页
187       currentChangeHandle (val) {
188         this.pageIndex = val
189         this.getDataList()
190       },
191       // 多选
192       selectionChangeHandle (val) {
193         this.dataListSelections = val
194       },
195       // 新增 / 修改
196       addOrUpdateHandle (id) {
197         this.addOrUpdateVisible = true
198         this.$nextTick(() => {
199           this.$refs.addOrUpdate.init(id)
200         })
201       },
202       // 删除
203       deleteHandle (id) {
204         var ids = id ? [id] : this.dataListSelections.map(item => {
205           return item.id
206         })
207         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
208           confirmButtonText: '确定',
209           cancelButtonText: '取消',
210           type: 'warning'
211         }).then(() => {
212           this.$http({
213             url: '/data/coal/preventive-plan/delete',
214             method: 'post',
215             data: this.$http.adornData(ids, false)
216           }).then(({data}) => {
217             if (data && data.code === 0) {
218               this.$message({
219                 message: '操作成功',
220                 type: 'success',
221                 duration: 1500,
222                 onClose: () => {
223                   this.getDataList()
224                 }
225               })
226             } else {
227               this.$message.error(data.msg)
228             }
229           })
230         }).catch(() => {})
231       }
232     }
233   }
234 </script>