upda
parent
853daaf00a
commit
52e1ccdaf3
@ -0,0 +1,31 @@
|
||||
import {
|
||||
request
|
||||
} from "@/utils/request";
|
||||
|
||||
export default {
|
||||
list(data) {
|
||||
return request({
|
||||
url: "/admin/goods/goodsList",
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
goodsEditAttribute(data) {
|
||||
return request({
|
||||
url: "/admin/goods/goodsEditAttribute",
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
classify: {
|
||||
list(data) {
|
||||
return request({
|
||||
url: "/admin/classify/list",
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<view class="myTable">
|
||||
<wd-toast />
|
||||
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
||||
<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
|
||||
<slot :list="list"></slot>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
||||
import { useToast } from '@/uni_modules/wot-design-uni'
|
||||
const toast = useToast()
|
||||
const props = defineProps({
|
||||
apiObj: {
|
||||
type: Function,
|
||||
default: () => (() => { })
|
||||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
const query = ref({
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const list = ref([])
|
||||
|
||||
const getData = async () => {
|
||||
console.log(getData);
|
||||
|
||||
loading.value = true
|
||||
const res = await props.apiObj({
|
||||
...query.value,
|
||||
...props.params
|
||||
})
|
||||
|
||||
if (res.data.rows.length) {
|
||||
query.value.pageSize = res.data.pageSize
|
||||
total.value = res.data.total
|
||||
list.value = [...list.value, ...res.data.rows]
|
||||
} else {
|
||||
toast.success('全部加载完了')
|
||||
}
|
||||
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
getData()
|
||||
|
||||
const upData = async (upParams = {}) => {
|
||||
loading.value = true
|
||||
query.value.page = 1
|
||||
query.value.pageSize = 20
|
||||
|
||||
const res = await props.apiObj({
|
||||
...query.value,
|
||||
...props.params,
|
||||
...upParams
|
||||
})
|
||||
|
||||
query.value.pageSize = res.data.pageSize
|
||||
total.value = res.data.total
|
||||
list.value = res.data.rows
|
||||
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const lower = e => {
|
||||
query.value.page++
|
||||
getData()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
upData
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.scroll-Y {
|
||||
height: calc(100vh - 120px);
|
||||
}
|
||||
</style>
|
||||
@ -1,26 +1,82 @@
|
||||
<template>
|
||||
<view class="myTable">
|
||||
<wd-pagination v-model="value" :total="total" :page-size="page" @change="handleChange" show-icon show-message />
|
||||
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
||||
|
||||
<wd-table :data="list" :border="true">
|
||||
<slot></slot>
|
||||
</wd-table>
|
||||
|
||||
<wd-pagination v-model="query.page" :total="total" :page-size="query.pageSize" @change="handleChange" show-icon
|
||||
show-message />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
||||
|
||||
const props = defineProps({
|
||||
apiObj: {
|
||||
type: Function,
|
||||
default: () => (() => { })
|
||||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
const value = ref("")
|
||||
const query = ref({
|
||||
page: 1,
|
||||
pageSize: 20
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const list = ref([])
|
||||
|
||||
const getData = async () => {
|
||||
loading.value = true
|
||||
const res = await props.apiObj({
|
||||
...query.value,
|
||||
...props.params
|
||||
})
|
||||
|
||||
query.value.pageSize = res.data.pageSize
|
||||
total.value = res.data.total
|
||||
list.value = res.data.rows
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
getData()
|
||||
|
||||
function handleChange(e) {
|
||||
console.log(e);
|
||||
const upData = async (upParams = {}) => {
|
||||
loading.value = true
|
||||
query.value.page = 1
|
||||
query.value.pageSize = 20
|
||||
|
||||
const res = await props.apiObj({
|
||||
...query.value,
|
||||
...props.params,
|
||||
...upParams
|
||||
})
|
||||
|
||||
query.value.pageSize = res.data.pageSize
|
||||
total.value = res.data.total
|
||||
list.value = res.data.rows
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
|
||||
function handleChange({ value }) {
|
||||
query.value.page = value
|
||||
getData()
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
upData
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
|
||||
@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<wd-notify />
|
||||
|
||||
<wd-search @search="search" v-model="params.keywords" hide-cancel>
|
||||
<template #prefix>
|
||||
<wd-popover v-model="popover" mode="menu" :content="menu" @menuclick="changeSearchType">
|
||||
<view class="search-type">
|
||||
<text>{{ searchType }}</text>
|
||||
<wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
|
||||
</view>
|
||||
</wd-popover>
|
||||
</template>
|
||||
</wd-search>
|
||||
|
||||
<myTable ref="table" :apiObj="goods.list" :params="params">
|
||||
<wd-table-col fixed prop="id" width="60" align="center" label="ID"></wd-table-col>
|
||||
<wd-table-col prop="name" width="180" label="商品名称"></wd-table-col>
|
||||
<wd-table-col prop="stock_num" align="center" width="80" label="库存">
|
||||
<template #value="{ row }">
|
||||
<view class="custom-class">
|
||||
<wd-tag v-if="row.stock_num > 0" type="primary">{{ row.stock_num }}</wd-tag>
|
||||
<wd-tag v-else type="warning">{{ row.stock_num }}</wd-tag>
|
||||
</view>
|
||||
</template>
|
||||
</wd-table-col>
|
||||
<wd-table-col prop="stock_num" align="center" width="80" label="状态">
|
||||
<template #value="{ row }">
|
||||
<view class="custom-class">
|
||||
<wd-switch @change="changeS(row)" v-model="row.status" :inactive-value="0" :active-value="1" size="16px" />
|
||||
</view>
|
||||
</template>
|
||||
</wd-table-col>
|
||||
|
||||
<wd-table-col width="120" align="center" label="操作">
|
||||
|
||||
<template #value="{ row }">
|
||||
<view class="custom-class">
|
||||
<wd-button :round="false" size="small">编辑</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
</wd-table-col>
|
||||
</myTable>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import myTable from "/components/myTable/index.vue"
|
||||
import goods from '@/api/store/goods.js'
|
||||
import utils from '@/utils/utils.js'
|
||||
import { useNotify } from '@/uni_modules/wot-design-uni'
|
||||
const { showNotify, closeNotify } = useNotify()
|
||||
|
||||
const params = {
|
||||
keywords: "",
|
||||
calssify_id: "",
|
||||
status: "",
|
||||
}
|
||||
|
||||
const searchType = ref('全部')
|
||||
const popover = ref(false)
|
||||
|
||||
const menu = ref([
|
||||
{
|
||||
content: '全部'
|
||||
},
|
||||
{
|
||||
content: '已上架'
|
||||
},
|
||||
{
|
||||
content: '已下架'
|
||||
}
|
||||
])
|
||||
|
||||
const table = ref(null)
|
||||
const search = ({ value }) => {
|
||||
table.value.upData({
|
||||
keywords: value
|
||||
})
|
||||
}
|
||||
|
||||
function changeSearchType({ item, index }) {
|
||||
searchType.value = item.content
|
||||
|
||||
if (item.content == '全部') {
|
||||
params.status = ""
|
||||
}
|
||||
|
||||
if (item.content == '已上架') {
|
||||
params.status = 1
|
||||
}
|
||||
|
||||
if (item.content == '已下架') {
|
||||
params.status = 0
|
||||
}
|
||||
|
||||
search({
|
||||
value: ""
|
||||
})
|
||||
}
|
||||
|
||||
const changeS = (row) => {
|
||||
goods.goodsEditAttribute({
|
||||
id: row.id,
|
||||
value: [1, 0][row.status],
|
||||
type: "status"
|
||||
}).then(res => {
|
||||
|
||||
if (res.code == 0) {
|
||||
showNotify({ type: 'primary', message: '操作成功' })
|
||||
} else {
|
||||
showNotify({ type: 'error', message: '出错了' })
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-type {
|
||||
position: relative;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 8px 0 16px;
|
||||
font-size: 24rpx;
|
||||
color: rgba(0, 0, 0, .45);
|
||||
}
|
||||
|
||||
.search-type::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
width: 1px;
|
||||
right: 0;
|
||||
top: 5px;
|
||||
bottom: 5px;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.search-type {
|
||||
:deep(.icon-arrow) {
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<view class="content p-4">
|
||||
|
||||
<!-- <myTable></myTable> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import utils from '@/utils/utils.js'
|
||||
import myTable from "/components/myTable/index.vue"
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
Loading…
Reference in New Issue