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.energytypename" 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('mcs:store-type:add')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
11           <el-button v-if="$hasPermission('mcs:store-type: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         >
32         </el-table-column>
33         <el-table-column
34                 prop="username"
35                 header-align="center"
36                 align="center"
37                 label="名称">
38         </el-table-column>
39         <el-table-column
40                 prop="adjuststatus"
41                 header-align="center"
42                 align="center"
43                 :formatter="formatStatus"
44                 label="调整状态">
45         </el-table-column>
46         <el-table-column
47                 v-if="$hasPermission('mcs:store-type:edit')"
48                 fixed="right"
49                 header-align="center"
50                 align="center"
51                 width="150"
52                 label="操作">
53           <template slot-scope="scope">
54             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
55           </template>
56         </el-table-column>
57       </el-table>
58       <el-pagination
59               @size-change="sizeChangeHandle"
60               @current-change="currentChangeHandle"
61               :current-page="pageIndex"
62               :page-sizes="[10, 20, 50, 100]"
63               :page-size="pageSize"
64               :total="totalPage"
65               layout="total, sizes, prev, pager, next, jumper">
66       </el-pagination>
67       <!-- 弹窗, 新增 / 修改 -->
68       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
69     </div>
70   </el-card>
71 </template>
72
73 <script>
74   import AddOrUpdate from './st-schedule-user-add-or-update'
75
76   export default {
77     data () {
78       return {
79         dataForm: {
80           username: ''
81         },
82         dataList: [],
83         pageIndex: 1,
84         pageSize: 10,
85         totalPage: 0,
86         dataListLoading: false,
87         dataListSelections: [],
88         addOrUpdateVisible: false
89       }
90     },
91     components: {
92       AddOrUpdate
93     },
94     activated () {
95       this.getDataList()
96     },
97     methods: {
98       searchDataList () {
99         this.pageIndex = 1
100         this.getDataList()
101       },
102       // 获取数据列表
103       getDataList () {
104         this.dataListLoading = true
105         this.$http({
106           url: '/iailab-ntt-model/mcs/schedule-user/list',
107           method: 'get',
108           params: this.$http.adornParams({
109             'page': this.pageIndex,
110             'limit': this.pageSize,
111             'username': this.dataForm.username
112           })
113         }).then(({data}) => {
114           if (data && data.code === 0) {
115             this.dataList = data.page.list
116             this.totalPage = data.page.totalCount
117           } else {
118             this.dataList = []
119             this.totalPage = 0
120           }
121           this.dataListLoading = false
122         })
123       },
124       // 每页数
125       sizeChangeHandle (val) {
126         this.pageSize = val
127         this.pageIndex = 1
128         this.getDataList()
129       },
130       // 当前页
131       currentChangeHandle (val) {
132         this.pageIndex = val
133         this.getDataList()
134       },
135       // 多选
136       selectionChangeHandle (val) {
137         this.dataListSelections = val
138       },
139       // 格式状态
140       formatStatus: function (row, column, cellValue, index) {
141         if ((cellValue + '') === '1') {
142           return '启用'
143         } else {
144           return '禁用'
145         }
146       },
147       // 新增 / 修改
148       addOrUpdateHandle (id) {
149         this.addOrUpdateVisible = true
150         this.$nextTick(() => {
151           this.$refs.addOrUpdate.init(id)
152         })
153       },
154       // 删除
155       deleteHandle (id) {
156         var ids = id ? [id] : this.dataListSelections.map(item => {
157           return item.id
158         })
159         this.$confirm(`确定删除选中的${ids.length}项数据?`, '提示', {
160           confirmButtonText: '确定',
161           cancelButtonText: '取消',
162           type: 'warning'
163         }).then(() => {
164           this.$http({
165             url: '/iailab-ntt-model/mcs/schedule-user/delete',
166             method: 'post',
167             data: this.$http.adornData(ids, false)
168           }).then(({data}) => {
169             if (data && data.code === 0) {
170               this.$message({
171                 message: '操作成功',
172                 type: 'success',
173                 duration: 1500,
174                 onClose: () => {
175                   this.getDataList()
176                 }
177               })
178             } else {
179               this.$message.error(data.msg)
180             }
181           })
182         }).catch(() => {})
183       }
184     }
185   }
186 </script>