|
@@ -1,9 +1,286 @@
|
|
1
|
+
|
1
|
2
|
<template>
|
2
|
|
- <div>商铺列表</div>
|
|
3
|
+ <div class="root">
|
|
4
|
+ <el-form :inline="true" :model="listQuery" class="form-listQuery">
|
|
5
|
+ <el-form-item class="filter-item" label="商铺编号">
|
|
6
|
+ <el-input v-model.trim="listQuery.id" onkeyup="this.value=this.value.replace(/\D/g,'')" placeholder="商铺编号" />
|
|
7
|
+ </el-form-item>
|
|
8
|
+ <el-form-item class="filter-item" label="商铺名称" >
|
|
9
|
+ <el-input v-model.trim="listQuery.shopName" placeholder="商铺名称" />
|
|
10
|
+ </el-form-item>
|
|
11
|
+ <el-form-item class="filter-item" label="商铺类型" >
|
|
12
|
+ <el-select v-model="listQuery.shopTypeId" placeholder="商铺类型" clearable class="filter-item" style="width: 200px">
|
|
13
|
+ <el-option v-for="item in shopTypeList" :key="item.id" :value="item.id" :label="item.typeName"/>
|
|
14
|
+ </el-select>
|
|
15
|
+ </el-form-item>
|
|
16
|
+ <el-form-item class="filter-item" label="上架状态" >
|
|
17
|
+ <el-select v-model="listQuery.shopStatus" placeholder="请选择">
|
|
18
|
+ <el-option label="已上架" value="1"/>
|
|
19
|
+ <el-option label="已下架" value="2"/>
|
|
20
|
+ </el-select>
|
|
21
|
+ </el-form-item>
|
|
22
|
+ <el-form-item>
|
|
23
|
+ <el-button type="info" class="filter-item" @click="handleFilter">清空</el-button>
|
|
24
|
+ <el-button type="primary" @click="search">查询</el-button>
|
|
25
|
+ </el-form-item>
|
|
26
|
+ </el-form>
|
|
27
|
+ <div class="button">
|
|
28
|
+ <el-button type="primary" @click="add">添加</el-button>
|
|
29
|
+ <el-button type="warning" @click="edit">修改</el-button>
|
|
30
|
+ <el-button type="danger" @click="deleteAnnouncement">作废</el-button>
|
|
31
|
+ </div>
|
|
32
|
+ <el-table
|
|
33
|
+ v-loading="listLoading"
|
|
34
|
+ ref="multipleTable"
|
|
35
|
+ :data="shopList"
|
|
36
|
+ border
|
|
37
|
+ tooltip-effect="dark"
|
|
38
|
+ style="width: 100%; margin-top: 20px;"
|
|
39
|
+ @selection-change="handleSelectionChange">
|
|
40
|
+ <el-table-column
|
|
41
|
+ type="selection"
|
|
42
|
+ width="55"/>
|
|
43
|
+ <el-table-column prop="id" label="商铺编号" align="center"/>
|
|
44
|
+ <el-table-column prop="shopName" label="商铺名称" align="center" >
|
|
45
|
+ <template slot-scope="scope"><a><span style="color: #63B8FF" @click="clickTitle(scope.row.shopName)">{{ scope.row.shopName }}</span></a></template>
|
|
46
|
+ </el-table-column>
|
|
47
|
+ <el-table-column prop="imgUrl" label="首页展示图" align="center">
|
|
48
|
+ <template scope="scope">
|
|
49
|
+ <img :src="scope.row.imgUrl" width="100%"/>
|
|
50
|
+ </template>
|
|
51
|
+ </el-table-column>
|
|
52
|
+ <el-table-column prop="sort" label="权重" align="center"/>
|
|
53
|
+ <el-table-column prop="typeName" label="商铺类型" align="center"/>
|
|
54
|
+ <el-table-column prop="shopStatus" label="上架状态" align="center">\
|
|
55
|
+ <template slot-scope="scope">
|
|
56
|
+ <span v-if="scope.row.shopStatus === '1'">已上架</span>
|
|
57
|
+ <span v-if="scope.row.shopStatus === '2'">已下架</span>
|
|
58
|
+ </template>
|
|
59
|
+ </el-table-column>
|
|
60
|
+ <el-table-column prop="updateDate" label="编辑时间" align="center" ><template slot-scope="scope">{{ formatDate(scope.row.updateDate) }}</template></el-table-column>
|
|
61
|
+ <el-table-column prop="userName" label="编辑人" align="center"/>
|
|
62
|
+ </el-table>
|
|
63
|
+ <div class="block">
|
|
64
|
+ <el-pagination
|
|
65
|
+ :current-page.sync="listQuery.pageNum"
|
|
66
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
67
|
+ :page-size.sync="listQuery.pageSize"
|
|
68
|
+ :total="total"
|
|
69
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
70
|
+ @size-change="handleSizeChange"
|
|
71
|
+ @current-change="handleCurrentChange"/>
|
|
72
|
+ </div>
|
|
73
|
+ </div>
|
3
|
74
|
</template>
|
4
|
75
|
|
5
|
76
|
<script>
|
|
77
|
+import { mapState, mapActions, mapMutations } from 'vuex'
|
|
78
|
+
|
|
79
|
+export default {
|
|
80
|
+ data() {
|
|
81
|
+ return {
|
|
82
|
+ listQuery: {
|
|
83
|
+ id: '',
|
|
84
|
+ shopName: '',
|
|
85
|
+ shopTypeId: '',
|
|
86
|
+ shopStatus: '',
|
|
87
|
+ pageNum: 1,
|
|
88
|
+ pageSize: 10
|
|
89
|
+ },
|
|
90
|
+ total: 0, // 数据总数
|
|
91
|
+ shopList: [],
|
|
92
|
+ shopTypeList: [],
|
|
93
|
+ deleteIds: [], // 选择的id集合
|
|
94
|
+ listLoading: true // 加载圈
|
|
95
|
+ }
|
|
96
|
+ },
|
|
97
|
+ mounted() {
|
|
98
|
+ // 获取数据
|
|
99
|
+ this.dataQuery()
|
|
100
|
+ this.getShopTypeList()
|
|
101
|
+ },
|
|
102
|
+ methods: {
|
|
103
|
+ ...mapActions('shopType', [
|
|
104
|
+ 'FetchShopList',
|
|
105
|
+ 'FetchShopTypeSelect'
|
|
106
|
+ ]),
|
|
107
|
+ handleSizeChange(val) {
|
|
108
|
+ console.log(`每页 ${val} 条`)
|
|
109
|
+ this.listQuery.pageSize = val
|
|
110
|
+ this.dataQuery()
|
|
111
|
+ },
|
|
112
|
+ handleCurrentChange(val) {
|
|
113
|
+ console.log(`当前页: ${val}`)
|
|
114
|
+ this.listQuery.pageNum = val
|
|
115
|
+ this.dataQuery()
|
|
116
|
+ },
|
|
117
|
+ padDate(value) {
|
|
118
|
+ value = value < 10 ? '0' + value : value
|
|
119
|
+ return value
|
|
120
|
+ },
|
|
121
|
+ getStatus(row) { // 获取状态
|
|
122
|
+ let statusName = ''
|
|
123
|
+
|
|
124
|
+ // 判断状态
|
|
125
|
+ switch (row.status) {
|
|
126
|
+ case '0':
|
|
127
|
+ statusName = '已作废'
|
|
128
|
+ break
|
|
129
|
+ case '1':
|
|
130
|
+ statusName = '已发布'
|
|
131
|
+ break
|
|
132
|
+ case '2':
|
|
133
|
+ statusName = '草稿'
|
|
134
|
+ break
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ // 如果修改时间和创建时间不一致, 就显示已修改
|
|
138
|
+ if (row.status === '1' && (row.updateDate > row.createDate)) {
|
|
139
|
+ statusName = '已修改'
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ return statusName
|
|
143
|
+ },
|
|
144
|
+ dataQuery() { // 查询数据
|
|
145
|
+ this.listLoading = true
|
|
146
|
+ this.$store.dispatch('shopType/FetchShopList', this.listQuery).then((res) => {
|
|
147
|
+ const resData = res.data
|
|
148
|
+ this.shopList = resData.list
|
|
149
|
+ this.total = resData.total
|
|
150
|
+ this.listLoading = false
|
|
151
|
+ }).catch(() => {
|
|
152
|
+ this.listLoading = false
|
|
153
|
+ console.log('error ListAnnouncement')
|
|
154
|
+ })
|
|
155
|
+ },
|
|
156
|
+ getShopTypeList() {
|
|
157
|
+ this.$store.dispatch('shopType/FetchShopTypeSelect', this.listQuery).then((res) => {
|
|
158
|
+ this.shopTypeList = res.data
|
|
159
|
+ }).catch(() => {
|
|
160
|
+ console.log('error ListAnnouncement')
|
|
161
|
+ })
|
|
162
|
+ },
|
|
163
|
+ handleSelectionChange(data) {
|
|
164
|
+ // 设置为 空
|
|
165
|
+ this.deleteIds = []
|
|
166
|
+ for (let i = 0; i < data.length; i++) {
|
|
167
|
+ this.deleteIds.push(data[i].id)
|
|
168
|
+ }
|
|
169
|
+ },
|
|
170
|
+ search() {
|
|
171
|
+ this.listQuery.pageNum = 1
|
|
172
|
+ this.dataQuery()
|
|
173
|
+ },
|
|
174
|
+ handleFilter() {
|
|
175
|
+ this.listQuery.pageNum = 1
|
|
176
|
+ this.listQuery.pageSize = 10
|
|
177
|
+ this.listQuery.id =''
|
|
178
|
+ this.listQuery.shopName=''
|
|
179
|
+ this.listQuery.shopTypeId=''
|
|
180
|
+ this.listQuery.shopStatus=''
|
|
181
|
+ this.dataQuery()
|
|
182
|
+ },
|
|
183
|
+ // 添加公告
|
|
184
|
+ add() {
|
|
185
|
+ this.$router.push({ name: 'announcement-add' })
|
|
186
|
+ },
|
|
187
|
+ edit(){// 编辑公告
|
|
188
|
+ const ids = this.deleteIds
|
|
189
|
+ if (ids.length > 1) {
|
|
190
|
+ this.$message.error('只能选择一行数据进行修改!')
|
|
191
|
+ return
|
|
192
|
+ }
|
|
193
|
+ if (ids < 1) {
|
|
194
|
+ this.$message.error('请选择一行数据进行修改!')
|
|
195
|
+ return
|
|
196
|
+ }
|
|
197
|
+ let ide= this.deleteIds[0]
|
|
198
|
+ this.listQuery.id = ide
|
|
199
|
+ this.$store.dispatch('AnnouncementById', this.listQuery).then((res) => {
|
|
200
|
+ const resData = res.data
|
|
201
|
+ const announcement = resData.tpAnnouncement
|
|
202
|
+ const imgList = resData.studentList
|
|
203
|
+ this.listQuery = announcement
|
|
204
|
+ this.listQuery.announcementTitle = ''
|
|
205
|
+ console.log("1",this.listQuery.status)
|
|
206
|
+ if(this.listQuery.status == 0){
|
|
207
|
+ this.$message.error('已作废不可以修改')
|
|
208
|
+ return
|
|
209
|
+ }
|
|
210
|
+ this.$router.push({ name: 'announcement-edit', query: { id: ide }})
|
|
211
|
+ })
|
|
212
|
+ },
|
|
213
|
+ deleteAnnouncement(){
|
|
214
|
+ let ide= this.deleteIds[0]
|
|
215
|
+ this.listQuery.id = ide
|
|
216
|
+ this.$store.dispatch('AnnouncementById', this.listQuery).then((res) => {
|
|
217
|
+ const resData = res.data
|
|
218
|
+ const announcement = resData.tpAnnouncement
|
|
219
|
+ const imgList = resData.studentList
|
|
220
|
+ this.listQuery.status= announcement.status
|
|
221
|
+ console.log("1",this.listQuery.status)
|
|
222
|
+ if(this.listQuery.status == 0){
|
|
223
|
+ this.$message.error('已作废不可以作废')
|
|
224
|
+ return
|
|
225
|
+ }
|
|
226
|
+ this.deleteId()
|
|
227
|
+ })
|
|
228
|
+ },
|
|
229
|
+
|
|
230
|
+ deleteId(){
|
|
231
|
+ const ids = this.deleteIds
|
|
232
|
+ this.listLoading = true
|
|
233
|
+ console.log(ids)
|
|
234
|
+ this.$store.dispatch('DeleteAnnouncement', ids).then((res) => {
|
|
235
|
+ this.listLoading = false
|
|
236
|
+ this.listQuery.announcementTitle = ''
|
|
237
|
+ this.dataQuery()
|
|
238
|
+ }).catch(() => {
|
|
239
|
+ this.listLoading = false
|
|
240
|
+ console.log('error DeleteAnnouncement')
|
|
241
|
+ })
|
|
242
|
+ },
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+ clickTitle(id) {
|
|
246
|
+ this.$router.push({ name: 'contentParticulars-details', query: { id: id }})
|
|
247
|
+ },
|
|
248
|
+ formatDate(val) {
|
|
249
|
+ if (val === null) {
|
|
250
|
+ return ''
|
|
251
|
+ }
|
|
252
|
+ var value = new Date(val)
|
|
253
|
+ var year = value.getFullYear()
|
|
254
|
+ var month = value.getMonth() + 1
|
|
255
|
+ var day = value.getDate()
|
|
256
|
+ return year + '-' + month + '-' + day
|
|
257
|
+ }
|
|
258
|
+ }
|
|
259
|
+}
|
6
|
260
|
</script>
|
7
|
261
|
|
8
|
|
-<style lang="scss" scoped>
|
|
262
|
+<style scoped>
|
|
263
|
+.root{
|
|
264
|
+ display: flex;
|
|
265
|
+ flex-flow: column;
|
|
266
|
+}
|
|
267
|
+.form-listQuery{
|
|
268
|
+ margin-top: 20px;
|
|
269
|
+ margin-left: 30px;
|
|
270
|
+}
|
|
271
|
+.operation{
|
|
272
|
+ display: flex;
|
|
273
|
+ justify-content: space-between;
|
|
274
|
+ margin-left: 20px;
|
|
275
|
+ margin-right: 20px;
|
|
276
|
+}
|
|
277
|
+.block{
|
|
278
|
+ display: flex;
|
|
279
|
+ justify-content: flex-end;
|
|
280
|
+ margin-top: 10px;
|
|
281
|
+}
|
|
282
|
+.button {
|
|
283
|
+ margin-left: 20px;
|
|
284
|
+}
|
9
|
285
|
</style>
|
|
286
|
+
|