商品分组更新:

增加编辑售卖时间
编辑分组名称
This commit is contained in:
YeMingfei666 2024-10-15 15:21:50 +08:00
parent a9fb79b9f5
commit 24f34e8f8c
6 changed files with 349 additions and 63 deletions

View File

@ -32,7 +32,7 @@
<text class="u-m-r-24">{{data.name}}</text>
</view>
<view class="u-font-32">
<text v-if="data.typeEnum=='单规格'">¥</text>
<text v-if="data.typeEnum=='单规格'||data.typeEnum=='normal'">¥</text>
<text>{{data.lowPrice}}</text>
</view>
</view>

View File

@ -14,12 +14,13 @@
</view>
<uni-easyinput clearable class='jeepay-search' :inputBorder="false"
:placeholder="pageData.search.placeholder" v-model="pageData.query.name"
@clear="searchFunc"
@confirm="searchFunc">
<template #prefixIcon>
<image src="@/static/iconImg/icon-search.svg" class="input-icon" />
</template>
</uni-easyinput>
<button type="text" @click="searchFunc()">搜索</button>
<button type="text" @click="searchFunc">搜索</button>
</view>
</view>
<view class="u-flex states1 u-row-between u-font-28">
@ -36,13 +37,12 @@
<view class="goods-list u-p-30">
<template v-if="pageData.bindGoodsList.length">
<view class="u-m-b-32" v-for="(item,index) in pageData.bindGoodsList" :key="index">
<my-goods isBind @radioClick="goodsRadioClick" :index="index"
:data="item" @del="goodsDel" :showChecked="showChecked"
:showDetail="pageData.showGoodsDetail"></my-goods>
<my-goods isBind @radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
</view>
</template>
<template v-if="pageData.hasAjax&&!pageData.bindGoodsList.length">
<my-img-empty tips="暂无绑定商品"></my-img-empty>
<my-img-empty :tips="isSearch?'未搜索到相关绑定商品':'暂无绑定商品' "></my-img-empty>
</template>
<view style="height: 100rpx;"></view>
</view>
@ -52,9 +52,9 @@
<view class="bg-fff border-r-18 u-p-t-16 u-p-b-16 box-shadow">
<template v-if="pageData.goodsList.length">
<view class="" v-for="(item,index) in pageData.goodsList" :key="index">
<my-goods @goodsClick="goodsClick"
@radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
<my-goods @goodsClick="goodsClick" @radioClick="goodsRadioClick" :index="index" :data="item"
@del="goodsDel" :showChecked="showChecked"
:showDetail="pageData.showGoodsDetail"></my-goods>
</view>
</template>
<template v-if="pageData.hasAjax&&!pageData.goodsList.length">
@ -117,9 +117,11 @@
upGroupSort,
tbProductGroupPost
} from "@/http/yskApi/shop.js"
import {hasPermission} from '@/commons/utils/hasPermission.js';
import {
hasPermission
} from '@/commons/utils/hasPermission.js';
import {
returnAllCategory
} from '@/pageProduct/util.js'
@ -154,17 +156,7 @@
categoryName: '',
hasAjax: false
})
watch(() => pageData.query.categoryId, (newval) => {
getGoodsList()
})
watch(()=>pageData.stateCurrent,(newval)=>{
if(newval){
setGoodsList()
}else{
init()
}
})
function isGroundingChange(e) {
const {
@ -191,27 +183,33 @@
console.log(e);
pageData.goodsList[e].checked = !pageData.goodsList[e].checked
}
function setCategory(category) {
pageData.query.categoryId = category.id
console.log(pageData.query.categoryId );
pageData.categoryName = category.name
}
let $goodsList=[]
function setGoodsList(){
pageData.goodsList = $goodsList.filter(v=>!pageData.bindGoodsList.find(bindGoods=>bindGoods.id==v.id))
let $goodsList = []
function setGoodsList() {
pageData.goodsList = $goodsList.filter(v => {
return !pageData.bindGoodsList.find(bindGoods => bindGoods.id == v.id)
})
}
function getGoodsList() {
$tbProductV2(pageData.query).then(res => {
pageData.hasAjax = true
pageData.totalElements = res.totalElements
$goodsList=res.content.map(v=>{
$goodsList = res.content.map(v => {
return {
...v,checked:false
...v,
checked: false
}
})
setGoodsList()
})
}
onShow(() => {
@ -219,21 +217,16 @@
})
async function getGroupBindGoods() {
const res = await productListGet(option.id)
pageData.bindGoodsList = res
pageData.bindGoodsList = res.filter(v=>{
return pageData.query.categoryId===''?true:(v.categoryId==pageData.query.categoryId)&&(v.name.includes(pageData.query.name))
})
}
const option = reactive({})
async function init() {
const res = await productListGet(option.id)
pageData.bindGoodsList = res
await getGroupBindGoods()
getGoodsList()
}
onLoad((opt) => {
tbProductGroupGet({
page: 0,
size: 999,
sort: 'id',
shopId: uni.getStorageSync('shopId')
})
Object.assign(option, opt)
init()
// $tbShopCategory({
@ -263,28 +256,30 @@
}
async function save() {
const res=await hasPermission('允许修改分组')
if(!res){
const res = await hasPermission('允许修改分组')
if (!res) {
return
}
console.log(pageData.goodsList);
await tbProductGroupPut({
...option,
shopId:uni.getStorageSync('shopId'),
productIds:[...pageData.bindGoodsList.map(v=>v.id),...pageData.goodsList.filter(v=>v.checked).map(v=>v.id)]
shopId: uni.getStorageSync('shopId'),
productIds: [...pageData.bindGoodsList.map(v => v.id), ...pageData.goodsList.filter(v => v.checked)
.map(v => v.id)
]
})
pageData.stateCurrent=0
pageData.stateCurrent = 0
}
function updateGroup(){
function updateGroup() {
}
//
async function goodsDel(index) {
const res=await hasPermission('允许修改分组')
if(!res){
const res = await hasPermission('允许修改分组')
if (!res) {
return
}
const goods = pageData.bindGoodsList[index]
@ -296,8 +291,8 @@
pageData.bindGoodsList.splice(index, 1)
tbProductGroupPut({
...option,
shopId:uni.getStorageSync('shopId'),
productIds:pageData.bindGoodsList.map(v=>v.id)
shopId: uni.getStorageSync('shopId'),
productIds: pageData.bindGoodsList.map(v => v.id)
})
} else if (res.cancel) {}
}
@ -307,6 +302,7 @@
function statesTableClick(index) {
pageData.stateCurrent = index
console.log(pageData.stateCurrent);
}
@ -341,10 +337,20 @@
function isHasChekdGoods() {
return getChechkedGoodsList().length ? true : false
}
function searchFunc() {
let isSearch=ref(false)
async function searchFunc() {
isSearch.value=true
console.log('searchFunc');
getGoodsList()
if (pageData.stateCurrent) {
getGoodsList()
} else {
const res = await productListGet(option.id)
pageData.bindGoodsList = res.filter(v=>{
return v.name.includes(pageData.query.name)&&(pageData.query.categoryId===''?true:v.categoryId==pageData.query.categoryId)
})
}
}
let showChecked = ref(false)
@ -407,6 +413,21 @@
pageData.category = cate
getGoodsList()
}
watch(() => pageData.query.categoryId, (newval) => {
if(pageData.stateCurrent==1){
getGoodsList()
}else{
getGroupBindGoods()
}
})
watch(() => pageData.stateCurrent, (newval) => {
if (newval==1) {
getGoodsList()
} else {
getGroupBindGoods()
}
})
</script>
<style scoped>
page {

View File

@ -7,8 +7,8 @@
<view class="block">
<view class="">
<uni-forms-item label="分类名称" required name="name">
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="category.name" placeholder="输入分类名称" />
<uni-easyinput paddingNone :placeholderStyle="placeholderStyle"
:inputBorder="inputBorder" v-model="category.name" placeholder="输入分类名称" />
</uni-forms-item>
</view>
<template v-if="option.type=='edit'">
@ -17,7 +17,7 @@
v-model="category.sort" type="number" placeholder="排序越小越靠前" />
</uni-forms-item>
</template>
<uni-forms-item label="">
<view class="u-flex u-row-between u-col-center">
<view class="label-title">分组状态</view>
@ -26,6 +26,35 @@
</view>
</view>
</uni-forms-item>
<uni-forms-item label="">
<view class="u-flex u-row-between u-col-center">
<view class="label-title">售卖时间管控</view>
<view class="u-flex">
<my-switch v-model="category.useTime"></my-switch>
</view>
</view>
<view v-if="category.useTime" class="u-flex u-row-between u-col-center u-m-t-30 u-p-b-12">
<view class="u-flex timesel" @click="changeTime('start')">
<up-icon name="clock" size="14"></up-icon>
<view class="u-m-l-20">
<text v-if="!category.saleStartTime" class="color-999">起始时间</text>
<text v-else>{{category.saleStartTime}}</text>
</view>
</view>
<view class="u-p-l-30 u-p-r-30"></view>
<view class="u-flex timesel" @click="changeTime('end')">
<up-icon name="clock" size="14"></up-icon>
<view class="u-m-l-20">
<text v-if="!category.saleEndTime" class="color-999">结束时间</text>
<text>{{category.saleEndTime}}</text>
</view>
</view>
</view>
</uni-forms-item>
<uni-forms-item label="分组排序" required name="name">
<uni-number-box :value="category.sort" />
</uni-forms-item>
</view>
</uni-forms>
</view>
@ -36,6 +65,9 @@
</view>
</view>
<view class="bottom" ref="bottom"></view>
<up-datetime-picker @cancel="timeCancel" @confirm="timeConfirm" :show="time.show" v-model="time.val" mode="time"></up-datetime-picker>
</view>
</template>
@ -90,6 +122,7 @@
}
//
const placeholderStyle = ref('font-size:28rpx;')
//
@ -122,6 +155,31 @@
}
};
}
const time=reactive({
show:false,
val:'',
key:''
})
function timeCancel(){
time.show=false
}
function timeConfirm(e){
console.log(e);
if(time.key=='start'){
category.saleStartTime=e.value
}else{
category.saleEndTime=e.value
}
time.val=''
time.show=false
}
function changeTime(key) {
time.key=key;
time.show=true;
}
function toTimer(timer, index) {
console.log(timer);
@ -184,6 +242,8 @@
productIds: [],
saleTime: [],
useTime: 0,
saleEndTime:'',
saleStartTime:'',
shopId: uni.getStorageSync('shopId')
}
const categoryChild = ref({
@ -549,6 +609,13 @@
background: #F9F9F9;
}
.timesel {
border: 1px solid #eee;
border-radius: 10rpx;
padding: 10rpx 20rpx;
flex: 1;
}
.option-item {
margin-bottom: 34rpx;
}

View File

@ -16,8 +16,8 @@
</view>
</view>
<view class="u-m-t-24 u-p-l-54 ">
<view class="u-flex-1 u-flex">
<view class="color-666">分组名</view>
<view class="u-flex-1 u-flex u-col-top">
<view class="color-666 no-wrap">分组名</view>
<view class="color-333 u-m-l-60">{{data.name}}</view>
<view class="u-flex u-m-l-16 " @click="editName">
<image src="/pageGoodsGroup/static/image/icon-edit.svg" class="icon-edit" mode=""></image>

View File

@ -0,0 +1,183 @@
<template>
<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
<view class="u-p-32 box u-font-28">
<view class="u-flex u-relative u-row-center">
<view class="u-font-32">编辑</view>
<view class="u-absolute close">
<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
</view>
</view>
<view class="u-m-t-36">
<view class="u-flex u-row-between">
<view class="">
售卖时间管控
</view>
<my-switch v-model="category.useTime"></my-switch>
</view>
<view v-if="category.useTime" class="u-flex u-row-between u-col-center u-m-t-30 u-p-b-12">
<view class="u-flex timesel" @click="changeTime('start')">
<up-icon name="clock" size="14"></up-icon>
<view class="u-m-l-20">
<text v-if="!category.saleStartTime" class="color-999">起始时间</text>
<text v-else>{{category.saleStartTime}}</text>
</view>
</view>
<view class="u-p-l-30 u-p-r-30"></view>
<view class="u-flex timesel" @click="changeTime('end')">
<up-icon name="clock" size="14"></up-icon>
<view class="u-m-l-20">
<text v-if="!category.saleEndTime" class="color-999">结束时间</text>
<text>{{category.saleEndTime}}</text>
</view>
</view>
</view>
<view class="u-m-t-38">
<view class="u-m-b-32">
</view>
<view class="u-m-t-60">
<my-button type="primary" shape="circle" @tap="save">
<view class="u-font-32">
保存
</view>
</my-button>
</view>
</view>
</view>
<up-datetime-picker @cancel="timeCancel" @confirm="timeConfirm" :show="time.show" v-model="time.val" mode="time"></up-datetime-picker>
</view>
</up-popup>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted,
computed
} from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
const props = defineProps({
show: {
type: Boolean,
default: false
},
item: {
type: Object,
default: () => {
name: ''
}
}
})
const category =reactive({
useTime: 0,
saleEndTime:'',
saleStartTime:'',
})
const time=reactive({
show:false,
val:'',
key:''
})
function timeCancel(){
time.show=false
}
function timeConfirm(e){
console.log(e);
if(time.key=='start'){
category.saleStartTime=e.value
}else{
category.saleEndTime=e.value
}
time.val=''
time.show=false
}
function changeTime(key) {
time.key=key;
time.val=key=='start'?category.saleStartTime:category.saleEndTime
time.show=true;
}
function changeShowRecoders(show) {
recoders.show = show
}
const data = ref(props.item)
const emits = defineEmits(['update:show', 'save'])
const form = reactive({
note: ''
})
let popShow = ref(props.show)
let name = ref('')
watch(() => props.item.name, (newval) => {
name.value = newval
})
watch(() => props.show, (newval) => {
popShow.value = newval
if (newval) {
data.value = props.item
console.log(props.item);
Object.assign(category,props.item)
console.log(props.item);
}
})
const isSku = computed(() => {
// return data.value.typeEnum == ''
return false
})
watch(() => popShow.value, (newval) => {
emits('update:show', newval)
})
function close() {
popShow.value = false
}
function open() {
}
function save() {
if(category.useTime){
if(!category.saleStartTime){
return infoBox.showToast('请选择起始时间')
}
if(!category.saleEndTime){
return infoBox.showToast('请选择结束时间')
}
}
emits('save', {
...data.value,...category
})
}
</script>
<style lang="scss" scoped>
.box {
width: 600rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
box-sizing: border-box;
}
.timesel {
border: 1px solid #eee;
border-radius: 10rpx;
padding: 10rpx 20rpx;
flex: 1;
}
.close {
position: absolute;
right: 0;
}
.number {
color: #EE4646;
}
</style>

View File

@ -25,6 +25,7 @@
<edit-sort @save="updataGroup" :item="popup.selData" v-model:show="popup.sort.show"></edit-sort>
<edit-name @save="updataGroup" :item="popup.selData" v-model:show="popup.name.show"></edit-name>
<edit-time @save="updataGroup" :item="popup.selData" v-model:show="popup.time.show"></edit-time>
<up-action-sheet :round="10" @select="actionSelect" @close="actionsHide" cancelText="取消" :actions="actions.list"
:show="actions.show"></up-action-sheet>
@ -44,6 +45,7 @@
import infoBox from "@/commons/utils/infoBox.js"
import editSort from './components/edit-sort.vue';
import editName from './components/edit-name.vue';
import editTime from './components/edit-time.vue';
import {
tbProductGroupGet,
tbProductGroupDelete,
@ -66,7 +68,13 @@
name: '管理商品',
color: '#333',
fontSize: '16'
}],
},
{
name: '售卖时间',
color: '#333',
fontSize: '16'
}
],
show: false,
})
@ -82,6 +90,9 @@
})
}
if (e.name == '售卖时间') {
return popupShow(actions.selIndex, 'time', true)
}
}
function actionsHide() {
@ -106,6 +117,9 @@
},
name:{
show: false
},
time:{
show: false
}
})
@ -119,6 +133,7 @@
const res = await $productCategory.update(e)
popup.sort.show = false;
popup.name.show = false;
popup.time.show = false;
pageData.list[popup.selIndex] = e
infoBox.showToast('更新成功')
}