feat: 新增产品分类模块页面&api
parent
d6f2eafbde
commit
b8ce330c12
@ -0,0 +1,60 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类
|
||||||
|
*/
|
||||||
|
export interface CategoryVO {
|
||||||
|
/**
|
||||||
|
* 分类编号
|
||||||
|
*/
|
||||||
|
id?: number
|
||||||
|
/**
|
||||||
|
* 父分类编号
|
||||||
|
*/
|
||||||
|
parentId?: number
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
name: string
|
||||||
|
/**
|
||||||
|
* 分类图片
|
||||||
|
*/
|
||||||
|
picUrl: string
|
||||||
|
/**
|
||||||
|
* 分类排序
|
||||||
|
*/
|
||||||
|
sort?: number
|
||||||
|
/**
|
||||||
|
* 分类描述
|
||||||
|
*/
|
||||||
|
description?: string
|
||||||
|
/**
|
||||||
|
* 开启状态
|
||||||
|
*/
|
||||||
|
status: number
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建商品分类
|
||||||
|
export const createCategory = (data: CategoryVO) => {
|
||||||
|
return request.post({ url: '/product/category/create', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新商品分类
|
||||||
|
export const updateCategory = (data: CategoryVO) => {
|
||||||
|
return request.put({ url: '/product/category/update', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除商品分类
|
||||||
|
export const deleteCategory = (id: number) => {
|
||||||
|
return request.delete({ url: `/product/category/delete?id=${id}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得商品分类
|
||||||
|
export const getCategory = (id: number) => {
|
||||||
|
return request.get({ url: `/product/category/get?id=${id}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得商品分类列表
|
||||||
|
export const getCategoryList = (params: any) => {
|
||||||
|
return request.get({ url: '/product/category/list', params })
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
export const parseTime = (time) => {
|
||||||
|
if (!time) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const format = '{y}-{m}-{d} {h}:{i}:{s}'
|
||||||
|
let date
|
||||||
|
if (typeof time === 'object') {
|
||||||
|
date = time
|
||||||
|
} else {
|
||||||
|
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
|
||||||
|
time = parseInt(time)
|
||||||
|
} else if (typeof time === 'string') {
|
||||||
|
time = time
|
||||||
|
.replace(new RegExp(/-/gm), '/')
|
||||||
|
.replace('T', ' ')
|
||||||
|
.replace(new RegExp(/\.[\d]{3}/gm), '')
|
||||||
|
}
|
||||||
|
if (typeof time === 'number' && time.toString().length === 10) {
|
||||||
|
time = time * 1000
|
||||||
|
}
|
||||||
|
date = new Date(time)
|
||||||
|
}
|
||||||
|
const formatObj = {
|
||||||
|
y: date.getFullYear(),
|
||||||
|
m: date.getMonth() + 1,
|
||||||
|
d: date.getDate(),
|
||||||
|
h: date.getHours(),
|
||||||
|
i: date.getMinutes(),
|
||||||
|
s: date.getSeconds(),
|
||||||
|
a: date.getDay()
|
||||||
|
}
|
||||||
|
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||||
|
let value = formatObj[key]
|
||||||
|
// Note: getDay() returns 0 on Sunday
|
||||||
|
if (key === 'a') {
|
||||||
|
return ['日', '一', '二', '三', '四', '五', '六'][value]
|
||||||
|
}
|
||||||
|
if (result.length > 0 && value < 10) {
|
||||||
|
value = '0' + value
|
||||||
|
}
|
||||||
|
return value || 0
|
||||||
|
})
|
||||||
|
return time_str
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue