feat(custom): i

This commit is contained in:
2023-09-06 03:48:46 +08:00
parent 3b3cb7ba34
commit a9707c6d94
51 changed files with 2273 additions and 87 deletions

View 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>