This commit is contained in:
YunaiV 2023-09-03 19:25:33 +08:00
commit 881ec67236
23 changed files with 888 additions and 450 deletions

View File

@ -16,3 +16,11 @@ export const getCouponPage = async (params: PageParam) => {
params: params params: params
}) })
} }
// 发送优惠券
export const sendCoupon = async (data: any) => {
return request.post({
url: '/promotion/coupon/send',
data: data
})
}

View File

@ -9,7 +9,7 @@ export interface CouponTemplateVO {
takeType: number takeType: number
usePrice: number usePrice: number
productScope: number productScope: number
productSpuIds: string productScopeValues: number[]
validityType: number validityType: number
validStartTime: Date validStartTime: Date
validEndTime: Date validEndTime: Date

View File

@ -15,11 +15,11 @@ export interface OrderVO {
cancelTime?: Date | null // 订单取消时间 cancelTime?: Date | null // 订单取消时间
cancelType?: number | null // 取消类型 cancelType?: number | null // 取消类型
remark?: string // 商家备注 remark?: string // 商家备注
payOrderId: number | null // 支付订单编号 payOrderId?: number | null // 支付订单编号
payed?: boolean // 是否已支付 payed?: boolean // 是否已支付
payTime?: Date | null // 付款时间 payTime?: Date | null // 付款时间
payChannelCode?: string // 支付渠道 payChannelCode?: string // 支付渠道
originalPrice?: number | null // 商品原价(总) totalPrice?: number | null // 商品原价(总)
orderPrice?: number | null // 订单原价(总) orderPrice?: number | null // 订单原价(总)
discountPrice?: number | null // 订单优惠(总) discountPrice?: number | null // 订单优惠(总)
deliveryPrice?: number | null // 运费金额 deliveryPrice?: number | null // 运费金额
@ -44,12 +44,19 @@ export interface OrderVO {
pointPrice?: number | null // 积分抵扣的金额 pointPrice?: number | null // 积分抵扣的金额
receiverAreaName?: string //收件人地区名字 receiverAreaName?: string //收件人地区名字
items?: OrderItemRespVO[] // 订单项列表 items?: OrderItemRespVO[] // 订单项列表
//用户信息 // 用户信息
user?: { user?: {
id?: number | null id?: number | null
nickname?: string nickname?: string
avatar?: string avatar?: string
} }
// 订单操作日志
orderLog: orderLog[]
}
export interface orderLog {
content?: string
createTime?: Date
} }
export interface OrderItemRespVO { export interface OrderItemRespVO {
@ -94,6 +101,11 @@ export const getOrder = async (id: number | null) => {
return await request.get({ url: `/trade/order/get-detail?id=` + id }) return await request.get({ url: `/trade/order/get-detail?id=` + id })
} }
// 查询交易订单物流详情
export const getExpressTrackList = async (id: number | null) => {
return await request.get({ url: `/trade/order/get-express-track-list?id=` + id })
}
export interface DeliveryVO { export interface DeliveryVO {
id: number // 订单编号 id: number // 订单编号
logisticsId: number | null // 物流公司编号 logisticsId: number | null // 物流公司编号

View File

@ -209,17 +209,39 @@ export const CouponTemplateValidityTypeEnum = {
} }
} }
/**
*
*/
export const CouponTemplateTakeTypeEnum = {
USER: {
type: 1,
name: '直接领取'
},
ADMIN: {
type: 2,
name: '指定发放'
},
REGISTER: {
type: 3,
name: '新人券'
}
}
/** /**
* *
*/ */
export const PromotionProductScopeEnum = { export const PromotionProductScopeEnum = {
ALL: { ALL: {
scope: 1, scope: 1,
name: '全部商品参与' name: '通用劵'
}, },
SPU: { SPU: {
scope: 2, scope: 2,
name: '指定商品参与' name: '商品劵'
},
CATEGORY: {
scope: 3,
name: '品类劵'
} }
} }

View File

@ -59,7 +59,7 @@
<el-table-column label="品牌名称" prop="name" sortable /> <el-table-column label="品牌名称" prop="name" sortable />
<el-table-column label="品牌图片" align="center" prop="picUrl"> <el-table-column label="品牌图片" align="center" prop="picUrl">
<template #default="scope"> <template #default="scope">
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="品牌图片" class="h-100px" /> <img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="品牌图片" class="h-30px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="品牌排序" align="center" prop="sort" /> <el-table-column label="品牌排序" align="center" prop="sort" />

View File

@ -0,0 +1,47 @@
<template>
<el-tree-select
v-model="selectCategoryId"
:data="categoryList"
:props="defaultProps"
:multiple="multiple"
:show-checkbox="multiple"
class="w-1/1"
node-key="id"
placeholder="请选择商品分类"
/>
</template>
<script lang="ts" setup>
import { defaultProps, handleTree } from '@/utils/tree'
import * as ProductCategoryApi from '@/api/mall/product/category'
import { oneOfType } from 'vue-types'
import { propTypes } from '@/utils/propTypes'
/** 商品分类选择组件 */
defineOptions({ name: 'ProductCategorySelect' })
const props = defineProps({
modelValue: oneOfType([propTypes.number.def(undefined), propTypes.array.def([])]).def(undefined), // ID
multiple: propTypes.bool.def(false) //
})
/** 选中的分类 ID */
const selectCategoryId = computed({
get: () => {
return props.modelValue
},
set: (val: number | number[]) => {
emit('update:modelValue', val)
}
})
/** 分类选择 */
const emit = defineEmits(['update:modelValue'])
/** 初始化 **/
const categoryList = ref([]) //
onMounted(async () => {
//
const data = await ProductCategoryApi.getCategoryList({})
categoryList.value = handleTree(data, 'id', 'parentId')
})
</script>

View File

@ -38,7 +38,7 @@
<el-table-column label="分类名称" prop="name" sortable /> <el-table-column label="分类名称" prop="name" sortable />
<el-table-column label="移动端分类图" align="center" prop="picUrl"> <el-table-column label="移动端分类图" align="center" prop="picUrl">
<template #default="scope"> <template #default="scope">
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="移动端分类图" class="h-100px" /> <img v-if="scope.row.picUrl" :src="scope.row.picUrl" alt="移动端分类图" class="h-30px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="分类排序" align="center" prop="sort" /> <el-table-column label="分类排序" align="center" prop="sort" />

View File

@ -115,7 +115,7 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="170" width="170"
/> />
<el-table-column label="状态" align="center" width="65px"> <el-table-column label="是否展示" align="center" width="80px">
<template #default="scope"> <template #default="scope">
<el-switch <el-switch
v-model="scope.row.visible" v-model="scope.row.visible"

View File

@ -147,7 +147,7 @@ const handleDelete = async (id: number) => {
// //
await message.delConfirm() await message.delConfirm()
// //
await PropertyApi.deleteProperty(id) await PropertyApi.deletePropertyValue(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()

View File

@ -328,12 +328,10 @@ const tableHeaders = ref<{ prop: string; label: string }[]>([]) // 多属性表
* 保存时每个商品规格的表单要校验下例如说销售金额最低是 0.01 这种 * 保存时每个商品规格的表单要校验下例如说销售金额最低是 0.01 这种
*/ */
const validateSku = () => { const validateSku = () => {
const checks = ['price', 'marketPrice', 'costPrice']
let warningInfo = '请检查商品各行相关属性配置,' let warningInfo = '请检查商品各行相关属性配置,'
let validate = true // let validate = true //
for (const sku of formData.value!.skus!) { for (const sku of formData.value!.skus!) {
// //
if (props.isActivityComponent) {
for (const rule of props?.ruleConfig) { for (const rule of props?.ruleConfig) {
const arg = getValue(sku, rule.name) const arg = getValue(sku, rule.name)
if (!rule.rule(arg)) { if (!rule.rule(arg)) {
@ -342,13 +340,6 @@ const validateSku = () => {
break break
} }
} }
} else {
if (checks.some((check) => sku[check] < 0.01)) {
validate = false //
warningInfo = '商品相关价格不能低于 0.01 元!!'
break
}
}
// //
if (!validate) { if (!validate) {
message.warning(warningInfo) message.warning(warningInfo)

View File

@ -1,5 +1,6 @@
<template> <template>
<Dialog v-model="dialogVisible" :appendToBody="true" title="选择商品" width="70%"> <Dialog v-model="dialogVisible" :appendToBody="true" title="选择商品" width="70%">
<ContentWrap>
<el-row :gutter="20" class="mb-10px"> <el-row :gutter="20" class="mb-10px">
<el-col :span="6"> <el-col :span="6">
<el-input <el-input
@ -43,10 +44,26 @@
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-table ref="spuListRef" v-loading="loading" :data="list" show-overflow-tooltip> <el-table v-loading="loading" :data="list" show-overflow-tooltip>
<el-table-column label="#" width="55"> <!-- 多选模式 -->
<el-table-column key="2" type="selection" width="55" v-if="multiple">
<template #header>
<el-checkbox
:value="allChecked && checkedPageNos.indexOf(queryParams.pageNo) > -1"
@change="handleCheckAll"
/>
</template>
<template #default="{ row }"> <template #default="{ row }">
<el-radio :label="row.id" v-model="selectedSpuId" @change="handleSelected(row)" <el-checkbox
:value="checkedSpuIds.indexOf(row.id) > -1"
@change="(checked: boolean) => handleCheckOne(checked, row)"
/>
</template>
</el-table-column>
<!-- 单选模式 -->
<el-table-column label="#" width="55" v-else>
<template #default="{ row }">
<el-radio :label="row.id" v-model="selectedSpuId" @change="handleSingleSelected(row)"
>&nbsp;</el-radio >&nbsp;</el-radio
> >
</template> </template>
@ -65,7 +82,7 @@
<el-table-column label="商品名称" min-width="200" prop="name" /> <el-table-column label="商品名称" min-width="200" prop="name" />
<el-table-column label="商品分类" min-width="100" prop="categoryId"> <el-table-column label="商品分类" min-width="100" prop="categoryId">
<template #default="{ row }"> <template #default="{ row }">
<span>{{ categoryList.find((c) => c.id === row.categoryId)?.name }}</span> <span>{{ categoryList?.find((c) => c.id === row.categoryId)?.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -76,6 +93,11 @@
:total="total" :total="total"
@pagination="getList" @pagination="getList"
/> />
</ContentWrap>
<template #footer v-if="multiple">
<el-button type="primary" @click="handleEmitChange"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog> </Dialog>
</template> </template>
@ -85,12 +107,19 @@ import { defaultProps, handleTree } from '@/utils/tree'
import * as ProductCategoryApi from '@/api/mall/product/category' import * as ProductCategoryApi from '@/api/mall/product/category'
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import { propTypes } from '@/utils/propTypes'
type Spu = Required<ProductSpuApi.Spu>
defineOptions({ name: 'SpuTableSelect' }) defineOptions({ name: 'SpuTableSelect' })
const message = useMessage() // const props = defineProps({
//
multiple: propTypes.bool.def(false)
})
const total = ref(0) // const total = ref(0) //
const list = ref<any[]>([]) // const list = ref<Spu[]>([]) //
const loading = ref(false) // const loading = ref(false) //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const queryParams = ref({ const queryParams = ref({
@ -101,26 +130,24 @@ const queryParams = ref({
categoryId: null, categoryId: null,
createTime: [] createTime: []
}) // }) //
const spuListRef = ref<InstanceType<typeof ElTable>>()
const selectedSpuId = ref() // spuId const selectedSpuId = ref() // spuId
/** 选中时触发 */
const handleSelected = (row: ProductSpuApi.Spu) => {
emits('change', row)
//
dialogVisible.value = false
selectedSpuId.value = undefined
}
//
const emits = defineEmits<{
(e: 'change', spu: ProductSpuApi.Spu): void
}>()
/** 打开弹窗 */ /** 打开弹窗 */
const open = () => { const open = (spus?: Spu[]) => {
if (spus && spus.length > 0) {
// todo check-box
checkedSpus.value = [...spus]
checkedSpuIds.value = spus.map((spu) => spu.id)
} else {
checkedSpus.value = []
checkedSpuIds.value = []
}
allChecked.value = false
checkedPageNos.value = []
dialogVisible.value = true dialogVisible.value = true
resetQuery()
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -138,6 +165,7 @@ const getList = async () => {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNo = 1
getList() getList()
} }
@ -154,9 +182,65 @@ const resetQuery = () => {
getList() getList()
} }
const allChecked = ref(false) //
const checkedPageNos = ref<number[]>([]) //
const checkedSpuIds = ref<number[]>([]) //ID
const checkedSpus = ref<Spu[]>([]) //
/** 单选中时触发 */
const handleSingleSelected = (row: Spu) => {
emits('change', row)
//
dialogVisible.value = false
// ID
selectedSpuId.value = row.id
}
/** 多选完成 */
const handleEmitChange = () => {
//
dialogVisible.value = false
emits('change', [...checkedSpus.value])
}
/** 确认选择时的触发事件 */
const emits = defineEmits<{
(e: 'change', spu: Spu | Spu[] | any): void
}>()
/** 全选 */
const handleCheckAll = (checked: boolean) => {
debugger
console.log('checkAll', checked)
allChecked.value = checked
const index = checkedPageNos.value.indexOf(queryParams.value.pageNo)
checkedPageNos.value.push(queryParams.value.pageNo)
if (index > -1) {
checkedPageNos.value.splice(index, 1)
}
list.value.forEach((item) => handleCheckOne(checked, item))
}
/** 选中一行 */
const handleCheckOne = (checked: boolean, spu: Spu) => {
if (checked) {
const index = checkedSpuIds.value.indexOf(spu.id)
if (index === -1) {
checkedSpuIds.value.push(spu.id)
checkedSpus.value.push(spu)
}
} else {
const index = checkedSpuIds.value.indexOf(spu.id)
if (index > -1) {
checkedSpuIds.value.splice(index, 1)
checkedSpus.value.splice(index, 1)
}
}
}
const categoryList = ref() // const categoryList = ref() //
const categoryTreeList = ref() // const categoryTreeList = ref() //
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
await getList() await getList()

View File

@ -1,4 +1,5 @@
import SkuList from './SkuList.vue' import SkuList from './SkuList.vue'
import { Spu } from '@/api/mall/product/spu'
interface PropertyAndValues { interface PropertyAndValues {
id: number id: number
@ -22,4 +23,32 @@ interface RuleConfig {
message: string message: string
} }
export { SkuList, PropertyAndValues, RuleConfig } /**
* -
*
* @param spu
* @return PropertyAndValues
*/
const getPropertyList = (spu: Spu): PropertyAndValues[] => {
// 直接拿返回的 skus 属性逆向生成出 propertyList
const properties: PropertyAndValues[] = []
// 只有是多规格才处理
if (spu.specType) {
spu.skus?.forEach((sku) => {
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
// 添加属性
if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId!, name: propertyName!, values: [] })
}
// 添加属性值
const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values?.push({ id: valueId!, name: valueName! })
}
})
})
}
return properties
}
export { SkuList, PropertyAndValues, RuleConfig, getPropertyList }

View File

@ -109,7 +109,12 @@
<!-- 多规格添加--> <!-- 多规格添加-->
<el-col :span="24"> <el-col :span="24">
<el-form-item v-if="!formData.specType"> <el-form-item v-if="!formData.specType">
<SkuList ref="skuListRef" :prop-form-data="formData" :propertyList="propertyList" /> <SkuList
ref="skuListRef"
:prop-form-data="formData"
:propertyList="propertyList"
:rule-config="ruleConfig"
/>
</el-form-item> </el-form-item>
<el-form-item v-if="formData.specType" label="商品属性"> <el-form-item v-if="formData.specType" label="商品属性">
<el-button class="mr-15px mb-10px" @click="attributesAddFormRef.open">添加规格</el-button> <el-button class="mr-15px mb-10px" @click="attributesAddFormRef.open">添加规格</el-button>
@ -120,7 +125,12 @@
<SkuList :is-batch="true" :prop-form-data="formData" :propertyList="propertyList" /> <SkuList :is-batch="true" :prop-form-data="formData" :propertyList="propertyList" />
</el-form-item> </el-form-item>
<el-form-item label="属性列表"> <el-form-item label="属性列表">
<SkuList ref="skuListRef" :prop-form-data="formData" :propertyList="propertyList" /> <SkuList
ref="skuListRef"
:prop-form-data="formData"
:propertyList="propertyList"
:rule-config="ruleConfig"
/>
</el-form-item> </el-form-item>
</template> </template>
</el-col> </el-col>
@ -175,7 +185,7 @@ import { propTypes } from '@/utils/propTypes'
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree' import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { PropertyAndValues, SkuList } from '@/views/mall/product/spu/components/index.ts' import { getPropertyList, RuleConfig, SkuList } from '@/views/mall/product/spu/components/index.ts'
import ProductAttributes from './ProductAttributes.vue' import ProductAttributes from './ProductAttributes.vue'
import ProductPropertyAddForm from './ProductPropertyAddForm.vue' import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
import { basicInfoSchema } from './spu.data' import { basicInfoSchema } from './spu.data'
@ -186,6 +196,30 @@ import * as ExpressTemplateApi from '@/api/mall/trade/delivery/expressTemplate'
defineOptions({ name: 'ProductSpuBasicInfoForm' }) defineOptions({ name: 'ProductSpuBasicInfoForm' })
// sku
const ruleConfig: RuleConfig[] = [
{
name: 'stock',
rule: (arg) => arg >= 1,
message: '商品库存必须大于等于 1 '
},
{
name: 'price',
rule: (arg) => arg >= 0.01,
message: '商品销售价格必须大于等于 0.01 '
},
{
name: 'marketPrice',
rule: (arg) => arg >= 0.01,
message: '商品市场价格必须大于等于 0.01 '
},
{
name: 'costPrice',
rule: (arg) => arg >= 0.01,
message: '商品成本价格必须大于等于 0.01 '
}
]
// ====== ====== // ====== ======
const { allSchemas } = useCrudSchemas(basicInfoSchema) const { allSchemas } = useCrudSchemas(basicInfoSchema)
/** 商品图预览 */ /** 商品图预览 */
@ -203,34 +237,6 @@ const imagePreview = (args) => {
}) })
} }
/**
* 获得商品的规格列表
*
* @param spu
* @return PropertyAndValues 规格列表
*/
const getPropertyList = (spu: Spu): PropertyAndValues[] => {
// skus propertyList
const properties: PropertyAndValues[] = []
//
if (spu.specType) {
spu.skus?.forEach((sku) => {
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
//
if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId!, name: propertyName!, values: [] })
}
//
const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values?.push({ id: valueId!, name: valueName! })
}
})
})
}
return properties
}
// ====== end ====== // ====== end ======
const message = useMessage() // const message = useMessage() //

View File

@ -142,17 +142,6 @@ const submitForm = async () => {
await unref(otherSettingsRef)?.validate() await unref(otherSettingsRef)?.validate()
// , server // , server
const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu
// sku
formData.value.skus!.forEach((sku) => {
//
if (sku.barCode === '') {
const index = deepCopyFormData.skus!.findIndex(
(item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties)
)
// sku
deepCopyFormData.skus!.splice(index, 1)
}
})
deepCopyFormData.skus!.forEach((item) => { deepCopyFormData.skus!.forEach((item) => {
// sku name // sku name
item.name = deepCopyFormData.name item.name = deepCopyFormData.name
@ -189,7 +178,7 @@ const submitForm = async () => {
/** 关闭按钮 */ /** 关闭按钮 */
const close = () => { const close = () => {
delView(unref(currentRoute)) delView(unref(currentRoute))
push('/product/product-spu') push({ name: 'ProductSpu' })
} }
/** 初始化 */ /** 初始化 */
onMounted(async () => { onMounted(async () => {

View File

@ -170,6 +170,14 @@
> >
详情 详情
</el-button> </el-button>
<el-button
v-hasPermi="['product:spu:update']"
link
type="primary"
@click="openForm(row.id)"
>
修改
</el-button>
<template v-if="queryParams.tabType === 4"> <template v-if="queryParams.tabType === 4">
<el-button <el-button
v-hasPermi="['product:spu:delete']" v-hasPermi="['product:spu:delete']"
@ -189,16 +197,6 @@
</el-button> </el-button>
</template> </template>
<template v-else> <template v-else>
<!-- 只有不是上架和回收站的商品可以编辑 -->
<el-button
v-if="queryParams.tabType !== 0"
v-hasPermi="['product:spu:update']"
link
type="primary"
@click="openForm(row.id)"
>
修改
</el-button>
<el-button <el-button
v-hasPermi="['product:spu:update']" v-hasPermi="['product:spu:update']"
link link

View File

@ -0,0 +1,162 @@
<template>
<Dialog v-model="dialogVisible" :appendToBody="true" title="发送优惠券" width="70%">
<!-- 搜索工作栏 -->
<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>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
</el-form-item>
</el-form>
<!-- 列表 -->
<el-table v-loading="loading" :data="list" show-overflow-tooltip>
<el-table-column align="center" label="优惠券名称" prop="name" min-width="60" />
<el-table-column
label="优惠金额 / 折扣"
align="center"
prop="discount"
:formatter="discountFormat"
min-width="60"
/>
<el-table-column
align="center"
label="最低消费"
prop="usePrice"
min-width="60"
:formatter="usePriceFormat"
/>
<el-table-column
align="center"
label="有效期限"
prop="validityType"
min-width="140"
:formatter="validityTypeFormat"
/>
<el-table-column
align="center"
label="剩余数量"
min-width="60"
:formatter="remainedCountFormat"
/>
<el-table-column label="操作" align="center" min-width="60px" fixed="right">
<template #default="scope">
<el-button
link
type="primary"
:disabled="sendLoading"
:loading="sendLoading"
@click="handleSendCoupon(scope.row.id)"
v-hasPermi="['member:level:update']"
>
发送
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
<div class="clear-both"></div>
</Dialog>
</template>
<script lang="ts" setup>
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
import * as CouponApi from '@/api/mall/promotion/coupon/coupon'
import {
discountFormat,
remainedCountFormat,
usePriceFormat,
validityTypeFormat
} from '@/views/mall/promotion/coupon/formatter'
import { CouponTemplateTakeTypeEnum } from '@/utils/constants'
defineOptions({ name: 'PromotionCouponSendForm' })
const message = useMessage() //
const total = ref(0) //
const list = ref<any[]>([]) //
const loading = ref(false) //
const sendLoading = ref(false) //
const dialogVisible = ref(false) //
const queryParams = ref({
pageNo: 1,
pageSize: 10,
name: null,
canTakeTypes: [CouponTemplateTakeTypeEnum.ADMIN.type]
}) //
const queryFormRef = ref() //
//
let userIds: number[] = []
/** 打开弹窗 */
const open = (ids: number[]) => {
userIds = ids
//
resetQuery()
dialogVisible.value = true
}
defineExpose({ open }) // open
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await CouponTemplateApi.getCouponTemplatePage(queryParams.value)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef?.value?.resetFields()
handleQuery()
}
/** 发送操作 **/
const handleSendCoupon = async (templateId: number) => {
try {
sendLoading.value = true
await CouponApi.sendCoupon({ templateId, userIds })
//
message.success('发送成功')
dialogVisible.value = false
} finally {
sendLoading.value = false
}
}
</script>

View File

@ -0,0 +1,44 @@
import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants'
import { formatDate } from '@/utils/formatTime'
import { CouponTemplateVO } from '@/api/mall/promotion/coupon/couponTemplate'
import { floatToFixed2 } from '@/utils'
// 格式化【优惠金额/折扣】
export const discountFormat = (row: CouponTemplateVO) => {
if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) {
return `${floatToFixed2(row.discountPrice)}`
}
if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) {
return `${row.discountPrice}%`
}
return '未知【' + row.discountType + '】'
}
// 格式化【领取上限】
export const takeLimitCountFormat = (row: CouponTemplateVO) => {
if (row.takeLimitCount === -1) {
return '无领取限制'
}
return `${row.takeLimitCount} 张/人`
}
// 格式化【有效期限】
export const validityTypeFormat = (row: CouponTemplateVO) => {
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 + '】'
}
// 格式化【剩余数量】
export const remainedCountFormat = (row: CouponTemplateVO) => {
return row.totalCount - row.takeCount
}
// 格式化【最低消费】
export const usePriceFormat = (row: CouponTemplateVO) => {
return `${floatToFixed2(row.usePrice)}`
}

View File

@ -122,7 +122,8 @@ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
createTime: [], createTime: [],
status: undefined status: undefined,
nickname: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref() //

View File

@ -10,7 +10,40 @@
<el-form-item label="优惠券名称" prop="name"> <el-form-item label="优惠券名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入优惠券名称" /> <el-input v-model="formData.name" placeholder="请输入优惠券名称" />
</el-form-item> </el-form-item>
<el-form-item label="优惠券类型" prop="discountType"> <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
label="商品"
v-if="formData.productScope === PromotionProductScopeEnum.SPU.scope"
prop="productSpuIds"
>
<div class="flex items-center gap-1 flex-wrap">
<div class="select-box spu-pic" v-for="(spu, index) in productSpus" :key="spu.id">
<el-image :src="spu.picUrl" />
<Icon icon="ep:circle-close-filled" class="del-icon" @click="handleRemoveSpu(index)" />
</div>
<div class="select-box" @click="openSpuTableSelect">
<Icon icon="ep:plus" />
</div>
</div>
</el-form-item>
<el-form-item
label="分类"
v-if="formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
prop="productCategoryIds"
>
<ProductCategorySelect v-model="formData.productCategoryIds" />
</el-form-item>
<el-form-item label="优惠类型" prop="discountType">
<el-radio-group v-model="formData.discountType"> <el-radio-group v-model="formData.discountType">
<el-radio <el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
@ -29,7 +62,7 @@
<el-input-number <el-input-number
v-model="formData.discountPrice" v-model="formData.discountPrice"
placeholder="请输入优惠金额,单位:元" placeholder="请输入优惠金额,单位:元"
style="width: 400px" class="!w-400px mr-2"
:precision="2" :precision="2"
:min="0" :min="0"
/> />
@ -43,7 +76,7 @@
<el-input-number <el-input-number
v-model="formData.discountPercent" v-model="formData.discountPercent"
placeholder="优惠券折扣不能小于 1 折,且不可大于 9.9 折" placeholder="优惠券折扣不能小于 1 折,且不可大于 9.9 折"
style="width: 400px" class="!w-400px mr-2"
:precision="1" :precision="1"
:min="1" :min="1"
:max="9.9" :max="9.9"
@ -58,7 +91,7 @@
<el-input-number <el-input-number
v-model="formData.discountLimitPrice" v-model="formData.discountLimitPrice"
placeholder="请输入最多优惠" placeholder="请输入最多优惠"
style="width: 400px" class="!w-400px mr-2"
:precision="2" :precision="2"
:min="0" :min="0"
/> />
@ -68,7 +101,7 @@
<el-input-number <el-input-number
v-model="formData.usePrice" v-model="formData.usePrice"
placeholder="无门槛请设为 0" placeholder="无门槛请设为 0"
style="width: 400px" class="!w-400px mr-2"
:precision="2" :precision="2"
:min="0" :min="0"
/> />
@ -84,7 +117,7 @@
<el-input-number <el-input-number
v-model="formData.totalCount" v-model="formData.totalCount"
placeholder="发放数量,没有之后不能领取或发放,-1 为不限制" placeholder="发放数量,没有之后不能领取或发放,-1 为不限制"
style="width: 400px" class="!w-400px mr-2"
:precision="0" :precision="0"
:min="-1" :min="-1"
/> />
@ -94,7 +127,7 @@
<el-input-number <el-input-number
v-model="formData.takeLimitCount" v-model="formData.takeLimitCount"
placeholder="设置为 -1 时,可无限领取" placeholder="设置为 -1 时,可无限领取"
style="width: 400px" class="!w-400px mr-2"
:precision="0" :precision="0"
:min="-1" :min="-1"
/> />
@ -119,7 +152,7 @@
<el-date-picker <el-date-picker
v-model="formData.validTimes" v-model="formData.validTimes"
style="width: 240px" style="width: 240px"
value-format="YYYY-MM-DD HH:mm:ss" value-format="x"
type="datetimerange" type="datetimerange"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]" :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
/> />
@ -133,7 +166,7 @@
<el-input-number <el-input-number
v-model="formData.fixedStartTerm" v-model="formData.fixedStartTerm"
placeholder="0 为今天生效" placeholder="0 为今天生效"
style="width: 165px" class="mx-2"
:precision="0" :precision="0"
:min="0" :min="0"
/> />
@ -141,49 +174,19 @@
<el-input-number <el-input-number
v-model="formData.fixedEndTerm" v-model="formData.fixedEndTerm"
placeholder="请输入结束天数" placeholder="请输入结束天数"
style="width: 165px" class="mx-2"
:precision="0" :precision="0"
:min="0" :min="0"
/> />
天有效 天有效
</el-form-item> </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> </el-form>
<template #footer> <template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button> <el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
</template> </template>
</Dialog> </Dialog>
<SpuTableSelect ref="spuTableSelectRef" multiple @change="handleSpuSelected" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
@ -194,6 +197,8 @@ import {
PromotionDiscountTypeEnum, PromotionDiscountTypeEnum,
PromotionProductScopeEnum PromotionProductScopeEnum
} from '@/utils/constants' } from '@/utils/constants'
import SpuTableSelect from '@/views/mall/product/spu/components/SpuTableSelect.vue'
import ProductCategorySelect from '@/views/mall/product/category/components/ProductCategorySelect.vue'
defineOptions({ name: 'CouponTemplateForm' }) defineOptions({ name: 'CouponTemplateForm' })
@ -222,7 +227,9 @@ const formData = ref({
fixedStartTerm: undefined, fixedStartTerm: undefined,
fixedEndTerm: undefined, fixedEndTerm: undefined,
productScope: PromotionProductScopeEnum.ALL.scope, productScope: PromotionProductScopeEnum.ALL.scope,
productSpuIds: [] productScopeValues: [], //
productCategoryIds: [], //
productSpuIds: [] //
}) })
const formRules = reactive({ const formRules = reactive({
name: [{ required: true, message: '优惠券名称不能为空', trigger: 'blur' }], name: [{ required: true, message: '优惠券名称不能为空', trigger: 'blur' }],
@ -239,10 +246,11 @@ const formRules = reactive({
fixedStartTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }], fixedStartTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
fixedEndTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }], fixedEndTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }], productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }] productSpuIds: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
productCategoryIds: [{ required: true, message: '分类不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const productSpus = ref([]) // const productSpus = ref<ProductSpuApi.Spu[]>([]) //
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
@ -265,12 +273,12 @@ const open = async (type: string, id?: number) => {
usePrice: data.usePrice !== undefined ? data.usePrice / 100.0 : undefined, usePrice: data.usePrice !== undefined ? data.usePrice / 100.0 : undefined,
validTimes: [data.validStartTime, data.validEndTime] validTimes: [data.validStartTime, data.validEndTime]
} }
//
await getProductScope()
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
//
productSpus.value = await ProductSpuApi.getSpuSimpleList()
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -305,7 +313,11 @@ const submitForm = async () => {
formData.value.validTimes && formData.value.validTimes.length === 2 formData.value.validTimes && formData.value.validTimes.length === 2
? formData.value.validTimes[1] ? formData.value.validTimes[1]
: undefined : undefined
} as CouponTemplateApi.CouponTemplateVO } as unknown as CouponTemplateApi.CouponTemplateVO
//
setProductScopeValues(data)
if (formType.value === 'create') { if (formType.value === 'create') {
await CouponTemplateApi.createCouponTemplate(data) await CouponTemplateApi.createCouponTemplate(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -341,8 +353,92 @@ const resetForm = () => {
fixedStartTerm: undefined, fixedStartTerm: undefined,
fixedEndTerm: undefined, fixedEndTerm: undefined,
productScope: PromotionProductScopeEnum.ALL.scope, productScope: PromotionProductScopeEnum.ALL.scope,
productSpuIds: [] productScopeValues: [],
productSpuIds: [],
productCategoryIds: []
} }
formRef.value?.resetFields() formRef.value?.resetFields()
productSpus.value = []
}
/** 获得商品范围 */
const getProductScope = async () => {
switch (formData.value.productScope) {
case PromotionProductScopeEnum.SPU.scope:
//
formData.value.productSpuIds = formData.value.productScopeValues
//
productSpus.value = await ProductSpuApi.getSpuDetailList(formData.value.productScopeValues)
break
case PromotionProductScopeEnum.CATEGORY.scope:
await nextTick(() => {
let productCategoryIds = formData.value.productScopeValues
if (Array.isArray(productCategoryIds) && productCategoryIds.length > 0) {
// 使
productCategoryIds = productCategoryIds[0]
}
//
formData.value.productCategoryIds = productCategoryIds
})
break
default:
break
}
}
/** 设置商品范围 */
function setProductScopeValues(data: CouponTemplateApi.CouponTemplateVO) {
switch (formData.value.productScope) {
case PromotionProductScopeEnum.SPU.scope:
data.productScopeValues = formData.value.productSpuIds
break
case PromotionProductScopeEnum.CATEGORY.scope:
data.productScopeValues = Array.isArray(formData.value.productCategoryIds)
? formData.value.productCategoryIds
: [formData.value.productCategoryIds]
break
default:
break
}
}
/** 活动商品的按钮 */
const spuTableSelectRef = ref()
const openSpuTableSelect = () => {
spuTableSelectRef.value.open(productSpus.value)
}
/** 选择商品后触发 */
const handleSpuSelected = (spus: ProductSpuApi.Spu[]) => {
productSpus.value = spus
formData.value.productSpuIds = spus.map((spu) => spu.id) as []
}
/** 选择商品后触发 */
const handleRemoveSpu = (index: number) => {
productSpus.value.splice(index, 1)
formData.value.productSpuIds.splice(index, 1)
} }
</script> </script>
<style scoped lang="scss">
.select-box {
display: flex;
align-items: center;
justify-content: center;
border: 1px dashed var(--el-border-color-darker);
border-radius: 8px;
width: 60px;
height: 60px;
}
.spu-pic {
position: relative;
}
.del-icon {
position: absolute;
z-index: 1;
width: 20px !important;
height: 20px !important;
right: -10px;
top: -10px;
}
</style>

View File

@ -103,7 +103,7 @@
label="剩余数量" label="剩余数量"
align="center" align="center"
prop="totalCount" prop="totalCount"
:formatter="(row) => row.totalCount - row.takeCount" :formatter="remainedCountFormat"
/> />
<el-table-column <el-table-column
label="领取上限" label="领取上限"
@ -171,14 +171,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate' import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
import { import { CommonStatusEnum } from '@/utils/constants'
CommonStatusEnum,
CouponTemplateValidityTypeEnum,
PromotionDiscountTypeEnum
} from '@/utils/constants'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter, formatDate } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import CouponTemplateForm from './CouponTemplateForm.vue' import CouponTemplateForm from './CouponTemplateForm.vue'
import {
discountFormat,
remainedCountFormat,
takeLimitCountFormat,
validityTypeFormat
} from '@/views/mall/promotion/coupon/formatter'
defineOptions({ name: 'PromotionCouponTemplate' }) defineOptions({ name: 'PromotionCouponTemplate' })
@ -193,6 +195,7 @@ const queryParams = reactive({
pageSize: 10, pageSize: 10,
name: null, name: null,
status: null, status: null,
discountType: null,
type: null, type: null,
createTime: [] createTime: []
}) })
@ -258,36 +261,6 @@ const handleDelete = async (id: number) => {
} catch {} } 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(() => { onMounted(() => {
getList() getList()

View File

@ -122,8 +122,36 @@
</el-row> </el-row>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<!-- 售后信息 TODO @puhui999需要接入 --> <el-descriptions title="售后日志">
<el-descriptions title="售后日志" /> <el-descriptions-item labelClassName="no-colon">
<el-timeline>
<el-timeline-item
v-for="saleLog in formData.afterSaleLog"
:key="saleLog.id"
:timestamp="formatDate(saleLog.createTime)"
placement="top"
>
<el-card>
<span>用户类型</span>
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="saleLog.userType" class="mr-10px" />
<span>售后状态(之前)</span>
<dict-tag
:type="DICT_TYPE.TRADE_AFTER_SALE_STATUS"
:value="saleLog.beforeStatus"
class="mr-10px"
/>
<span>售后状态(之后)</span>
<dict-tag
:type="DICT_TYPE.TRADE_AFTER_SALE_STATUS"
:value="saleLog.afterStatus"
class="mr-10px"
/>
<span>操作明细{{ saleLog.content }}</span>
</el-card>
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
</el-descriptions>
</ContentWrap> </ContentWrap>
<!-- 各种操作的弹窗 --> <!-- 各种操作的弹窗 -->
@ -138,12 +166,14 @@ import UpdateAuditReasonForm from '@/views/mall/trade/afterSale/form/AfterSaleDi
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import { isArray } from '@/utils/is' import { isArray } from '@/utils/is'
defineOptions({ name: 'TradeOrderDetailForm' }) defineOptions({ name: 'TradeAfterSaleDetail' })
const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const { params } = useRoute() // const { params } = useRoute() //
const formData = ref({ const formData = ref({
order: {} order: {},
afterSaleLog: []
}) })
const updateAuditReasonFormRef = ref() // Ref const updateAuditReasonFormRef = ref() // Ref
@ -154,44 +184,48 @@ const getDetail = async () => {
formData.value = await AfterSaleApi.getAfterSale(id) formData.value = await AfterSaleApi.getAfterSale(id)
} }
} }
/**
* 同意售后 /** 同意售后 */
*/
const agree = () => { const agree = () => {
message.confirm('是否同意售后?').then(() => { message.confirm('是否同意售后?').then(() => {
AfterSaleApi.agree(formData.value.id) AfterSaleApi.agree(formData.value.id)
message.success(t('common.success'))
getDetail()
}) })
} }
/**
* 拒绝售后 /** 拒绝售后 */
*/
const disagree = () => { const disagree = () => {
updateAuditReasonFormRef.value?.open(formData.value) updateAuditReasonFormRef.value?.open(formData.value)
} }
/**
* 确认收货 /** 确认收货 */
*/
const receive = () => { const receive = () => {
message.confirm('是否确认收货?').then(() => { message.confirm('是否确认收货?').then(() => {
AfterSaleApi.receive(formData.value.id) AfterSaleApi.receive(formData.value.id)
message.success(t('common.success'))
getDetail()
}) })
} }
/**
* 拒绝收货 /** 拒绝收货 */
*/
const refuse = () => { const refuse = () => {
message.confirm('是否拒绝收货?').then(() => { message.confirm('是否拒绝收货?').then(() => {
AfterSaleApi.refuse(formData.value.id) AfterSaleApi.refuse(formData.value.id)
message.success(t('common.success'))
getDetail()
}) })
} }
/**
* 确认退款 /** 确认退款 */
*/
const refund = () => { const refund = () => {
message.confirm('是否确认退款?').then(() => { message.confirm('是否确认退款?').then(() => {
AfterSaleApi.refund(formData.value.id) AfterSaleApi.refund(formData.value.id)
message.success(t('common.success'))
getDetail()
}) })
} }
/** 图片预览 */ /** 图片预览 */
const imagePreview = (args) => { const imagePreview = (args) => {
const urlList = [] const urlList = []
@ -206,6 +240,7 @@ const imagePreview = (args) => {
urlList urlList
}) })
} }
onMounted(async () => { onMounted(async () => {
await getDetail() await getDetail()
}) })

View File

@ -2,32 +2,32 @@
<ContentWrap> <ContentWrap>
<!-- 订单信息 --> <!-- 订单信息 -->
<el-descriptions title="订单信息"> <el-descriptions title="订单信息">
<el-descriptions-item label="订单号: ">{{ orderInfo.no }}</el-descriptions-item> <el-descriptions-item label="订单号: ">{{ formData.no }}</el-descriptions-item>
<el-descriptions-item label="配送方式: "> <el-descriptions-item label="配送方式: ">
<dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="orderInfo.deliveryType" /> <dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="formData.deliveryType!" />
</el-descriptions-item> </el-descriptions-item>
<!-- TODO 营销活动待实现 --> <!-- TODO 营销活动待实现 -->
<el-descriptions-item label="营销活动: ">秒杀活动</el-descriptions-item> <el-descriptions-item label="营销活动: ">秒杀活动</el-descriptions-item>
<el-descriptions-item label="订单类型: "> <el-descriptions-item label="订单类型: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="orderInfo.type" /> <dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="formData.type!" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="收货人: ">{{ orderInfo.receiverName }}</el-descriptions-item> <el-descriptions-item label="收货人: ">{{ formData.receiverName }}</el-descriptions-item>
<el-descriptions-item label="买家留言: ">{{ orderInfo.userRemark }}</el-descriptions-item> <el-descriptions-item label="买家留言: ">{{ formData.userRemark }}</el-descriptions-item>
<el-descriptions-item label="订单来源: "> <el-descriptions-item label="订单来源: ">
<dict-tag :type="DICT_TYPE.TERMINAL" :value="orderInfo.terminal" /> <dict-tag :type="DICT_TYPE.TERMINAL" :value="formData.terminal!" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="联系电话: ">{{ orderInfo.receiverMobile }}</el-descriptions-item> <el-descriptions-item label="联系电话: ">{{ formData.receiverMobile }}</el-descriptions-item>
<el-descriptions-item label="商家备注: ">{{ orderInfo.remark }}</el-descriptions-item> <el-descriptions-item label="商家备注: ">{{ formData.remark }}</el-descriptions-item>
<el-descriptions-item label="支付单号: ">{{ orderInfo.payOrderId }}</el-descriptions-item> <el-descriptions-item label="支付单号: ">{{ formData.payOrderId }}</el-descriptions-item>
<el-descriptions-item label="付款方式: "> <el-descriptions-item label="付款方式: ">
<dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="orderInfo.payChannelCode" /> <dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.payChannelCode!" />
</el-descriptions-item> </el-descriptions-item>
<!-- <el-descriptions-item label="买家: ">{{ orderInfo.user.nickname }}</el-descriptions-item> --> <!-- <el-descriptions-item label="买家: ">{{ formData.user.nickname }}</el-descriptions-item> -->
<!-- TODO 芋艿待实现跳转会员 --> <!-- TODO @puhui999待实现跳转会员 -->
<el-descriptions-item label="收货地址: "> <el-descriptions-item label="收货地址: ">
{{ orderInfo.receiverAreaName }} {{ orderInfo.receiverDetailAddress }} {{ formData.receiverAreaName }} {{ formData.receiverDetailAddress }}
<el-link <el-link
v-clipboard:copy="orderInfo.receiverAreaName + ' ' + orderInfo.receiverDetailAddress" v-clipboard:copy="formData.receiverAreaName + ' ' + formData.receiverDetailAddress"
v-clipboard:success="clipboardSuccess" v-clipboard:success="clipboardSuccess"
icon="ep:document-copy" icon="ep:document-copy"
type="primary" type="primary"
@ -38,8 +38,9 @@
<!-- 订单状态 --> <!-- 订单状态 -->
<el-descriptions :column="1" title="订单状态"> <el-descriptions :column="1" title="订单状态">
<el-descriptions-item label="订单状态: "> <el-descriptions-item label="订单状态: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" /> <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
</el-descriptions-item> </el-descriptions-item>
<!-- TODO @puhui999根据状态进行展示按钮 -->
<el-descriptions-item label-class-name="no-colon"> <el-descriptions-item label-class-name="no-colon">
<el-button type="primary" @click="openForm('updatePrice')">调整价格</el-button> <el-button type="primary" @click="openForm('updatePrice')">调整价格</el-button>
<el-button type="primary" @click="openForm('remark')">备注</el-button> <el-button type="primary" @click="openForm('remark')">备注</el-button>
@ -59,7 +60,7 @@
<el-descriptions-item labelClassName="no-colon"> <el-descriptions-item labelClassName="no-colon">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="15"> <el-col :span="15">
<el-table :data="orderInfo.items" border> <el-table :data="formData.items" border>
<el-table-column label="商品" prop="spuName" width="auto"> <el-table-column label="商品" prop="spuName" width="auto">
<template #default="{ row }"> <template #default="{ row }">
{{ row.spuName }} {{ row.spuName }}
@ -91,111 +92,75 @@
</el-descriptions> </el-descriptions>
<el-descriptions :column="6"> <el-descriptions :column="6">
<el-descriptions-item label="商品总额: "> <el-descriptions-item label="商品总额: ">
{{ floatToFixed2(orderInfo.totalPrice) }} {{ floatToFixed2(formData.totalPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="运费金额: "> <el-descriptions-item label="运费金额: ">
{{ floatToFixed2(orderInfo.deliveryPrice) }} {{ floatToFixed2(formData.deliveryPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="订单调价: "> <el-descriptions-item label="订单调价: ">
{{ floatToFixed2(orderInfo.updatePrice) }} {{ floatToFixed2(formData.adjustPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">商品优惠: </span></template> <template #label><span style="color: red">商品优惠: </span></template>
{{ floatToFixed2(orderInfo.couponPrice) }} {{ floatToFixed2(formData.couponPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">订单优惠: </span></template> <template #label><span style="color: red">订单优惠: </span></template>
{{ floatToFixed2(orderInfo.discountPrice) }} {{ floatToFixed2(formData.discountPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">积分抵扣: </span></template> <template #label><span style="color: red">积分抵扣: </span></template>
{{ floatToFixed2(orderInfo.pointPrice) }} {{ floatToFixed2(formData.pointPrice!) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" /> <el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" />
<!-- 占位 --> <!-- 占位 -->
<el-descriptions-item label="应付金额: "> <el-descriptions-item label="应付金额: ">
{{ floatToFixed2(orderInfo.payPrice) }} {{ floatToFixed2(formData.payPrice!) }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<!-- TODO 芋艿需要改改 --> <!-- TODO 芋艿需要改改 -->
<div v-for="group in detailGroups" :key="group.title"> <el-descriptions :column="4" title="物流信息">
<el-descriptions :title="group.title" v-bind="group.groupProps"> <el-descriptions-item label="物流公司: ">
<!-- 订单操作日志 --> {{ deliveryExpressList.find((item) => item.id === formData.logisticsId)?.name }}
<el-descriptions-item v-if="group.key === 'orderLog'" labelClassName="no-colon"> </el-descriptions-item>
<el-descriptions-item label="运单号: ">{{ formData.logisticsNo }}</el-descriptions-item>
<el-descriptions-item label="发货时间: ">
{{ formatDate(formData.deliveryTime!) }}
</el-descriptions-item>
<el-descriptions-item label="物流状态: ">
<!-- TODO 物流状态怎么获取 -->
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.deliveryStatus!" />
</el-descriptions-item>
<!-- 占位 4 -->
<el-descriptions-item v-for="item in 4" :key="item" label-class-name="no-colon" />
<el-descriptions-item label="物流详情: ">
<el-timeline> <el-timeline>
<el-timeline-item <el-timeline-item
v-for="activity in detailInfo[group.key]" v-for="(express, index) in expressTrackList"
:key="activity.timestamp"
:timestamp="activity.timestamp"
>
{{ activity.content }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
<!-- 物流信息 TODO 等物流接口搞定重构一下 -->
<!-- TODO @xiaobai改成一个包裹哈目前只允许发货一次 -->
<el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon">
<!-- 循环包裹物流信息 -->
<div v-show="(pkgInfo = detailInfo[group.key]) !== null" style="border: 1px dashed">
<!-- 包裹详情 -->
<el-descriptions class="m-5">
<el-descriptions-item
v-for="(pkgChild, pkgCIdx) in group.children"
:key="`pkgChild_${pkgCIdx}`"
:label="pkgChild.label"
v-bind="pkgChild.childProps"
>
<!-- 包裹商品列表 -->
<template v-if="pkgChild.valueKey === 'goodsList' && pkgInfo[pkgChild.valueKey]">
<div
v-for="(goodInfo, goodInfoIdx) in pkgInfo[pkgChild.valueKey]"
:key="`goodInfo_${goodInfoIdx}`"
style="display: flex"
>
<el-image
:src="goodInfo.imgUrl"
style="width: 100px; height: 100px; flex: none"
/>
<el-descriptions :column="1">
<el-descriptions-item labelClassName="no-colon"
>{{ goodInfo.name }}
</el-descriptions-item>
<el-descriptions-item label="数量"
>{{ goodInfo.count }}
</el-descriptions-item>
</el-descriptions>
</div>
</template>
<!-- 包裹物流详情 -->
<template v-else-if="pkgChild.valueKey === 'wlxq'">
<el-row :gutter="10">
<el-col :offset="1" :span="6">
<el-timeline>
<el-timeline-item
v-for="(activity, index) in pkgInfo[pkgChild.valueKey]"
:key="index" :key="index"
:timestamp="activity.timestamp" :timestamp="formatDate(express.time)"
> >
{{ activity.content }} {{ express.content }}
</el-timeline-item> </el-timeline-item>
</el-timeline> </el-timeline>
</el-col>
</el-row>
</template>
<template v-else>
{{ pkgInfo[pkgChild.valueKey] }}
</template>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</div> <el-descriptions title="订单操作日志">
<el-descriptions-item labelClassName="no-colon">
<el-timeline>
<el-timeline-item
v-for="(log, index) in formData.orderLog"
:key="index"
:timestamp="formatDate(log.createTime!)"
>
{{ log.content }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</div>
</ContentWrap> </ContentWrap>
<!-- 各种操作的弹窗 --> <!-- 各种操作的弹窗 -->
@ -207,84 +172,24 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
import { floatToFixed2 } from '@/utils' import { floatToFixed2 } from '@/utils'
import { formatDate } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import OrderUpdateRemarkForm from '@/views/mall/trade/order/form/OrderUpdateRemarkForm.vue' import OrderUpdateRemarkForm from '@/views/mall/trade/order/form/OrderUpdateRemarkForm.vue'
import OrderDeliveryForm from '@/views/mall/trade/order/form/OrderDeliveryForm.vue' import OrderDeliveryForm from '@/views/mall/trade/order/form/OrderDeliveryForm.vue'
import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAddressForm.vue' import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAddressForm.vue'
import OrderUpdatePriceForm from '@/views/mall/trade/order/form/OrderUpdatePriceForm.vue' import OrderUpdatePriceForm from '@/views/mall/trade/order/form/OrderUpdatePriceForm.vue'
import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
defineOptions({ name: 'TradeOrderDetailForm' }) defineOptions({ name: 'TradeOrderDetail' })
const message = useMessage() // const message = useMessage() //
const { params } = useRoute() //
const orderInfo = ref<TradeOrderApi.OrderVO>({})
// TODO @puhui999 //
const detailGroups = ref([ const formData = ref<TradeOrderApi.OrderVO>({
{ orderLog: [] // TODO @puhui999orderLogs
title: '物流信息',
key: 'expressInfo',
children: [
{ label: '发货时间: ', valueKey: 'fhsj' },
{ label: '物流公司: ', valueKey: 'wlgs' },
{ label: '运单号: ', valueKey: 'ydh' },
{ label: '物流状态: ', valueKey: 'wlzt', childProps: { span: 3 } },
{ label: '物流详情: ', valueKey: 'wlxq' }
]
},
{
title: '订单操作日志',
key: 'orderLog'
}
])
// TODO @puhui999
const detailInfo = ref({
//
expressInfo: {
label: '包裹1',
name: 'bg1',
fhsj: '2022-11-03 16:50:45',
wlgs: '极兔',
ydh: '2132123',
wlzt: '不支持此快递公司',
wlxq: [
{
content: '正在派送途中,请您准备签收(派件人:王涛,电话:13854563814)',
timestamp: '2018-04-15 15:00:16'
},
{
content: '快件到达 【烟台龙口东江村委营业点】',
timestamp: '2018-04-13 14:54:19'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
},
{
content: '快件已发车',
timestamp: '2018-04-11 12:55:52'
}
]
},
orderLog: [
//
{
content: '买家【乌鸦】关闭了订单',
timestamp: '2018-04-15 15:00:16'
},
{
content: '买家【乌鸦】下单了',
timestamp: '2018-04-15 15:00:16'
}
],
goodsInfo: [] // tableData
}) })
// TODO @puhui999
const deliveryFormRef = ref() // Ref const deliveryFormRef = ref() // Ref
const updateRemarkForm = ref() // Ref const updateRemarkForm = ref() // Ref
const updateAddressFormRef = ref() // Ref const updateAddressFormRef = ref() // Ref
@ -292,36 +197,43 @@ const updatePriceFormRef = ref() // 订单调价表单 Ref
const openForm = (type: string) => { const openForm = (type: string) => {
switch (type) { switch (type) {
case 'remark': case 'remark':
updateRemarkForm.value?.open(orderInfo.value) updateRemarkForm.value?.open(formData.value)
break break
case 'delivery': case 'delivery':
deliveryFormRef.value?.open(orderInfo.value) deliveryFormRef.value?.open(formData.value)
break break
case 'updateAddress': case 'updateAddress':
updateAddressFormRef.value?.open(orderInfo.value) updateAddressFormRef.value?.open(formData.value)
break break
case 'updatePrice': case 'updatePrice':
updatePriceFormRef.value?.open(orderInfo.value) updatePriceFormRef.value?.open(formData.value)
break break
} }
} }
/** 获得详情 */ /** 获得详情 */
const { params } = useRoute() //
const getDetail = async () => { const getDetail = async () => {
const id = params.orderId as unknown as number const id = params.orderId as unknown as number
if (id) { if (id) {
const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO
orderInfo.value = res formData.value = res
} }
} }
onMounted(async () => { /** 复制 */
await getDetail()
})
const clipboardSuccess = () => { const clipboardSuccess = () => {
message.success('复制成功') message.success('复制成功')
} }
/** 初始化 **/
const deliveryExpressList = ref([]) //
const expressTrackList = ref([]) //
onMounted(async () => {
await getDetail()
deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList()
expressTrackList.value = await TradeOrderApi.getExpressTrackList(formData.value.id!)
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.el-descriptions) { :deep(.el-descriptions) {

View File

@ -60,13 +60,21 @@
<el-form-item> <el-form-item>
<el-button @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-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button @click="openCoupon" v-hasPermi="['promotion:coupon:send']">发送优惠券</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</ContentWrap> </ContentWrap>
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column label="用户编号" align="center" prop="id" width="120px" /> <el-table-column label="用户编号" align="center" prop="id" width="120px" />
<el-table-column label="头像" align="center" prop="avatar" width="80px"> <el-table-column label="头像" align="center" prop="avatar" width="80px">
<template #default="scope"> <template #default="scope">
@ -145,6 +153,8 @@
<UserForm ref="formRef" @success="getList" /> <UserForm ref="formRef" @success="getList" />
<!-- 修改用户等级弹窗 --> <!-- 修改用户等级弹窗 -->
<UpdateLevelForm ref="updateLevelFormRef" @success="getList" /> <UpdateLevelForm ref="updateLevelFormRef" @success="getList" />
<!-- 发送优惠券弹窗 -->
<CouponSendForm ref="couponSendFormRef" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
@ -154,9 +164,12 @@ import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue' import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue'
import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue' import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
import UpdateLevelForm from '@/views/member/user/UpdateLevelForm.vue' import UpdateLevelForm from '@/views/member/user/UpdateLevelForm.vue'
import CouponSendForm from '@/views/mall/promotion/coupon/components/CouponSendForm.vue'
defineOptions({ name: 'MemberUser' }) defineOptions({ name: 'MemberUser' })
const message = useMessage() //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
@ -173,6 +186,7 @@ const queryParams = reactive({
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const updateLevelFormRef = ref() // const updateLevelFormRef = ref() //
const selectedIds = ref<number[]>([]) // ID
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
@ -204,6 +218,21 @@ const openDetail = (id: number) => {
push({ name: 'MemberUserDetail', params: { id } }) push({ name: 'MemberUserDetail', params: { id } })
} }
/** 表格选中事件 */
const handleSelectionChange = (rows: UserApi.UserVO[]) => {
selectedIds.value = rows.map((row) => row.id)
}
/** 发送优惠券 */
const couponSendFormRef = ref()
const openCoupon = () => {
if (selectedIds.value.length === 0) {
message.warning('请选择要发送优惠券的用户')
return
}
couponSendFormRef.value.open(selectedIds.value)
}
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()