commit
190c6e384c
@ -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 { oneOf } from 'vue-types'
|
||||||
|
import { propTypes } from '@/utils/propTypes'
|
||||||
|
|
||||||
|
/** 商品分类选择组件 */
|
||||||
|
defineOptions({ name: 'ProductCategorySelect' })
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
value: oneOf([propTypes.number, propTypes.array.def([])]).isRequired, // 选中的ID
|
||||||
|
multiple: propTypes.bool.def(false) // 是否多选
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 选中的分类ID */
|
||||||
|
const selectCategoryId = computed({
|
||||||
|
get: () => {
|
||||||
|
return props.value
|
||||||
|
},
|
||||||
|
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>
|
||||||
@ -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 userPriceFormat = (row: CouponTemplateVO) => {
|
||||||
|
return `¥${floatToFixed2(row.usePrice)}`
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue