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