mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-09-17 18:41:55 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -148,6 +148,8 @@ import { ElLoading } from 'element-plus'
|
||||
import LoginFormTitle from './LoginFormTitle.vue'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
|
||||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
||||
const { wsCache } = useCache()
|
||||
import { useIcon } from '@/hooks/web/useIcon'
|
||||
|
||||
import * as authUtil from '@/utils/auth'
|
||||
@@ -244,6 +246,7 @@ const handleLogin = async (params) => {
|
||||
if (!res) {
|
||||
return
|
||||
}
|
||||
wsCache.delete(CACHE_KEY.USER) // 清除上次登录用户信息
|
||||
ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在加载系统中...',
|
||||
|
@@ -30,7 +30,7 @@
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
|
@@ -46,7 +46,7 @@
|
||||
<el-form-item label="请求时间" prop="beginTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.beginTime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
|
@@ -46,7 +46,7 @@
|
||||
<el-form-item label="异常时间" prop="exceptionTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.exceptionTime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
|
@@ -37,7 +37,7 @@
|
||||
end-placeholder="结束日期"
|
||||
start-placeholder="开始日期"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
@@ -67,7 +67,7 @@
|
||||
<el-form-item v-if="formData.storage === 11" label="连接模式" prop="config.mode">
|
||||
<el-radio-group v-model="formData.config.mode">
|
||||
<el-radio key="Active" label="Active">主动模式</el-radio>
|
||||
<el-radio key="Passive" label="Passive">主动模式</el-radio>
|
||||
<el-radio key="Passive" label="Passive">被动模式</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<!-- S3 -->
|
||||
|
@@ -129,7 +129,6 @@ const getSpuDetails = async (
|
||||
if (typeof products !== 'undefined') {
|
||||
const product = products.find((item) => item.skuId === sku.id)
|
||||
if (product) {
|
||||
// 分转元
|
||||
product.bargainFirstPrice = formatToFraction(product.bargainFirstPrice)
|
||||
product.bargainPrice = formatToFraction(product.bargainPrice)
|
||||
}
|
@@ -65,8 +65,8 @@
|
||||
import { allSchemas } from './bargainActivity.data'
|
||||
import * as BargainActivityApi from '@/api/mall/promotion/bargain/bargainActivity'
|
||||
import BargainActivityForm from './BargainActivityForm.vue'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { createImageViewer } from '@/components/ImageViewer'
|
||||
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
|
||||
|
||||
defineOptions({ name: 'PromotionBargainActivity' })
|
||||
|
||||
@@ -98,20 +98,10 @@ const handleDelete = (id: number) => {
|
||||
tableMethods.delList(id, false)
|
||||
}
|
||||
|
||||
// TODO @puhui999:要不还是使用原生的 element plus 做。感觉 crud schema 复杂界面,做起来麻烦
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
/**
|
||||
TODO
|
||||
后面准备封装成一个函数来操作 tableColumns 重新排列:比如说需求是表单上商品选择是在后面的而列表展示的时候需要调到位置。
|
||||
封装效果支持批量操作,给出 field 和需要插入的位置,例:[{field:'spuId',index: 1}] 效果为把 field 为 spuId 的 column 移动到第一个位置
|
||||
*/
|
||||
// 处理一下表格列让商品往前
|
||||
const index = allSchemas.tableColumns.findIndex((item) => item.field === 'spuId')
|
||||
const column = cloneDeep(allSchemas.tableColumns[index])
|
||||
allSchemas.tableColumns.splice(index, 1)
|
||||
// 添加到开头
|
||||
allSchemas.tableColumns.unshift(column)
|
||||
// 获得活动列表
|
||||
sortTableColumns(allSchemas.tableColumns, 'spuId')
|
||||
getList()
|
||||
})
|
||||
</script>
|
@@ -19,7 +19,7 @@
|
||||
<el-table-column align="center" label="拼团价格(元)" min-width="168">
|
||||
<template #default="{ row: sku }">
|
||||
<el-input-number
|
||||
v-model="sku.productConfig.activePrice"
|
||||
v-model="sku.productConfig.combinationPrice"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.1"
|
||||
@@ -45,6 +45,7 @@ import { SpuAndSkuList, SpuProperty, SpuSelect } from '@/views/mall/promotion/co
|
||||
import { getPropertyList, RuleConfig } from '@/views/mall/product/spu/components'
|
||||
import * as ProductSpuApi from '@/api/mall/product/spu'
|
||||
import { convertToInteger, formatToFraction } from '@/utils'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
defineOptions({ name: 'PromotionCombinationActivityForm' })
|
||||
|
||||
@@ -65,8 +66,8 @@ const spuList = ref<CombinationActivityApi.SpuExtension[]>([]) // 选择的 spu
|
||||
const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([])
|
||||
const ruleConfig: RuleConfig[] = [
|
||||
{
|
||||
name: 'productConfig.activePrice',
|
||||
rule: (arg) => arg > 0.01,
|
||||
name: 'productConfig.combinationPrice',
|
||||
rule: (arg) => arg >= 0.01,
|
||||
message: '商品拼团价格不能小于0.01 !!!'
|
||||
}
|
||||
]
|
||||
@@ -98,13 +99,12 @@ const getSpuDetails = async (
|
||||
let config: CombinationProductVO = {
|
||||
spuId: spu.id!,
|
||||
skuId: sku.id!,
|
||||
activePrice: 0
|
||||
combinationPrice: 0
|
||||
}
|
||||
if (typeof products !== 'undefined') {
|
||||
const product = products.find((item) => item.skuId === sku.id)
|
||||
if (product) {
|
||||
// 分转元
|
||||
product.activePrice = formatToFraction(product.activePrice)
|
||||
product.combinationPrice = formatToFraction(product.combinationPrice)
|
||||
}
|
||||
config = product || config
|
||||
}
|
||||
@@ -162,13 +162,14 @@ const submitForm = async () => {
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO
|
||||
const products = spuAndSkuListRef.value.getSkuConfigs('productConfig')
|
||||
products.forEach((item: CombinationProductVO) => {
|
||||
// 拼团价格元转分
|
||||
item.activePrice = convertToInteger(item.activePrice)
|
||||
// 获得拼团商品配置
|
||||
const products = cloneDeep(spuAndSkuListRef.value.getSkuConfigs('productConfig'))
|
||||
products.forEach((item: CombinationActivityApi.CombinationProductVO) => {
|
||||
item.combinationPrice = convertToInteger(item.combinationPrice)
|
||||
})
|
||||
const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO
|
||||
data.products = products
|
||||
// 真正提交
|
||||
if (formType.value === 'create') {
|
||||
await CombinationActivityApi.createCombinationActivity(data)
|
||||
message.success(t('common.createSuccess'))
|
@@ -122,13 +122,13 @@ const crudSchemas = reactive<CrudSchema[]>([
|
||||
},
|
||||
{
|
||||
label: '开团组数',
|
||||
field: 'totalNum',
|
||||
field: 'totalCount',
|
||||
isSearch: false,
|
||||
isForm: false
|
||||
},
|
||||
{
|
||||
label: '成团组数',
|
||||
field: 'successNum',
|
||||
field: 'successCount',
|
||||
isSearch: false,
|
||||
isForm: false
|
||||
},
|
@@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
|
||||
@@ -10,8 +12,7 @@
|
||||
type="primary"
|
||||
@click="openForm('create')"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" />
|
||||
新增
|
||||
<Icon class="mr-5px" icon="ep:plus" /> 新增
|
||||
</el-button>
|
||||
</template>
|
||||
</Search>
|
||||
@@ -65,7 +66,7 @@
|
||||
import { allSchemas } from './combinationActivity.data'
|
||||
import * as CombinationActivityApi from '@/api/mall/promotion/combination/combinationActivity'
|
||||
import CombinationActivityForm from './CombinationActivityForm.vue'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
|
||||
import { createImageViewer } from '@/components/ImageViewer'
|
||||
|
||||
defineOptions({ name: 'PromotionCombinationActivity' })
|
||||
@@ -98,20 +99,10 @@ const handleDelete = (id: number) => {
|
||||
tableMethods.delList(id, false)
|
||||
}
|
||||
|
||||
// TODO @puhui999:要不还是使用原生的 element plus 做。感觉 crud schema 复杂界面,做起来麻烦
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
/**
|
||||
TODO
|
||||
后面准备封装成一个函数来操作 tableColumns 重新排列:比如说需求是表单上商品选择是在后面的而列表展示的时候需要调到位置。
|
||||
封装效果支持批量操作,给出 field 和需要插入的位置,例:[{field:'spuId',index: 1}] 效果为把 field 为 spuId 的 column 移动到第一个位置
|
||||
*/
|
||||
// 处理一下表格列让商品往前
|
||||
const index = allSchemas.tableColumns.findIndex((item) => item.field === 'spuId')
|
||||
const column = cloneDeep(allSchemas.tableColumns[index])
|
||||
allSchemas.tableColumns.splice(index, 1)
|
||||
// 添加到开头
|
||||
allSchemas.tableColumns.unshift(column)
|
||||
// 获得活动列表
|
||||
sortTableColumns(allSchemas.tableColumns, 'spuId')
|
||||
getList()
|
||||
})
|
||||
</script>
|
@@ -1,12 +1,19 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
|
||||
<el-form
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
:model="queryParams"
|
||||
class="-mb-15px"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="会员昵称" prop="nickname">
|
||||
<el-input
|
||||
v-model="queryParams.nickname"
|
||||
class="!w-240px"
|
||||
placeholder="请输入会员昵称"
|
||||
clearable
|
||||
@keyup="handleQuery"
|
||||
@@ -15,27 +22,19 @@
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
style="width: 240px"
|
||||
type="datetimerange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
range-separator="-"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" /> 搜索
|
||||
</el-button>
|
||||
<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-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<!-- <el-row :gutter="10" class="mb8">
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
|
||||
</el-row> -->
|
||||
</ContentWrap>
|
||||
|
||||
<ContentWrap>
|
||||
@@ -86,43 +85,38 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['promotion:coupon:delete']"
|
||||
><Icon icon="ep:delete" :size="12" class="mr-1px" />回收</el-button
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(scope.row.id)"
|
||||
>
|
||||
回收
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="PromotionCoupon">
|
||||
import { deleteCoupon, getCouponPage } from '@/api/mall/promotion/coupon'
|
||||
import { deleteCoupon, getCouponPage } from '@/api/mall/promotion/coupon/coupon'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { FormInstance } from 'element-plus'
|
||||
|
||||
// 消息弹窗
|
||||
const message = useMessage()
|
||||
defineOptions({ name: 'PromotionCoupon' })
|
||||
|
||||
// 遮罩层
|
||||
const loading = ref(true)
|
||||
// 总条数
|
||||
const total = ref(0)
|
||||
// 优惠劵列表
|
||||
const list = ref([])
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 字典表格数据
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
@@ -130,9 +124,9 @@ const queryParams = reactive({
|
||||
createTime: [],
|
||||
status: undefined
|
||||
})
|
||||
// Tab 筛选
|
||||
const activeTab = ref('all')
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
const activeTab = ref('all') // Tab 筛选
|
||||
const statusTabs = reactive([
|
||||
{
|
||||
label: '全部',
|
||||
@@ -140,8 +134,6 @@ const statusTabs = reactive([
|
||||
}
|
||||
])
|
||||
|
||||
const queryFormRef = ref<FormInstance | null>(null)
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
@@ -168,16 +160,17 @@ const resetQuery = () => {
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row) => {
|
||||
const id = row.id
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 二次确认
|
||||
await message.confirm(
|
||||
'回收将会收回会员领取的待使用的优惠券,已使用的将无法回收,确定要回收所选优惠券吗?'
|
||||
)
|
||||
// 发起删除
|
||||
await deleteCoupon(id)
|
||||
getList()
|
||||
message.notifySuccess('回收成功')
|
||||
// 重新加载列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -187,6 +180,7 @@ const onTabChange = (tabName) => {
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
// 设置 statuses 过滤
|
||||
|
348
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
Normal file
348
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
Normal file
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="140px"
|
||||
>
|
||||
<el-form-item label="优惠券名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入优惠券名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券类型" prop="discountType">
|
||||
<el-radio-group v-model="formData.discountType">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.discountType === PromotionDiscountTypeEnum.PRICE.type"
|
||||
label="优惠券面额"
|
||||
prop="discountPrice"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="formData.discountPrice"
|
||||
placeholder="请输入优惠金额,单位:元"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.discountType === PromotionDiscountTypeEnum.PERCENT.type"
|
||||
label="优惠券折扣"
|
||||
prop="discountPercent"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="formData.discountPercent"
|
||||
placeholder="优惠券折扣不能小于 1 折,且不可大于 9.9 折"
|
||||
style="width: 400px"
|
||||
:precision="1"
|
||||
:min="1"
|
||||
:max="9.9"
|
||||
/>
|
||||
折
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.discountType === PromotionDiscountTypeEnum.PERCENT.type"
|
||||
label="最多优惠"
|
||||
prop="discountLimitPrice"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="formData.discountLimitPrice"
|
||||
placeholder="请输入最多优惠"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item label="满多少元可以使用" prop="usePrice">
|
||||
<el-input-number
|
||||
v-model="formData.usePrice"
|
||||
placeholder="无门槛请设为 0"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item label="领取方式" prop="takeType">
|
||||
<el-radio-group v-model="formData.takeType">
|
||||
<el-radio :key="1" :label="1">直接领取</el-radio>
|
||||
<el-radio :key="2" :label="2">指定发放</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="formData.takeType === 1" label="发放数量" prop="totalCount">
|
||||
<el-input-number
|
||||
v-model="formData.totalCount"
|
||||
placeholder="发放数量,没有之后不能领取或发放,-1 为不限制"
|
||||
style="width: 400px"
|
||||
:precision="0"
|
||||
:min="-1"
|
||||
/>
|
||||
张
|
||||
</el-form-item>
|
||||
<el-form-item v-if="formData.takeType === 1" label="每人限领个数" prop="takeLimitCount">
|
||||
<el-input-number
|
||||
v-model="formData.takeLimitCount"
|
||||
placeholder="设置为 -1 时,可无限领取"
|
||||
style="width: 400px"
|
||||
:precision="0"
|
||||
:min="-1"
|
||||
/>
|
||||
张
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期类型" prop="validityType">
|
||||
<el-radio-group v-model="formData.validityType">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_COUPON_TEMPLATE_VALIDITY_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.validityType === CouponTemplateValidityTypeEnum.DATE.type"
|
||||
label="固定日期"
|
||||
prop="validTimes"
|
||||
>
|
||||
<el-date-picker
|
||||
v-model="formData.validTimes"
|
||||
style="width: 240px"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="datetimerange"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.validityType === CouponTemplateValidityTypeEnum.TERM.type"
|
||||
label="领取日期"
|
||||
prop="fixedStartTerm"
|
||||
>
|
||||
第
|
||||
<el-input-number
|
||||
v-model="formData.fixedStartTerm"
|
||||
placeholder="0 为今天生效"
|
||||
style="width: 165px"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
/>
|
||||
至
|
||||
<el-input-number
|
||||
v-model="formData.fixedEndTerm"
|
||||
placeholder="请输入结束天数"
|
||||
style="width: 165px"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
/>
|
||||
天有效
|
||||
</el-form-item>
|
||||
<el-form-item label="活动商品" prop="productScope">
|
||||
<el-radio-group v-model="formData.productScope">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_PRODUCT_SCOPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="formData.productScope === PromotionProductScopeEnum.SPU.scope"
|
||||
prop="productSpuIds"
|
||||
>
|
||||
<el-select
|
||||
v-model="formData.productSpuIds"
|
||||
placeholder="请选择活动商品"
|
||||
clearable
|
||||
multiple
|
||||
filterable
|
||||
style="width: 400px"
|
||||
>
|
||||
<el-option v-for="item in productSpus" :key="item.id" :label="item.name" :value="item.id">
|
||||
<span style="float: left">{{ item.name }}</span>
|
||||
<span style="float: right; font-size: 13px; color: #8492a6">
|
||||
¥{{ (item.minPrice / 100.0).toFixed(2) }}
|
||||
</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
|
||||
import * as ProductSpuApi from '@/api/mall/product/spu'
|
||||
import {
|
||||
CouponTemplateValidityTypeEnum,
|
||||
PromotionDiscountTypeEnum,
|
||||
PromotionProductScopeEnum
|
||||
} from '@/utils/constants'
|
||||
|
||||
defineOptions({ name: 'CouponTemplateForm' })
|
||||
|
||||
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,
|
||||
name: undefined,
|
||||
discountType: PromotionDiscountTypeEnum.PRICE.type,
|
||||
discountPrice: undefined,
|
||||
discountPercent: undefined,
|
||||
discountLimitPrice: undefined,
|
||||
usePrice: undefined,
|
||||
takeType: 1,
|
||||
totalCount: undefined,
|
||||
takeLimitCount: undefined,
|
||||
validityType: CouponTemplateValidityTypeEnum.DATE.type,
|
||||
validTimes: [],
|
||||
validStartTime: undefined,
|
||||
validEndTime: undefined,
|
||||
fixedStartTerm: undefined,
|
||||
fixedEndTerm: undefined,
|
||||
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||
productSpuIds: []
|
||||
})
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '优惠券名称不能为空', trigger: 'blur' }],
|
||||
discountType: [{ required: true, message: '优惠券类型不能为空', trigger: 'change' }],
|
||||
discountPrice: [{ required: true, message: '优惠券面额不能为空', trigger: 'blur' }],
|
||||
discountPercent: [{ required: true, message: '优惠券折扣不能为空', trigger: 'blur' }],
|
||||
discountLimitPrice: [{ required: true, message: '最多优惠不能为空', trigger: 'blur' }],
|
||||
usePrice: [{ required: true, message: '满多少元可以使用不能为空', trigger: 'blur' }],
|
||||
takeType: [{ required: true, message: '领取方式不能为空', trigger: 'change' }],
|
||||
totalCount: [{ required: true, message: '发放数量不能为空', trigger: 'blur' }],
|
||||
takeLimitCount: [{ required: true, message: '每人限领个数不能为空', trigger: 'blur' }],
|
||||
validityType: [{ required: true, message: '有效期类型不能为空', trigger: 'change' }],
|
||||
validTimes: [{ required: true, message: '固定日期不能为空', trigger: 'change' }],
|
||||
fixedStartTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
|
||||
fixedEndTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
|
||||
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
|
||||
productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const productSpus = ref([]) // 商品列表
|
||||
|
||||
/** 打开弹窗 */
|
||||
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 {
|
||||
const data = await CouponTemplateApi.getCouponTemplate(id)
|
||||
formData.value = {
|
||||
...data,
|
||||
discountPrice: data.discountPrice !== undefined ? data.discountPrice / 100.0 : undefined,
|
||||
discountPercent:
|
||||
data.discountPercent !== undefined ? data.discountPercent / 10.0 : undefined,
|
||||
discountLimitPrice:
|
||||
data.discountLimitPrice !== undefined ? data.discountLimitPrice / 100.0 : undefined,
|
||||
usePrice: data.usePrice !== undefined ? data.usePrice / 100.0 : undefined,
|
||||
validTimes: [data.validStartTime, data.validEndTime]
|
||||
}
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
// 获得商品列表
|
||||
productSpus.value = await ProductSpuApi.getSpuSimpleList()
|
||||
}
|
||||
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,
|
||||
discountPrice:
|
||||
formData.value.discountPrice !== undefined ? formData.value.discountPrice * 100 : undefined,
|
||||
discountPercent:
|
||||
formData.value.discountPercent !== undefined
|
||||
? formData.value.discountPercent * 10
|
||||
: undefined,
|
||||
discountLimitPrice:
|
||||
formData.value.discountLimitPrice !== undefined
|
||||
? formData.value.discountLimitPrice * 100
|
||||
: undefined,
|
||||
usePrice: formData.value.usePrice !== undefined ? formData.value.usePrice * 100 : undefined,
|
||||
validStartTime:
|
||||
formData.value.validTimes && formData.value.validTimes.length === 2
|
||||
? formData.value.validTimes[0]
|
||||
: undefined,
|
||||
validEndTime:
|
||||
formData.value.validTimes && formData.value.validTimes.length === 2
|
||||
? formData.value.validTimes[1]
|
||||
: undefined
|
||||
} as CouponTemplateApi.CouponTemplateVO
|
||||
if (formType.value === 'create') {
|
||||
await CouponTemplateApi.createCouponTemplate(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await CouponTemplateApi.updateCouponTemplate(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
discountType: PromotionDiscountTypeEnum.PRICE.type,
|
||||
discountPrice: undefined,
|
||||
discountPercent: undefined,
|
||||
discountLimitPrice: undefined,
|
||||
usePrice: undefined,
|
||||
takeType: 1,
|
||||
totalCount: undefined,
|
||||
takeLimitCount: undefined,
|
||||
validityType: CouponTemplateValidityTypeEnum.DATE.type,
|
||||
validTimes: [],
|
||||
validStartTime: undefined,
|
||||
validEndTime: undefined,
|
||||
fixedStartTerm: undefined,
|
||||
fixedEndTerm: undefined,
|
||||
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||
productSpuIds: []
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
295
src/views/mall/promotion/coupon/template/index.vue
Executable file
295
src/views/mall/promotion/coupon/template/index.vue
Executable file
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
:model="queryParams"
|
||||
class="-mb-15px"
|
||||
label-width="82px"
|
||||
>
|
||||
<el-form-item label="优惠券名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
class="!w-240px"
|
||||
placeholder="请输入优惠劵名"
|
||||
clearable
|
||||
@keyup="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券类型" prop="discountType">
|
||||
<el-select
|
||||
v-model="queryParams.discountType"
|
||||
class="!w-240px"
|
||||
placeholder="请选择优惠券类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
class="!w-240px"
|
||||
placeholder="请选择优惠券状态"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</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
|
||||
v-hasPermi="['promotion:coupon-template:create']"
|
||||
plain
|
||||
type="primary"
|
||||
@click="openForm('create')"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
plain
|
||||
type="success"
|
||||
@click="$router.push('/promotion/coupon')"
|
||||
v-hasPermi="['promotion:coupon:query']"
|
||||
>
|
||||
<Icon icon="ep:operation" 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="name" />
|
||||
<el-table-column label="优惠券类型" align="center" prop="discountType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="scope.row.discountType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="优惠金额 / 折扣"
|
||||
align="center"
|
||||
prop="discount"
|
||||
:formatter="discountFormat"
|
||||
/>
|
||||
<el-table-column label="发放数量" align="center" prop="totalCount" />
|
||||
<el-table-column
|
||||
label="剩余数量"
|
||||
align="center"
|
||||
prop="totalCount"
|
||||
:formatter="(row) => row.totalCount - row.takeCount"
|
||||
/>
|
||||
<el-table-column
|
||||
label="领取上限"
|
||||
align="center"
|
||||
prop="takeLimitCount"
|
||||
:formatter="takeLimitCountFormat"
|
||||
/>
|
||||
<el-table-column
|
||||
label="有效期限"
|
||||
align="center"
|
||||
prop="validityType"
|
||||
width="190"
|
||||
:formatter="validityTypeFormat"
|
||||
/>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.status"
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPermi="['promotion:coupon-template:update']"
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['promotion:coupon-template:delete']"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<CouponTemplateForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
|
||||
import {
|
||||
CommonStatusEnum,
|
||||
CouponTemplateValidityTypeEnum,
|
||||
PromotionDiscountTypeEnum
|
||||
} from '@/utils/constants'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter, formatDate } from '@/utils/formatTime'
|
||||
import CouponTemplateForm from './CouponTemplateForm.vue'
|
||||
|
||||
defineOptions({ name: 'PromotionCouponTemplate' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 字典表格数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
status: null,
|
||||
type: null,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 执行查询
|
||||
const data = await CouponTemplateApi.getCouponTemplatePage(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 handleStatusChange = async (row: any) => {
|
||||
// 此时,row 已经变成目标状态了,所以可以直接提交请求和提示
|
||||
let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
||||
|
||||
try {
|
||||
await message.confirm('确认要"' + text + '""' + row.name + '"优惠劵吗?')
|
||||
await CouponTemplateApi.updateCouponTemplateStatus(row.id, row.status)
|
||||
message.success(text + '成功')
|
||||
} catch {
|
||||
// 异常时,需要将 row.status 状态重置回之前的
|
||||
row.status =
|
||||
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.confirm('是否确认删除优惠劵编号为"' + id + '"的数据项?')
|
||||
// 发起删除
|
||||
await CouponTemplateApi.deleteCouponTemplate(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// 格式化【优惠金额/折扣】
|
||||
const discountFormat = (row: any) => {
|
||||
if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) {
|
||||
return `¥${(row.discountPrice / 100.0).toFixed(2)}`
|
||||
}
|
||||
if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) {
|
||||
return `¥${(row.discountPrice / 100.0).toFixed(2)}`
|
||||
}
|
||||
return '未知【' + row.discountType + '】'
|
||||
}
|
||||
|
||||
// 格式化【领取上限】
|
||||
const takeLimitCountFormat = (row: any) => {
|
||||
if (row.takeLimitCount === -1) {
|
||||
return '无领取限制'
|
||||
}
|
||||
return `${row.takeLimitCount} 张/人`
|
||||
}
|
||||
|
||||
// 格式化【有效期限】
|
||||
const validityTypeFormat = (row: any) => {
|
||||
if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) {
|
||||
return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}`
|
||||
}
|
||||
if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) {
|
||||
return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用`
|
||||
}
|
||||
return '未知【' + row.validityType + '】'
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
@@ -1,614 +0,0 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="82px"
|
||||
>
|
||||
<el-form-item label="优惠券名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入优惠劵名"
|
||||
clearable
|
||||
@keyup="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券类型" prop="discountType">
|
||||
<el-select v-model="queryParams.discountType" placeholder="请选择优惠券类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择优惠券状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
style="width: 240px"
|
||||
type="datetimerange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @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-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['promotion:coupon-template:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" />新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
@click="$router.push('/promotion/coupon')"
|
||||
v-hasPermi="['promotion:coupon:query']"
|
||||
>
|
||||
<Icon icon="ep:operation" class="mr-5px" />会员优惠劵
|
||||
</el-button>
|
||||
</el-col>
|
||||
<!-- <right-toolbar v-model:showSearch="showSearch" @query-table="getList" /> -->
|
||||
</el-row>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="优惠券名称" align="center" prop="name" />
|
||||
<el-table-column label="优惠券类型" align="center" prop="discountType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PROMOTION_DISCOUNT_TYPE" :value="scope.row.discountType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="优惠金额 / 折扣"
|
||||
align="center"
|
||||
prop="discount"
|
||||
:formatter="discountFormat"
|
||||
/>
|
||||
<el-table-column label="发放数量" align="center" prop="totalCount" />
|
||||
<el-table-column
|
||||
label="剩余数量"
|
||||
align="center"
|
||||
prop="totalCount"
|
||||
:formatter="(row) => row.totalCount - row.takeCount"
|
||||
/>
|
||||
<el-table-column
|
||||
label="领取上限"
|
||||
align="center"
|
||||
prop="takeLimitCount"
|
||||
:formatter="takeLimitCountFormat"
|
||||
/>
|
||||
<el-table-column
|
||||
label="有效期限"
|
||||
align="center"
|
||||
prop="validityType"
|
||||
width="180"
|
||||
:formatter="validityTypeFormat"
|
||||
/>
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.status"
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['promotion:coupon-template:update']"
|
||||
>
|
||||
<Icon icon="ep:edit" :size="12" class="mr-1px" />
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['promotion:coupon-template:delete']"
|
||||
>
|
||||
<Icon icon="ep:delete" :size="12" class="mr-1px" />
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="140px">
|
||||
<el-form-item label="优惠券名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入优惠券名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券类型" prop="discountType">
|
||||
<el-radio-group v-model="form.discountType">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.discountType === PromotionDiscountTypeEnum.PRICE.type"
|
||||
label="优惠券面额"
|
||||
prop="discountPrice"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.discountPrice"
|
||||
placeholder="请输入优惠金额,单位:元"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.discountType === PromotionDiscountTypeEnum.PERCENT.type"
|
||||
label="优惠券折扣"
|
||||
prop="discountPercent"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.discountPercent"
|
||||
placeholder="优惠券折扣不能小于 1 折,且不可大于 9.9 折"
|
||||
style="width: 400px"
|
||||
:precision="1"
|
||||
:min="1"
|
||||
:max="9.9"
|
||||
/>
|
||||
折
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.discountType === PromotionDiscountTypeEnum.PERCENT.type"
|
||||
label="最多优惠"
|
||||
prop="discountLimitPrice"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.discountLimitPrice"
|
||||
placeholder="请输入最多优惠"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item label="满多少元可以使用" prop="usePrice">
|
||||
<el-input-number
|
||||
v-model="form.usePrice"
|
||||
placeholder="无门槛请设为 0"
|
||||
style="width: 400px"
|
||||
:precision="2"
|
||||
:min="0"
|
||||
/>
|
||||
元
|
||||
</el-form-item>
|
||||
<el-form-item label="领取方式" prop="takeType">
|
||||
<el-radio-group v-model="form.takeType">
|
||||
<el-radio :key="1" :label="1">直接领取</el-radio>
|
||||
<el-radio :key="2" :label="2">指定发放</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.takeType === 1" label="发放数量" prop="totalCount">
|
||||
<el-input-number
|
||||
v-model="form.totalCount"
|
||||
placeholder="发放数量,没有之后不能领取或发放,-1 为不限制"
|
||||
style="width: 400px"
|
||||
:precision="0"
|
||||
:min="-1"
|
||||
/>
|
||||
张
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.takeType === 1" label="每人限领个数" prop="takeLimitCount">
|
||||
<el-input-number
|
||||
v-model="form.takeLimitCount"
|
||||
placeholder="设置为 -1 时,可无限领取"
|
||||
style="width: 400px"
|
||||
:precision="0"
|
||||
:min="-1"
|
||||
/>
|
||||
张
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期类型" prop="validityType">
|
||||
<el-radio-group v-model="form.validityType">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_COUPON_TEMPLATE_VALIDITY_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.validityType === CouponTemplateValidityTypeEnum.DATE.type"
|
||||
label="固定日期"
|
||||
prop="validTimes"
|
||||
>
|
||||
<el-date-picker
|
||||
v-model="form.validTimes"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
type="datetimerange"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.validityType === CouponTemplateValidityTypeEnum.TERM.type"
|
||||
label="领取日期"
|
||||
prop="fixedStartTerm"
|
||||
>
|
||||
第
|
||||
<el-input-number
|
||||
v-model="form.fixedStartTerm"
|
||||
placeholder="0 为今天生效"
|
||||
style="width: 165px"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
/>
|
||||
至
|
||||
<el-input-number
|
||||
v-model="form.fixedEndTerm"
|
||||
placeholder="请输入结束天数"
|
||||
style="width: 165px"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
/>
|
||||
天有效
|
||||
</el-form-item>
|
||||
<el-form-item label="活动商品" prop="productScope">
|
||||
<el-radio-group v-model="form.productScope">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_PRODUCT_SCOPE)"
|
||||
:key="dict.value"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.productScope === PromotionProductScopeEnum.SPU.scope"
|
||||
prop="productSpuIds"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.productSpuIds"
|
||||
placeholder="请选择活动商品"
|
||||
clearable
|
||||
size="small"
|
||||
multiple
|
||||
filterable
|
||||
style="width: 400px"
|
||||
>
|
||||
<el-option v-for="item in productSpus" :key="item.id" :label="item.name" :value="item.id">
|
||||
<span style="float: left">{{ item.name }}</span>
|
||||
<span style="float: right; font-size: 13px; color: #8492a6"
|
||||
>¥{{ (item.minPrice / 100.0).toFixed(2) }}</span
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="PromotionCouponTemplate">
|
||||
import {
|
||||
createCouponTemplate,
|
||||
updateCouponTemplate,
|
||||
deleteCouponTemplate,
|
||||
getCouponTemplate,
|
||||
getCouponTemplatePage,
|
||||
updateCouponTemplateStatus
|
||||
} from '@/api/mall/promotion/couponTemplate'
|
||||
import {
|
||||
CommonStatusEnum,
|
||||
CouponTemplateValidityTypeEnum,
|
||||
PromotionDiscountTypeEnum,
|
||||
PromotionProductScopeEnum
|
||||
} from '@/utils/constants'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { getSpuSimpleList } from '@/api/mall/product/spu'
|
||||
import { dateFormatter, formatDate } from '@/utils/formatTime'
|
||||
import { FormInstance } from 'element-plus'
|
||||
|
||||
// 消息弹窗
|
||||
const message = useMessage()
|
||||
|
||||
// 遮罩层
|
||||
const loading = ref(true)
|
||||
// 显示搜索条件
|
||||
const showSearch = ref(true)
|
||||
// 总条数
|
||||
const total = ref(0)
|
||||
// 优惠劵列表
|
||||
const list = ref([])
|
||||
// 弹出层标题
|
||||
const title = ref('')
|
||||
// 是否显示弹出层
|
||||
const open = ref(false)
|
||||
// 查询参数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
status: null,
|
||||
type: null,
|
||||
createTime: []
|
||||
})
|
||||
// 表单参数
|
||||
const form = ref<any>({})
|
||||
// 表单校验
|
||||
const rules = {
|
||||
name: [{ required: true, message: '优惠券名称不能为空', trigger: 'blur' }],
|
||||
discountType: [{ required: true, message: '优惠券类型不能为空', trigger: 'change' }],
|
||||
discountPrice: [{ required: true, message: '优惠券面额不能为空', trigger: 'blur' }],
|
||||
discountPercent: [{ required: true, message: '优惠券折扣不能为空', trigger: 'blur' }],
|
||||
discountLimitPrice: [{ required: true, message: '最多优惠不能为空', trigger: 'blur' }],
|
||||
usePrice: [{ required: true, message: '满多少元可以使用不能为空', trigger: 'blur' }],
|
||||
takeType: [{ required: true, message: '领取方式不能为空', trigger: 'change' }],
|
||||
totalCount: [{ required: true, message: '发放数量不能为空', trigger: 'blur' }],
|
||||
takeLimitCount: [{ required: true, message: '每人限领个数不能为空', trigger: 'blur' }],
|
||||
validityType: [{ required: true, message: '有效期类型不能为空', trigger: 'change' }],
|
||||
validTimes: [{ required: true, message: '固定日期不能为空', trigger: 'change' }],
|
||||
fixedStartTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
|
||||
fixedEndTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
|
||||
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
|
||||
productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }]
|
||||
}
|
||||
// 商品列表
|
||||
const productSpus = ref([])
|
||||
const queryFormRef = ref<FormInstance | null>(null)
|
||||
const formRef = ref<FormInstance | null>(null)
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 执行查询
|
||||
const data = await getCouponTemplatePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
// 查询商品列表
|
||||
productSpus.value = await getSpuSimpleList()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
discountType: PromotionDiscountTypeEnum.PRICE.type,
|
||||
discountPrice: undefined,
|
||||
discountPercent: undefined,
|
||||
discountLimitPrice: undefined,
|
||||
usePrice: undefined,
|
||||
takeType: 1,
|
||||
totalCount: undefined,
|
||||
takeLimitCount: undefined,
|
||||
validityType: CouponTemplateValidityTypeEnum.DATE.type,
|
||||
validTimes: [],
|
||||
validStartTime: undefined,
|
||||
validEndTime: undefined,
|
||||
fixedStartTerm: undefined,
|
||||
fixedEndTerm: undefined,
|
||||
productScope: PromotionProductScopeEnum.ALL.scope,
|
||||
productSpuIds: []
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef?.value?.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '添加优惠劵'
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: any) => {
|
||||
reset()
|
||||
const id = row.id
|
||||
try {
|
||||
const data = await getCouponTemplate(id)
|
||||
form.value = {
|
||||
...data,
|
||||
discountPrice: data.discountPrice !== undefined ? data.discountPrice / 100.0 : undefined,
|
||||
discountPercent: data.discountPercent !== undefined ? data.discountPercent / 10.0 : undefined,
|
||||
discountLimitPrice:
|
||||
data.discountLimitPrice !== undefined ? data.discountLimitPrice / 100.0 : undefined,
|
||||
usePrice: data.usePrice !== undefined ? data.usePrice / 100.0 : undefined,
|
||||
validTimes: [data.validStartTime, data.validEndTime]
|
||||
}
|
||||
open.value = true
|
||||
title.value = '修改优惠劵'
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
|
||||
// 金额相关字段的缩放
|
||||
let data = {
|
||||
...form.value,
|
||||
discountPrice:
|
||||
form.value.discountPrice !== undefined ? form.value.discountPrice * 100 : undefined,
|
||||
discountPercent:
|
||||
form.value.discountPercent !== undefined ? form.value.discountPercent * 10 : undefined,
|
||||
discountLimitPrice:
|
||||
form.value.discountLimitPrice !== undefined ? form.value.discountLimitPrice * 100 : undefined,
|
||||
usePrice: form.value.usePrice !== undefined ? form.value.usePrice * 100 : undefined,
|
||||
validStartTime:
|
||||
form.value.validTimes && form.value.validTimes.length === 2
|
||||
? form.value.validTimes[0]
|
||||
: undefined,
|
||||
validEndTime:
|
||||
form.value.validTimes && form.value.validTimes.length === 2
|
||||
? form.value.validTimes[1]
|
||||
: undefined
|
||||
}
|
||||
|
||||
// 修改的提交
|
||||
if (form.value.id != null) {
|
||||
try {
|
||||
await updateCouponTemplate(data)
|
||||
message.success('修改成功')
|
||||
open.value = false
|
||||
getList()
|
||||
} catch {}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await createCouponTemplate(data)
|
||||
message.success('新增成功')
|
||||
open.value = false
|
||||
getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 优惠劵模板状态修改 */
|
||||
const handleStatusChange = async (row: any) => {
|
||||
// 此时,row 已经变成目标状态了,所以可以直接提交请求和提示
|
||||
let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
||||
|
||||
try {
|
||||
await message.confirm('确认要"' + text + '""' + row.name + '"优惠劵吗?')
|
||||
await updateCouponTemplateStatus(row.id, row.status)
|
||||
message.success(text + '成功')
|
||||
} catch {
|
||||
// 异常时,需要将 row.status 状态重置回之前的
|
||||
row.status =
|
||||
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: any) => {
|
||||
const id = row.id
|
||||
try {
|
||||
await message.confirm('是否确认删除优惠劵编号为"' + id + '"的数据项?')
|
||||
await deleteCouponTemplate(id)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// 格式化【优惠金额/折扣】
|
||||
const discountFormat = (row: any) => {
|
||||
if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) {
|
||||
return `¥${(row.discountPrice / 100.0).toFixed(2)}`
|
||||
}
|
||||
if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) {
|
||||
return `¥${(row.discountPrice / 100.0).toFixed(2)}`
|
||||
}
|
||||
return '未知【' + row.discountType + '】'
|
||||
}
|
||||
|
||||
// 格式化【领取上限】
|
||||
const takeLimitCountFormat = (row: any) => {
|
||||
if (row.takeLimitCount === -1) {
|
||||
return '无领取限制'
|
||||
}
|
||||
return `${row.takeLimitCount} 张/人`
|
||||
}
|
||||
|
||||
// 格式化【有效期限】
|
||||
const validityTypeFormat = (row: any) => {
|
||||
if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) {
|
||||
return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}`
|
||||
}
|
||||
if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) {
|
||||
return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用`
|
||||
}
|
||||
return '未知【' + row.validityType + '】'
|
||||
}
|
||||
</script>
|
@@ -45,6 +45,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { SpuAndSkuList, SpuProperty, SpuSelect } from '../../components'
|
||||
import { allSchemas, rules } from './seckillActivity.data'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
|
||||
import { SeckillProductVO } from '@/api/mall/promotion/seckill/seckillActivity'
|
||||
@@ -70,13 +71,13 @@ const spuAndSkuListRef = ref() // sku 秒杀配置组件Ref
|
||||
const ruleConfig: RuleConfig[] = [
|
||||
{
|
||||
name: 'productConfig.stock',
|
||||
rule: (arg) => arg > 1,
|
||||
message: '商品秒杀库存必须大于 1 !!!'
|
||||
rule: (arg) => arg >= 1,
|
||||
message: '商品秒杀库存必须大于等于 1 !!!'
|
||||
},
|
||||
{
|
||||
name: 'productConfig.seckillPrice',
|
||||
rule: (arg) => arg > 0.01,
|
||||
message: '商品秒杀价格必须大于 0.01 !!!'
|
||||
rule: (arg) => arg >= 0.01,
|
||||
message: '商品秒杀价格必须大于等于 0.01 !!!'
|
||||
}
|
||||
]
|
||||
const spuList = ref<SeckillActivityApi.SpuExtension[]>([]) // 选择的 spu
|
||||
@@ -112,7 +113,6 @@ const getSpuDetails = async (
|
||||
if (typeof products !== 'undefined') {
|
||||
const product = products.find((item) => item.skuId === sku.id)
|
||||
if (product) {
|
||||
// 分转元
|
||||
product.seckillPrice = formatToFraction(product.seckillPrice)
|
||||
}
|
||||
config = product || config
|
||||
@@ -153,13 +153,6 @@ const open = async (type: string, id?: number) => {
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = async () => {
|
||||
spuList.value = []
|
||||
spuPropertyList.value = []
|
||||
await nextTick()
|
||||
formRef.value.getElFormRef().resetFields()
|
||||
}
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
@@ -170,14 +163,14 @@ const submitForm = async () => {
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formRef.value.formModel as SeckillActivityApi.SeckillActivityVO
|
||||
const products = spuAndSkuListRef.value.getSkuConfigs('productConfig')
|
||||
// 获取秒杀商品配置
|
||||
const products = cloneDeep(spuAndSkuListRef.value.getSkuConfigs('productConfig'))
|
||||
products.forEach((item: SeckillProductVO) => {
|
||||
// 秒杀价格元转分
|
||||
item.seckillPrice = convertToInteger(item.seckillPrice)
|
||||
})
|
||||
// 获取秒杀商品配置
|
||||
const data = formRef.value.formModel as SeckillActivityApi.SeckillActivityVO
|
||||
data.products = products
|
||||
// 真正提交
|
||||
if (formType.value === 'create') {
|
||||
await SeckillActivityApi.createSeckillActivity(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
@@ -192,6 +185,15 @@ const submitForm = async () => {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = async () => {
|
||||
spuList.value = []
|
||||
spuPropertyList.value = []
|
||||
await nextTick()
|
||||
formRef.value.getElFormRef().resetFields()
|
||||
}
|
||||
// TODO @puhui999:下面的 css 名字,是不是可以改下;demo-table-expand
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.demo-table-expand {
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
|
||||
@@ -10,8 +12,7 @@
|
||||
type="primary"
|
||||
@click="openForm('create')"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" />
|
||||
新增
|
||||
<Icon class="mr-5px" icon="ep:plus" /> 新增
|
||||
</el-button>
|
||||
</template>
|
||||
</Search>
|
||||
@@ -71,11 +72,11 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { allSchemas } from './seckillActivity.data'
|
||||
import { getListAllSimple } from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
import { getSimpleSeckillConfigList } from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
|
||||
import SeckillActivityForm from './SeckillActivityForm.vue'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { createImageViewer } from '@/components/ImageViewer'
|
||||
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
|
||||
|
||||
defineOptions({ name: 'PromotionSeckillActivity' })
|
||||
|
||||
@@ -99,12 +100,14 @@ const openForm = (type: string, id?: number) => {
|
||||
const handleDelete = (id: number) => {
|
||||
tableMethods.delList(id, false)
|
||||
}
|
||||
|
||||
/** 商品图预览 */
|
||||
const imagePreview = (imgUrl: string) => {
|
||||
createImageViewer({
|
||||
urlList: [imgUrl]
|
||||
})
|
||||
}
|
||||
|
||||
const configList = ref([]) // 时段配置精简列表
|
||||
const convertSeckillConfigNames = computed(
|
||||
() => (row) =>
|
||||
@@ -120,18 +123,10 @@ const expandChange = (row, expandedRows) => {
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
/*
|
||||
TODO
|
||||
后面准备封装成一个函数来操作 tableColumns 重新排列:比如说需求是表单上商品选择是在后面的而列表展示的时候需要调到位置。
|
||||
封装效果支持批量操作,给出 field 和需要插入的位置,例:[{field:'spuId',index: 1}] 效果为把 field 为 spuId 的 column 移动到第一个位置
|
||||
*/
|
||||
// 处理一下表格列让商品往前
|
||||
const index = allSchemas.tableColumns.findIndex((item) => item.field === 'spuId')
|
||||
const column = cloneDeep(allSchemas.tableColumns[index])
|
||||
allSchemas.tableColumns.splice(index, 1)
|
||||
// 添加到开头
|
||||
allSchemas.tableColumns.unshift(column)
|
||||
// 获得活动列表
|
||||
sortTableColumns(allSchemas.tableColumns, 'spuId')
|
||||
await getList()
|
||||
configList.value = await getListAllSimple()
|
||||
// 获得秒杀时间段
|
||||
configList.value = await getSimpleSeckillConfigList()
|
||||
})
|
||||
</script>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
|
||||
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
|
||||
import { getListAllSimple } from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
import { getSimpleSeckillConfigList } from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
|
||||
// 表单校验
|
||||
export const rules = reactive({
|
||||
@@ -88,7 +88,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
||||
valueField: 'id'
|
||||
}
|
||||
},
|
||||
api: getListAllSimple
|
||||
api: getSimpleSeckillConfigList
|
||||
},
|
||||
table: {
|
||||
width: 300
|
||||
|
@@ -10,7 +10,6 @@
|
||||
<script lang="ts" name="SeckillConfigForm" setup>
|
||||
import * as SeckillConfigApi from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
import { allSchemas, rules } from './seckillConfig.data'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
@@ -53,19 +52,22 @@ const submitForm = async () => {
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 处理轮播图列表
|
||||
const data = formRef.value.formModel as SeckillConfigApi.SeckillConfigVO
|
||||
const cloneData = cloneDeep(data)
|
||||
const newSliderPicUrls = []
|
||||
cloneData.sliderPicUrls.forEach((item) => {
|
||||
const sliderPicUrls = []
|
||||
formRef.value.formModel.sliderPicUrls.forEach((item) => {
|
||||
// 如果是前端选的图
|
||||
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
|
||||
typeof item === 'object' ? sliderPicUrls.push(item.url) : sliderPicUrls.push(item)
|
||||
})
|
||||
cloneData.sliderPicUrls = newSliderPicUrls
|
||||
|
||||
// 真正提交
|
||||
const data = {
|
||||
...formRef.value.formModel,
|
||||
sliderPicUrls
|
||||
} as SeckillConfigApi.SeckillConfigVO
|
||||
if (formType.value === 'create') {
|
||||
await SeckillConfigApi.createSeckillConfig(cloneData)
|
||||
await SeckillConfigApi.createSeckillConfig(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await SeckillConfigApi.updateSeckillConfig(cloneData)
|
||||
await SeckillConfigApi.updateSeckillConfig(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="功能开启" url="https://doc.iocoder.cn/mall/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
|
||||
@@ -76,7 +78,6 @@ import * as SeckillConfigApi from '@/api/mall/promotion/seckill/seckillConfig'
|
||||
import SeckillConfigForm from './SeckillConfigForm.vue'
|
||||
import { createImageViewer } from '@/components/ImageViewer'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import { isArray } from '@/utils/is'
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
// tableObject:表格的属性对象,可获得分页大小、条数等属性
|
||||
@@ -89,21 +90,6 @@ const { tableObject, tableMethods } = useTable({
|
||||
// 获得表格的各种操作
|
||||
const { getList, setSearchParams } = tableMethods
|
||||
|
||||
/** 轮播图预览预览 */
|
||||
const imagePreview = (args) => {
|
||||
const urlList = []
|
||||
if (isArray(args)) {
|
||||
args.forEach((item) => {
|
||||
urlList.push(item)
|
||||
})
|
||||
} else {
|
||||
urlList.push(args)
|
||||
}
|
||||
createImageViewer({
|
||||
urlList
|
||||
})
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
@@ -131,6 +117,14 @@ const handleStatusChange = async (row: SeckillConfigApi.SeckillConfigVO) => {
|
||||
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
||||
}
|
||||
}
|
||||
|
||||
/** 轮播图预览预览 */
|
||||
const imagePreview = (args) => {
|
||||
createImageViewer({
|
||||
urlList: args
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
|
@@ -34,7 +34,7 @@
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
|
@@ -21,8 +21,8 @@
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="支付结果的回调地址" prop="payNotifyUrl">
|
||||
<el-input v-model="formData.payNotifyUrl" placeholder="请输入支付结果的回调地址" />
|
||||
<el-form-item label="支付结果的回调地址" prop="orderNotifyUrl">
|
||||
<el-input v-model="formData.orderNotifyUrl" placeholder="请输入支付结果的回调地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="退款结果的回调地址" prop="refundNotifyUrl">
|
||||
<el-input v-model="formData.refundNotifyUrl" placeholder="请输入退款结果的回调地址" />
|
||||
@@ -66,7 +66,7 @@ const formData = ref({
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '应用名不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }],
|
||||
payNotifyUrl: [{ required: true, message: '支付结果的回调地址不能为空', trigger: 'blur' }],
|
||||
orderNotifyUrl: [{ required: true, message: '支付结果的回调地址不能为空', trigger: 'blur' }],
|
||||
refundNotifyUrl: [{ required: true, message: '退款结果的回调地址不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
@@ -122,7 +122,7 @@ const resetForm = () => {
|
||||
name: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined,
|
||||
payNotifyUrl: undefined,
|
||||
orderNotifyUrl: undefined,
|
||||
refundNotifyUrl: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
|
||||
<!-- 搜索 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
@@ -54,15 +55,6 @@
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['system:tenant:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
@@ -392,20 +384,6 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await AppApi.exportApp(queryParams)
|
||||
download.excel(data, '支付应用信息.xls')
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据渠道编码判断渠道列表中是否存在
|
||||
*
|
||||
|
482
src/views/pay/cashier/index.vue
Normal file
482
src/views/pay/cashier/index.vue
Normal file
@@ -0,0 +1,482 @@
|
||||
<template>
|
||||
<!-- 支付信息 -->
|
||||
<el-card v-loading="loading">
|
||||
<el-descriptions title="支付信息" :column="3" border>
|
||||
<el-descriptions-item label="支付单号">{{ payOrder.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品标题">{{ payOrder.subject }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品内容">{{ payOrder.body }}</el-descriptions-item>
|
||||
<el-descriptions-item label="支付金额">
|
||||
¥{{ (payOrder.price / 100.0).toFixed(2) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ formatDate(payOrder.createTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="过期时间">
|
||||
{{ formatDate(payOrder.expireTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<!-- 支付选择框 -->
|
||||
<el-card style="margin-top: 10px" v-loading="submitLoading" element-loading-text="提交支付中...">
|
||||
<!-- 支付宝 -->
|
||||
<el-descriptions title="选择支付宝支付" />
|
||||
<div class="pay-channel-container">
|
||||
<div
|
||||
class="box"
|
||||
v-for="channel in channelsAlipay"
|
||||
:key="channel.code"
|
||||
@click="submit(channel.code)"
|
||||
>
|
||||
<img :src="channel.icon" />
|
||||
<div class="title">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 微信支付 -->
|
||||
<el-descriptions title="选择微信支付" style="margin-top: 20px" />
|
||||
<div class="pay-channel-container">
|
||||
<div
|
||||
class="box"
|
||||
v-for="channel in channelsWechat"
|
||||
:key="channel.code"
|
||||
@click="submit(channel.code)"
|
||||
>
|
||||
<img :src="channel.icon" />
|
||||
<div class="title">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 其它支付 -->
|
||||
<el-descriptions title="选择其它支付" style="margin-top: 20px" />
|
||||
<div class="pay-channel-container">
|
||||
<div
|
||||
class="box"
|
||||
v-for="channel in channelsMock"
|
||||
:key="channel.code"
|
||||
@click="submit(channel.code)"
|
||||
>
|
||||
<img :src="channel.icon" />
|
||||
<div class="title">{{ channel.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 展示形式:二维码 URL -->
|
||||
<Dialog
|
||||
:title="qrCode.title"
|
||||
v-model="qrCode.visible"
|
||||
width="350px"
|
||||
append-to-body
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<qrcode-vue :value="qrCode.url" :size="310" level="L" />
|
||||
</Dialog>
|
||||
|
||||
<!-- 展示形式:BarCode 条形码 -->
|
||||
<Dialog
|
||||
:title="barCode.title"
|
||||
v-model="barCode.visible"
|
||||
width="500px"
|
||||
append-to-body
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-form ref="form" label-width="80px">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="条形码" prop="name">
|
||||
<el-input v-model="barCode.value" placeholder="请输入条形码" required />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<div style="text-align: right">
|
||||
或使用
|
||||
<el-link
|
||||
type="danger"
|
||||
target="_blank"
|
||||
href="https://baike.baidu.com/item/条码支付/10711903"
|
||||
>
|
||||
(扫码枪/扫码盒)
|
||||
</el-link>
|
||||
扫码
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submit0(barCode.channelCode)"
|
||||
:disabled="barCode.value.length === 0"
|
||||
>
|
||||
确认支付
|
||||
</el-button>
|
||||
<el-button @click="barCode.visible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import QrcodeVue from 'qrcode.vue'
|
||||
import * as PayOrderApi from '@/api/pay/order'
|
||||
import { PayChannelEnum, PayDisplayModeEnum, PayOrderStatusEnum } from '@/utils/constants'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import { useTagsViewStore } from '@/store/modules/tagsView'
|
||||
|
||||
// 导入图标
|
||||
import svg_alipay_pc from '@/assets/svgs/pay/icon/alipay_pc.svg'
|
||||
import svg_alipay_wap from '@/assets/svgs/pay/icon/alipay_wap.svg'
|
||||
import svg_alipay_app from '@/assets/svgs/pay/icon/alipay_app.svg'
|
||||
import svg_alipay_qr from '@/assets/svgs/pay/icon/alipay_qr.svg'
|
||||
import svg_alipay_bar from '@/assets/svgs/pay/icon/alipay_bar.svg'
|
||||
import svg_wx_pub from '@/assets/svgs/pay/icon/wx_pub.svg'
|
||||
import svg_wx_lite from '@/assets/svgs/pay/icon/wx_lite.svg'
|
||||
import svg_wx_app from '@/assets/svgs/pay/icon/wx_app.svg'
|
||||
import svg_wx_native from '@/assets/svgs/pay/icon/wx_native.svg'
|
||||
import svg_wx_bar from '@/assets/svgs/pay/icon/wx_bar.svg'
|
||||
import svg_mock from '@/assets/svgs/pay/icon/mock.svg'
|
||||
|
||||
defineOptions({ name: 'PayCashier' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const route = useRoute() // 路由
|
||||
const { push, currentRoute } = useRouter() // 路由
|
||||
const { delView } = useTagsViewStore() // 视图操作
|
||||
|
||||
const id = ref(undefined) // 支付单号
|
||||
const returnUrl = ref<string | undefined>(undefined) // 支付完的回调地址
|
||||
const loading = ref(false) // 支付信息的 loading
|
||||
const payOrder = ref({}) // 支付信息
|
||||
const channelsAlipay = [
|
||||
{
|
||||
name: '支付宝 PC 网站支付',
|
||||
icon: svg_alipay_pc,
|
||||
code: 'alipay_pc'
|
||||
},
|
||||
{
|
||||
name: '支付宝 Wap 网站支付',
|
||||
icon: svg_alipay_wap,
|
||||
code: 'alipay_wap'
|
||||
},
|
||||
{
|
||||
name: '支付宝 App 网站支付',
|
||||
icon: svg_alipay_app,
|
||||
code: 'alipay_app'
|
||||
},
|
||||
{
|
||||
name: '支付宝扫码支付',
|
||||
icon: svg_alipay_qr,
|
||||
code: 'alipay_qr'
|
||||
},
|
||||
{
|
||||
name: '支付宝条码支付',
|
||||
icon: svg_alipay_bar,
|
||||
code: 'alipay_bar'
|
||||
}
|
||||
]
|
||||
const channelsWechat = [
|
||||
{
|
||||
name: '微信公众号支付',
|
||||
icon: svg_wx_pub,
|
||||
code: 'wx_pub'
|
||||
},
|
||||
{
|
||||
name: '微信小程序支付',
|
||||
icon: svg_wx_lite,
|
||||
code: 'wx_lite'
|
||||
},
|
||||
{
|
||||
name: '微信 App 支付',
|
||||
icon: svg_wx_app,
|
||||
code: 'wx_app'
|
||||
},
|
||||
{
|
||||
name: '微信扫码支付',
|
||||
icon: svg_wx_native,
|
||||
code: 'wx_native'
|
||||
},
|
||||
{
|
||||
name: '微信条码支付',
|
||||
icon: svg_wx_bar,
|
||||
code: 'wx_bar'
|
||||
}
|
||||
]
|
||||
const channelsMock = [
|
||||
{
|
||||
name: '模拟支付',
|
||||
icon: svg_mock,
|
||||
code: 'mock'
|
||||
}
|
||||
]
|
||||
|
||||
const submitLoading = ref(false) // 提交支付的 loading
|
||||
const interval = ref<any>(undefined) // 定时任务,轮询是否完成支付
|
||||
const qrCode = ref({
|
||||
// 展示形式:二维码
|
||||
url: '',
|
||||
title: '',
|
||||
visible: false
|
||||
})
|
||||
const barCode = ref({
|
||||
// 展示形式:条形码
|
||||
channelCode: '',
|
||||
value: '',
|
||||
title: '',
|
||||
visible: false
|
||||
})
|
||||
|
||||
/** 获得支付信息 */
|
||||
const getDetail = async () => {
|
||||
// 1.1 未传递订单编号
|
||||
if (!id.value) {
|
||||
message.error('未传递支付单号,无法查看对应的支付信息')
|
||||
goReturnUrl('cancel')
|
||||
return
|
||||
}
|
||||
const data = await PayOrderApi.getOrder(id.value)
|
||||
payOrder.value = data
|
||||
// 1.2 无法查询到支付信息
|
||||
if (!data) {
|
||||
message.error('支付订单不存在,请检查!')
|
||||
goReturnUrl('cancel')
|
||||
return
|
||||
}
|
||||
// 1.3 如果已支付、或者已关闭,则直接跳转
|
||||
if (data.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
message.success('支付成功')
|
||||
goReturnUrl('success')
|
||||
return
|
||||
} else if (data.status === PayOrderStatusEnum.CLOSED.status) {
|
||||
message.error('无法支付,原因:订单已关闭')
|
||||
goReturnUrl('close')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交支付 */
|
||||
const submit = (channelCode) => {
|
||||
// 条形码支付,需要特殊处理
|
||||
if (channelCode === PayChannelEnum.ALIPAY_BAR.code) {
|
||||
barCode.value = {
|
||||
channelCode: channelCode,
|
||||
value: '',
|
||||
title: '“支付宝”条码支付',
|
||||
visible: true
|
||||
}
|
||||
return
|
||||
}
|
||||
if (channelCode === PayChannelEnum.WX_BAR.code) {
|
||||
barCode.value = {
|
||||
channelCode: channelCode,
|
||||
value: '',
|
||||
title: '“微信”条码支付',
|
||||
visible: true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 微信公众号、小程序支付,无法在 PC 网页中进行
|
||||
if (channelCode === PayChannelEnum.WX_PUB.code) {
|
||||
message.error('微信公众号支付:不支持 PC 网站')
|
||||
return
|
||||
}
|
||||
if (channelCode === PayChannelEnum.WX_LITE.code) {
|
||||
message.error('微信小程序:不支持 PC 网站')
|
||||
return
|
||||
}
|
||||
|
||||
// 默认的提交处理
|
||||
submit0(channelCode)
|
||||
}
|
||||
|
||||
const submit0 = async (channelCode) => {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const formData = {
|
||||
id: id.value,
|
||||
channelCode: channelCode,
|
||||
returnUrl: location.href, // 支付成功后,支付渠道跳转回当前页;再由当前页,跳转回 {@link returnUrl} 对应的地址
|
||||
...buildSubmitParam(channelCode)
|
||||
}
|
||||
const data = await PayOrderApi.submitOrder(formData)
|
||||
// 直接返回已支付的情况,例如说扫码支付
|
||||
if (data.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
clearQueryInterval()
|
||||
message.success('支付成功!')
|
||||
goReturnUrl('success')
|
||||
return
|
||||
}
|
||||
|
||||
// 展示对应的界面
|
||||
if (data.displayMode === PayDisplayModeEnum.URL.mode) {
|
||||
displayUrl(channelCode, data)
|
||||
} else if (data.displayMode === PayDisplayModeEnum.QR_CODE.mode) {
|
||||
displayQrCode(channelCode, data)
|
||||
} else if (data.displayMode === PayDisplayModeEnum.APP.mode) {
|
||||
displayApp(channelCode)
|
||||
}
|
||||
|
||||
// 打开轮询任务
|
||||
createQueryInterval()
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 构建提交支付的额外参数 */
|
||||
const buildSubmitParam = (channelCode) => {
|
||||
// ① 支付宝 BarCode 支付时,需要传递 authCode 条形码
|
||||
if (channelCode === PayChannelEnum.ALIPAY_BAR.code) {
|
||||
return {
|
||||
channelExtras: {
|
||||
auth_code: barCode.value.value
|
||||
}
|
||||
}
|
||||
}
|
||||
// ② 微信 BarCode 支付时,需要传递 authCode 条形码
|
||||
if (channelCode === PayChannelEnum.WX_BAR.code) {
|
||||
return {
|
||||
channelExtras: {
|
||||
authCode: barCode.value.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return {}
|
||||
}
|
||||
|
||||
/** 提交支付后,URL 的展示形式 */
|
||||
const displayUrl = (_channelCode, data) => {
|
||||
location.href = data.displayContent
|
||||
submitLoading.value = false
|
||||
}
|
||||
|
||||
/** 提交支付后(扫码支付) */
|
||||
const displayQrCode = (channelCode, data) => {
|
||||
let title = '请使用手机浏览器“扫一扫”'
|
||||
if (channelCode === PayChannelEnum.ALIPAY_WAP.code) {
|
||||
// 考虑到 WAP 测试,所以引导手机浏览器搞
|
||||
} else if (channelCode.indexOf('alipay_') === 0) {
|
||||
title = '请使用支付宝“扫一扫”扫码支付'
|
||||
} else if (channelCode.indexOf('wx_') === 0) {
|
||||
title = '请使用微信“扫一扫”扫码支付'
|
||||
}
|
||||
qrCode.value = {
|
||||
title: title,
|
||||
url: data.displayContent,
|
||||
visible: true
|
||||
}
|
||||
submitLoading.value = false
|
||||
}
|
||||
|
||||
/** 提交支付后(App) */
|
||||
const displayApp = (channelCode) => {
|
||||
if (channelCode === PayChannelEnum.ALIPAY_APP.code) {
|
||||
message.error('支付宝 App 支付:无法在网页支付!')
|
||||
}
|
||||
if (channelCode === PayChannelEnum.WX_APP.code) {
|
||||
message.error('微信 App 支付:无法在网页支付!')
|
||||
}
|
||||
submitLoading.value = false
|
||||
}
|
||||
|
||||
/** 轮询查询任务 */
|
||||
const createQueryInterval = () => {
|
||||
if (interval.value) {
|
||||
return
|
||||
}
|
||||
interval.value = setInterval(async () => {
|
||||
const data = await PayOrderApi.getOrder(id.value)
|
||||
// 已支付
|
||||
if (data.status === PayOrderStatusEnum.SUCCESS.status) {
|
||||
clearQueryInterval()
|
||||
message.success('支付成功!')
|
||||
goReturnUrl('success')
|
||||
}
|
||||
// 已取消
|
||||
if (data.status === PayOrderStatusEnum.CLOSED.status) {
|
||||
clearQueryInterval()
|
||||
message.error('支付已关闭!')
|
||||
goReturnUrl('close')
|
||||
}
|
||||
}, 1000 * 2)
|
||||
}
|
||||
|
||||
/** 清空查询任务 */
|
||||
const clearQueryInterval = () => {
|
||||
// 清空各种弹窗
|
||||
qrCode.value = {
|
||||
title: '',
|
||||
url: '',
|
||||
visible: false
|
||||
}
|
||||
// 清空任务
|
||||
clearInterval(interval.value)
|
||||
interval.value = undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* 回到业务的 URL
|
||||
*
|
||||
* @param payResult 支付结果
|
||||
* ① success:支付成功
|
||||
* ② cancel:取消支付
|
||||
* ③ close:支付已关闭
|
||||
*/
|
||||
const goReturnUrl = (payResult) => {
|
||||
// 清理任务
|
||||
clearQueryInterval()
|
||||
|
||||
// 未配置的情况下,只能关闭
|
||||
if (!returnUrl.value) {
|
||||
delView(unref(currentRoute))
|
||||
return
|
||||
}
|
||||
|
||||
const url =
|
||||
returnUrl.value.indexOf('?') >= 0
|
||||
? returnUrl.value + '&payResult=' + payResult
|
||||
: returnUrl.value + '?payResult=' + payResult
|
||||
// 如果有配置,且是 http 开头,则浏览器跳转
|
||||
if (returnUrl.value.indexOf('http') === 0) {
|
||||
location.href = url
|
||||
} else {
|
||||
delView(unref(currentRoute))
|
||||
push({
|
||||
path: url
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
id.value = route.query.id
|
||||
if (route.query.returnUrl) {
|
||||
returnUrl.value = decodeURIComponent(route.query.returnUrl)
|
||||
}
|
||||
getDetail()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.pay-channel-container {
|
||||
display: flex;
|
||||
margin-top: -10px;
|
||||
|
||||
.box {
|
||||
width: 160px;
|
||||
border: 1px solid #e6ebf5;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 5px;
|
||||
margin-right: 10px;
|
||||
|
||||
img {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding-top: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
238
src/views/pay/demo/index.vue
Normal file
238
src/views/pay/demo/index.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
|
||||
<doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
|
||||
<doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
|
||||
<doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain @click="openForm"><Icon icon="ep:plus" />发起订单</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="订单编号" align="center" prop="id" />
|
||||
<el-table-column label="用户编号" align="center" prop="userId" />
|
||||
<el-table-column label="商品名字" align="center" prop="spuName" />
|
||||
<el-table-column label="支付价格" align="center" prop="price">
|
||||
<template #default="scope">
|
||||
<span>¥{{ (scope.row.price / 100.0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="退款金额" align="center" prop="refundPrice">
|
||||
<template #default="scope">
|
||||
<span>¥{{ (scope.row.refundPrice / 100.0).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="支付单号" align="center" prop="payOrderId" />
|
||||
<el-table-column label="是否支付" align="center" prop="payStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.payStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="支付时间"
|
||||
align="center"
|
||||
prop="payTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="退款时间" align="center" prop="refundTime" width="180">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.refundTime">{{ formatDate(scope.row.refundTime) }}</span>
|
||||
<span v-else-if="scope.row.payRefundId">退款中,等待退款结果</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="handlePay(scope.row)" v-if="!scope.row.payStatus">
|
||||
前往支付
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleRefund(scope.row)"
|
||||
v-if="scope.row.payStatus && !scope.row.payRefundId"
|
||||
>
|
||||
发起退款
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<Dialog title="发起订单" v-model="dialogVisible" width="500px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="商品" prop="spuId">
|
||||
<el-select
|
||||
v-model="formData.spuId"
|
||||
placeholder="请输入下单商品"
|
||||
clearable
|
||||
style="width: 380px"
|
||||
>
|
||||
<el-option v-for="item in spus" :key="item.id" :label="item.name" :value="item.id">
|
||||
<span style="float: left">{{ item.name }}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px">
|
||||
¥{{ (item.price / 100.0).toFixed(2) }}
|
||||
</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup name="PayDemoOrder">
|
||||
import * as PayDemoApi from '@/api/pay/demo'
|
||||
import { dateFormatter, formatDate } from '@/utils/formatTime'
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const router = useRouter() // 路由对象
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
|
||||
const formRef = ref()
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PayDemoApi.getDemoOrderPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 支付按钮操作 */
|
||||
const handlePay = (row) => {
|
||||
router.push({
|
||||
name: 'PayCashier',
|
||||
query: {
|
||||
id: row.payOrderId,
|
||||
returnUrl: encodeURIComponent('/pay/demo-order?id=' + row.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 退款按钮操作 */
|
||||
const handleRefund = async (row: any) => {
|
||||
const id = row.id
|
||||
try {
|
||||
await message.confirm('是否确认退款编号为"' + id + '"的示例订单?')
|
||||
await PayDemoApi.refundDemoOrder(id)
|
||||
await getList()
|
||||
message.success('发起退款成功!')
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// ========== 弹窗 ==========
|
||||
|
||||
// 商品数组
|
||||
const spus = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: '华为手机',
|
||||
price: 1
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '小米电视',
|
||||
price: 10
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '苹果手表',
|
||||
price: 100
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '华硕笔记本',
|
||||
price: 1000
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '蔚来汽车',
|
||||
price: 200000
|
||||
}
|
||||
])
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const formData = ref({}) // 表单数据
|
||||
const formRules = {
|
||||
spuId: [{ required: true, message: '商品编号不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
formData.value = {
|
||||
spuId: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const openForm = () => {
|
||||
reset()
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
await PayDemoApi.createDemoOrder(formData.value)
|
||||
message.success(t('common.createSuccess'))
|
||||
dialogVisible.value = false
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
@@ -1,113 +0,0 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="商户全称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入商户全称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商户简称" prop="shortName">
|
||||
<el-input v-model="formData.shortName" placeholder="请输入商户简称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="开启状态" prop="status">
|
||||
<el-select v-model="formData.status" clearable placeholder="请选择状态">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import * as MerchantApi from '@/api/pay/merchant'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
|
||||
defineOptions({ name: 'PayMerchantForm' })
|
||||
|
||||
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,
|
||||
name: '',
|
||||
shortName: '',
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
})
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '商户名称不能为空', trigger: 'blur' }],
|
||||
shortName: [{ required: true, message: '商户简称不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
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 MerchantApi.getMerchant(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 MerchantApi.MerchantVO
|
||||
if (formType.value === 'create') {
|
||||
await MerchantApi.createMerchant(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await MerchantApi.updateMerchant(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
name: '',
|
||||
shortName: '',
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
@@ -1,245 +0,0 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="商户号" prop="no">
|
||||
<el-input v-model="queryParams.no" placeholder="请输入商户号" clearable class="!w-240px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商户全称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入商户全称"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商户简称" prop="shortName">
|
||||
<el-input
|
||||
v-model="queryParams.shortName"
|
||||
placeholder="请输入商户简称"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<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.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="queryParams.remark"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="datetimerange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</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
|
||||
plain
|
||||
type="primary"
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['pay:merchant:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['pay:merchant: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="no" />
|
||||
<el-table-column label="商户全称" align="center" prop="name" />
|
||||
<el-table-column label="商户简称" align="center" prop="shortName" />
|
||||
<el-table-column label="开启状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.status"
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['pay:merchant:update']"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['pay:merchant: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>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<MerchantForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import * as MerchantApi from '@/api/pay/merchant'
|
||||
import MerchantForm from './MerchantForm.vue'
|
||||
|
||||
defineOptions({ name: 'PayMerchant' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: '',
|
||||
shortName: '',
|
||||
status: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await MerchantApi.getMerchantPage(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 MerchantApi.deleteMerchant(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 修改状态操作 */
|
||||
const handleStatusChange = async (row: MerchantApi.MerchantVO) => {
|
||||
try {
|
||||
// 修改状态的二次确认
|
||||
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
||||
await message.confirm('确认要"' + text + '""' + row.name + '"商户吗?', t('common.reminder'))
|
||||
// 发起修改状态
|
||||
await MerchantApi.updateMerchantStatus(row.id, row.status)
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {
|
||||
// 取消后,进行恢复按钮
|
||||
row.status =
|
||||
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await MerchantApi.exportMerchant(queryParams)
|
||||
download.excel(data, '商户信息.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
89
src/views/pay/notify/NotifyDetail.vue
Normal file
89
src/views/pay/notify/NotifyDetail.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" title="通知详情" width="50%">
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="商户订单编号">
|
||||
<el-tag>{{ detailData.merchantOrderId }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="通知状态">
|
||||
<dict-tag :type="DICT_TYPE.PAY_NOTIFY_STATUS" :value="detailData.status" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="应用编号">{{ detailData.appId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应用名称">{{ detailData.appName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="关联编号">{{ detailData.dataId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="通知类型">
|
||||
<dict-tag :type="DICT_TYPE.PAY_NOTIFY_TYPE" :value="detailData.type" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="通知次数">{{ detailData.notifyTimes }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最大通知次数">
|
||||
{{ detailData.maxNotifyTimes }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="最后通知时间">
|
||||
{{ formatDate(detailData.lastExecuteTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="下次通知时间">
|
||||
{{ formatDate(detailData.nextNotifyTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ formatDate(detailData.createTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ formatDate(detailData.updateTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<!-- 分割线 -->
|
||||
<el-divider />
|
||||
<el-descriptions :column="1" direction="vertical" border>
|
||||
<el-descriptions-item label="回调日志">
|
||||
<el-table :data="detailData.logs">
|
||||
<el-table-column label="日志编号" align="center" prop="id" />
|
||||
<el-table-column label="通知状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_NOTIFY_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="通知次数" align="center" prop="notifyTimes" />
|
||||
<el-table-column label="通知时间" align="center" prop="lastExecuteTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ formatDate(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="响应结果" align="center" prop="response" />
|
||||
</el-table>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
import * as PayNotifyApi from '@/api/pay/notify'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
|
||||
defineOptions({ name: 'PayNotifyDetail' })
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const detailLoading = ref(false) // 表单的加载中
|
||||
const detailData = ref({})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (id: number) => {
|
||||
dialogVisible.value = true
|
||||
// 设置数据
|
||||
detailLoading.value = true
|
||||
try {
|
||||
detailData.value = await PayNotifyApi.getNotifyTaskDetail(id)
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
</script>
|
224
src/views/pay/notify/index.vue
Normal file
224
src/views/pay/notify/index.vue
Normal file
@@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<doc-alert title="支付功能开启" url="https://doc.iocoder.cn/pay/build/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="应用编号" prop="appId">
|
||||
<el-select
|
||||
v-model="queryParams.appId"
|
||||
placeholder="请选择应用信息"
|
||||
clearable
|
||||
filterable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option v-for="item in appList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="通知类型" prop="type">
|
||||
<el-select
|
||||
v-model="queryParams.type"
|
||||
placeholder="请选择通知类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PAY_NOTIFY_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联编号" prop="dataId">
|
||||
<el-input
|
||||
v-model="queryParams.dataId"
|
||||
placeholder="请输入关联编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<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.PAY_NOTIFY_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商户订单编号" prop="merchantOrderId">
|
||||
<el-input
|
||||
v-model="queryParams.merchantOrderId"
|
||||
placeholder="请输入商户订单编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
style="width: 240px"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</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-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="appName" />
|
||||
<el-table-column label="商户订单编号" align="center" prop="merchantOrderId" />
|
||||
<el-table-column label="通知类型" align="center" prop="type">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_NOTIFY_TYPE" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="关联编号" align="center" prop="dataId" />
|
||||
<el-table-column label="通知状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_NOTIFY_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="最后通知时间"
|
||||
align="center"
|
||||
prop="lastExecuteTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="下次通知时间"
|
||||
align="center"
|
||||
prop="nextNotifyTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="通知次数" align="center" prop="notifyTimes">
|
||||
<template #default="scope">
|
||||
<el-tag size="small" type="success">
|
||||
{{ scope.row.notifyTimes }} / {{ scope.row.maxNotifyTimes }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openDetail(scope.row.id)"
|
||||
v-hasPermi="['pay:notify:query']"
|
||||
>
|
||||
查看详情
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:预览 -->
|
||||
<NotifyDetail ref="detailRef" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import * as PayNotifyApi from '@/api/pay/notify'
|
||||
import * as PayAppApi from '@/api/pay/app'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import NotifyDetail from './NotifyDetail.vue'
|
||||
|
||||
defineOptions({ name: 'PayNotify' })
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref() // 列表的数据
|
||||
const queryParams = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
appId: null,
|
||||
type: null,
|
||||
dataId: null,
|
||||
status: null,
|
||||
merchantOrderId: null,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const appList = ref([]) // 支付应用列表集合
|
||||
// 是否显示弹出层
|
||||
const open = ref(false)
|
||||
// 通知详情
|
||||
const notifyDetail = ref<any>({
|
||||
logs: []
|
||||
})
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PayNotifyApi.getNotifyTaskPage(queryParams.value)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
loading.value = false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 详情按钮操作 */
|
||||
const detailRef = ref()
|
||||
const openDetail = (id: number) => {
|
||||
detailRef.value.open(id)
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
// 获得筛选项
|
||||
appList.value = await PayAppApi.getAppList()
|
||||
})
|
||||
</script>
|
@@ -1,79 +1,84 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" title="详情" width="50%">
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="商户名称">{{ detailData.merchantName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应用名称">{{ detailData.appName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品名称">{{ detailData.subject }}</el-descriptions-item>
|
||||
<Dialog v-model="dialogVisible" title="订单详情" width="700px">
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="商户单号">
|
||||
<el-tag size="small">{{ detailData.merchantOrderId }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="支付单号">
|
||||
<el-tag type="warning" size="small" v-if="detailData.no">{{ detailData.no }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-divider />
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="商户订单号">
|
||||
<el-tag>{{ detailData.merchantOrderId }}</el-tag>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="应用编号">{{ detailData.appId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应用名称">{{ detailData.appName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="支付状态">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_STATUS" :value="detailData.status" size="small" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道订单号">
|
||||
<el-tag class="tag-purple">{{ detailData.channelOrderNo }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="支付订单号">
|
||||
<el-tag v-if="detailData.payOrderExtension" class="tag-pink">
|
||||
{{ detailData.payOrderExtension.no }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="金额">
|
||||
<el-tag type="success">¥{{ parseFloat(detailData.amount / 100, 2).toFixed(2) }}</el-tag>
|
||||
<el-descriptions-item label="支付金额">
|
||||
<el-tag type="success" size="small">¥{{ (detailData.price / 100.0).toFixed(2) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="手续费">
|
||||
<el-tag type="warning">
|
||||
¥{{ parseFloat(detailData.channelFeeAmount / 100, 2).toFixed(2) }}
|
||||
<el-tag type="warning" size="small">
|
||||
¥{{ (detailData.channelFeePrice / 100.0).toFixed(2) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="手续费比例">
|
||||
{{ parseFloat(detailData.channelFeeRate / 100, 2) }}%
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="支付状态">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_STATUS" :value="detailData.status" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="回调状态">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_NOTIFY_STATUS" :value="detailData.notifyStatus" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="回调地址">{{ detailData.notifyUrl }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ formatDate(detailData.createTime) }}
|
||||
{{ (detailData.channelFeeRate / 100.0).toFixed(2) }}%
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="支付时间">
|
||||
{{ formatDate(detailData.successTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="失效时间">
|
||||
{{ formatDate(detailData.expireTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="通知时间">
|
||||
{{ formatDate(detailData.notifyTime) }}
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ formatDate(detailData.createTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">
|
||||
{{ formatDate(detailData.updateTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<!-- 分割线 -->
|
||||
<el-divider />
|
||||
<el-descriptions :column="2">
|
||||
<el-descriptions-item label="支付渠道"
|
||||
>{{ detailData.channelCodeName }}
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="商品标题">{{ detailData.subject }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品描述">{{ detailData.body }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="支付渠道">
|
||||
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="detailData.channelCode" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="支付IP">{{ detailData.userIp }}</el-descriptions-item>
|
||||
<el-descriptions-item label="退款状态">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_REFUND_STATUS" :value="detailData.refundStatus" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="退款次数">{{ detailData.refundTimes }}</el-descriptions-item>
|
||||
<el-descriptions-item label="退款金额">
|
||||
<el-tag type="warning">
|
||||
{{ parseFloat(detailData.refundAmount / 100, 2) }}
|
||||
<el-descriptions-item label="支付 IP">{{ detailData.userIp }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="渠道单号">
|
||||
<el-tag size="mini" type="success" v-if="detailData.channelOrderNo">
|
||||
{{ detailData.channelOrderNo }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道用户">{{ detailData.channelUserId }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-divider />
|
||||
<el-descriptions :column="1" border direction="vertical">
|
||||
<el-descriptions-item label="商品描述">
|
||||
{{ detailData.body }}
|
||||
<el-descriptions :column="2" label-class-name="desc-label">
|
||||
<el-descriptions-item label="退款金额">
|
||||
<el-tag size="mini" type="danger">
|
||||
¥{{ (detailData.refundPrice / 100.0).toFixed(2) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="通知 URL">{{ detailData.notifyUrl }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<!-- 分割线 -->
|
||||
<el-divider />
|
||||
<el-descriptions :column="1" label-class-name="desc-label" direction="vertical" border>
|
||||
<el-descriptions-item label="支付通道异步回调内容">
|
||||
<div style="width: 700px; overflow: auto">
|
||||
{{ detailData.payOrderExtension?.channelNotifyData }}
|
||||
</div>
|
||||
{{ detailData.extension.channelNotifyData }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</Dialog>
|
||||
@@ -87,7 +92,9 @@ defineOptions({ name: 'PayOrderDetail' })
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const detailLoading = ref(false) // 表单的加载中
|
||||
const detailData = ref({})
|
||||
const detailData = ref({
|
||||
extension: {}
|
||||
})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (id: number) => {
|
||||
@@ -96,6 +103,9 @@ const open = async (id: number) => {
|
||||
detailLoading.value = true
|
||||
try {
|
||||
detailData.value = await OrderApi.getOrderDetail(id)
|
||||
if (!detailData.value.extension) {
|
||||
detailData.value.extension = {}
|
||||
}
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
|
@@ -1,4 +1,8 @@
|
||||
<template>
|
||||
<doc-alert title="支付宝支付接入" url="https://doc.iocoder.cn/pay/alipay-pay-demo/" />
|
||||
<doc-alert title="微信公众号支付接入" url="https://doc.iocoder.cn/pay/wx-pub-pay-demo/" />
|
||||
<doc-alert title="微信小程序支付接入" url="https://doc.iocoder.cn/pay/wx-lite-pay-demo/" />
|
||||
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
@@ -7,21 +11,6 @@
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="所属商户" prop="merchantId">
|
||||
<el-select
|
||||
v-model="queryParams.merchantId"
|
||||
clearable
|
||||
placeholder="请选择所属商户"
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in merchantList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="应用编号" prop="appId">
|
||||
<el-select
|
||||
clearable
|
||||
@@ -32,10 +21,10 @@
|
||||
<el-option v-for="item in appList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道编码" prop="channelCode">
|
||||
<el-form-item label="支付渠道" prop="channelCode">
|
||||
<el-select
|
||||
v-model="queryParams.channelCode"
|
||||
placeholder="请输入渠道编码"
|
||||
placeholder="请选择支付渠道"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
@@ -47,19 +36,28 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商户订单编号" prop="merchantOrderId">
|
||||
<el-form-item label="商户单号" prop="merchantOrderId">
|
||||
<el-input
|
||||
v-model="queryParams.merchantOrderId"
|
||||
placeholder="请输入商户订单编号"
|
||||
placeholder="请输入商户单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道订单号" prop="channelOrderNo">
|
||||
<el-form-item label="支付单号" prop="no">
|
||||
<el-input
|
||||
v-model="queryParams.no"
|
||||
placeholder="请输入支付单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道单号" prop="channelOrderNo">
|
||||
<el-input
|
||||
v-model="queryParams.channelOrderNo"
|
||||
placeholder="请输入渠道订单号"
|
||||
placeholder="请输入渠道单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
@@ -80,36 +78,6 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="退款状态" prop="refundStatus">
|
||||
<el-select
|
||||
v-model="queryParams.refundStatus"
|
||||
placeholder="请选择退款状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PAY_ORDER_REFUND_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="回调商户状态" prop="notifyStatus">
|
||||
<el-select
|
||||
v-model="queryParams.notifyStatus"
|
||||
placeholder="请选择订单回调商户状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
@@ -137,58 +105,10 @@
|
||||
</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="merchantName" width="120" />
|
||||
<el-table-column label="应用名称" align="center" prop="appName" width="120" />
|
||||
<el-table-column label="渠道名称" align="center" prop="channelCodeName" width="120" />
|
||||
<el-table-column label="渠道订单号" align="center" prop="merchantOrderId" width="120" />
|
||||
<el-table-column label="商品标题" align="center" prop="subject" width="250" />
|
||||
<el-table-column label="商品描述" align="center" prop="body" width="250" />
|
||||
<el-table-column label="异步通知地址" align="center" prop="notifyUrl" width="250" />
|
||||
<el-table-column label="回调状态" align="center" prop="notifyStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_NOTIFY_STATUS" :value="scope.row.notifyStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付订单" width="280">
|
||||
<template #default="scope">
|
||||
<p class="order-font">
|
||||
<el-tag>商户</el-tag>
|
||||
{{ scope.row.merchantOrderId }}
|
||||
</p>
|
||||
<p class="order-font">
|
||||
<el-tag type="warning">支付</el-tag>
|
||||
{{ scope.row.channelOrderNo }}
|
||||
</p>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付金额" align="center" prop="amount">
|
||||
<template #default="scope">
|
||||
¥{{ parseFloat(scope.row.amount / 100).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="手续金额" align="center" prop="channelFeeAmount">
|
||||
<template #default="scope">
|
||||
¥{{ parseFloat(scope.row.channelFeeAmount / 100).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="退款金额" align="center" prop="refundAmount">
|
||||
<template #default="scope">
|
||||
¥{{ parseFloat(scope.row.refundAmount / 100).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="回调状态" align="center" prop="notifyStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_NOTIFY_STATUS" :value="scope.row.notifyStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编号" align="center" prop="id" width="80" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
@@ -196,6 +116,42 @@
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="支付金额" align="center" prop="price" width="100">
|
||||
<template #default="scope"> ¥{{ parseFloat(scope.row.price / 100).toFixed(2) }} </template>
|
||||
</el-table-column>
|
||||
<el-table-column label="退款金额" align="center" prop="refundPrice" width="100">
|
||||
<template #default="scope">
|
||||
¥{{ parseFloat(scope.row.refundPrice / 100).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="手续金额" align="center" prop="channelFeePrice" width="100">
|
||||
<template #default="scope">
|
||||
¥{{ parseFloat(scope.row.channelFeePrice / 100).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="订单号" align="left" width="300">
|
||||
<template #default="scope">
|
||||
<p class="order-font">
|
||||
<el-tag size="small"> 商户</el-tag> {{ scope.row.merchantOrderId }}
|
||||
</p>
|
||||
<p class="order-font" v-if="scope.row.no">
|
||||
<el-tag size="small" type="warning">支付</el-tag> {{ scope.row.no }}
|
||||
</p>
|
||||
<p class="order-font" v-if="scope.row.channelOrderNo">
|
||||
<el-tag size="small" type="success">渠道</el-tag> {{ scope.row.channelOrderNo }}
|
||||
</p>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_ORDER_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="支付渠道" align="center" prop="channelCode" width="140">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="scope.row.channelCode" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="支付时间"
|
||||
align="center"
|
||||
@@ -203,6 +159,8 @@
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="支付应用" align="center" prop="appName" width="100" />
|
||||
<el-table-column label="商品标题" align="center" prop="subject" width="180" />
|
||||
<el-table-column label="操作" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@@ -231,7 +189,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as MerchantApi from '@/api/pay/merchant'
|
||||
import * as OrderApi from '@/api/pay/order'
|
||||
import OrderDetail from './OrderDetail.vue'
|
||||
import download from '@/utils/download'
|
||||
@@ -246,34 +203,16 @@ const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
merchantId: undefined,
|
||||
appId: undefined,
|
||||
channelId: undefined,
|
||||
channelCode: undefined,
|
||||
merchantOrderId: undefined,
|
||||
subject: undefined,
|
||||
body: undefined,
|
||||
notifyUrl: undefined,
|
||||
notifyStatus: undefined,
|
||||
amount: undefined,
|
||||
channelFeeRate: undefined,
|
||||
channelFeeAmount: undefined,
|
||||
status: undefined,
|
||||
userIp: undefined,
|
||||
successExtensionId: undefined,
|
||||
refundStatus: undefined,
|
||||
refundTimes: undefined,
|
||||
refundAmount: undefined,
|
||||
channelUserId: undefined,
|
||||
channelOrderNo: undefined,
|
||||
expireTime: [],
|
||||
successTime: [],
|
||||
notifyTime: [],
|
||||
appId: null,
|
||||
channelCode: null,
|
||||
merchantOrderId: null,
|
||||
channelOrderNo: null,
|
||||
no: null,
|
||||
status: null,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出等待
|
||||
const merchantList = ref([]) // 商户列表
|
||||
const appList = ref([]) // 支付应用列表集合
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
@@ -324,16 +263,11 @@ const openDetail = (id: number) => {
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
// 加载商户列表
|
||||
// merchantList.value = await MerchantApi.getMerchantListByName()
|
||||
// 加载 App 列表
|
||||
// TODO 芋艿:候选少一个查询应用列表的接口
|
||||
// appList.value = await AppApi.getAppListByMerchantId()
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
.order-font {
|
||||
padding: 2px 0;
|
||||
font-size: 12px;
|
||||
padding: 2px 0;
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<template>
|
||||
<doc-alert title="支付宝、微信退款接入" url="https://doc.iocoder.cn/pay/refund-demo/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
@@ -235,7 +237,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as MerchantApi from '@/api/pay/merchant'
|
||||
// import * as MerchantApi from '@/api/pay/merchant'
|
||||
import * as RefundApi from '@/api/pay/refund'
|
||||
import RefundDetail from './RefundDetail.vue'
|
||||
import download from '@/utils/download'
|
||||
@@ -330,7 +332,7 @@ const openDetail = (id: number) => {
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
// 加载商户列表
|
||||
merchantList.value = await MerchantApi.getMerchantListByName()
|
||||
// merchantList.value = await MerchantApi.getMerchantListByName()
|
||||
// TODO 芋艿:候选少一个查询应用列表的接口
|
||||
// appList.value = await AppApi.getAppListByMerchantId()
|
||||
})
|
||||
|
@@ -49,7 +49,7 @@
|
||||
end-placeholder="结束日期"
|
||||
start-placeholder="开始日期"
|
||||
type="daterange"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
Reference in New Issue
Block a user