转海贝模块

This commit is contained in:
Leo_Ding 2025-09-26 14:43:07 +08:00
parent 7c038aaf8b
commit 0dc1d5dc88
7 changed files with 653 additions and 1 deletions

View File

@ -0,0 +1,16 @@
/**
* 区域模块接口
*/
import request from '@/utils/request'
// 获取项目列表
export const getProjectList = (params) => request.basic.get('/api/v1/earn-points', params)
// 获取单挑数据
export const getItem = (id) => request.basic.get(`/api/v1/earn-points/${id}`)
// 添加条目
export const createProject = (params) => request.basic.post('/api/v1/earn-points', params)
// 更新role
export const updateItem = (id, params) => request.basic.put(`/api/v1/earn-points/${id}`, params)
// 删除数据
export const delItem = (id) => request.basic.delete(`/api/v1/earn-points/${id}`)
// 获取签到列表
export const getSignInList = (params) => request.basic.get('/api/v1/earn-point-logs', params)

View File

@ -106,4 +106,7 @@ export default {
signInSet:'签到设置', signInSet:'签到设置',
signInModule:'签到模块', signInModule:'签到模块',
signInLog:'核销记录', signInLog:'核销记录',
earnPointModule:'赚海贝模块',
earnPointLog:'赚海贝记录',
earnPointRule:'赚海贝规则',
} }

View File

@ -0,0 +1,40 @@
import { DollarOutlined } from '@ant-design/icons-vue'
export default [
{
path: 'earnPointModule',
name: 'earnPointModule',
component: 'RouteViewLayout',
meta: {
icon: DollarOutlined,
title: '赚海贝模块',
isMenu: true,
keepAlive: true,
permission: '*',
},
children: [
{
path: 'earnPointRule',
name: 'earnPointRule',
component: 'earnPointModule/earnPointRule/index.vue',
meta: {
title: '赚海贝设置',
isMenu: true,
keepAlive: true,
permission: '*',
},
},
{
path: 'earnPointLog',
name: 'earnPointLog',
component: 'earnPointModule/earnPointLog/index.vue',
meta: {
title: '赚海贝记录',
isMenu: true,
keepAlive: true,
permission: '*',
},
},
],
},
]

View File

@ -20,6 +20,7 @@ import ycequite from './ycequite'
import signIn from './signIn' import signIn from './signIn'
import lottery from './lottery' import lottery from './lottery'
import equiteMgt from './equiteMgt' import equiteMgt from './equiteMgt'
import earnPoint from './earnPoint'
export default [ export default [
...home, ...home,
@ -43,5 +44,6 @@ export default [
...lottery, ...lottery,
...ycequite, ...ycequite,
...equiteMgt, ...equiteMgt,
...signIn ...signIn,
...earnPoint,
] ]

View File

@ -0,0 +1,192 @@
<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">
<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 === 'customerName'">
<span>{{ record.customerName }}</span>
</template>
<template v-if="column.dataIndex === 'customerPhone'">
<span>{{ record.customerPhone }}</span>
</template>
<template v-if="column.dataIndex === 'duration'">
<span>{{ record.duration }}</span>
</template>
<template v-if="column.dataIndex === 'earnAt'">
<span>{{ dayjs(record.earnAt).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template v-if="column.dataIndex === 'points'">
<span>{{ record.points }}</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="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>
<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 { config } from '@/config'
import { usePagination } from '@/hooks'
// import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n'
import { signInEnum } from "@/enums/useEnum"
import dayjs from 'dayjs'
defineOptions({
name: 'signInSet',
})
const { t } = useI18n() // t
const columns = [
{ title: '浏览时长/秒', dataIndex: 'duration' },
{ title: '赚取时间', dataIndex: 'earnAt', align: 'center' },
{ title: '奖励积分', dataIndex: 'points', width: 100, align: 'center' },
{ title: '客户名称', dataIndex: 'customerName', align: 'center' },
{ title: '客户电话', dataIndex: 'customerPhone', width: 130, align: 'center' },
// { title: '', dataIndex: 'status', align: 'center' },
// { title: t('button.action'), key: 'action', fixed: 'right', width: 100, 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.earnPoint
.getSignInList({
pageSize,
current: 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.earnPoint.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()
}
})()
})
},
})
}
/**
* 分页
*/
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>

View File

@ -0,0 +1,190 @@
<template>
<a-modal :open="modal.open" :title="modal.title" :width="800" :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="duration">
<a-input :placeholder="'请输入浏览时长'" v-model:value="formData.duration"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'次数/每周期'" name="maxCount">
<a-input-number :placeholder="'请输入次数/每周期'" v-model:value="formData.maxCount"
style="width: 100%;"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'积分数'" name="points" >
<a-input-number :placeholder="'请输入积分数'" v-model:value="formData.points"
style="width: 100%;"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'天数/每周期'" name="maxDays">
<a-input-number :placeholder="'请输入天数/每周期'" v-model:value="formData.maxDays"
style="width: 100%;"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'信件内容'">
<x-editor v-model="editorContent" :uploadHandler="uploadHandler"
:height="300"></x-editor>
</a-form-item>
</a-col>
<a-col :span="24">
<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-row>
</a-card>
</a-form>
</a-spin>
</a-modal>
</template>
<script setup>
import { ref, h, 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 { spliceUrl,decryptString,encryptString } from "@/utils/util.js"
import { signInEnum } 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 listData = ref([])
const numChecked = ref(false)
const editorContent = ref('')
const probabilityChecked = ref(false)
formRules.value = {
duration: { required: true, message: '请输入浏览时长' },
points: { required: true, message: '请输入积分' },
maxCount: { required: true, message: '请输入次数' },
maxDays: { required: true, message: '请输入天数/每周期', trigger: 'change' },
status: [{ required: true, message: '请输入状态', trigger: 'change' }],
content: { required: true, message: '请输入信件内容' },
}
/**
* 新建
*/
function handleCreate() {
showModal({
type: 'create',
title: '签到设置',
})
formData.value.status = 'enabled'
}
/**
* 编辑
*/
async function handleEdit(record = {}) {
showModal({
type: 'edit',
title: '签到设置',
})
try {
showSpining()
const { data, success } = await apis.earnPoint.getItem(record.id).catch()
if (!success) {
hideModal()
return
}
hideSpining()
formData.value = {
...data,
cycleType: data.maxDays < 0 ? '自然月' : '固定天数',
}
editorContent.value = decryptString(data.content) || ''
} catch (error) {
message.error({ content: error.message })
hideSpining()
}
}
/**
* 确定
*/
function handleOk() {
formRef.value.validateFields().then(async (values) => {
try {
showLoading()
const params = {
...formData.value,
content: encryptString(editorContent.value),
}
let result = null
switch (modal.value.type) {
case 'create':
result = await apis.earnPoint.createProject(params).catch((error) => {
console.log(error.message)
throw new Error(error)
})
break
case 'edit':
result = await apis.earnPoint.updateItem(formData.value.id, params).catch(() => {
console.log(error.message)
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()
})
}
// setup
/**
* 取消
*/
function handleCancel() {
hideModal()
}
/**
* 关闭后
*/
function onAfterClose() {
resetForm()
hideLoading()
}
defineExpose({
handleCreate,
handleEdit,
})
</script>
<style lang="less" scoped></style>

View File

@ -0,0 +1,209 @@
<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 === 'duration'">
<span>{{ record.duration }}</span>
</template>
<template v-if="column.dataIndex === 'maxCount'">
<span>{{ signInEnum.getName(record.maxCount) }}</span>
</template>
<template v-if="column.dataIndex === 'maxDays'">
<span>{{ record.maxDays }}</span>
</template>
<template v-if="column.dataIndex === 'content'">
<span style="cursor: pointer;color:#1677ff;"
@click="content = decryptString(record.content) || '';qropen = 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="'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="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="qropen" :title="'查看内容'" @ok="qropen = false" :footer="null">
<a-card>
<div style="height: 450px;overflow-y: auto;">
<div v-html="content" ></div>
</div>
</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 { config } from '@/config'
import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n'
import { signInEnum } from "@/enums/useEnum"
import { decryptString } from "@/utils/util"
defineOptions({
name: 'signInSet',
})
const { t } = useI18n() // t
const columns = [
{ title: '浏览时长/秒', dataIndex: 'duration' },
{ title: '次数/每周期', dataIndex: 'maxCount',align: 'center' },
{ title: '奖励积分', dataIndex: 'points', width: 100, align: 'center' },
{ title: '天数/每周期', dataIndex: 'maxDays', align: 'center' },
{ title: '规则内容', dataIndex: 'content', align: 'center' },
{ title: '状态', dataIndex: 'status', align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
]
const content = ref('')
const qropen=ref(false)
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.earnPoint
.getProjectList({
pageSize,
current: 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.earnPoint.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()
}
})()
})
},
})
}
/**
* 分页
*/
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>