案场、权益、积分
2
.env.dev
@ -2,7 +2,7 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# app
|
# app
|
||||||
VITE_TITLE=GuXuan-Admin
|
VITE_TITLE=ShiBeiTong-Admin
|
||||||
VITE_PUBLIC_PATH=/
|
VITE_PUBLIC_PATH=/
|
||||||
VITE_OUT_DIR=dist
|
VITE_OUT_DIR=dist
|
||||||
VITE_PERMISSION=false
|
VITE_PERMISSION=false
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# app
|
# app
|
||||||
VITE_TITLE=GuXuan-Admin
|
VITE_TITLE=ShiBeiTong-Admin
|
||||||
VITE_PUBLIC_PATH=/
|
VITE_PUBLIC_PATH=/
|
||||||
VITE_OUT_DIR=dist
|
VITE_OUT_DIR=dist
|
||||||
VITE_PERMISSION=true
|
VITE_PERMISSION=true
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon"
|
<link rel="icon" href="/favicon.ico" />
|
||||||
href="/favicon.ico" />
|
<!-- public/index.html -->
|
||||||
<meta name="viewport"
|
<meta name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0" />
|
content="width=device-width, initial-scale=1.0" />
|
||||||
<title></title>
|
<title></title>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 843 KiB |
BIN
public/favicon2.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/images/2.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/logo.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 867 B After Width: | Height: | Size: 264 KiB |
@ -1,10 +1,8 @@
|
|||||||
const modules = import.meta.glob('./modules/*.js', { eager: true })
|
const modules = import.meta.glob('./modules/*.js', { eager: true })
|
||||||
|
|
||||||
const api = {}
|
const api = {}
|
||||||
|
|
||||||
Object.keys(modules).forEach((key) => {
|
Object.keys(modules).forEach((key) => {
|
||||||
const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'))
|
const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'))
|
||||||
api[name] = { ...modules[key] }
|
api[name] = { ...modules[key] }
|
||||||
})
|
})
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
|
|||||||
14
src/apis/modules/activity.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* 区域模块接口
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取项目列表
|
||||||
|
export const getProjectList = (params) => request.basic.get('/api/v1/activities', params)
|
||||||
|
// 获取单挑数据
|
||||||
|
export const getItem = (id) => request.basic.get(`/api/v1/activities/${id}`)
|
||||||
|
// 添加条目
|
||||||
|
export const createProject = (params) => request.basic.post('/api/v1/activities', params)
|
||||||
|
// 更新role
|
||||||
|
export const updateItem = (id, params) => request.basic.put(`/api/v1/activities/${id}`, params)
|
||||||
|
// 删除数据
|
||||||
|
export const delItem = (id) => request.basic.delete(`/api/v1/activities/${id}`)
|
||||||
BIN
src/assets/qrlogo.png
Normal file
|
After Width: | Height: | Size: 843 KiB |
@ -1,10 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div class="x-qrcode" :style="{
|
||||||
class="x-qrcode"
|
width: `${size}px`,
|
||||||
:style="{
|
height: `${size}px`,
|
||||||
width: `${size}px`,
|
|
||||||
height: `${size}px`,
|
}" style="display: flex;align-items: center;flex-direction: column;justify-content: center;margin: 20px;">
|
||||||
}">
|
|
||||||
<template v-if="'active' !== status">
|
<template v-if="'active' !== status">
|
||||||
<div class="x-qrcode__mask">
|
<div class="x-qrcode__mask">
|
||||||
<template v-if="'loading' === status">
|
<template v-if="'loading' === status">
|
||||||
@ -12,10 +11,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-if="'expired' === status">
|
<template v-if="'expired' === status">
|
||||||
<div>二维码已过期</div>
|
<div>二维码已过期</div>
|
||||||
<a-button
|
<a-button type="link" class="x-qrcode__reload-btn" @click="handleRefresh">
|
||||||
type="link"
|
|
||||||
class="x-qrcode__reload-btn"
|
|
||||||
@click="handleRefresh">
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<reload-outlined></reload-outlined>
|
<reload-outlined></reload-outlined>
|
||||||
</template>
|
</template>
|
||||||
@ -25,6 +21,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<canvas ref="qrCodeRef"></canvas>
|
<canvas ref="qrCodeRef"></canvas>
|
||||||
|
|
||||||
|
<!-- 添加下载按钮 -->
|
||||||
|
<a-button type="primary" v-if="status === 'active'" @click="handleDownload" style="margin-top:20px">
|
||||||
|
<template #icon>
|
||||||
|
<DownloadOutlined />
|
||||||
|
</template>
|
||||||
|
下载
|
||||||
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -32,7 +36,7 @@
|
|||||||
import QRCode from 'qrcode'
|
import QRCode from 'qrcode'
|
||||||
import { onMounted, ref, toRefs, watch } from 'vue'
|
import { onMounted, ref, toRefs, watch } from 'vue'
|
||||||
|
|
||||||
import { ReloadOutlined } from '@ant-design/icons-vue'
|
import { ReloadOutlined, DownloadOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'XQrCode',
|
name: 'XQrCode',
|
||||||
@ -49,6 +53,7 @@ defineOptions({
|
|||||||
* @property {string} iconBackgroundColor icon 背景色
|
* @property {string} iconBackgroundColor icon 背景色
|
||||||
* @property {string} errorLevel 纠错等级。默认:M,【L=low, M=medium, Q=quartile, H=high】
|
* @property {string} errorLevel 纠错等级。默认:M,【L=low, M=medium, Q=quartile, H=high】
|
||||||
* @property {string} status 状态,【active=有效,loading=加载中,expired=已过期】
|
* @property {string} status 状态,【active=有效,loading=加载中,expired=已过期】
|
||||||
|
* @property {string} downloadFileName 下载文件名(不带扩展名)。默认:qrcode
|
||||||
*/
|
*/
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
@ -92,9 +97,13 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'active',
|
default: 'active',
|
||||||
},
|
},
|
||||||
|
downloadFileName: {
|
||||||
|
type: String,
|
||||||
|
default: 'qrcode'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['refresh'])
|
const emit = defineEmits(['refresh', 'download'])
|
||||||
|
|
||||||
const qrCodeRef = ref()
|
const qrCodeRef = ref()
|
||||||
|
|
||||||
@ -130,7 +139,7 @@ async function init() {
|
|||||||
*/
|
*/
|
||||||
async function renderQRCode() {
|
async function renderQRCode() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
;(async () => {
|
; (async () => {
|
||||||
await QRCode.toCanvas(qrCodeRef.value, props.value, {
|
await QRCode.toCanvas(qrCodeRef.value, props.value, {
|
||||||
width: props.size,
|
width: props.size,
|
||||||
color: {
|
color: {
|
||||||
@ -175,6 +184,29 @@ function handleRefresh() {
|
|||||||
emit('refresh')
|
emit('refresh')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载二维码
|
||||||
|
*/
|
||||||
|
function handleDownload() {
|
||||||
|
if (!qrCodeRef.value) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const canvas = qrCodeRef.value;
|
||||||
|
const dataUrl = canvas.toDataURL('image/png');
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = dataUrl;
|
||||||
|
link.download = `${props.downloadFileName || 'qrcode'}.png`;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
|
||||||
|
// 触发下载事件
|
||||||
|
emit('download', dataUrl);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('下载二维码失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换成 data URI
|
* 转换成 data URI
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
@ -185,12 +217,14 @@ async function toDataURL() {
|
|||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
toDataURL,
|
toDataURL,
|
||||||
|
handleDownload
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.x-qrcode {
|
.x-qrcode {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
&__mask {
|
&__mask {
|
||||||
background: rgba(255, 255, 255, 0.96);
|
background: rgba(255, 255, 255, 0.96);
|
||||||
@ -207,5 +241,32 @@ defineExpose({
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 下载按钮样式 */
|
||||||
|
&__download {
|
||||||
|
|
||||||
|
right: 4px;
|
||||||
|
bottom: 4px;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
z-index: 20;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__download-icon {
|
||||||
|
color: white;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -2,7 +2,7 @@ import { env } from '@/utils/util'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: env('title'),
|
title: env('title'),
|
||||||
logo: `${import.meta.env.BASE_URL}images/logo.svg`,
|
logo: `${import.meta.env.BASE_URL}images/2.png`,
|
||||||
mock: env('mock'),
|
mock: env('mock'),
|
||||||
permission: env('permission'),
|
permission: env('permission'),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
welcome: '欢迎',
|
welcome: '欢迎',
|
||||||
home: '首页',
|
home: '首页',
|
||||||
@ -62,5 +64,6 @@ export default {
|
|||||||
paddOrder: '过期订单',
|
paddOrder: '过期订单',
|
||||||
erCodeList: '二维码列表',
|
erCodeList: '二维码列表',
|
||||||
order:"权益订单",
|
order:"权益订单",
|
||||||
points:'积分列表'
|
points:'积分列表',
|
||||||
|
activity:'案场活动'
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/router/routes/activity.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { CoffeeOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: 'activity/index',
|
||||||
|
name: 'activity',
|
||||||
|
component: 'activity/index.vue',
|
||||||
|
meta: {
|
||||||
|
icon: CoffeeOutlined,
|
||||||
|
title: '案场活动',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
]
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { TableOutlined } from '@ant-design/icons-vue'
|
import {BellOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ export default [
|
|||||||
name: 'announcement',
|
name: 'announcement',
|
||||||
component: 'RouteViewLayout',
|
component: 'RouteViewLayout',
|
||||||
meta: {
|
meta: {
|
||||||
icon: TableOutlined,
|
icon: BellOutlined,
|
||||||
title: '消息公告',
|
title: '消息公告',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import integral from './integral'
|
|||||||
import regional from './regional'
|
import regional from './regional'
|
||||||
import announcement from './announcement'
|
import announcement from './announcement'
|
||||||
import order from './order'
|
import order from './order'
|
||||||
|
import activity from './activity'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
...home,
|
...home,
|
||||||
@ -31,5 +32,6 @@ export default [
|
|||||||
...integral,
|
...integral,
|
||||||
...regional,
|
...regional,
|
||||||
...announcement,
|
...announcement,
|
||||||
...order
|
...order,
|
||||||
|
...activity
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { TableOutlined } from '@ant-design/icons-vue'
|
import { DollarOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ export default [
|
|||||||
name: 'integral',
|
name: 'integral',
|
||||||
component: 'RouteViewLayout',
|
component: 'RouteViewLayout',
|
||||||
meta: {
|
meta: {
|
||||||
icon: TableOutlined,
|
icon: DollarOutlined,
|
||||||
title: '积分模块',
|
title: '积分模块',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { TableOutlined } from '@ant-design/icons-vue'
|
import { SolutionOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ export default [
|
|||||||
name: 'order',
|
name: 'order',
|
||||||
component: 'order/index.vue',
|
component: 'order/index.vue',
|
||||||
meta: {
|
meta: {
|
||||||
icon: TableOutlined,
|
icon: SolutionOutlined,
|
||||||
title: '订单列表',
|
title: '订单列表',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { TableOutlined } from '@ant-design/icons-vue'
|
import { AimOutlined} from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ export default [
|
|||||||
name: 'regional',
|
name: 'regional',
|
||||||
component: 'RouteViewLayout',
|
component: 'RouteViewLayout',
|
||||||
meta: {
|
meta: {
|
||||||
icon: TableOutlined,
|
icon: AimOutlined,
|
||||||
title: '区域模块',
|
title: '区域模块',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { TableOutlined } from '@ant-design/icons-vue'
|
import { UserOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ export default [
|
|||||||
name: 'userManagement',
|
name: 'userManagement',
|
||||||
component: 'RouteViewLayout',
|
component: 'RouteViewLayout',
|
||||||
meta: {
|
meta: {
|
||||||
icon: TableOutlined,
|
icon: UserOutlined,
|
||||||
title: '客户管理',
|
title: '客户管理',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
|||||||
255
src/views/activity/components/EditDialog.vue
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
||||||
|
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||||
|
<a-spin :spinning="spining">
|
||||||
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-row :gutter="12">
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动标题'" name="title">
|
||||||
|
<a-input :placeholder="'请输入活动标题'" v-model:value="formData.title"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动地址'" name="address">
|
||||||
|
<a-input :placeholder="'请输入活动地址'" v-model:value="formData.address"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动开始时间'" name="startAt">
|
||||||
|
<a-date-picker v-model:value="formData.startAt" :show-time="{ format: 'YYYY-MM-DD HH:mm' }" format="YYYY-MM-DD HH:mm" style="width: 100%;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动结束时间'" name="endAt">
|
||||||
|
<a-date-picker v-model:value="formData.endAt" :show-time="{ format: 'YYYY-MM-DD HH:mm' }" format="YYYY-MM-DD HH:mm" style="width: 100%;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'报名截止时间'" name="endSignupAt">
|
||||||
|
<a-date-picker v-model:value="formData.endSignupAt" :show-time="{ format: 'YYYY-MM-DD HH:mm' }" format="YYYY-MM-DD HH:mm" style="width: 100%;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'活动限制人数'" name="maxSignupNum">
|
||||||
|
<a-input-number :placeholder="'请输入活动限制人数'" style="width: 100%;"
|
||||||
|
v-model:value="formData.maxSignupNum"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'活动所需积分'" name="point">
|
||||||
|
<a-input-number :placeholder="'请输入活动所需积分'" style="width: 100%;"
|
||||||
|
v-model:value="formData.point"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动详情'" name="content">
|
||||||
|
<a-textarea :placeholder="'请输入活动详情'" v-model:value="formData.content"
|
||||||
|
style="width: 100%;" :rows="4"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'所属区域'" name="areaId">
|
||||||
|
<a-select ref="select" v-model:value="formData.areaId">
|
||||||
|
<a-select-option v-for="item in areaEnum.getAll()" :value="item.value">{{
|
||||||
|
item.name }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'状态'" name="status">
|
||||||
|
<a-radio-group v-model:value="formData.status" :options="[
|
||||||
|
{ label: '启用', value: 'enabled' },
|
||||||
|
{ label: '停用', value: 'disabled' },
|
||||||
|
]"></a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'活动图片'" name="fileList">
|
||||||
|
<gx-upload v-model="formData.fileList" accept-types=".jpg,.png,.webp" :fileNumber="20"
|
||||||
|
@uploadSuccess="uploadSuccess" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-card>
|
||||||
|
</a-form>
|
||||||
|
</a-spin>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
import { ref, onBeforeMount } from 'vue'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { useForm, useModal, useSpining } from '@/hooks'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import GxUpload from '@/components/GxUpload/index.vue'
|
||||||
|
import { customersEnum, areaEnum } from "@/enums/useEnum"
|
||||||
|
const emit = defineEmits(['ok'])
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
|
const { spining, showSpining, hideSpining } = useSpining()
|
||||||
|
const cancelText = ref(t('button.cancel'))
|
||||||
|
const okText = ref(t('button.confirm'))
|
||||||
|
const fileList = ref([])
|
||||||
|
formRules.value = {
|
||||||
|
title: [{ required: true, message: '请输入活动名称' }],
|
||||||
|
address: [{ required: true, message: '请输入活动地址' }],
|
||||||
|
timeRange: [{
|
||||||
|
required: true, message: '请选择活动时间', trigger: 'change', validator: (_, value) => {
|
||||||
|
if (!value || !value.length) {
|
||||||
|
return Promise.reject(new Error('请选择日期范围'));
|
||||||
|
}
|
||||||
|
const [start, end] = value;
|
||||||
|
if (!start || !end) {
|
||||||
|
return Promise.reject(new Error('日期范围必须完整'));
|
||||||
|
}
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
fileList: [{
|
||||||
|
required: true, message: '请上传图片', trigger: 'change', validator: (_, value) => {
|
||||||
|
if (!value || !value.length) {
|
||||||
|
return Promise.reject(new Error('请上传图片'));
|
||||||
|
}
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
endAt: [{ required: true, message: '请选择活动结束时间', trigger: 'change' }],
|
||||||
|
startAt: [{ required: true, message: '请选择活动开始时间', trigger: 'change' }],
|
||||||
|
endSignupAt: [{ required: true, message: '请选择活动报名截止时间', trigger: 'change' }],
|
||||||
|
maxSignupNum: [{ required: true, message: '请选择活动报名人数' }],
|
||||||
|
points: [{ required: true, message: '请输入参加活动所需积分' }],
|
||||||
|
content: [{ required: true, message: '请输入活动详情' }],
|
||||||
|
address: [{ required: true, message: '请输入活动地址' }],
|
||||||
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
|
areaId: [{ required: true, message: '请选择所属区域', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
formData.value.areaId = 1
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建
|
||||||
|
*/
|
||||||
|
function handleCreate() {
|
||||||
|
showModal({
|
||||||
|
type: 'create',
|
||||||
|
title: '新增活动',
|
||||||
|
})
|
||||||
|
// initData()
|
||||||
|
formData.value.status = 'enabled'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record = {}) {
|
||||||
|
showModal({
|
||||||
|
type: 'edit',
|
||||||
|
title: '编辑活动',
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
showSpining()
|
||||||
|
const { data, success } = await apis.activity.getItem(record.id).catch()
|
||||||
|
if (!success) {
|
||||||
|
hideModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hideSpining()
|
||||||
|
formData.value = { ...data }
|
||||||
|
formData.value.startAt = dayjs(data.startAt)
|
||||||
|
formData.value.endAt = dayjs(data.endAt)
|
||||||
|
formData.value.endSignupAt = dayjs(data.endSignupAt)
|
||||||
|
|
||||||
|
if (data.images&&data.images.length>0) {
|
||||||
|
formData.value.fileList = data.images.map(item=>config('http.apiBasic') + item)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideSpining()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
const uploadSuccess = (data) => {
|
||||||
|
fileList.value.push(data)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 确定
|
||||||
|
*/
|
||||||
|
function handleOk() {
|
||||||
|
formRef.value.validateFields().then(async (values) => {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const params = {
|
||||||
|
...values,
|
||||||
|
cover: fileList.value[0],
|
||||||
|
images:[...fileList.value]
|
||||||
|
}
|
||||||
|
let result = null
|
||||||
|
switch (modal.value.type) {
|
||||||
|
case 'create':
|
||||||
|
result = await apis.activity.createProject(params).catch((error) => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
result = await apis.activity.updateItem(formData.value.id, params).catch(() => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
hideModal()
|
||||||
|
emit('ok')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消
|
||||||
|
*/
|
||||||
|
function handleCancel() {
|
||||||
|
formData.value.areaId = 1
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
const onRangeChange = (value, dateString) => {
|
||||||
|
console.log('value',value)
|
||||||
|
console.log('Formatted Selected Time: ', dateString);
|
||||||
|
formData.value.startAt=dayjs(dateString[0])
|
||||||
|
formData.value.endAt=dayjs(dateString[1])
|
||||||
|
console.log(formData.value)
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭后
|
||||||
|
*/
|
||||||
|
function onAfterClose() {
|
||||||
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
handleCreate,
|
||||||
|
handleEdit,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
248
src/views/activity/index.vue
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
<template>
|
||||||
|
<!-- <x-search-bar class="mb-8-2">
|
||||||
|
<template #default="{ gutter, colSpan }">
|
||||||
|
<a-form :model="searchFormData" layout="inline">
|
||||||
|
<a-row :gutter="gutter">
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="姓名" name="name">
|
||||||
|
<a-input placeholder="请输入姓名" v-model:value="searchFormData.name"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="状态" name="status">
|
||||||
|
<a-select v-model:value="searchFormData.status" allowClear>
|
||||||
|
<a-select-option value="">全部</a-select-option>
|
||||||
|
<a-select-option value="enabled">启用</a-select-option>
|
||||||
|
<a-select-option value="disabled">停用</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col class="align-right" v-bind="colSpan">
|
||||||
|
<a-space>
|
||||||
|
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||||
|
<a-button ghost type="primary" @click="handleSearch">
|
||||||
|
{{ $t('button.search') }}
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
</x-search-bar> -->
|
||||||
|
|
||||||
|
<a-row :gutter="8" :wrap="false">
|
||||||
|
<a-col flex="auto">
|
||||||
|
<a-card type="flex">
|
||||||
|
<x-action-bar class="mb-8-2">
|
||||||
|
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||||
|
<template #icon>
|
||||||
|
<plus-outlined></plus-outlined>
|
||||||
|
</template>
|
||||||
|
新增活动
|
||||||
|
</a-button>
|
||||||
|
</x-action-bar>
|
||||||
|
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||||
|
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.dataIndex === 'startAt'">
|
||||||
|
<span>{{ record.startAt && dayjs(record.startAt).format('YYYY-MM-DD HH:mm') }}</span>
|
||||||
|
<span>{{ ' ~ ' }}</span>
|
||||||
|
<span>{{ record.endAt && dayjs(record.endAt).format('YYYY-MM-DD HH:mm') }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'endSignupAt'">
|
||||||
|
<span>{{ record.endSignupAt && dayjs(record.endSignupAt).format('YYYY-MM-DD HH:mm')
|
||||||
|
}}</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'images'">
|
||||||
|
<span style="cursor: pointer;color:#1677ff;"
|
||||||
|
@click="imgList = record.images || []; type = 1; open = true" type="link">点击查看</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'content'">
|
||||||
|
<span style="cursor: pointer;color:#1677ff;"
|
||||||
|
@click="content = record.content || ''; type = 2; open = true" type="link">点击查看</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="'status' === column.dataIndex">
|
||||||
|
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
||||||
|
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
||||||
|
</template>
|
||||||
|
<template v-if="column.dataIndex === 'areaId'">
|
||||||
|
<span>{{ areaEnum.getName(record.areaId) }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-if="'action' === column.key">
|
||||||
|
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
||||||
|
<edit-outlined /> </a-tooltip></x-action-button>
|
||||||
|
<x-action-button @click="createQrcode(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>二维码</template>
|
||||||
|
<QrcodeOutlined />
|
||||||
|
</a-tooltip></x-action-button>
|
||||||
|
<x-action-button @click="handleDelete(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||||
|
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-card>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-modal v-model:open="open" :title="type === 1 ? '活动图片' : '活动详情'" @ok="open = false">
|
||||||
|
<template v-if="type === 1">
|
||||||
|
<a-image v-if="imgList.length > 0" :width="200" v-for="item of imgList"
|
||||||
|
:src="config('http.apiBasic') + item" />
|
||||||
|
<span v-else>
|
||||||
|
暂无图片
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<span>{{ content }}</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</a-modal>
|
||||||
|
<a-modal v-model:open="qropen" :title="'生成二维码'" @ok="qropen = false" :footer="null">
|
||||||
|
<a-card class="mb-8-2" style="display: flex;align-items: center;flex-direction: column;justify-content: center;">
|
||||||
|
<x-qrCode :value="qrValue" :icon="qrlogo" :iconBackgroundColor="'#ffffff'" :size="180"></x-qrCode>
|
||||||
|
</a-card>
|
||||||
|
</a-modal>
|
||||||
|
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { formatUtcDateTime } from '@/utils/util'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { usePagination } from '@/hooks'
|
||||||
|
import { customersEnum, areaEnum } from "@/enums/useEnum"
|
||||||
|
import EditDialog from './components/EditDialog.vue'
|
||||||
|
import { PlusOutlined, EditOutlined, DeleteOutlined, QrcodeOutlined } from '@ant-design/icons-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import qrlogo from '@/assets/qrlogo.png'
|
||||||
|
defineOptions({
|
||||||
|
name: 'activity',
|
||||||
|
})
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const open = ref(false)
|
||||||
|
const imgList = ref([])
|
||||||
|
const type = ref(1)
|
||||||
|
const content = ref('')
|
||||||
|
const qrValue = ref('')
|
||||||
|
const qropen = ref(false)
|
||||||
|
const columns = [
|
||||||
|
{ title: '活动标题', dataIndex: 'title', width: 200 },
|
||||||
|
{ title: '活动时间', dataIndex: 'startAt', width: 300, align: 'center' },
|
||||||
|
// { title: '结束时间', dataIndex: 'endAt', width: 150, align: 'center' },
|
||||||
|
{ title: '报名截止时间', dataIndex: 'endSignupAt', width: 150, align: 'center' },
|
||||||
|
{ title: '限制人数', dataIndex: 'maxSignupNum', width: 120 },
|
||||||
|
{ title: '已报人数', dataIndex: 'signupNum', width: 120 },
|
||||||
|
{ title: '活动地址', dataIndex: 'address', align: 'center', width: 200 },
|
||||||
|
{ title: '活动图片', dataIndex: 'images', align: 'center', width: 100 },
|
||||||
|
{ title: '消耗积分', dataIndex: 'point', width: 90, align: 'center' },
|
||||||
|
{ title: '所属区域', dataIndex: 'areaId', width: 90, align: 'center' },
|
||||||
|
{ title: '活动详情', dataIndex: 'content', width: 90, align: 'center' },
|
||||||
|
{ title: '状态', dataIndex: 'status', key: 'introduce', width: 60, align: 'center' },
|
||||||
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 150, align: 'center' },
|
||||||
|
]
|
||||||
|
|
||||||
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||||
|
usePagination()
|
||||||
|
|
||||||
|
const editDialogRef = ref()
|
||||||
|
getPageList()
|
||||||
|
/**
|
||||||
|
* 获取表格数据
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function getPageList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const { pageSize, current } = paginationState
|
||||||
|
const { success, data, total } = await apis.activity
|
||||||
|
.getProjectList({
|
||||||
|
pageSize,
|
||||||
|
page: current,
|
||||||
|
...searchFormData.value,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
listData.value = data
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
function handleDelete({ id }) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: t('pages.system.user.delTip'),
|
||||||
|
content: t('button.confirm'),
|
||||||
|
okText: t('button.confirm'),
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
; (async () => {
|
||||||
|
try {
|
||||||
|
const { success } = await apis.activity.delItem(id).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
resolve()
|
||||||
|
message.success(t('component.message.success.delete'))
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const createQrcode = (params) => {
|
||||||
|
qrValue.value = 'ceshi'
|
||||||
|
qropen.value = true
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
function onTableChange({ current, pageSize }) {
|
||||||
|
paginationState.current = current
|
||||||
|
paginationState.pageSize = pageSize
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
*/
|
||||||
|
function handleSearch() {
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重置
|
||||||
|
*/
|
||||||
|
function handleResetSearch() {
|
||||||
|
searchFormData.value = {}
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑完成
|
||||||
|
*/
|
||||||
|
async function onOk() {
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
@ -93,9 +93,7 @@ formRules.value = {
|
|||||||
lat: { required: true, message: '请输入纬度' },
|
lat: { required: true, message: '请输入纬度' },
|
||||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
}
|
}
|
||||||
onBeforeMount(() => {
|
|
||||||
formData.value.labels = ['']
|
|
||||||
})
|
|
||||||
/**
|
/**
|
||||||
* 新建
|
* 新建
|
||||||
*/
|
*/
|
||||||
@ -105,6 +103,7 @@ function handleCreate() {
|
|||||||
title: '新增区域',
|
title: '新增区域',
|
||||||
})
|
})
|
||||||
// initData()
|
// initData()
|
||||||
|
formData.value.labels=['']
|
||||||
formData.value.status = 'enabled'
|
formData.value.status = 'enabled'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +184,7 @@ const removeLabel = (index) => {
|
|||||||
* 取消
|
* 取消
|
||||||
*/
|
*/
|
||||||
function handleCancel() {
|
function handleCancel() {
|
||||||
|
|
||||||
hideModal()
|
hideModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||