增加店铺的审核功能

This commit is contained in:
zhl 2021-05-14 19:59:42 +08:00
parent 2b8a557ceb
commit be24b9489d
2 changed files with 103 additions and 38 deletions

View File

@ -61,3 +61,10 @@ export const updateShopQtypes = (data: any) =>
method: 'post',
data
})
export const updateShopPublish = (data: any) =>
request({
url: '/shop/publish',
method: 'post',
data
})

View File

@ -5,6 +5,17 @@
<el-form-item label="关键字" prop="key">
<el-input v-model="filterForm.key" placeholder="关键字"/>
</el-form-item>
<el-form-item label="审核状态">
<el-select
v-model="filterForm.publish"
placeholder="所有"
class="w100"
>
<el-option value="all">所有</el-option>
<el-option value="true">已审核</el-option>
<el-option value="false">未审核</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="search">查询</el-button>
@ -13,25 +24,25 @@
</el-form>
<router-link to="/system/create">
<el-button
type="primary"
icon="el-icon-edit"
v-permission="['shopman:edit']"
type="primary"
icon="el-icon-edit"
v-permission="['shopman:edit']"
>
添加
</el-button>
</router-link>
<el-table
v-loading="listLoading"
:data="list"
border
fit
highlight-current-row
style="width: 100%;margin-top:30px;"
v-loading="listLoading"
:data="list"
border
fit
highlight-current-row
style="width: 100%;margin-top:30px;"
>
<el-table-column
width="180px"
align="center"
label="添加时间"
width="180px"
align="center"
label="添加时间"
>
<template slot-scope="{row}">
<span>{{ row.createdAt | parseTime }}</span>
@ -39,13 +50,13 @@
</el-table-column>
<el-table-column
min-width="200px"
label="店铺名"
min-width="200px"
label="店铺名"
>
<template slot-scope="{row}">
<router-link
:to="'/system/edit/'+row._id"
class="link-type"
:to="'/system/edit/'+row._id"
class="link-type"
>
<span>{{ row.name }}</span>
</router-link>
@ -53,34 +64,58 @@
</el-table-column>
<el-table-column
label="区域"
label="区域"
>
<template slot-scope="{row}">
<span>{{ row.areaStr }}</span>
<span>{{ row.areaStr }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
prop="publish"
align="center"
label="审核状态"
>
<template slot-scope="{row}">
<el-tag
size="small"
:type="row.publish ? 'info': 'danger'"
>{{ formPublish(row.publish) }}</el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
fixed="right"
width="320"
>
<template slot-scope="scope">
<el-button
:type="scope.row.publish? 'warning': 'success'"
size="small"
style="margin-left: 10px"
v-permission="['shopman:review']"
@click="publishShop(scope)"
>
{{ scope.row.publish? '取消审核': '通过审核' }}
</el-button>
<router-link :to="'/system/edit/'+scope.row._id">
<el-button
type="primary"
size="small"
icon="el-icon-edit"
v-permission="['shopman:edit']"
type="primary"
size="small"
icon="el-icon-edit"
style="margin-left: 10px"
v-permission="['shopman:edit']"
>
编辑
编辑
</el-button>
</router-link>
<el-button
type="danger"
size="small"
style="margin-left: 10px"
v-permission="['shopman:delete']"
@click="handleDelete(scope)"
type="danger"
size="small"
style="margin-left: 10px"
v-permission="['shopman:delete']"
@click="handleDelete(scope)"
>
{{ $t('permission.delete') }}
</el-button>
@ -89,11 +124,11 @@
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="listQuery.page"
:limit.sync="listQuery.limit"
@pagination="getList"
v-show="total>0"
:total="total"
:page.sync="listQuery.page"
:limit.sync="listQuery.limit"
@pagination="getList"
/>
</div>
</template>
@ -102,7 +137,7 @@
import { Component, Vue } from 'vue-property-decorator'
import { IShopData } from '@/api/types'
import Pagination from '@/components/Pagination/index.vue'
import { deleteShop, getShops } from '@/api/shop'
import { deleteShop, getShops, updateShopPublish } from '@/api/shop'
import { parseTime } from '@/utils'
@Component({
@ -124,11 +159,13 @@ export default class extends Vue {
private listQuery = {
page: 1,
limit: 20,
key: ''
key: '',
publish: 'all'
}
private filterForm = {
key: ''
key: '',
publish: 'all'
}
$refs!: {
@ -151,6 +188,10 @@ export default class extends Vue {
this.total = data.total
}
private formPublish(cellValue: boolean) {
return cellValue ? '已审核' : '未审核'
}
private async handleDelete(scope: any) {
const { $index, row } = scope
await this.$confirm('确认删除该店铺?', 'Warning', {
@ -166,6 +207,22 @@ export default class extends Vue {
})
}
private async publishShop(scope: any) {
const { row } = scope
const str = row.publish ? '确认取消该店铺的审核状态?' : '确定通过该店铺的审核?'
try {
await this.$confirm(str, 'Warning', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
await updateShopPublish({id: row._id, publish: !row.publish})
row.publish = !row.publish
} catch(err) {
console.log(err)
}
}
private search() {
this.filterData()
}
@ -173,6 +230,7 @@ export default class extends Vue {
private filterData() {
this.listQuery.key = this.filterForm.key
this.listQuery.page = 1
this.listQuery.publish = this.filterForm.publish
this.getList()
}