feat: 商品首页
This commit is contained in:
parent
03f8a53cb0
commit
cf6aa9033e
11
src/api/order.ts
Normal file
11
src/api/order.ts
Normal file
@ -0,0 +1,11 @@
|
||||
const order = {
|
||||
/**
|
||||
* 订单管理
|
||||
*/
|
||||
getOrderList: ['/order/list'], // 获取订单管理
|
||||
packOrder: ['/order/topack'], // 打包
|
||||
unpackOrder: ['/order/unpack'], // 取消打包
|
||||
unpackOrder: ['/order/delivered'] // 妥投
|
||||
}
|
||||
|
||||
export default order
|
||||
@ -55,14 +55,14 @@ export const getTableData = (
|
||||
.$api(params)
|
||||
.then((res) => {
|
||||
const result = res as {
|
||||
data: { rows: [] }
|
||||
data: { rows: []; totalPage: number }
|
||||
code: string
|
||||
resultMsg: string
|
||||
totalPage: number
|
||||
}
|
||||
table.$loading = false
|
||||
table.$data = result.data.rows
|
||||
table.$pages.total = result.totalPage
|
||||
table.$pages.total = result.data.totalPage
|
||||
})
|
||||
.catch(() => {
|
||||
table.$loading = false
|
||||
|
||||
@ -69,7 +69,7 @@ const onChangeStatus = (row: any) => {
|
||||
const type = row.status === 'online' ? '下架' : '上架'
|
||||
handleMessageBox({
|
||||
msg: `是否确认${type}吗?`,
|
||||
success: api.commodity.addOrUpdateCommodity.post!,
|
||||
success: api.commodity.changeCommodityInfo.post!,
|
||||
data: {
|
||||
id: row.id,
|
||||
status: row.status === 'online' ? 'down' : 'online'
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
type TCommodityType = 'online' | 'quit' | 'edit' | 'delete'
|
||||
type TCommodityType = 'online' | 'down' | 'draft' | 'delete'
|
||||
|
||||
export const useCommodityType = (search: any, table: any) => {
|
||||
let beforeValue = 'online'
|
||||
const commodityType = ref<TCommodityType>('online')
|
||||
const commodityTypeOptions = [
|
||||
{ label: '在线商品', value: 'online' },
|
||||
{ label: '下架商品', value: 'quit' },
|
||||
{ label: '草稿', value: 'edit' },
|
||||
{ label: '下架商品', value: 'down' },
|
||||
{ label: '草稿', value: 'draft' },
|
||||
{ label: '已删商品', value: 'delete' }
|
||||
]
|
||||
const cacheTableData = { online: [], quit: [], edit: [], delete: [] } // 缓存表单数据
|
||||
const cacheTablePage = { online: {}, quit: {}, edit: {}, delete: {} } // 缓存表单页面数据
|
||||
const onChangeCommodityType = (type: 'online' | 'quit' | 'edit' | 'delete') => {
|
||||
const cacheTableData = { online: [], down: [], draft: [], delete: [] } // 缓存表单数据
|
||||
const cacheTablePage = { online: {}, down: {}, draft: {}, delete: {} } // 缓存表单页面数据
|
||||
const onChangeCommodityType = (type: 'online' | 'down' | 'draft' | 'delete') => {
|
||||
cacheTableData[beforeValue as typeof type] = toRaw(table.value.$data)
|
||||
cacheTablePage[beforeValue as typeof type] = toRaw(table.value.$pages)
|
||||
beforeValue = type
|
||||
search.value.$default = { type }
|
||||
search.value.$default = { status: type }
|
||||
search.value.$data = { status: type }
|
||||
handleSetTableConfig(table, type)
|
||||
if (cacheTableData[type].length) {
|
||||
table.value.$data = cacheTableData[type]
|
||||
@ -24,10 +25,10 @@ export const useCommodityType = (search: any, table: any) => {
|
||||
table.value.$onGetData(table.value, 1, search)
|
||||
}
|
||||
}
|
||||
const handleSetTableConfig = (table: any, type: 'online' | 'quit' | 'edit' | 'delete') => {
|
||||
const btnOnlineName = { online: '下架', quit: '上架', edit: '', delete: '' } // 上下架按钮名称
|
||||
const btnHomeName = { online: '加入首页', quit: '', edit: '', delete: '' } // 上下架按钮名称
|
||||
const btnWidth = { online: '230', quit: '180', edit: '160', delete: '160' } // 上下架按钮名称
|
||||
const handleSetTableConfig = (table: any, type: 'online' | 'down' | 'draft' | 'delete') => {
|
||||
const btnOnlineName = { online: '下架', down: '上架', draft: '', delete: '' } // 上下架按钮名称
|
||||
const btnHomeName = { online: '加入首页', down: '', draft: '', delete: '' } // 上下架按钮名称
|
||||
const btnWidth = { online: '230', down: '180', draft: '160', delete: '160' } // 上下架按钮名称
|
||||
table.value.btn.$attr.names[2] = btnHomeName[type]
|
||||
table.value.btn.$attr.names[3] = btnOnlineName[type]
|
||||
table.value.btn.$attr.width = btnWidth[type]
|
||||
|
||||
@ -11,9 +11,9 @@ export const initConfig = () => {
|
||||
sales: { label: '销量' },
|
||||
price: { label: '价格' },
|
||||
btn: {
|
||||
types: ['primary', 'info', 'warning', 'success', 'danger'],
|
||||
names: ['编辑', '复制', '加入首页', '上下架', '删除'],
|
||||
width: 230
|
||||
types: ['primary'],
|
||||
names: ['移除首页'],
|
||||
width: 90
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -15,14 +15,8 @@
|
||||
import { useDraggable } from 'vue-draggable-plus'
|
||||
import { initConfig } from './config'
|
||||
|
||||
/** 新增&编辑 */
|
||||
const onAddOrEdit = (type: string, row: any) => {}
|
||||
|
||||
/** 复制 */
|
||||
const onCopy = (row: any) => {}
|
||||
|
||||
// 加入首页
|
||||
const onAddHome = (row: any) => {}
|
||||
// 移除首页
|
||||
const onRemoveHome = (row: any) => {}
|
||||
|
||||
// 删除
|
||||
const onDelete = (row: any) => {
|
||||
@ -37,12 +31,11 @@ const onDelete = (row: any) => {
|
||||
|
||||
/** 初始化页面 */
|
||||
const ConfigData = initConfig()
|
||||
const { search, table } = handleInit(ConfigData, api.commodity.getHomeCommodityList.post, [
|
||||
onAddOrEdit.bind(null, 'edit'),
|
||||
onCopy,
|
||||
onAddHome,
|
||||
onDelete
|
||||
const { search, table } = handleInit(ConfigData, api.commodity.getCommodityList.post, [
|
||||
onRemoveHome
|
||||
])
|
||||
search.value.$default = { frontPage: 1 }
|
||||
table.value.$pages.pageSize = 1000
|
||||
table.value.$onGetData(table.value, 1, search)
|
||||
setTimeout(() => {
|
||||
useDraggable('#table-drag-wrap .el-table__body tbody', table.value.$data)
|
||||
|
||||
21
src/views/goods/order-manage/config.ts
Normal file
21
src/views/goods/order-manage/config.ts
Normal file
@ -0,0 +1,21 @@
|
||||
const configData = ref()
|
||||
export const initConfig = () => {
|
||||
configData.value = pageConfig({
|
||||
search: {
|
||||
comTitle: { label: '标题', clearable: true },
|
||||
comCategoryId: { label: '类目', option: [], clearable: true }
|
||||
},
|
||||
table: {
|
||||
id: { label: '产品ID' },
|
||||
comTitle: { label: '标题' },
|
||||
sales: { label: '销量' },
|
||||
price: { label: '价格' },
|
||||
btn: {
|
||||
types: ['primary', 'info', 'warning', 'success', 'danger'],
|
||||
names: ['编辑', '复制', '加入首页', '上下架', '删除'],
|
||||
width: 230
|
||||
}
|
||||
}
|
||||
})
|
||||
return configData
|
||||
}
|
||||
53
src/views/goods/order-manage/index.vue
Normal file
53
src/views/goods/order-manage/index.vue
Normal file
@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div>
|
||||
<search-module :search="search" :table="table">
|
||||
<template #btn>
|
||||
<el-button @click="onAddOrEdit('add', null)" type="success">新增</el-button>
|
||||
</template>
|
||||
</search-module>
|
||||
<div id="table-drag-wrap">
|
||||
<table-module :table="table"> </table-module>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useDraggable } from 'vue-draggable-plus'
|
||||
import { initConfig } from './config'
|
||||
|
||||
/** 新增&编辑 */
|
||||
const onAddOrEdit = (type: string, row: any) => {}
|
||||
|
||||
/** 复制 */
|
||||
const onCopy = (row: any) => {}
|
||||
|
||||
// 加入首页
|
||||
const onAddHome = (row: any) => {}
|
||||
|
||||
// 删除
|
||||
const onDelete = (row: any) => {
|
||||
handleMessageBox({
|
||||
msg: `是否确认删除吗?`,
|
||||
success: api.commodity.delCommodity.post!,
|
||||
data: { id: row.id }
|
||||
}).then(() => {
|
||||
table.value.$onGetData(table.value)
|
||||
})
|
||||
}
|
||||
|
||||
/** 初始化页面 */
|
||||
const ConfigData = initConfig()
|
||||
const { search, table } = handleInit(ConfigData, api.commodity.getHomeCommodityList.post, [
|
||||
onAddOrEdit.bind(null, 'edit'),
|
||||
onCopy,
|
||||
onAddHome,
|
||||
onDelete
|
||||
])
|
||||
table.value.$onGetData(table.value, 1, search)
|
||||
setTimeout(() => {
|
||||
useDraggable('#table-drag-wrap .el-table__body tbody', table.value.$data)
|
||||
}, 2000)
|
||||
|
||||
/** 页面缓存 */
|
||||
defineOptions({ name: 'HomeGoods' })
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user