Commit 881ec672 by YunaiV
parents 067f89f1 13020895
...@@ -16,3 +16,11 @@ export const getCouponPage = async (params: PageParam) => { ...@@ -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
})
}
...@@ -9,7 +9,7 @@ export interface CouponTemplateVO { ...@@ -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
......
...@@ -15,11 +15,11 @@ export interface OrderVO { ...@@ -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 { ...@@ -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) => { ...@@ -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 // 物流公司编号
......
...@@ -210,16 +210,38 @@ export const CouponTemplateValidityTypeEnum = { ...@@ -210,16 +210,38 @@ 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: '品类劵'
} }
} }
......
...@@ -59,7 +59,7 @@ ...@@ -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" />
......
<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>
...@@ -38,7 +38,7 @@ ...@@ -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" />
......
...@@ -115,7 +115,7 @@ ...@@ -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"
......
...@@ -147,7 +147,7 @@ const handleDelete = async (id: number) => { ...@@ -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()
......
...@@ -328,12 +328,10 @@ const tableHeaders = ref<{ prop: string; label: string }[]>([]) // 多属性表 ...@@ -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 = () => { ...@@ -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)
......
<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 @@ ...@@ -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 }">
<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 }"> <template #default="{ row }">
<el-radio :label="row.id" v-model="selectedSpuId" @change="handleSelected(row)" <el-radio :label="row.id" v-model="selectedSpuId" @change="handleSingleSelected(row)"
>&nbsp;</el-radio >&nbsp;</el-radio
> >
</template> </template>
...@@ -65,7 +82,7 @@ ...@@ -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 @@ ...@@ -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' ...@@ -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({ ...@@ -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 () => { ...@@ -138,6 +165,7 @@ const getList = async () => {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNo = 1
getList() getList()
} }
...@@ -154,9 +182,65 @@ const resetQuery = () => { ...@@ -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()
......
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 { ...@@ -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 }
...@@ -109,7 +109,12 @@ ...@@ -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 @@ ...@@ -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' ...@@ -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' ...@@ -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) => { ...@@ -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() // 消息弹窗
......
...@@ -142,17 +142,6 @@ const submitForm = async () => { ...@@ -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 () => { ...@@ -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 () => {
......
...@@ -170,6 +170,14 @@ ...@@ -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 @@ ...@@ -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
......
<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>
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)}`
}
...@@ -122,7 +122,8 @@ const queryParams = reactive({ ...@@ -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() // 搜索的表单
......
...@@ -103,7 +103,7 @@ ...@@ -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 @@ ...@@ -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({ ...@@ -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) => { ...@@ -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()
......
...@@ -122,8 +122,36 @@ ...@@ -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 ...@@ -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 () => { ...@@ -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) => { ...@@ -206,6 +240,7 @@ const imagePreview = (args) => {
urlList urlList
}) })
} }
onMounted(async () => { onMounted(async () => {
await getDetail() await getDetail()
}) })
......
...@@ -60,13 +60,21 @@ ...@@ -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 @@ ...@@ -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' ...@@ -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({ ...@@ -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) => { ...@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment