Merge remote-tracking branch 'yudao/dev' into dev-to-dev
This commit is contained in:
commit
a5330958ba
@ -8,32 +8,12 @@ export interface ConfigVO {
|
||||
tradeGivePoint: number
|
||||
}
|
||||
|
||||
// 查询积分设置列表
|
||||
export const getConfigPage = async (params) => {
|
||||
return await request.get({ url: `/point/config/page`, params })
|
||||
}
|
||||
|
||||
// 查询积分设置详情
|
||||
export const getConfig = async (id: number) => {
|
||||
return await request.get({ url: `/point/config/get?id=` + id })
|
||||
export const getConfig = async () => {
|
||||
return await request.get({ url: `/point/config/get` })
|
||||
}
|
||||
|
||||
// 新增积分设置
|
||||
export const createConfig = async (data: ConfigVO) => {
|
||||
return await request.post({ url: `/point/config/create`, data })
|
||||
}
|
||||
|
||||
// 修改积分设置
|
||||
export const updateConfig = async (data: ConfigVO) => {
|
||||
return await request.put({ url: `/point/config/update`, data })
|
||||
}
|
||||
|
||||
// 删除积分设置
|
||||
export const deleteConfig = async (id: number) => {
|
||||
return await request.delete({ url: `/point/config/delete?id=` + id })
|
||||
}
|
||||
|
||||
// 导出积分设置 Excel
|
||||
export const exportConfig = async (params) => {
|
||||
return await request.download({ url: `/point/config/export-excel`, params })
|
||||
// 新增修改积分设置
|
||||
export const saveConfig = async (data: ConfigVO) => {
|
||||
return await request.put({ url: `/point/config/save`, data })
|
||||
}
|
||||
|
@ -146,9 +146,8 @@ export enum DICT_TYPE {
|
||||
MP_MESSAGE_TYPE = 'mp_message_type', // 消息类型
|
||||
|
||||
// ========== MALL - 会员模块 ==========
|
||||
// 积分模块 TODO 芋艿:改成 member_ 前缀;包括枚举和值;
|
||||
POINT_BIZ_TYPE = 'point_biz_type',
|
||||
POINT_STATUS = 'point_status',
|
||||
MEMBER_POINT_BIZ_TYPE = 'member_point_biz_type', // 积分的业务类型
|
||||
MEMBER_POINT_STATUS = 'member_point_status', // 积分的状态
|
||||
|
||||
// ========== MALL - 商品模块 ==========
|
||||
PRODUCT_UNIT = 'product_unit', // 商品单位
|
||||
|
@ -7,6 +7,7 @@ import SkuList from './SkuList.vue'
|
||||
|
||||
import { Spu } from '@/api/mall/product/spu'
|
||||
|
||||
// TODO @puhui999:Properties 改成 Property 更合适?
|
||||
interface Properties {
|
||||
id: number
|
||||
name: string
|
||||
@ -30,8 +31,10 @@ interface RuleConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品通用函数
|
||||
* 获得商品的规格列表
|
||||
*
|
||||
* @param spu
|
||||
* @return Property 规格列表
|
||||
*/
|
||||
const getPropertyList = (spu: Spu): Properties[] => {
|
||||
// 直接拿返回的 skus 属性逆向生成出 propertyList
|
||||
|
@ -437,6 +437,7 @@ const categoryList = ref() // 分类树
|
||||
const categoryString = (categoryId) => {
|
||||
return treeToString(categoryList.value, categoryId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验所选是否为二级及以下节点
|
||||
*/
|
||||
@ -446,6 +447,7 @@ const nodeClick = () => {
|
||||
message.warning('必须选择二级及以下节点!!')
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getTabsCount()
|
||||
|
@ -256,7 +256,6 @@ const imagePreview = (imgUrl: string) => {
|
||||
|
||||
const categoryList = ref() // 分类树
|
||||
|
||||
// TODO @puhui999:商品搜索的时候,可以通过一级搜二级;所以这个校验可以去掉哈;也就是说,只允许挂在二级,但是一级可搜索到
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
|
@ -7,6 +7,7 @@ type SpuProperty<T> = {
|
||||
spuDetail: T
|
||||
propertyList: Properties[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供商品活动商品选择通用组件
|
||||
*/
|
||||
|
@ -89,6 +89,8 @@ const openForm = (type: string, id?: number) => {
|
||||
const handleDelete = (id: number) => {
|
||||
tableMethods.delList(id, false)
|
||||
}
|
||||
|
||||
// TODO @puhui:是不是直接叫 configList 就好啦
|
||||
const seckillConfigAllSimple = ref([]) // 时段配置精简列表
|
||||
const convertSeckillConfigNames = computed(
|
||||
() => (row) =>
|
||||
@ -96,6 +98,7 @@ const convertSeckillConfigNames = computed(
|
||||
?.filter((item) => row.configIds.includes(item.id))
|
||||
?.map((config) => config.name)
|
||||
)
|
||||
|
||||
const expandChange = (row, expandedRows) => {
|
||||
// TODO puhui:等 CRUD 完事后弄
|
||||
console.log(row, expandedRows)
|
||||
|
@ -219,7 +219,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status', // TODO @puhui999:状态在 table 格式化不对;建表插入的数据状态值不对,改为 0 或 1 就好了
|
||||
field: 'status',
|
||||
dictType: DICT_TYPE.COMMON_STATUS,
|
||||
dictClass: 'number',
|
||||
isForm: false,
|
||||
|
93
src/views/member/point/config/index.vue
Normal file
93
src/views/member/point/config/index.vue
Normal file
@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="120px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="hideId" v-show="false">
|
||||
<el-input v-model="formData.id" />
|
||||
</el-form-item>
|
||||
<!-- TODO @xiaqing:展示给用户的字段名,可以和 crmeb 保持一直,然后每一个表单都有类似 crmeb 的 tip;例如说:积分抵用比例(1积分抵多少金额)单位:元 -->
|
||||
<el-form-item label="积分抵扣" prop="tradeDeductEnable">
|
||||
<el-switch v-model="formData.tradeDeductEnable" />
|
||||
</el-form-item>
|
||||
<!-- TODO @xiaqing:用户看到的是元,最多 2 位;分是后端的存储哈 -->
|
||||
<el-form-item label="抵扣单位(分)" prop="tradeDeductUnitPrice">
|
||||
<el-input-number
|
||||
v-model="formData.tradeDeductUnitPrice"
|
||||
placeholder="请输入抵扣单位(分)"
|
||||
style="width: 300px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="积分抵扣最大值" prop="tradeDeductMaxPrice">
|
||||
<el-input-number
|
||||
v-model="formData.tradeDeductMaxPrice"
|
||||
placeholder="请输入积分抵扣最大值"
|
||||
style="width: 300px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="1 元赠送多少分" prop="tradeGivePoint">
|
||||
<el-input-number
|
||||
v-model="formData.tradeGivePoint"
|
||||
placeholder="请输入 1 元赠送多少积分"
|
||||
style="width: 300px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit">提交</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import * as ConfigApi from '@/api/point/config'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
tradeDeductEnable: undefined,
|
||||
tradeDeductUnitPrice: undefined,
|
||||
tradeDeductMaxPrice: undefined,
|
||||
tradeGivePoint: undefined
|
||||
})
|
||||
const formRules = reactive({})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 修改积分配置 */
|
||||
const onSubmit = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as ConfigApi.ConfigVO
|
||||
await ConfigApi.saveConfig(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
dialogVisible.value = false
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 获得积分配置 */
|
||||
const getConfig = async () => {
|
||||
try {
|
||||
const data = await ConfigApi.getConfig()
|
||||
formData.value = data
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getConfig()
|
||||
})
|
||||
</script>
|
@ -13,7 +13,7 @@
|
||||
<el-form-item label="业务类型" prop="bizType">
|
||||
<el-select v-model="formData.bizType" placeholder="请选择业务类型">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.POINT_BIZ_TYPE)"
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
@ -41,7 +41,7 @@
|
||||
<el-form-item label="积分状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="积分状态">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.POINT_STATUS)"
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_POINT_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
@ -157,6 +157,7 @@ const submitForm = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @xiaqing:不需要更新操作哇?
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
@ -25,7 +25,7 @@
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.POINT_BIZ_TYPE)"
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
@ -50,14 +50,14 @@
|
||||
<el-form-item label="积分状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.POINT_STATUS)"
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.MEMBER_POINT_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发生时间" prop="createDate">
|
||||
<el-form-item label="获得时间" prop="createDate">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createDate"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@ -71,18 +71,6 @@
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button type="primary" @click="openForm('create')" v-hasPermi="['point:record:create']">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['point:record:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
@ -90,13 +78,18 @@
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="序号" align="center" prop="id" />
|
||||
<el-table-column label="业务编码" align="center" prop="bizId" />
|
||||
<el-table-column label="业务类型" align="center" prop="bizType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.POINT_BIZ_TYPE" :value="scope.row.bizType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编号" align="center" prop="id" />
|
||||
<!-- TODO @xiaqing:展示用户的昵称哈; -->
|
||||
<el-table-column label="用户" align="center" prop="userId" />
|
||||
<el-table-column label="积分标题" align="center" prop="title" />
|
||||
<el-table-column label="积分描述" align="center" prop="description" />
|
||||
<el-table-column
|
||||
label="获得时间"
|
||||
align="center"
|
||||
prop="createDate"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<!-- todo @xiaqing:可以参考 crmeb 的展示,把积分和增加减少放一起,用红色和绿色展示 -->
|
||||
<el-table-column
|
||||
label="操作类型"
|
||||
align="center"
|
||||
@ -107,16 +100,19 @@
|
||||
}
|
||||
"
|
||||
/>
|
||||
<el-table-column label="积分标题" align="center" prop="title" />
|
||||
<el-table-column label="积分描述" align="center" prop="description" />
|
||||
<el-table-column label="积分" align="center" prop="point" />
|
||||
<el-table-column label="变动后的积分" align="center" prop="totalPoint" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<el-table-column label="业务编码" align="center" prop="bizId" />
|
||||
<el-table-column label="业务类型" align="center" prop="bizType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.POINT_STATUS" :value="scope.row.status" />
|
||||
<dict-tag :type="DICT_TYPE.MEMBER_POINT_BIZ_TYPE" :value="scope.row.bizType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.MEMBER_POINT_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用户id" align="center" prop="userId" />
|
||||
<el-table-column
|
||||
label="冻结时间"
|
||||
align="center"
|
||||
@ -129,32 +125,6 @@
|
||||
prop="thawingTime"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="发生时间"
|
||||
align="center"
|
||||
prop="createDate"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['point:record:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['point:record:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
@ -172,15 +142,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import * as RecordApi from '@/api/point/record'
|
||||
import RecordForm from './RecordForm.vue'
|
||||
|
||||
defineOptions({ name: 'PointRecord' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
@ -195,7 +161,6 @@ const queryParams = reactive({
|
||||
createDate: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
@ -221,40 +186,6 @@ const resetQuery = () => {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await RecordApi.deleteRecord(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await RecordApi.exportRecord(queryParams)
|
||||
download.excel(data, '用户积分记录.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
@ -8,6 +8,7 @@
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<!-- TODO @xiaqing:搜索可以去掉,因为一共就没几条配置哈 -->
|
||||
<el-form-item label="签到天数" prop="day">
|
||||
<el-input
|
||||
v-model="queryParams.day"
|
||||
@ -35,6 +36,7 @@
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['point:sign-in-config:export']"
|
||||
>
|
||||
<!-- TODO @xiaqing:四个功能的导出都可以去掉 -->
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
@ -44,15 +46,10 @@
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="序号" align="center" prop="id" v-if="false" />
|
||||
<!-- TODO @xiaqing:展示优化下,改成第 1 天、第 2 天这种 -->
|
||||
<el-table-column label="签到天数" align="center" prop="day" />
|
||||
<el-table-column label="签到分数" align="center" prop="point" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="获得积分" align="center" prop="point" />
|
||||
<!-- TODO @xiaqing:展示一个是否开启 -->
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@ -88,7 +85,6 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import * as SignInConfigApi from '@/api/point/signInConfig'
|
||||
import SignInConfigForm from './SignInConfigForm.vue'
|
||||
@ -109,6 +105,7 @@ const queryParams = reactive({
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
// TODO @xiaqing:可以不分页;
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
@ -40,14 +40,6 @@
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- @click="openForm('create')"-->
|
||||
<!-- v-hasPermi="['point:sign-in-record:create']"-->
|
||||
<!-- >-->
|
||||
<!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
|
||||
<!-- </el-button>-->
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@ -64,10 +56,11 @@
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="序号" align="center" prop="id" />
|
||||
<el-table-column label="编号" align="center" prop="id" />
|
||||
<!-- TODO @xiaqing:展示用户昵称 -->
|
||||
<el-table-column label="签到用户" align="center" prop="userId" />
|
||||
<el-table-column label="签到天数" align="center" prop="day" />
|
||||
<el-table-column label="签到的分数" align="center" prop="point" />
|
||||
<el-table-column label="获得积分" align="center" prop="point" />
|
||||
<el-table-column
|
||||
label="签到时间"
|
||||
align="center"
|
||||
@ -76,14 +69,6 @@
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<!-- <el-button-->
|
||||
<!-- link-->
|
||||
<!-- type="primary"-->
|
||||
<!-- @click="openForm('update', scope.row.id)"-->
|
||||
<!-- v-hasPermi="['point:sign-in-record:update']"-->
|
||||
<!-- >-->
|
||||
<!-- 编辑-->
|
||||
<!-- </el-button>-->
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
@ -1,122 +0,0 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" style="width: 600px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="120px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="积分抵扣" prop="tradeDeductEnable">
|
||||
<el-select v-model="formData.tradeDeductEnable" placeholder="请选择是否开启">
|
||||
<el-option
|
||||
v-for="dict in options"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="抵扣单位(元)" prop="tradeDeductUnitPrice">
|
||||
<el-input v-model="formData.tradeDeductUnitPrice" placeholder="请输入抵扣单位(元)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="积分抵扣最大值" prop="tradeDeductMaxPrice">
|
||||
<el-input v-model="formData.tradeDeductMaxPrice" placeholder="请输入积分抵扣最大值" />
|
||||
</el-form-item>
|
||||
<el-form-item label="1元赠送多少分" prop="tradeGivePoint">
|
||||
<el-input v-model="formData.tradeGivePoint" placeholder="请输入1元赠送多少分" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import * as ConfigApi from '@/api/point/config'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
tradeDeductEnable: undefined,
|
||||
tradeDeductUnitPrice: undefined,
|
||||
tradeDeductMaxPrice: undefined,
|
||||
tradeGivePoint: undefined
|
||||
})
|
||||
const formRules = reactive({})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: '1',
|
||||
label: '是'
|
||||
},
|
||||
{
|
||||
value: '0',
|
||||
label: '否'
|
||||
}
|
||||
]
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await ConfigApi.getConfig(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as ConfigApi.ConfigVO
|
||||
if (formType.value === 'create') {
|
||||
await ConfigApi.createConfig(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await ConfigApi.updateConfig(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
tradeDeductEnable: undefined,
|
||||
tradeDeductUnitPrice: undefined,
|
||||
tradeDeductMaxPrice: undefined,
|
||||
tradeGivePoint: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
@ -1,202 +0,0 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="是否开启" prop="tradeDeductEnable">
|
||||
<el-select
|
||||
v-model="queryParams.tradeDeductEnable"
|
||||
placeholder="请选择是否开启"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in options"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button type="primary" @click="openForm('create')" v-hasPermi="['point:config:create']">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['point:config:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="序号" align="center" prop="id" />
|
||||
<el-table-column
|
||||
label="积分抵扣(是否开启)"
|
||||
align="center"
|
||||
prop="tradeDeductEnable"
|
||||
:formatter="tradeDeductFormat"
|
||||
/>
|
||||
<el-table-column label="抵扣单位(元)" align="center" prop="tradeDeductUnitPrice" />
|
||||
<el-table-column label="积分抵扣最大值" align="center" prop="tradeDeductMaxPrice" />
|
||||
<el-table-column label="1元赠送多少分" align="center" prop="tradeGivePoint" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="变更时间"
|
||||
align="center"
|
||||
prop="updateTime"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['point:config:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['point:config:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ConfigForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import * as ConfigApi from '@/api/point/config'
|
||||
import ConfigForm from './ConfigForm.vue'
|
||||
|
||||
defineOptions({ name: 'PointConfig' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
tradeDeductEnable: null
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: '1',
|
||||
label: '是'
|
||||
},
|
||||
{
|
||||
value: '0',
|
||||
label: '否'
|
||||
}
|
||||
]
|
||||
|
||||
const tradeDeductFormat = (row, column, cellValue) => {
|
||||
return cellValue === 1 ? '是' : '否'
|
||||
}
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await ConfigApi.getConfigPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await ConfigApi.deleteConfig(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await ConfigApi.exportConfig(queryParams)
|
||||
download.excel(data, '积分设置.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user