houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div class="mod-clock">
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.clockCode" placeholder="编号" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-input v-model="dataForm.clockName" placeholder="名称" clearable></el-input>
10         </el-form-item>
11         <el-form-item>
12           <el-button @click="getDataList()">查询</el-button>
13           <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
14         </el-form-item>
15       </el-form>
16       <el-table
17               :data="dataList"
18               border
19               v-loading="dataListLoading"
20               style="width: 100%;">
21         <el-table-column
22                 type="index"
23                 header-align="center"
24                 align="center"
25                 width="50">
26         </el-table-column>
27         <el-table-column
28                 prop="clockCode"
29                 header-align="center"
30                 align="center"
31                 label="编号">
32         </el-table-column>
33         <el-table-column
34                 prop="clockName"
35                 header-align="center"
36                 align="center"
37                 label="名称">
38         </el-table-column>
39         <el-table-column
40                 prop="clockTypeName"
41                 header-align="center"
42                 align="center"
43                 label="类别">
44         </el-table-column>
45         <el-table-column
46                 prop="description"
47                 header-align="center"
48                 align="center"
49                 label="描述">
50         </el-table-column>
51         <el-table-column
52                 prop="statusName"
53                 header-align="center"
54                 align="center"
55                 label="状态">
56         </el-table-column>
57         <el-table-column
58                 fixed="right"
59                 header-align="center"
60                 align="center"
61                 width="100"
62                 label="操作">
63           <template slot-scope="scope">
64             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
65             <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
66           </template>
67         </el-table-column>
68       </el-table>
69       <el-pagination
70               @size-change="sizeChangeHandle"
71               @current-change="currentChangeHandle"
72               :current-page="pageIndex"
73               :page-sizes="[10, 20, 50, 100]"
74               :page-size="pageSize"
75               :total="totalPage"
76               layout="total, sizes, prev, pager, next, jumper">
77       </el-pagination>
78       <!-- 弹窗, 新增 / 修改 -->
79       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
80     </div>
81   </el-card>
82 </template>
83 <script>
84   import AddOrUpdate from './clock-add-or-update'
85   export default {
86     data () {
87       return {
88         dataForm: {
89           clockCode: '',
90           clockName: ''
91         },
92         dataList: [],
93         pageIndex: 1,
94         pageSize: 10,
95         totalPage: 0,
96         dataListLoading: false,
97         dataListSelections: [],
98         addOrUpdateVisible: false
99       }
100     },
101     components: {
102       AddOrUpdate
103     },
104     mounted () {
105       this.getDataList()
106     },
107     methods: {
108       // 获取数据列表
109       getDataList () {
110         this.dataListLoading = true
111         this.$http({
112           url: '/data/index-data/clock/list',
113           method: 'get',
114           params: this.$http.adornParams({
115             'page': this.pageIndex,
116             'limit': this.pageSize,
117             'clockCode': this.dataForm.clockCode,
118             'clockName': this.dataForm.clockName
119           })
120         }).then(({code, page}) => {
121           if (page && code === 0) {
122             this.dataList = page.list
123             this.totalPage = page.totalCount
124           } else {
125             this.dataList = []
126             this.totalPage = 0
127           }
128           this.dataListLoading = false
129         })
130       },
131       // 每页数
132       sizeChangeHandle (val) {
133         this.pageSize = val
134         this.pageIndex = 1
135         this.getDataList()
136       },
137       // 当前页
138       currentChangeHandle (val) {
139         this.pageIndex = val
140         this.getDataList()
141       },
142       // 多选
143       selectionChangeHandle (val) {
144         this.dataListSelections = val
145       },
146       // 新增 / 修改
147       addOrUpdateHandle (id) {
148         this.addOrUpdateVisible = true
149         this.$nextTick(() => {
150           this.$refs.addOrUpdate.init(id)
151         })
152       },
153       // 删除
154       deleteHandle (id) {
155         this.$confirm(`确定对选中项进行删除操作?`, '提示', {
156           confirmButtonText: '确定',
157           cancelButtonText: '取消',
158           type: 'warning'
159         }).then(() => {
160           this.$http({
161             url: '/data/index-data/clock/delete',
162             method: 'post',
163             params: this.$http.adornParams({
164               id: id
165             })
166           }).then(({data}) => {
167             if (data && data.code === 0) {
168               this.$message({
169                 message: '操作成功',
170                 type: 'success',
171                 duration: 1500,
172                 onClose: () => {
173                   this.getDataList()
174                 }
175               })
176             } else {
177               this.$message.error(data.msg)
178             }
179           })
180         }).catch(() => {})
181       }
182     }
183   }
184 </script>