!270 合并商城最新代码

Merge pull request !270 from 芋道源码/dev
This commit is contained in:
芋道源码
2023-10-12 13:53:25 +00:00
committed by Gitee
91 changed files with 4047 additions and 1177 deletions

View File

@ -4,12 +4,20 @@
* 枚举类
*/
// ========== COMMON 模块 ==========
// 全局通用状态枚举
export const CommonStatusEnum = {
ENABLE: 0, // 开启
DISABLE: 1 // 禁用
}
// 全局用户类型枚举
export const UserTypeEnum = {
MEMBER: 1, // 会员
ADMIN: 2 // 管理员
}
// ========== SYSTEM 模块 ==========
/**
* 菜单的类型枚举
*/
@ -38,6 +46,25 @@ export const SystemDataScopeEnum = {
DEPT_SELF: 5 // 仅本人数据权限
}
/**
* 用户的社交平台的类型枚举
*/
export const SystemUserSocialTypeEnum = {
DINGTALK: {
title: '钉钉',
type: 20,
source: 'dingtalk',
img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
},
WECHAT_ENTERPRISE: {
title: '企业微信',
type: 30,
source: 'wechat_enterprise',
img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
}
}
// ========== INFRA 模块 ==========
/**
* 代码生成模板类型
*/
@ -65,24 +92,7 @@ export const InfraApiErrorLogProcessStatusEnum = {
IGNORE: 2 // 已忽略
}
/**
* 用户的社交平台的类型枚举
*/
export const SystemUserSocialTypeEnum = {
DINGTALK: {
title: '钉钉',
type: 20,
source: 'dingtalk',
img: 'https://s1.ax1x.com/2022/05/22/OzMDRs.png'
},
WECHAT_ENTERPRISE: {
title: '企业微信',
type: 30,
source: 'wechat_enterprise',
img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png'
}
}
// ========== PAY 模块 ==========
/**
* 支付渠道枚举
*/
@ -177,6 +187,7 @@ export const PayOrderStatusEnum = {
}
}
// ========== MALL - 商品模块 ==========
/**
* 商品 SPU 状态
*/
@ -195,6 +206,7 @@ export const ProductSpuStatusEnum = {
}
}
// ========== MALL - 营销模块 ==========
/**
* 优惠劵模板的有限期类型的枚举
*/
@ -273,17 +285,22 @@ export const PromotionDiscountTypeEnum = {
}
}
// ========== MALL - 交易模块 ==========
/**
* 分销关系绑定模式枚举
*/
export const BrokerageBindModeEnum = {
ANYTIME: {
mode: 0,
name: '没有推广人'
mode: 1,
name: '首次绑定'
},
REGISTER: {
mode: 1,
name: '新用户'
mode: 2,
name: '注册绑定'
},
OVERRIDE: {
mode: 3,
name: '覆盖绑定'
}
}
/**
@ -291,11 +308,11 @@ export const BrokerageBindModeEnum = {
*/
export const BrokerageEnabledConditionEnum = {
ALL: {
condition: 0,
condition: 1,
name: '人人分销'
},
ADMIN: {
condition: 1,
condition: 2,
name: '指定分销'
}
}
@ -358,3 +375,42 @@ export const BrokerageWithdrawTypeEnum = {
name: '支付宝'
}
}
/**
* 配送方式枚举
*/
export const DeliveryTypeEnum = {
EXPRESS: {
type: 1,
name: '快递发货'
},
PICK_UP: {
type: 2,
name: '到店自提'
}
}
/**
* 交易订单 - 状态
*/
export const TradeOrderStatusEnum = {
UNPAID: {
status: 0,
name: '待支付'
},
UNDELIVERED: {
status: 10,
name: '待发货'
},
DELIVERED: {
status: 20,
name: '已发货'
},
COMPLETED: {
status: 30,
name: '已完成'
},
CANCELED: {
status: 40,
name: '已取消'
}
}

View File

@ -24,7 +24,7 @@ export const getDictOptions = (dictType: string) => {
return dictStore.getDictByType(dictType) || []
}
export const getIntDictOptions = (dictType: string) => {
export const getIntDictOptions = (dictType: string): DictDataType[] => {
const dictOption: DictDataType[] = []
const dictOptions: DictDataType[] = getDictOptions(dictType)
dictOptions.forEach((dict: DictDataType) => {
@ -180,5 +180,7 @@ export enum DICT_TYPE {
PROMOTION_COUPON_STATUS = 'promotion_coupon_status', // 优惠劵的状态
PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式
PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态
PROMOTION_CONDITION_TYPE = 'promotion_condition_type' // 营销的条件类型枚举
PROMOTION_CONDITION_TYPE = 'promotion_condition_type', // 营销的条件类型枚举
PROMOTION_BARGAIN_RECORD_STATUS = 'promotion_bargain_record_status', // 砍价记录的状态
PROMOTION_COMBINATION_RECORD_STATUS = 'promotion_combination_record_status' // 拼团记录的状态
}

View File

@ -1,5 +1,56 @@
import dayjs from 'dayjs'
/**
* 日期快捷选项适用于 el-date-picker
*/
export const defaultShortcuts = [
{
text: '今天',
value: () => {
return new Date()
}
},
{
text: '昨天',
value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24)
return [date, date]
}
},
{
text: '最近七天',
value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
return [date, new Date()]
}
},
{
text: '最近 30 天',
value: () => {
const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 30)
return [date, new Date()]
}
},
{
text: '本月',
value: () => {
const date = new Date()
date.setDate(1) // 设置为当前月的第一天
return [date, new Date()]
}
},
{
text: '今年',
value: () => {
const date = new Date()
return [new Date(`${date.getFullYear()}-01-01`), date]
}
}
]
/**
* 时间日期转换
* @param date 当前时间new Date() 格式
@ -11,7 +62,7 @@ import dayjs from 'dayjs'
* @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ"
* @returns 返回拼接后的时间字符串
*/
export function formatDate(date: Date | number, format?: string): string {
export function formatDate(date: dayjs.ConfigType, format?: string): string {
// 日期不存在,则返回空
if (!date) {
return ''
@ -221,3 +272,68 @@ export function convertDate(param: Date | string) {
}
return param
}
/**
* 指定的两个日期, 是否为同一天
* @param a 日期 A
* @param b 日期 B
*/
export function isSameDay(a: dayjs.ConfigType, b: dayjs.ConfigType): boolean {
if (!a || !b) return false
const aa = dayjs(a)
const bb = dayjs(b)
return aa.year() == bb.year() && aa.month() == bb.month() && aa.day() == bb.day()
}
/**
* 获取一天的开始时间、截止时间
* @param date 日期
* @param days 天数
*/
export function getDayRange(
date: dayjs.ConfigType,
days: number
): [dayjs.ConfigType, dayjs.ConfigType] {
const day = dayjs(date).add(days, 'd')
return getDateRange(day, day)
}
/**
* 获取最近7天的开始时间、截止时间
*/
export function getLast7Days(): [dayjs.ConfigType, dayjs.ConfigType] {
const lastWeekDay = dayjs().subtract(7, 'd')
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastWeekDay, yesterday)
}
/**
* 获取最近30天的开始时间、截止时间
*/
export function getLast30Days(): [dayjs.ConfigType, dayjs.ConfigType] {
const lastMonthDay = dayjs().subtract(30, 'd')
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastMonthDay, yesterday)
}
/**
* 获取最近1年的开始时间、截止时间
*/
export function getLast1Year(): [dayjs.ConfigType, dayjs.ConfigType] {
const lastYearDay = dayjs().subtract(1, 'y')
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastYearDay, yesterday)
}
/**
* 获取指定日期的开始时间、截止时间
* @param beginDate 开始日期
* @param endDate 截止日期
*/
export function getDateRange(
beginDate: dayjs.ConfigType,
endDate: dayjs.ConfigType
): [dayjs.ConfigType, dayjs.ConfigType] {
return [dayjs(beginDate).startOf('d'), dayjs(endDate).endOf('d')]
}

View File

@ -1,12 +1,7 @@
import { fenToYuan } from '@/utils'
import { TableColumnCtx } from 'element-plus'
import { floatToFixed2 } from '@/utils'
// 格式化金额【分转元】
export const fenToYuanFormat = (
row: any,
column: TableColumnCtx<any>,
cellValue: any,
index: number
) => {
return `${fenToYuan(cellValue)}`
// @ts-ignore
export const fenToYuanFormat = (_, __, cellValue: any, ___) => {
return `${floatToFixed2(cellValue)}`
}

View File

@ -224,12 +224,12 @@ export const convertToInteger = (num: number | string | undefined): number => {
* 元转分
*/
export const yuanToFen = (amount: string | number): number => {
return Math.round(Number(amount) * 100)
return convertToInteger(amount)
}
/**
* 分转元
*/
export const fenToYuan = (amount: string | number): number => {
return Number((Number(amount) / 100).toFixed(2))
export const fenToYuan = (price: string | number): number => {
return formatToFraction(price)
}

View File

@ -13,7 +13,8 @@ export const defaultProps = {
children: 'children',
label: 'name',
value: 'id',
isLeaf: 'leaf'
isLeaf: 'leaf',
emitPath: false // 用于 cascader 组件:在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false则只返回该节点的值
}
const getConfig = (config: Partial<TreeHelperConfig>) => Object.assign({}, DEFAULT_CONFIG, config)
@ -377,10 +378,10 @@ export const treeToString = (tree: any[], nodeId) => {
function performAThoroughValidation(arr) {
for (const item of arr) {
if (item.id === nodeId) {
str += `/${item.name}`
str += ` / ${item.name}`
return true
} else if (typeof item.children !== 'undefined' && item.children.length !== 0) {
str += `/${item.name}`
str += ` / ${item.name}`
if (performAThoroughValidation(item.children)) {
return true
}