3 Commits
3.0.5 ... 3.0.7

Author SHA1 Message Date
zzc
69fd59dada feat: tips
Some checks failed
continuous-integration/drone/tag Build encountered an error
2026-02-09 02:56:53 +08:00
zzc
43f38207bf fix: record page
All checks were successful
continuous-integration/drone/tag Build is passing
2026-02-09 01:43:01 +08:00
zzc
23b0ae35af fix: make content api 2026-02-06 14:21:14 +08:00
11 changed files with 959 additions and 186 deletions

View File

@@ -53,3 +53,11 @@ export function toggleEnable(id, isEnabled) {
data: { isEnabled }, data: { isEnabled },
}) })
} }
export function getCreateList(data) {
return request({
url: '/management/api/spring/avatar/create/list',
method: 'get',
params: data,
})
}

View File

@@ -8,6 +8,14 @@ export function getList(data) {
}) })
} }
export function getDrawList(data) {
return request({
url: 'management/api/spring/fortune/card/draw/list',
method: 'get',
params: data,
})
}
export function doAdd(data) { export function doAdd(data) {
return request({ return request({
url: '/management/api/spring/fortune/card', url: '/management/api/spring/fortune/card',

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: '/management/api/spring/index/tips/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: '/management/api/spring/index/tips',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/spring/index/tips/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: '/management/api/spring/index/tips/delete',
method: 'put',
data,
})
}
export function doMoveUp(id) {
return request({
url: `/management/api/spring/index/tips/moveUp/${id}`,
method: 'patch',
})
}
export function doMoveDown(id) {
return request({
url: `/management/api/spring/index/tips/moveDown/${id}`,
method: 'patch',
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/spring/index/tips/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}
export function getItemDetail(data) {
return request({
url: '/management/api/spring/index/tips/check',
method: 'get',
params: data,
})
}

View File

@@ -73,6 +73,12 @@ export const asyncRoutes = [
component: () => import('@/views/spring/index/recommend/index'), component: () => import('@/views/spring/index/recommend/index'),
meta: { title: '推介列表', icon: 'list' }, meta: { title: '推介列表', icon: 'list' },
}, },
{
path: 'tips',
name: 'tips',
component: () => import('@/views/spring/index/tips/index'),
meta: { title: '首页跳转', icon: 'list' },
},
], ],
}, },
{ {
@@ -169,6 +175,12 @@ export const asyncRoutes = [
component: () => import('@/views/spring/avatar/avatarDecor/index'), component: () => import('@/views/spring/avatar/avatarDecor/index'),
meta: { title: '头像挂饰' }, meta: { title: '头像挂饰' },
}, },
{
path: 'record',
name: 'AvatarRecord',
component: () => import('@/views/spring/avatar/record/index'),
meta: { title: '头像记录' },
},
], ],
}, },
{ {
@@ -189,6 +201,12 @@ export const asyncRoutes = [
component: () => import('@/views/spring/fortune/card/index'), component: () => import('@/views/spring/fortune/card/index'),
meta: { title: '抽签卡片' }, meta: { title: '抽签卡片' },
}, },
{
path: 'drawRecord',
name: 'DrawRecord',
component: () => import('@/views/spring/fortune/drawRecord/index'),
meta: { title: '抽签记录' },
},
], ],
}, },
{ {
@@ -243,174 +261,174 @@ export const asyncRoutes = [
}, },
], ],
}, },
{ // {
path: '/maomaotou', // path: '/maomaotou',
component: Layout, // component: Layout,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'CxshMini', // name: 'CxshMini',
meta: { title: '猫猫头', icon: 'cat', permissions: ['admin'] }, // meta: { title: '猫猫头', icon: 'cat', permissions: ['admin'] },
children: [ // children: [
{ // {
path: 'cat', // path: 'cat',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'cat', // name: 'cat',
meta: { // meta: {
title: '猫猫', // title: '猫猫',
icon: 'cat', // icon: 'cat',
permissions: ['admin'], // permissions: ['admin'],
}, // },
children: [ // children: [
{ // {
path: 'cat', // path: 'cat',
name: 'Cat', // name: 'Cat',
component: () => import('@/views/maomao/cat/cat/index'), // component: () => import('@/views/maomao/cat/cat/index'),
meta: { title: '猫猫' }, // meta: { title: '猫猫' },
}, // },
], // ],
}, // },
{ // {
path: 'post', // path: 'post',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'Post', // name: 'Post',
meta: { // meta: {
title: '帖子', // title: '帖子',
icon: 'post', // icon: 'post',
permissions: ['admin'], // permissions: ['admin'],
}, // },
children: [ // children: [
{ // {
path: 'post', // path: 'post',
name: 'Post', // name: 'Post',
component: () => import('@/views/maomao/post/post/index'), // component: () => import('@/views/maomao/post/post/index'),
meta: { title: '帖子' }, // meta: { title: '帖子' },
}, // },
], // ],
}, // },
{ // {
path: 'user', // path: 'user',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'User', // name: 'User',
meta: { // meta: {
title: '用户', // title: '用户',
icon: 'user', // icon: 'user',
permissions: ['admin'], // permissions: ['admin'],
}, // },
children: [ // children: [
{ // {
path: 'user', // path: 'user',
name: 'User', // name: 'User',
component: () => import('@/views/maomao/user/user/index'), // component: () => import('@/views/maomao/user/user/index'),
meta: { title: '用户' }, // meta: { title: '用户' },
}, // },
{ // {
path: 'userChat', // path: 'userChat',
name: 'UserChat', // name: 'UserChat',
component: () => import('@/views/maomao/user/chat/index'), // component: () => import('@/views/maomao/user/chat/index'),
meta: { title: '聊天' }, // meta: { title: '聊天' },
}, // },
], // ],
}, // },
], // ],
}, // },
{ // {
path: '/cxshMini', // path: '/cxshMini',
component: Layout, // component: Layout,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'CxshMini', // name: 'CxshMini',
meta: { title: '小程序', icon: 'comment', permissions: ['admin', 'csxh_admin', 'csxh_user'] }, // meta: { title: '小程序', icon: 'comment', permissions: ['admin', 'csxh_admin', 'csxh_user'] },
children: [ // children: [
{ // {
path: 'home', // path: 'home',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'Home', // name: 'Home',
meta: { // meta: {
title: '首页', // title: '首页',
icon: 'home', // icon: 'home',
permissions: ['admin', 'csxh_admin', 'csxh_user'], // permissions: ['admin', 'csxh_admin', 'csxh_user'],
}, // },
children: [ // children: [
{ // {
path: 'banner', // path: 'banner',
name: 'Banner', // name: 'Banner',
component: () => import('@/views/cxshMini/home/banner/index'), // component: () => import('@/views/cxshMini/home/banner/index'),
meta: { title: '轮播图' }, // meta: { title: '轮播图' },
}, // },
{ // {
path: 'news', // path: 'news',
name: 'News', // name: 'News',
component: () => import('@/views/cxshMini/home/news/index'), // component: () => import('@/views/cxshMini/home/news/index'),
meta: { title: '花絮动态' }, // meta: { title: '花絮动态' },
}, // },
{ // {
path: 'createNews', // path: 'createNews',
name: 'CreateNews', // name: 'CreateNews',
component: () => import('@/views/cxshMini/home/createNews/index'), // component: () => import('@/views/cxshMini/home/createNews/index'),
meta: { title: '新建花絮' }, // meta: { title: '新建花絮' },
}, // },
], // ],
}, // },
{ // {
path: 'anli', // path: 'anli',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'Anli', // name: 'Anli',
meta: { // meta: {
title: '精彩案例', // title: '精彩案例',
icon: 'handshake', // icon: 'handshake',
permissions: ['admin', 'csxh_admin', 'csxh_user'], // permissions: ['admin', 'csxh_admin', 'csxh_user'],
}, // },
children: [ // children: [
{ // {
path: 'article', // path: 'article',
name: 'Article', // name: 'Article',
component: () => import('@/views/cxshMini/anli/article/index'), // component: () => import('@/views/cxshMini/anli/article/index'),
meta: { title: '新建案例' }, // meta: { title: '新建案例' },
}, // },
{ // {
path: 'list', // path: 'list',
name: 'List', // name: 'List',
component: () => import('@/views/cxshMini/anli/list/index'), // component: () => import('@/views/cxshMini/anli/list/index'),
meta: { title: '案例列表' }, // meta: { title: '案例列表' },
}, // },
{ // {
path: 'category', // path: 'category',
name: 'Category', // name: 'Category',
component: () => import('@/views/cxshMini/anli/category/index'), // component: () => import('@/views/cxshMini/anli/category/index'),
meta: { title: '案例分类' }, // meta: { title: '案例分类' },
}, // },
], // ],
}, // },
{ // {
path: 'lianxi', // path: 'lianxi',
component: EmptyLayout, // component: EmptyLayout,
alwaysShow: true, // alwaysShow: true,
redirect: 'noRedirect', // redirect: 'noRedirect',
name: 'Lianxi', // name: 'Lianxi',
meta: { // meta: {
title: '联系我们', // title: '联系我们',
icon: 'user-friends', // icon: 'user-friends',
permissions: ['admin', 'csxh_admin', 'csxh_user'], // permissions: ['admin', 'csxh_admin', 'csxh_user'],
}, // },
children: [ // children: [
{ // {
path: 'member', // path: 'member',
name: 'Member', // name: 'Member',
component: () => import('@/views/cxshMini/lianxi/member/index'), // component: () => import('@/views/cxshMini/lianxi/member/index'),
meta: { title: '成员' }, // meta: { title: '成员' },
}, // },
], // ],
}, // },
], // ],
}, // },
/* { /* {
path: "/test", path: "/test",
component: Layout, component: Layout,

View File

@@ -0,0 +1,182 @@
<template>
<div class="avatar-record-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入查询条件" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-left-panel>
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText" @selection-change="setSelectRows">
<el-table-column align="center" label="生成结果" width="100">
<template slot-scope="scope">
<el-tooltip class="item" :content="scope.row.id" effect="dark" placement="top">
<el-image fit="cover" :preview-src-list="[scope.row.imageUrl]" :src="scope.row.imageUrl" style="width: 50px; height: 50px" />
</el-tooltip>
</template>
</el-table-column>
<el-table-column align="left" label="信息" show-overflow-tooltip>
<template #default="{ row }">
<div>
<div>
<strong>设备</strong>
<template v-if="row.deviceId">
<el-link type="primary" :underline="false" @click="goToDevice(row.deviceId)">{{ row.deviceModel || row.deviceId }}</el-link>
</template>
<template v-else>--</template>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="作者信息" show-overflow-tooltip>
<template #default="{ row }">
<div class="author-cell">
<img alt="avatar" class="author-avatar" :src="row?.fromUser?.avatar" />
<div class="author-meta">
<div>
<strong>id</strong>
{{ row?.fromUser?.id || '--' }}
</div>
<div>
<strong>昵称</strong>
{{ row?.fromUser?.nickname || '--' }}
</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" show-overflow-tooltip>
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</template>
<script>
import { getCreateList } from '@/api/spring/avatar'
import { formatTime } from '@/utils'
export default {
name: 'AvatarRecord',
data() {
return {
host: 'https://file.lihailezzc.com/',
list: null,
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: '',
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
},
timeOutID: null,
}
},
created() {
const { id } = this.$route.query || {}
if (id) {
this.queryForm.keyword = id
this.queryForm.pageNo = 1
}
this.fetchData()
},
beforeDestroy() {
clearTimeout(this.timeOutID)
},
methods: {
formatTime,
setSelectRows(val) {
this.selectRows = val
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
},
async fetchData() {
this.listLoading = true
const { data } = await getCreateList(this.queryForm)
this.list = data.list
this.total = data.totalCount
this.timeOutID = setTimeout(() => {
this.listLoading = false
}, 300)
},
},
}
</script>
<style scoped>
.author-option {
display: flex;
align-items: center;
}
.author-avatar {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
margin-right: 8px;
}
.author-name {
font-size: 14px;
}
.author-cell {
display: flex;
align-items: center;
gap: 12px;
}
.author-avatar {
width: 50px;
height: 50px;
object-fit: cover;
border-radius: 50%;
}
.author-meta {
display: flex;
flex-direction: column;
}
.image-grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.grid-image {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 8px;
}
</style>

View File

@@ -64,24 +64,6 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="交互信息" show-overflow-tooltip>
<template #default="{ row }">
<div>
<div>
<strong>查看数</strong>
{{ row.viewCount }}
</div>
<div>
<strong>分享数</strong>
{{ row.shareCount }}
</div>
<div>
<strong>保存数</strong>
{{ row.saveCount }}
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="作者信息" show-overflow-tooltip> <el-table-column align="left" label="作者信息" show-overflow-tooltip>
<template #default="{ row }"> <template #default="{ row }">
<div class="author-cell"> <div class="author-cell">

View File

@@ -0,0 +1,193 @@
<template>
<div class="draw-record-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入查询条件" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-left-panel>
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText" @selection-change="setSelectRows">
<el-table-column align="center" label="抽签结果" width="100">
<template slot-scope="scope">
<el-tooltip class="item" :content="scope.row.id" effect="dark" placement="top">
<el-image fit="cover" :preview-src-list="[scope.row.imageUrl]" :src="scope.row.imageUrl" style="width: 50px; height: 50px" />
</el-tooltip>
</template>
</el-table-column>
<!-- <el-table-column align="left" label="信息" show-overflow-tooltip>
<template #default="{ row }">
<div>
<div>
<strong>设备</strong>
<template v-if="row.deviceId">
<el-link type="primary" :underline="false" @click="goToDevice(row.deviceId)">{{ row.deviceModel || row.deviceId }}</el-link>
</template>
<template v-else>--</template>
</div>
<div>
<strong>卡片id</strong>
<template v-if="row.cardId">
<el-link type="primary" :underline="false" @click="goToCard(row.cardId)">{{ row.cardId }}</el-link>
</template>
<template v-else>--</template>
</div>
</div>
</template>
</el-table-column> -->
<el-table-column align="left" label="抽签人" show-overflow-tooltip>
<template #default="{ row }">
<div class="author-cell">
<img alt="avatar" class="author-avatar" :src="row?.fromUser?.avatar" />
<div class="author-meta">
<div>
<strong>id</strong>
{{ row?.fromUser?.id || '--' }}
</div>
<div>
<strong>昵称</strong>
{{ row?.fromUser?.nickname || '--' }}
</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" show-overflow-tooltip>
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</template>
<script>
import { getDrawList } from '@/api/spring/fortune/card'
import { formatTime } from '@/utils'
export default {
name: 'DrawRecord',
data() {
return {
host: 'https://file.lihailezzc.com/',
list: null,
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: '',
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
},
timeOutID: null,
}
},
created() {
const { id } = this.$route.query || {}
if (id) {
this.queryForm.keyword = id
this.queryForm.pageNo = 1
}
this.fetchData()
},
beforeDestroy() {
clearTimeout(this.timeOutID)
},
methods: {
formatTime,
setSelectRows(val) {
this.selectRows = val
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
},
goToCard(cardId) {
// Assuming there is a card detail or list page, but for now just placeholder or link to card list
this.$router.push({ path: '/spring/fortune/card', query: { id: cardId } })
},
async fetchData() {
this.listLoading = true
const { data } = await getDrawList(this.queryForm)
this.list = data.list
this.total = data.totalCount
this.timeOutID = setTimeout(() => {
this.listLoading = false
}, 300)
},
},
}
</script>
<style scoped>
.author-option {
display: flex;
align-items: center;
}
.author-avatar {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
margin-right: 8px;
}
.author-name {
font-size: 14px;
}
.author-cell {
display: flex;
align-items: center;
gap: 12px;
}
.author-avatar {
width: 50px;
height: 50px;
object-fit: cover;
border-radius: 50%;
}
.author-meta {
display: flex;
flex-direction: column;
}
.image-grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.grid-image {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 8px;
}
</style>

View File

@@ -40,6 +40,8 @@
<el-select v-model="form.tag" placeholder="请选择标签" style="width: 100%"> <el-select v-model="form.tag" placeholder="请选择标签" style="width: 100%">
<el-option label="最新" value="new" /> <el-option label="最新" value="new" />
<el-option label="热门" value="hot" /> <el-option label="热门" value="hot" />
<el-option label="精选" value="featured" />
<el-option label="爆款" value="hot2" />
<el-option label="无" value="" /> <el-option label="无" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>

View File

@@ -43,6 +43,8 @@
<template #default="{ row }"> <template #default="{ row }">
<el-tag v-if="row.tag === 'new'" type="success">最新</el-tag> <el-tag v-if="row.tag === 'new'" type="success">最新</el-tag>
<el-tag v-else-if="row.tag === 'hot'" type="danger">热门</el-tag> <el-tag v-else-if="row.tag === 'hot'" type="danger">热门</el-tag>
<el-tag v-else-if="row.tag === 'featured'" type="info">精选</el-tag>
<el-tag v-else-if="row.tag === 'hot2'" type="warning">爆款</el-tag>
<span v-else>{{ row.tag || '--' }}</span> <span v-else>{{ row.tag || '--' }}</span>
</template> </template>
</el-table-column> </el-table-column>

View File

@@ -0,0 +1,110 @@
<template>
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
<el-form ref="form" label-width="80px" :model="form" :rules="rules">
<el-form-item label="文案" prop="text">
<el-input v-model="form.text" autocomplete="off" :rows="2" type="textarea" />
</el-form-item>
<el-form-item label="跳转地址" prop="url">
<el-input v-model="form.url" autocomplete="off" />
</el-form-item>
<el-form-item label="标签" prop="tag">
<el-select v-model="form.tag" placeholder="请选择标签" style="width: 100%">
<el-option label="新品" value="new" />
<el-option label="热门" value="hot" />
<el-option label="爆款" value="hot2" />
<el-option label="精选" value="featured" />
</el-select>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width: 100%">
<el-option label="默认" value="" />
<el-option label="页面" value="path" />
<el-option label="tab页" value="switchTab" />
</el-select>
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-switch v-model="form.isEnabled" active-text="启用" :active-value="true" inactive-text="禁用" :inactive-value="false" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doEdit, doAdd } from '@/api/spring/index/tips'
export default {
name: 'AppManagementEdit',
data() {
return {
id: '',
form: {
text: '',
url: '',
tag: '',
type: '',
isEnabled: true,
},
rules: {
text: [{ required: true, trigger: 'blur', message: '请输入文案' }],
url: [{ required: true, trigger: 'blur', message: '请输入跳转地址' }],
isEnabled: [{ required: true, trigger: 'blur', message: '请选择是否启用' }],
},
title: '',
dialogFormVisible: false,
}
},
methods: {
showEdit(row) {
if (!row) {
this.title = '添加'
this.form = {
text: '',
url: '',
tag: '',
type: '',
isEnabled: true,
}
} else {
this.title = '编辑'
this.form = {
text: row.text,
url: row.url,
tag: row.tag,
type: row.type,
isEnabled: row.isEnabled,
}
this.id = row.id
}
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.id = ''
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
if (this.id) {
const { msg } = await doEdit(this.id, this.form)
this.$baseMessage(msg, 'success')
} else {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
}
this.$emit('fetch-data')
this.close()
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,205 @@
<template>
<div class="tips-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
<!-- <el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</el-button> -->
</vab-query-form-left-panel>
<vab-query-form-right-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入查询条件" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-right-panel>
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" label="排序" prop="sort" show-overflow-tooltip />
<el-table-column align="center" label="文案" prop="text" show-overflow-tooltip />
<el-table-column align="center" label="跳转地址" prop="url" show-overflow-tooltip />
<el-table-column align="center" label="标签" show-overflow-tooltip>
<template #default="{ row }">
<el-tag v-if="row.tag === 'new'" type="success">新品</el-tag>
<el-tag v-else-if="row.tag === 'hot'" type="danger">热门</el-tag>
<el-tag v-else-if="row.tag === 'hot2'" type="warning">爆款</el-tag>
<el-tag v-else-if="row.tag === 'featured'" type="info">精选</el-tag>
<span v-else>--</span>
</template>
</el-table-column>
<el-table-column align="center" label="类型" show-overflow-tooltip>
<template #default="{ row }">
<span v-if="row.type === 'path'">页面</span>
<span v-else-if="row.type === 'switchTab'">tab页</span>
<span v-else>默认</span>
</template>
</el-table-column>
<el-table-column align="center" label="是否启用" show-overflow-tooltip>
<template #default="{ row }">
<el-switch active-color="#13ce66" inactive-color="#ff4949" :value="row.isEnabled" @change="handleToggleEnable(row, $event)" />
</template>
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope">
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
<el-button :disabled="!scope.row.isEnabled || isFirstEnabled(scope.row)" type="text" @click="handleMoveUp(scope.row)">
上移
</el-button>
<el-button :disabled="!scope.row.isEnabled || isLastEnabled(scope.row)" type="text" @click="handleMoveDown(scope.row)">
下移
</el-button>
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { doDelete, getList, toggleEnable, doMoveUp, doMoveDown } from '@/api/spring/index/tips'
import Edit from './components/AppManagementEdit'
export default {
name: 'Tips',
components: { Edit },
data() {
return {
list: null,
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: '',
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
},
timeOutID: null,
}
},
created() {
this.fetchData()
},
beforeDestroy() {
clearTimeout(this.timeOutID)
},
methods: {
setSelectRows(val) {
this.selectRows = val
},
handleEdit(row) {
if (row && row.id) {
this.$refs['edit'].showEdit(row)
} else {
this.$refs['edit'].showEdit()
}
},
handleDelete(row) {
if (row.id) {
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
const { msg } = await doDelete({ ids: [row.id] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const ids = this.selectRows.map((item) => item.id).join()
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
const { msg } = await doDelete({ ids: ids.split(',') })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
this.listLoading = true
const { data } = await getList(this.queryForm)
this.list = data.list
this.total = data.totalCount
this.timeOutID = setTimeout(() => {
this.listLoading = false
}, 300)
},
async handleToggleEnable(row, val) {
const prev = row.isEnabled
row.isEnabled = val
try {
const { msg } = await toggleEnable(row.id, val)
if (msg) this.$baseMessage(msg, 'success')
this.fetchData()
} catch (e) {
row.isEnabled = prev
this.$baseMessage('更新失败', 'error')
}
},
async handleMoveUp(row) {
try {
const { msg } = await doMoveUp(row.id)
if (msg) this.$baseMessage(msg, 'success')
this.fetchData()
} catch (e) {
this.$baseMessage('操作失败', 'error')
}
},
async handleMoveDown(row) {
try {
const { msg } = await doMoveDown(row.id)
if (msg) this.$baseMessage(msg, 'success')
this.fetchData()
} catch (e) {
this.$baseMessage('操作失败', 'error')
}
},
isFirstEnabled(row) {
if (!this.list || this.list.length === 0) return false
const enabled = this.list.filter((item) => item.isEnabled)
if (enabled.length === 0) return false
return enabled[0].id === row.id
},
isLastEnabled(row) {
if (!this.list || this.list.length === 0) return false
const enabled = this.list.filter((item) => item.isEnabled)
if (enabled.length === 0) return false
return enabled[enabled.length - 1].id === row.id
},
},
}
</script>
<style scoped>
.content-cell {
white-space: pre-wrap;
word-break: break-word;
line-height: 1.6;
}
</style>