feat(custom): i
This commit is contained in:
6
src/views/commodity/commodity_class/api.js
Normal file
6
src/views/commodity/commodity_class/api.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { request } from '@/utils'
|
||||
|
||||
export default {
|
||||
getMerClass: (data) => request.post('/classify', data),
|
||||
addMerClass: (data) => request.post('/classify/edit', data),
|
||||
}
|
||||
182
src/views/commodity/commodity_class/index.vue
Normal file
182
src/views/commodity/commodity_class/index.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<CommonPage show-footer :title="$route.title">
|
||||
<n-button type="primary" @click="handleAdd(1)">新增商品分类</n-button>
|
||||
<!-- {{ formValue }} -->
|
||||
<n-data-table
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
:pagination="pagination"
|
||||
:bordered="false"
|
||||
/>
|
||||
<n-modal v-model:show="showModal">
|
||||
<n-card
|
||||
style="width: 400px"
|
||||
:title="modelTitle"
|
||||
:bordered="false"
|
||||
size="huge"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<n-form ref="formRef" label-placement="left" :model="formValue" :rules="rules">
|
||||
<n-form-item label="分类名称:" path="name">
|
||||
<n-input v-model:value="formValue.name" placeholder="请输入商户分类名称" />
|
||||
</n-form-item>
|
||||
<n-form-item label="分类状态:" path="status">
|
||||
<n-switch v-model:value="formValue.status" :checked-value="1" :unchecked-value="2" />
|
||||
</n-form-item>
|
||||
<n-form-item>
|
||||
<div class="m-auto">
|
||||
<n-button
|
||||
class="m-auto"
|
||||
type="primary"
|
||||
attr-type="button"
|
||||
@click="handleValidateClick"
|
||||
>
|
||||
提交
|
||||
</n-button>
|
||||
<n-button class="ml-10" @click="clear">取消</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
</n-modal>
|
||||
</CommonPage>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, h } from 'vue'
|
||||
import api from './api'
|
||||
import { NButton } from 'naive-ui'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: 'ID',
|
||||
align: 'center',
|
||||
key: 'ID',
|
||||
},
|
||||
{
|
||||
title: '分类名称',
|
||||
align: 'center',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
slot: 'status',
|
||||
render(row) {
|
||||
return h('span', row.status === 1 ? '正常' : '禁用')
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
slot: 'action',
|
||||
render(row) {
|
||||
return [
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
type: 'primary',
|
||||
size: 'small',
|
||||
onClick: () => {
|
||||
formValue.value = row
|
||||
handleAdd(2)
|
||||
},
|
||||
},
|
||||
() => '编辑'
|
||||
),
|
||||
]
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const data = ref([])
|
||||
|
||||
const formRef = ref(null)
|
||||
|
||||
const rules = {
|
||||
name: {
|
||||
required: true,
|
||||
message: '请输入商户分类名称',
|
||||
},
|
||||
}
|
||||
|
||||
const formValue = ref({
|
||||
name: '',
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const showModal = ref(false)
|
||||
|
||||
const pagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
onChange: (page) => {
|
||||
pagination.value.page = page
|
||||
getList()
|
||||
},
|
||||
onUpdatePageSize: (pageSize) => {
|
||||
pagination.value.pageSize = pageSize
|
||||
pagination.value.page = 1
|
||||
getList()
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await api.getMerClass({
|
||||
pageNum: pagination.value.current,
|
||||
pageSize: pagination.value.pageSize,
|
||||
})
|
||||
console.log(res)
|
||||
data.value = res.data.data
|
||||
} catch (error) {
|
||||
$message.error(error.msg)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const modelTitle = ref('')
|
||||
|
||||
const handleAdd = (e) => {
|
||||
modelTitle.value = e === 1 ? '新增商品分类' : '编辑商品分类'
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
const clear = () => {
|
||||
formValue.value = {
|
||||
name: '',
|
||||
status: 1,
|
||||
}
|
||||
showModal.value = false
|
||||
}
|
||||
|
||||
const handleValidateClick = async (e) => {
|
||||
e.preventDefault()
|
||||
formRef.value?.validate(async (errors) => {
|
||||
if (!errors) {
|
||||
try {
|
||||
await api.addMerClass(formValue.value)
|
||||
$message.success('成功')
|
||||
clear()
|
||||
getList()
|
||||
} catch (error) {
|
||||
$message.error(error.msg)
|
||||
}
|
||||
} else {
|
||||
$message.error('Invalid')
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
6
src/views/commodity/hot_list/api.js
Normal file
6
src/views/commodity/hot_list/api.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { request } from '@/utils'
|
||||
|
||||
export default {
|
||||
getHotlist: (data) => request.post('/goods', data),
|
||||
getHotStatus: (data) => request.post('/goods/process', data),
|
||||
}
|
||||
155
src/views/commodity/hot_list/index.vue
Normal file
155
src/views/commodity/hot_list/index.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<CommonPage show-footer :title="$route.title">
|
||||
<n-data-table
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
:pagination="pagination"
|
||||
:bordered="false"
|
||||
remote
|
||||
/>
|
||||
</CommonPage>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import api from './api'
|
||||
import { NDropdown, NButton } from 'naive-ui'
|
||||
import { h } from 'vue'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '商品名称',
|
||||
key: 'name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品封面',
|
||||
slot: 'cover',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
return h('img', {
|
||||
src: row.cover,
|
||||
style: {
|
||||
width: '30px',
|
||||
height: '30px',
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '商品分类',
|
||||
key: 'class_name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品价格',
|
||||
key: 'number',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品库存',
|
||||
key: 'stock',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品状态',
|
||||
slot: 'status',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
return row.status === 0 ? '待审核' : row.status === 1 ? '已审核' : '已拒绝'
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
slot: 'action',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
const el = []
|
||||
|
||||
if (row.status === 0) {
|
||||
el.push(
|
||||
h(
|
||||
NDropdown,
|
||||
{
|
||||
trigger: 'click',
|
||||
options: [
|
||||
{
|
||||
label: '审核',
|
||||
key: 1,
|
||||
},
|
||||
{
|
||||
label: '拒绝',
|
||||
key: 2,
|
||||
},
|
||||
],
|
||||
onSelect: (key) => {
|
||||
veeify(key, row)
|
||||
},
|
||||
},
|
||||
() =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
type: 'primary',
|
||||
text: true,
|
||||
},
|
||||
() => '审核'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return el
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const data = ref([])
|
||||
|
||||
const pagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
itamCount: 0,
|
||||
onChange: (page) => {
|
||||
pagination.value.page = page
|
||||
getList()
|
||||
},
|
||||
onUpdatePageSize: (pageSize) => {
|
||||
pagination.value.pageSize = pageSize
|
||||
pagination.value.page = 1
|
||||
getList()
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await api.getHotlist({
|
||||
pageNum: pagination.value.current,
|
||||
pageSize: pagination.value.pageSize,
|
||||
})
|
||||
console.log(res)
|
||||
data.value = res.data.data || []
|
||||
} catch (error) {
|
||||
$message.error(error.msg)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const veeify = async (key, row) => {
|
||||
const res = await api.getHotStatus({
|
||||
gid: row.gid,
|
||||
status: key,
|
||||
})
|
||||
console.log(res)
|
||||
getList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
6
src/views/commodity/point/api.js
Normal file
6
src/views/commodity/point/api.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { request } from '@/utils'
|
||||
|
||||
export default {
|
||||
getPointlist: (data) => request.post('/point/goods', data),
|
||||
getPointStatus: (data) => request.post('/point/goods/process', data),
|
||||
}
|
||||
155
src/views/commodity/point/index.vue
Normal file
155
src/views/commodity/point/index.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<CommonPage show-footer :title="$route.title">
|
||||
<n-data-table
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
:pagination="pagination"
|
||||
:bordered="false"
|
||||
/>
|
||||
</CommonPage>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import api from './api'
|
||||
import { NDropdown, NButton } from 'naive-ui'
|
||||
import { h } from 'vue'
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '商品名称',
|
||||
key: 'name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品封面',
|
||||
slot: 'cover',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
return h('img', {
|
||||
src: row.cover,
|
||||
style: {
|
||||
width: '30px',
|
||||
height: '30px',
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '商品分类',
|
||||
key: 'class_name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品价格',
|
||||
key: 'number',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品库存',
|
||||
key: 'stock',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '商品状态',
|
||||
slot: 'status',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
return row.status === 0 ? '待审核' : row.status === 1 ? '已审核' : '已拒绝'
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
slot: 'action',
|
||||
align: 'center',
|
||||
render(row) {
|
||||
const el = []
|
||||
|
||||
if (row.status === 0) {
|
||||
el.push(
|
||||
h(
|
||||
NDropdown,
|
||||
{
|
||||
trigger: 'click',
|
||||
options: [
|
||||
{
|
||||
label: '审核',
|
||||
key: 1,
|
||||
},
|
||||
{
|
||||
label: '拒绝',
|
||||
key: 2,
|
||||
},
|
||||
],
|
||||
onSelect: (key) => {
|
||||
veeify(key, row)
|
||||
},
|
||||
},
|
||||
() =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
type: 'primary',
|
||||
text: true,
|
||||
},
|
||||
() => '审核'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return el
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const data = ref([])
|
||||
|
||||
const pagination = ref({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
onChange: (page) => {
|
||||
pagination.value.page = page
|
||||
getList()
|
||||
},
|
||||
onUpdatePageSize: (pageSize) => {
|
||||
pagination.value.pageSize = pageSize
|
||||
pagination.value.page = 1
|
||||
getList()
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await api.getPointlist({
|
||||
pageNum: pagination.value.current,
|
||||
pageSize: pagination.value.pageSize,
|
||||
})
|
||||
console.log(res)
|
||||
data.value = res.data.data || []
|
||||
} catch (error) {
|
||||
$message.error(error.msg)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const veeify = async (key, row) => {
|
||||
console.log(typeof key)
|
||||
const res = await api.getPointStatus({
|
||||
gid: row.gid,
|
||||
status: key,
|
||||
})
|
||||
console.log(res)
|
||||
getList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
40
src/views/commodity/route.js
Normal file
40
src/views/commodity/route.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
|
||||
export default {
|
||||
name: '商品管理',
|
||||
path: '/commodity',
|
||||
component: Layout,
|
||||
redirect: '/commodity_class',
|
||||
children: [
|
||||
{
|
||||
name: 'CommodityClass',
|
||||
path: 'commodity_class',
|
||||
component: () => import('./commodity_class/index.vue'),
|
||||
meta: {
|
||||
title: '商品分类',
|
||||
icon: 'mdi:account-multiple',
|
||||
order: 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'HotList',
|
||||
path: 'hot_list',
|
||||
component: () => import('./hot_list/index.vue'),
|
||||
meta: {
|
||||
title: '活动商品',
|
||||
icon: 'mdi:account-multiple',
|
||||
order: 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'PointList',
|
||||
path: 'point_list',
|
||||
component: () => import('./point/index.vue'),
|
||||
meta: {
|
||||
title: '积分商品',
|
||||
icon: 'mdi:account-multiple',
|
||||
order: 10,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user