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.sbbm" placeholder="设备编码" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-input v-model="dataForm.sbmc" placeholder="设备名称" clearable></el-input>
10         </el-form-item>
11         <el-form-item>
12           <el-button @click="searchDataList()">查询</el-button>
13           <el-button v-if="$hasPermission('data:device:add')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
14           <el-button v-if="$hasPermission('data:device:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
15         </el-form-item>
16       </el-form>
17       <el-table
18               :data="dataList"
19               border
20               v-loading="dataListLoading"
21               @selection-change="selectionChangeHandle"
22               style="width: 100%;">
23         <el-table-column
24                 type="selection"
25                 header-align="center"
26                 align="center"
27                 width="50">
28         </el-table-column>
29         <el-table-column
30                 type="index"
31                 align="center"
32                 width="50"
33                 label="序号">
34         </el-table-column>
35         <el-table-column
36                 prop="mkbmName"
37                 header-align="center"
38                 align="center"
39                 label="煤矿">
40         </el-table-column>
41         <el-table-column
42                 prop="scxtbmName"
43                 header-align="center"
44                 align="center"
45                 label="生产系统">
46         </el-table-column>
47         <el-table-column
48                 prop="jkxtmc"
49                 header-align="center"
50                 align="center"
51                 label="监控系统">
52         </el-table-column>
53         <el-table-column
54                 prop="lsh"
55                 header-align="center"
56                 align="center"
57                 label="设备流水码">
58         </el-table-column>
59         <el-table-column
60                 prop="sbbm"
61                 header-align="center"
62                 align="center"
63                 label="设备编码">
64         </el-table-column>
65         <el-table-column
66                 prop="sbmc"
67                 header-align="center"
68                 align="center"
69                 label="设备名称">
70         </el-table-column>
71         <el-table-column
72                 v-if="$hasPermission('data:device:edit')"
73                 fixed="right"
74                 header-align="center"
75                 align="center"
76                 width="150"
77                 label="操作">
78           <template slot-scope="scope">
79             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
80           </template>
81         </el-table-column>
82       </el-table>
83       <el-pagination
84               @size-change="sizeChangeHandle"
85               @current-change="currentChangeHandle"
86               :current-page="pageIndex"
87               :page-sizes="[10, 20, 50, 100]"
88               :page-size="pageSize"
89               :total="totalPage"
90               layout="total, sizes, prev, pager, next, jumper">
91       </el-pagination>
92       <!-- 弹窗, 新增 / 修改 -->
93       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
94     </div>
95   </el-card>
96 </template>
97
98 <script>
99   import AddOrUpdate from './data-device-add-or-update'
100
101   export default {
102     data () {
103       return {
104         dataForm: {
105           sbbm: '',
106           sbmc: ''
107         },
108         dataList: [],
109         pageIndex: 1,
110         pageSize: 10,
111         totalPage: 0,
112         dataListLoading: false,
113         dataListSelections: [],
114         addOrUpdateVisible: false
115       }
116     },
117     components: {
118       AddOrUpdate
119     },
120     mounted () {
121       this.getDataList()
122     },
123     methods: {
124       searchDataList () {
125         this.pageIndex = 1
126         this.getDataList()
127       },
128       // 获取数据列表
129       getDataList () {
130         this.dataListLoading = true
131         this.$http({
132           url: '/data/data/device/list',
133           method: 'get',
134           params: this.$http.adornParams({
135             'page': this.pageIndex,
136             'limit': this.pageSize,
137             'sbbm': this.dataForm.sbbm,
138             'sbmc': this.dataForm.sbmc
139           })
140         }).then(({data}) => {
141           if (data && data.code === 0) {
142             this.dataList = data.page.list
143             this.totalPage = data.page.totalCount
144           } else {
145             this.dataList = []
146             this.totalPage = 0
147           }
148           this.dataListLoading = false
149         })
150       },
151       // 每页数
152       sizeChangeHandle (val) {
153         this.pageSize = val
154         this.pageIndex = 1
155         this.getDataList()
156       },
157       // 当前页
158       currentChangeHandle (val) {
159         this.pageIndex = val
160         this.getDataList()
161       },
162       // 多选
163       selectionChangeHandle (val) {
164         this.dataListSelections = val
165       },
166       // 新增 / 修改
167       addOrUpdateHandle (id) {
168         this.addOrUpdateVisible = true
169         this.$nextTick(() => {
170           this.$refs.addOrUpdate.init(id)
171         })
172       },
173       // 删除
174       deleteHandle (id) {
175         var ids = id ? [id] : this.dataListSelections.map(item => {
176           return item.id
177         })
178         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
179           confirmButtonText: '确定',
180           cancelButtonText: '取消',
181           type: 'warning'
182         }).then(() => {
183           this.$http['post'](`/data/data/device/delete`, ids).then(({ data: res }) => {
184             if (res.code !== 0) {
185               return this.$message.error(res.msg)
186             }
187             this.$message({
188               message: this.$t('prompt.success'),
189               type: 'success',
190               duration: 500,
191               onClose: () => {
192                 this.getDataList()
193               }
194             })
195           }).catch(() => {})
196         }).catch(() => {})
197       }
198     }
199   }
200 </script>