增加商品分组管理模块
This commit is contained in:
parent
106de94d2a
commit
3c7918211e
|
|
@ -0,0 +1,8 @@
|
||||||
|
<template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
<template>
|
||||||
|
<up-picker :show="show" keyName="name" @confirm="confirm" :columns="category.list" @close="close" @cancel="close" :closeOnClickOverlay="true"></up-picker>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref, warn, watch, watchEffect,
|
||||||
|
onMounted,reactive
|
||||||
|
} from 'vue';
|
||||||
|
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||||
|
const emite=defineEmits(['change','update:isShow','confirm'])
|
||||||
|
const props = defineProps({
|
||||||
|
showAllText:{
|
||||||
|
type:Boolean,
|
||||||
|
default:true
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 264
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 420
|
||||||
|
},
|
||||||
|
right: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 30
|
||||||
|
},
|
||||||
|
bottom: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
isShow:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let show = ref(props.isShow)
|
||||||
|
|
||||||
|
watch(()=>show.value,(newval)=>{
|
||||||
|
emite('change',newval)
|
||||||
|
emite('update:isShow',newval)
|
||||||
|
})
|
||||||
|
watch(()=>props.isShow,(newval)=>{
|
||||||
|
console.log(newval);
|
||||||
|
show.value=newval
|
||||||
|
})
|
||||||
|
|
||||||
|
function confirm(e){
|
||||||
|
console.log(e.value[0]);
|
||||||
|
show.value = false
|
||||||
|
emite('confirm',e.value[0])
|
||||||
|
}
|
||||||
|
function close() {
|
||||||
|
console.log('close');
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const category=reactive({
|
||||||
|
list:[],
|
||||||
|
})
|
||||||
|
onMounted(()=>{
|
||||||
|
$tbShopCategory({
|
||||||
|
page:0,size:200
|
||||||
|
}).then(res=>{
|
||||||
|
res.content.unshift({
|
||||||
|
name:'全部',
|
||||||
|
id:'',
|
||||||
|
childrenList:[]
|
||||||
|
})
|
||||||
|
category.list=[res.content.reduce((prve, cur) => {
|
||||||
|
prve.push(...[{
|
||||||
|
...cur,
|
||||||
|
name: '' + cur.name,
|
||||||
|
childrenList:undefined
|
||||||
|
}, ...cur.childrenList.map(v => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
name: '' + v.name
|
||||||
|
}
|
||||||
|
})])
|
||||||
|
return prve
|
||||||
|
}, [])]
|
||||||
|
console.log(category.list);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.category {
|
||||||
|
background: #FFFFFF;
|
||||||
|
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
|
||||||
|
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||||
|
position: fixed;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #333;
|
||||||
|
.list{
|
||||||
|
box-sizing: border-box;
|
||||||
|
.item{
|
||||||
|
padding: 24rpx 24rpx 24rpx 48rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<template>
|
||||||
|
<view class="control" :style="getComputedStyle()">
|
||||||
|
<view class="u-flex control1" v-if="showControl1">
|
||||||
|
<view class="btn" @click="changeShowControl1">批量管理</view>
|
||||||
|
<view class="btn" @tap="go.to('PAGES_PRODUCT_ADD')">商品添加</view>
|
||||||
|
<!-- <view class="color-999 btn u-flex u-row-center" @click="emitToggleCategory">
|
||||||
|
<text class="u-m-r-10">{{categoryName||'选择分类'}}</text>
|
||||||
|
<view class="arrow-down" :class="{'up':categoryShow}">
|
||||||
|
<uni-icons type="right" size="16" color="#999"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view> -->
|
||||||
|
</view>
|
||||||
|
<view class="u-flex control2 u-row-between" v-else>
|
||||||
|
<view class="u-flex u-flex-1 btn " @click="changeIsSelectAll">
|
||||||
|
<view class="u-m-l-28">
|
||||||
|
<my-radio v-model="isSelectAll" >
|
||||||
|
<view class="color-fff">全选</view>
|
||||||
|
</my-radio>
|
||||||
|
</view>
|
||||||
|
<!-- <label class="radio u-m-l-28" >
|
||||||
|
<radio class="scale7" @tap.stop="changeIsSelectAll" :color="ColorMain" value="" :checked="isSelectAll" />
|
||||||
|
<text>全选</text>
|
||||||
|
</label> -->
|
||||||
|
</view>
|
||||||
|
<view class=" btn u-flex-1 my-bg-main" @click="changeShowControl1">取消</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import {ColorMain} from '@/commons/color.js'
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
reactive,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
const props = defineProps({
|
||||||
|
bottom: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 30
|
||||||
|
},
|
||||||
|
categoryName:{
|
||||||
|
type:String,
|
||||||
|
default:''
|
||||||
|
},
|
||||||
|
categoryShow:{
|
||||||
|
type:Boolean,
|
||||||
|
default:false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
let showControl1 = ref(true)
|
||||||
|
const emits = defineEmits(['toggleCategory','controlChange','allCheckedChange','offShelf','categoryChange'])
|
||||||
|
|
||||||
|
function emitToggleCategory() {
|
||||||
|
emits('toggleCategory')
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeShowControl1() {
|
||||||
|
showControl1.value = !showControl1.value
|
||||||
|
if(!showControl1.value){
|
||||||
|
isSelectAll.value=false
|
||||||
|
}
|
||||||
|
emits('controlChange',!showControl1.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
let isSelectAll = ref(false)
|
||||||
|
|
||||||
|
function changeIsSelectAll() {
|
||||||
|
console.log('changeIsSelectAll');
|
||||||
|
isSelectAll.value = !isSelectAll.value
|
||||||
|
emits('allCheckedChange',isSelectAll.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getComputedStyle() {
|
||||||
|
return {
|
||||||
|
bottom: props.bottom + 'rpx'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//设置是否全选
|
||||||
|
function setisSelectAll(checked){
|
||||||
|
isSelectAll.value =checked
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
setisSelectAll
|
||||||
|
})
|
||||||
|
|
||||||
|
//下架
|
||||||
|
function offShelf(){
|
||||||
|
emits('offShelf')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.scale7 {
|
||||||
|
transform: scale(0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.borde-r {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 20rpx;
|
||||||
|
bottom: 20rpx;
|
||||||
|
width: 2px;
|
||||||
|
background-color: #fff;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.control {
|
||||||
|
position: fixed;
|
||||||
|
left: 110rpx;
|
||||||
|
right: 110rpx;
|
||||||
|
z-index: 100;
|
||||||
|
background: #3E3A3A;
|
||||||
|
border-radius: 100rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
.btn{
|
||||||
|
color: #fff;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.control1 {
|
||||||
|
.arrow-down {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
&.up{
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.control1 .btn:not(:last-child)::after {
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 20rpx;
|
||||||
|
bottom: 20rpx;
|
||||||
|
width: 2px;
|
||||||
|
background-color: #fff;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control1 .btn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control1 .btn,
|
||||||
|
.control2 .btn{
|
||||||
|
position: relative;
|
||||||
|
line-height: 76rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control2 {
|
||||||
|
overflow: hidden;
|
||||||
|
// padding: 0 28rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,286 @@
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<template v-if="isBind">
|
||||||
|
<view class="goods">
|
||||||
|
|
||||||
|
<view class="u-flex u-row-between">
|
||||||
|
<view class="u-flex">
|
||||||
|
<view class="color-333">
|
||||||
|
<text class="">排序</text>
|
||||||
|
<text class="u-m-l-20">{{data.sort}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="color-333 u-m-l-42 u-flex">
|
||||||
|
<text class="stock u-m-l-4">库存:{{data.stockNumber}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
<view class="u-m-t-32 u-flex u-col-top u-relative">
|
||||||
|
<view v-if="props.showChecked">
|
||||||
|
<label class="radio">
|
||||||
|
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
|
||||||
|
:checked="props.data.checked" /><text></text>
|
||||||
|
</label>
|
||||||
|
</view>
|
||||||
|
<view class="img">
|
||||||
|
<up--image :width="63" :height="63" :radius="3" :src="data.coverImg"></up--image>
|
||||||
|
</view>
|
||||||
|
<view class="w-full info u-p-l-30">
|
||||||
|
<view class=" color-333 u-flex u-row-between">
|
||||||
|
<view class="u-flex">
|
||||||
|
<text class="u-m-r-24">{{data.name}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="u-font-32">
|
||||||
|
<text v-if="data.typeEnum=='单规格'">¥</text>
|
||||||
|
<text>{{data.lowPrice}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-t-10 u-row-right">
|
||||||
|
<view class="btn-default btn" @tap="del">删除</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class=" u-flex u-p-l-30 u-p-r-30 u-p-t-16 u-p-b-16" @click="goodsClick">
|
||||||
|
<my-radio disabled @click.stop="goodsClick" :modelValue="data.checked"></my-radio>
|
||||||
|
<view class="u-flex u-m-l-32">
|
||||||
|
<text class="">{{data.name}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
watchEffect
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
$goodsIsHot,
|
||||||
|
$tbProskuConV2,
|
||||||
|
$updateProductData
|
||||||
|
} from '@/http/yskApi/goods.js'
|
||||||
|
import mySwitch from '@/components/my-components/my-switch.vue'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import {
|
||||||
|
ColorMain
|
||||||
|
} from '@/commons/color.js'
|
||||||
|
const emits = defineEmits(['goodsClick', 'changeClick', 'xiajia', 'del', 'changePrice', 'baosun', 'guigeClick',
|
||||||
|
'editStock'
|
||||||
|
])
|
||||||
|
const props = defineProps({
|
||||||
|
isBind: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
index: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {
|
||||||
|
checked:false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showChecked: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
showDetail: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function goodsClick(){
|
||||||
|
emits('goodsClick',props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function upDateGoods(par) {
|
||||||
|
const res = await $updateProductData([{
|
||||||
|
id: props.data.id,
|
||||||
|
isSku: 0,
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...par
|
||||||
|
}])
|
||||||
|
uni.showToast({
|
||||||
|
title: '修改成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function radioClick() {
|
||||||
|
console.log(props.index);
|
||||||
|
emits('radioClick', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeClick() {
|
||||||
|
emits('changeClick', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function xiajia() {
|
||||||
|
emits('xiajia', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function del() {
|
||||||
|
emits('del', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePrice() {
|
||||||
|
emits('changePrice', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function baosun() {
|
||||||
|
emits('baosun', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function guigeClick(guigeIndex) {
|
||||||
|
emits('guigeClick', props.index, guigeIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
function editStock() {
|
||||||
|
emits('editStock', props.index)
|
||||||
|
}
|
||||||
|
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
||||||
|
function toEdit() {
|
||||||
|
go.to('PAGES_PRODUCT_ADD', {
|
||||||
|
type: 'edit',
|
||||||
|
productId: props.data.id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$imgSize: 126rpx;
|
||||||
|
$price-color: #F02C45;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 6rpx 28rpx;
|
||||||
|
border-radius: 100rpx;
|
||||||
|
border: 2rpx solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gap-10 {
|
||||||
|
gap: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
border-color: $my-main-color;
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-default {
|
||||||
|
border-color: #999;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
color: $price-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h-100 {
|
||||||
|
height: $imgSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.img {
|
||||||
|
width: $imgSize;
|
||||||
|
height: $imgSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-p-l {
|
||||||
|
padding-left: 71px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-arrow-right {
|
||||||
|
width: 32rpx;
|
||||||
|
height: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock {
|
||||||
|
// padding-right: 46rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock::after {
|
||||||
|
// content: '';
|
||||||
|
// position: absolute;
|
||||||
|
// right: 10rpx;
|
||||||
|
// top: 50%;
|
||||||
|
// transform: translateY(-50%);
|
||||||
|
// display: block;
|
||||||
|
// width: 16rpx;
|
||||||
|
// border: 2rpx solid #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-red {
|
||||||
|
color: #F0465B;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods {
|
||||||
|
border-radius: 10rpx 10rpx 10rpx 10rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 24rpx 28rpx 16rpx 28rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
|
||||||
|
.skus {
|
||||||
|
background: #F9F9F9;
|
||||||
|
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
|
||||||
|
.sku {
|
||||||
|
color: #000;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 6rpx 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skds {
|
||||||
|
gap: 10rpx 50rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.skd {
|
||||||
|
padding: 14rpx 40rpx 14rpx 20rpx;
|
||||||
|
background: #F0F2F5;
|
||||||
|
border-radius: 4rpx;
|
||||||
|
position: relative;
|
||||||
|
color: #666;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
font-size: 12rpx;
|
||||||
|
right: 0;
|
||||||
|
padding: 2rpx 4rpx;
|
||||||
|
border-radius: 0rpx 4rpx 4rpx 4rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-primary {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-gray {
|
||||||
|
background-color: rgb(144, 147, 153);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,552 @@
|
||||||
|
<template>
|
||||||
|
<view class="safe-page">
|
||||||
|
<up-sticky>
|
||||||
|
<view class="bg-fff u-p-l-30 u-p-r-30 u-p-b-30">
|
||||||
|
<!-- <view class="myTabs ">
|
||||||
|
<myTabs :list="tabsList" @change="tabsChange"></myTabs>
|
||||||
|
</view> -->
|
||||||
|
<view class="input-wrapper">
|
||||||
|
<view class="input-main">
|
||||||
|
<view class="u-flex u-p-r-30 u-font-28" @click="onCategoryShowChange(true)">
|
||||||
|
<text class="u-m-r-10 u-line-1"
|
||||||
|
style="max-width: 100rpx;">{{pageData.categoryName||'全部' }}</text>
|
||||||
|
<up-icon name="arrow-down" size="16"></up-icon>
|
||||||
|
</view>
|
||||||
|
<uni-easyinput clearable class='jeepay-search' :inputBorder="false"
|
||||||
|
:placeholder="pageData.search.placeholder" v-model="pageData.query.name"
|
||||||
|
@confirm="searchFunc">
|
||||||
|
<template #prefixIcon>
|
||||||
|
<image src="@/static/iconImg/icon-search.svg" class="input-icon" />
|
||||||
|
</template>
|
||||||
|
</uni-easyinput>
|
||||||
|
<button type="text" @click="searchFunc()">搜索</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex states1 u-row-between u-font-28">
|
||||||
|
<view class=" u-flex-1 item u-flex u-row-center tranistion u-text-center color-333"
|
||||||
|
:class="{'active':pageData.stateCurrent==index}" @tap="statesTableClick(index)"
|
||||||
|
v-for="(item,index) in statesTabsList" :key="index">
|
||||||
|
<view class="text">{{item}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</up-sticky>
|
||||||
|
<template v-if="pageData.stateCurrent==0">
|
||||||
|
<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>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-if="pageData.hasAjax&&!pageData.bindGoodsList.length">
|
||||||
|
<my-img-empty tips="暂无绑定商品"></my-img-empty>
|
||||||
|
</template>
|
||||||
|
<view style="height: 100rpx;"></view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<view class="goods-list u-p-30">
|
||||||
|
<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>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<template v-if="pageData.hasAjax&&!pageData.goodsList.length">
|
||||||
|
<my-img-empty tips="未找到相关商品"></my-img-empty>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
<view class="fixed-b">
|
||||||
|
<my-button shape="circle" @click="save">确定</my-button>
|
||||||
|
</view>
|
||||||
|
<view style="height: 100rpx;"></view>
|
||||||
|
<!-- <my-pagination :totalElements="pageData.totalElements" :size="pageData.query.size"
|
||||||
|
@change="pageChange"></my-pagination> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <my-control></my-control> -->
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 分类 -->
|
||||||
|
<my-category v-model:isShow="pageData.categoryShow" @confirm="setCategory"></my-category>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady,
|
||||||
|
onShow,
|
||||||
|
onPageScroll,
|
||||||
|
onPullDownRefresh
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import myGoods from './components/goods.vue'
|
||||||
|
import myCategory from './components/category.vue'
|
||||||
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
import myControl from './components/control.vue'
|
||||||
|
import {
|
||||||
|
$tbProduct,
|
||||||
|
$upProSort,
|
||||||
|
$updateProduct,
|
||||||
|
$getProductDetail,
|
||||||
|
$delProduct,
|
||||||
|
$tbShopCategory,
|
||||||
|
$updateProductStatus,
|
||||||
|
$tbProductV2,
|
||||||
|
$updateProductData
|
||||||
|
} from "@/http/yskApi/goods.js"
|
||||||
|
import {
|
||||||
|
productListGet,
|
||||||
|
tbProductGroupGet,
|
||||||
|
tbProductGroupDelete,
|
||||||
|
tbProductGroupPut,
|
||||||
|
upGroupSort,
|
||||||
|
tbProductGroupPost
|
||||||
|
} from "@/http/yskApi/shop.js"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import {
|
||||||
|
returnAllCategory
|
||||||
|
} from '@/pageProduct/util.js'
|
||||||
|
|
||||||
|
const pageData = reactive({
|
||||||
|
modelDesc: '是否下架',
|
||||||
|
stateCurrent: 0,
|
||||||
|
componentBottom: 45,
|
||||||
|
search: {
|
||||||
|
value: '',
|
||||||
|
placeholder: '输入搜索的商品'
|
||||||
|
},
|
||||||
|
showGoodsDetail: false,
|
||||||
|
selGoodsIndex: '',
|
||||||
|
selGoods: {},
|
||||||
|
totalElements: 0,
|
||||||
|
totalPage: 0,
|
||||||
|
bindGoodsList: [],
|
||||||
|
goodsList: [],
|
||||||
|
query: {
|
||||||
|
page: 0,
|
||||||
|
size: 999,
|
||||||
|
categoryId: '',
|
||||||
|
name: ''
|
||||||
|
},
|
||||||
|
category: '',
|
||||||
|
categoryList: [], //分类列表
|
||||||
|
categoryShow: false,
|
||||||
|
categoryName: '',
|
||||||
|
hasAjax: false
|
||||||
|
})
|
||||||
|
watch(() => pageData.query.categoryId, (newval) => {
|
||||||
|
getGoodsList()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(()=>pageData.stateCurrent,(newval)=>{
|
||||||
|
if(newval){
|
||||||
|
setGoodsList()
|
||||||
|
}else{
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function isGroundingChange(e) {
|
||||||
|
const {
|
||||||
|
goodsIndex,
|
||||||
|
guigeIndex
|
||||||
|
} = popup.guige
|
||||||
|
pageData.goodsList[goodsIndex].skuList[guigeIndex].isGrounding = e
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPauseSaleChange(e) {
|
||||||
|
const {
|
||||||
|
goodsIndex,
|
||||||
|
guigeIndex
|
||||||
|
} = popup.guige
|
||||||
|
pageData.goodsList[goodsIndex].skuList[guigeIndex].isPauseSale = e
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCategoryShowChange(show) {
|
||||||
|
console.log(show);
|
||||||
|
pageData.categoryShow = show
|
||||||
|
}
|
||||||
|
|
||||||
|
function goodsClick(e) {
|
||||||
|
console.log(e);
|
||||||
|
pageData.goodsList[e].checked = !pageData.goodsList[e].checked
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCategory(category) {
|
||||||
|
pageData.query.categoryId = category.id
|
||||||
|
pageData.categoryName = category.name
|
||||||
|
}
|
||||||
|
|
||||||
|
let $goodsList=[]
|
||||||
|
function setGoodsList(){
|
||||||
|
pageData.goodsList = $goodsList.filter(v=>!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=>{
|
||||||
|
return {
|
||||||
|
...v,checked:false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setGoodsList()
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onShow(() => {
|
||||||
|
// getGoodsList()
|
||||||
|
})
|
||||||
|
async function getGroupBindGoods() {
|
||||||
|
const res = await productListGet(option.id)
|
||||||
|
pageData.bindGoodsList = res
|
||||||
|
}
|
||||||
|
const option = reactive({})
|
||||||
|
async function init() {
|
||||||
|
const res = await productListGet(option.id)
|
||||||
|
pageData.bindGoodsList = res
|
||||||
|
getGoodsList()
|
||||||
|
}
|
||||||
|
onLoad((opt) => {
|
||||||
|
tbProductGroupGet({
|
||||||
|
page: 0,
|
||||||
|
size: 999,
|
||||||
|
sort: 'id',
|
||||||
|
shopId: uni.getStorageSync('shopId')
|
||||||
|
})
|
||||||
|
Object.assign(option, opt)
|
||||||
|
init()
|
||||||
|
// $tbShopCategory({
|
||||||
|
// page: 0,
|
||||||
|
// size: 200
|
||||||
|
// }).then(res => {
|
||||||
|
// pageData.categoryList = returnAllCategory(res.content)
|
||||||
|
// console.log(pageData.categoryList);
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
|
||||||
|
const statesTabsList = ['已添加', '未添加']
|
||||||
|
|
||||||
|
const control = ref(null)
|
||||||
|
const model = ref(null)
|
||||||
|
const goodsStockModel = ref(null)
|
||||||
|
|
||||||
|
function returnGoodsStockData() {
|
||||||
|
return reactive({
|
||||||
|
sort: 0,
|
||||||
|
isStock: false,
|
||||||
|
isDistribute: false,
|
||||||
|
isPauseSale: false,
|
||||||
|
isGrounding: false,
|
||||||
|
stockNumber: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
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)]
|
||||||
|
})
|
||||||
|
pageData.stateCurrent=0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateGroup(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除商品
|
||||||
|
function goodsDel(index) {
|
||||||
|
const goods = pageData.bindGoodsList[index]
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '是否确认将' + goods.name + '从该分组中移除',
|
||||||
|
success: function(res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
pageData.bindGoodsList.splice(index, 1)
|
||||||
|
tbProductGroupPut({
|
||||||
|
...option,
|
||||||
|
shopId:uni.getStorageSync('shopId'),
|
||||||
|
productIds:pageData.bindGoodsList.map(v=>v.id)
|
||||||
|
})
|
||||||
|
} else if (res.cancel) {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function statesTableClick(index) {
|
||||||
|
pageData.stateCurrent = index
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function tabsChange(i) {
|
||||||
|
console.log(i);
|
||||||
|
pageData.showGoodsDetail = i ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//改变商品的选中状态
|
||||||
|
function changeGoodsChecked(checked, index) {
|
||||||
|
if (index !== undefined) {
|
||||||
|
pageData.goodsList[index].checked = checked
|
||||||
|
} else {
|
||||||
|
pageData.goodsList.map(v => {
|
||||||
|
v.checked = checked
|
||||||
|
})
|
||||||
|
}
|
||||||
|
control.value.setisSelectAll(isAllChecked() ? true : false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取已经选中的商品
|
||||||
|
function getChechkedGoodsList() {
|
||||||
|
return pageData.goodsList.filter(v => v.checked)
|
||||||
|
}
|
||||||
|
//是否全部选中
|
||||||
|
function isAllChecked() {
|
||||||
|
return getChechkedGoodsList().length === pageData.goodsList.length
|
||||||
|
}
|
||||||
|
// 是否有商品选中
|
||||||
|
function isHasChekdGoods() {
|
||||||
|
return getChechkedGoodsList().length ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchFunc() {
|
||||||
|
console.log('searchFunc');
|
||||||
|
getGoodsList()
|
||||||
|
}
|
||||||
|
|
||||||
|
let showChecked = ref(false)
|
||||||
|
|
||||||
|
//商品start
|
||||||
|
|
||||||
|
function goodsRadioClick(index) {
|
||||||
|
var checked = !pageData.goodsList[index].checked
|
||||||
|
changeGoodsChecked(checked, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//下架
|
||||||
|
function offShelf() {
|
||||||
|
const hasCheckedArr = getChechkedGoodsList()
|
||||||
|
const hasChecked = isHasChekdGoods()
|
||||||
|
if (!hasChecked) {
|
||||||
|
return infoBox.showToast('您还没有选中商品!')
|
||||||
|
}
|
||||||
|
model.value.open()
|
||||||
|
}
|
||||||
|
//下架确认
|
||||||
|
function modelConfirm() {
|
||||||
|
console.log('confirm');
|
||||||
|
model.value.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
//商品end
|
||||||
|
|
||||||
|
//控制条
|
||||||
|
function controlChange(bol) {
|
||||||
|
showChecked.value = bol
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 全选
|
||||||
|
function allCheckedChange(checked) {
|
||||||
|
changeGoodsChecked(checked)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页数改变事件
|
||||||
|
function pageChange(page) {
|
||||||
|
console.log(page);
|
||||||
|
pageData.query.page = page - 1
|
||||||
|
getGoodsList()
|
||||||
|
}
|
||||||
|
|
||||||
|
//分类
|
||||||
|
const category = ref(null)
|
||||||
|
|
||||||
|
function toggleCategory() {
|
||||||
|
category.value.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
function cateClick(cate) {
|
||||||
|
console.log(cate);
|
||||||
|
pageData.query.categoryId = cate.id
|
||||||
|
pageData.categoryName = cate.name
|
||||||
|
pageData.category = cate
|
||||||
|
getGoodsList()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.stock-btns {
|
||||||
|
padding: 0 100rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.safe-page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-guige {
|
||||||
|
width: 42rpx;
|
||||||
|
height: 42rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-fff {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myTabs {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 434rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 26rpx;
|
||||||
|
background-color: $J-bg-ff;
|
||||||
|
|
||||||
|
.input-main {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 64rpx;
|
||||||
|
|
||||||
|
image {
|
||||||
|
padding: 22rpx;
|
||||||
|
width: 26rpx;
|
||||||
|
height: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 27rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep uni-button {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $my-main-color;
|
||||||
|
background: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep.uni-easyinput {
|
||||||
|
.uni-easyinput__content {
|
||||||
|
background-color: $J-bg-f5 !important;
|
||||||
|
border-radius: $J-b-r12;
|
||||||
|
|
||||||
|
.uni-easyinput__content-input {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
|
||||||
|
.uni-input-input {
|
||||||
|
border-radius: $J-b-r12 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-input-placeholder {
|
||||||
|
font-size: 27rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-icons {
|
||||||
|
color: rgba(230, 230, 230, 1) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
background-color: transparent !important;
|
||||||
|
color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.states1 {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
position: relative;
|
||||||
|
padding-top: 14rpx;
|
||||||
|
padding-bottom: 16rpx;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
transition: all .2s ease-in-out;
|
||||||
|
left: 10rpx;
|
||||||
|
right: 10rpx;
|
||||||
|
bottom: 0;
|
||||||
|
height: 4rpx;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: $my-main-color;
|
||||||
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
|
||||||
|
.text {
|
||||||
|
&::after {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-b {
|
||||||
|
position: fixed;
|
||||||
|
bottom: calc(env(safe-area-inset-bottom) + 16rpx);
|
||||||
|
/* #ifdef H5 */
|
||||||
|
bottom: 50rpx;
|
||||||
|
/* #endif */
|
||||||
|
left: 110rpx;
|
||||||
|
right: 110rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,555 @@
|
||||||
|
<template>
|
||||||
|
<view class="page">
|
||||||
|
<view class="box">
|
||||||
|
<view>
|
||||||
|
<uni-forms :model="category" :rules="rules" err-show-type="toast" ref="form" :border="true"
|
||||||
|
label-position="top" label-width="350">
|
||||||
|
<view class="block">
|
||||||
|
<view class="">
|
||||||
|
<uni-forms-item label="分类名称" required name="name">
|
||||||
|
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
|
v-model="category.name" placeholder="输入分类名称" />
|
||||||
|
</uni-forms-item>
|
||||||
|
</view>
|
||||||
|
<template v-if="option.type=='edit'">
|
||||||
|
<uni-forms-item label="排序" required name="sort">
|
||||||
|
<uni-easyinput :placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
|
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>
|
||||||
|
<view class="u-flex">
|
||||||
|
<my-switch v-model="category.isShow"></my-switch>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</uni-forms-item>
|
||||||
|
</view>
|
||||||
|
</uni-forms>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
<view class="save-btn-box">
|
||||||
|
<button class="save-btn" hover-class="btn-hover-class" @click="save">保存</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="bottom" ref="bottom"></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import tColorPicker from '@/components/t-color-picker/t-color-picker'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js';
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
reactive,
|
||||||
|
nextTick,
|
||||||
|
ref,
|
||||||
|
onBeforeMount,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
tbProductGroupGet,
|
||||||
|
tbProductGroupDelete,
|
||||||
|
tbProductGroupPut,
|
||||||
|
upGroupSort,
|
||||||
|
tbProductGroupPost
|
||||||
|
} from '@/http/yskApi/shop.js'
|
||||||
|
|
||||||
|
const $productCategory = {
|
||||||
|
add: tbProductGroupPost,
|
||||||
|
del: tbProductGroupDelete,
|
||||||
|
update: tbProductGroupPut,
|
||||||
|
get: tbProductGroupGet
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const refAddChilCate = ref(null)
|
||||||
|
const refAddChilCateTitle = ref('添加子分类')
|
||||||
|
|
||||||
|
function refAddChilCateClose() {
|
||||||
|
refAddChilCate.value.close()
|
||||||
|
categoryChild.value = {
|
||||||
|
...categoryBasicData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let refMoreSheet = ref(null)
|
||||||
|
let selItem = {
|
||||||
|
data: '',
|
||||||
|
index: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 表单样式
|
||||||
|
const placeholderStyle = ref('font-size:28rpx;')
|
||||||
|
//表单边框
|
||||||
|
const inputBorder = ref(false)
|
||||||
|
const form = ref(null)
|
||||||
|
const bottom = ref(null)
|
||||||
|
//表单验证
|
||||||
|
const rules = {
|
||||||
|
name: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '输入分类名称'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '输入排序'
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const refFiles = ref([])
|
||||||
|
|
||||||
|
function setRefFile(index) {
|
||||||
|
refFiles.value[index] = null;
|
||||||
|
return (el) => {
|
||||||
|
if (el) {
|
||||||
|
refFiles.value[index] = el;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function toTimer(timer, index) {
|
||||||
|
console.log(timer);
|
||||||
|
uni.setStorageSync('timer', timer.map(v => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
cycleChecked: v.cycleChecked.map(v => v.value)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
go.to('PAGES_CATEGORY_TIMER', {
|
||||||
|
index: index
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnTimers(timers) {
|
||||||
|
const {
|
||||||
|
listingTime,
|
||||||
|
offShelf,
|
||||||
|
cycleChecked
|
||||||
|
} = timers
|
||||||
|
let len = cycleChecked.length
|
||||||
|
if (len === 7) {
|
||||||
|
return `每天 ${listingTime.value} - ${offShelf.value}`
|
||||||
|
}
|
||||||
|
let result = cycleChecked.reduce((prve, cur) => {
|
||||||
|
return prve + cur.text.replace('星期', '周')
|
||||||
|
}, '')
|
||||||
|
return `${result} ${listingTime.value} - ${offShelf.value}`
|
||||||
|
}
|
||||||
|
//图片上传
|
||||||
|
function FileUploadprogress() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadsuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadail() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileUploadselect(e) {
|
||||||
|
// TEST
|
||||||
|
// FormData.images.push(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function returnOptionsBasicData() {
|
||||||
|
return {
|
||||||
|
...categoryOptionsBasicData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 构造分类的基础数据
|
||||||
|
const categoryBasicData = {
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
isShow: 1,
|
||||||
|
sort: 0,
|
||||||
|
productIds: [],
|
||||||
|
saleTime: [],
|
||||||
|
useTime: 0,
|
||||||
|
shopId: uni.getStorageSync('shopId')
|
||||||
|
}
|
||||||
|
const categoryChild = ref({
|
||||||
|
...categoryBasicData
|
||||||
|
})
|
||||||
|
|
||||||
|
function onFieldChange(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
// 分类列表
|
||||||
|
const category = reactive({
|
||||||
|
...categoryBasicData,
|
||||||
|
childrenList: []
|
||||||
|
})
|
||||||
|
//添加子分类
|
||||||
|
function addcategoryChildren() {
|
||||||
|
refAddChilCate.value.open()
|
||||||
|
// category.childrenList.push({
|
||||||
|
// ...categoryBasicData
|
||||||
|
// })
|
||||||
|
// scrollPageBottom()
|
||||||
|
}
|
||||||
|
|
||||||
|
//页面滚动到最底部
|
||||||
|
function scrollPageBottom() {
|
||||||
|
nextTick(() => {
|
||||||
|
uni.pageScrollTo({
|
||||||
|
duration: 100, // 过渡时间
|
||||||
|
scrollTop: 100000, // 滚动的实际距离
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//设置表单验证规则
|
||||||
|
function setFormRules() {
|
||||||
|
form.value.setRules(rules)
|
||||||
|
}
|
||||||
|
const formRefs = ref([]);
|
||||||
|
//绑定表单元素
|
||||||
|
function setFormRef(index) {
|
||||||
|
formRefs.value[index] = null;
|
||||||
|
return (el) => {
|
||||||
|
if (el) {
|
||||||
|
formRefs.value[index] = el;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// 绑定option input元素
|
||||||
|
const refFormInput = ref([])
|
||||||
|
|
||||||
|
function setFormInputRef(index, index1) {
|
||||||
|
const newIndex = index * 10000 + index1
|
||||||
|
return (el) => {
|
||||||
|
if (el) {
|
||||||
|
if (!refFormInput.value[newIndex]) {
|
||||||
|
refFormInput.value[newIndex] = el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 当表单内容输入变化根据配置的rules进行验证
|
||||||
|
function inpuChange(index, index1) {
|
||||||
|
const newIndex = index * 10000 + index1
|
||||||
|
console.log(refFormInput.value[newIndex]);
|
||||||
|
refFormInput.value[newIndex].onFieldChange()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function triggerEvent(emitName, data) {
|
||||||
|
if (emitName) {
|
||||||
|
uni.$emit(emitName, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const option = reactive({
|
||||||
|
type: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
function isNoEmpty(obj) {
|
||||||
|
return obj && JSON.stringify(obj) !== '{}'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听定时器保存,拿到数据
|
||||||
|
* @param {Boolean} open //控制开启或关闭监听
|
||||||
|
*/
|
||||||
|
function watchTimerSave(open = true) {
|
||||||
|
if (open) {
|
||||||
|
uni.$on('timerSave', function(res) {
|
||||||
|
const {
|
||||||
|
index,
|
||||||
|
data
|
||||||
|
} = res
|
||||||
|
console.log('timerSave get');
|
||||||
|
console.log(res);
|
||||||
|
if (index == -1) {
|
||||||
|
category.timers = data
|
||||||
|
} else {
|
||||||
|
category.childrenList[index].timers = data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.$off('timerSave', function(data) {
|
||||||
|
console.log('timerSave remove');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
watchTimerSave()
|
||||||
|
|
||||||
|
onLoad(params => {
|
||||||
|
let cateItem = uni.getStorageSync('cateItem')
|
||||||
|
if (isNoEmpty(params)) {
|
||||||
|
option.type = params.type
|
||||||
|
}
|
||||||
|
if (option.type === 'edit' && isNoEmpty(cateItem)) {
|
||||||
|
console.log(cateItem);
|
||||||
|
for (let i in cateItem) {
|
||||||
|
if (i.substring(0, 2) === 'is' && i.length > 2) {
|
||||||
|
cateItem[i] = cateItem[i] * 1
|
||||||
|
} else {
|
||||||
|
cateItem[i] = cateItem[i] === 'null' ? '' : cateItem[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object.assign(category, cateItem)
|
||||||
|
}
|
||||||
|
console.log(category);
|
||||||
|
uni.setNavigationBarTitle({
|
||||||
|
title: option.type === 'add' ? '添加分组' : '编辑分组'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function emitcategorySave() {
|
||||||
|
// emitcategorySave 触发规格保存事件将数据给到添加商品页面
|
||||||
|
// guigeEdit 触发规格保存事件将数据给到添加规格页面
|
||||||
|
uni.removeStorageSync('guige')
|
||||||
|
triggerEvent(emitName, category.list)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function returnValidateResult(obj) {
|
||||||
|
const validateFuncObj = {
|
||||||
|
name: (value) => {
|
||||||
|
return {
|
||||||
|
pass: value.length >= 1,
|
||||||
|
errMeessage: '请输入分类名称'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sort: (value) => {
|
||||||
|
return {
|
||||||
|
pass: value !== '',
|
||||||
|
errMeessage: '请输入排序'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateFunc(key, value) {
|
||||||
|
if (validateFuncObj.hasOwnProperty(key)) {
|
||||||
|
const func = validateFuncObj[key]
|
||||||
|
return func(value)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
pass: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let resultArr = []
|
||||||
|
for (let key in obj) {
|
||||||
|
resultArr.push(validateFunc(key, obj[key]))
|
||||||
|
}
|
||||||
|
resultArr = resultArr.filter(v => !v.pass)
|
||||||
|
return resultArr
|
||||||
|
}
|
||||||
|
let timer = null
|
||||||
|
|
||||||
|
function onfileChange(val, data, key) {
|
||||||
|
data[key] = val
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
let isAllPassForm = 0
|
||||||
|
const formRules = {}
|
||||||
|
const result = []
|
||||||
|
result.push(...returnValidateResult(category))
|
||||||
|
for (let obj of category.childrenList) {
|
||||||
|
const res = returnValidateResult(obj)
|
||||||
|
result.push(...res)
|
||||||
|
}
|
||||||
|
if (result.length) {
|
||||||
|
return infoBox.showToast(result[0].errMeessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option.type === 'edit') {
|
||||||
|
const res = await $productCategory.update({
|
||||||
|
...category,
|
||||||
|
childrenList: ''
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const res = await $productCategory.add({
|
||||||
|
...category,
|
||||||
|
childrenList: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
infoBox.showToast(option.type === 'edit' ? '修改成功' : '添加成功')
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
clearTimeout(timer)
|
||||||
|
go.back()
|
||||||
|
}, 1500);
|
||||||
|
// const res = await form.value.validate().then(res => {
|
||||||
|
// go.back()
|
||||||
|
// })
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$icon-size: 34rpx;
|
||||||
|
$icon-line-width: 20rpx;
|
||||||
|
$icon-line-height: 4rpx;
|
||||||
|
|
||||||
|
.category-icon {
|
||||||
|
width: 60rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
padding: 30rpx;
|
||||||
|
padding-bottom: 200rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-switch {
|
||||||
|
transform: scale(0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .uni-forms-item__error {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .option .uni-forms-item {
|
||||||
|
padding: 0;
|
||||||
|
min-height: inherit;
|
||||||
|
background-color: transparent;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: $icon-size;
|
||||||
|
height: $icon-size;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&:before,
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-add {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
width: $icon-line-height;
|
||||||
|
height: $icon-line-width;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
width: $icon-line-width;
|
||||||
|
height: 4rpx;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-reduce {
|
||||||
|
background-color: $my-red-color;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
width: $icon-line-width;
|
||||||
|
height: $icon-line-height;
|
||||||
|
top: calc(($icon-size /2) - ($icon-line-height / 2));
|
||||||
|
left: calc(($icon-size /2) - ($icon-line-width / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-title {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lh40 {
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
font-size: 28rpx;
|
||||||
|
|
||||||
|
.block {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
|
padding: 12rpx 24rpx;
|
||||||
|
margin-bottom: 32rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn-box {
|
||||||
|
position: fixed;
|
||||||
|
left: 30rpx;
|
||||||
|
right: 30rpx;
|
||||||
|
bottom: 60rpx;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep.uni-forms-item {
|
||||||
|
align-items: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .uni-forms-item .uni-forms-item__label {
|
||||||
|
text-indent: 0;
|
||||||
|
font-size: 28rpx !important;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .border-top-0 .uni-forms-item.is-direction-top {
|
||||||
|
border-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-hover-class {
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zuofa {
|
||||||
|
padding: 28rpx 0;
|
||||||
|
background: #F9F9F9;
|
||||||
|
padding-left: 42rpx;
|
||||||
|
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .uni-input-placeholder {
|
||||||
|
font-size: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option {
|
||||||
|
padding: 26rpx 30rpx 24rpx 24rpx;
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-item {
|
||||||
|
margin-bottom: 34rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
<template>
|
||||||
|
<view class="u-p-30 min-page">
|
||||||
|
<view class="u-flex">
|
||||||
|
<view style="width: 210rpx;">
|
||||||
|
<my-button shape="circle" @click="addTimer">添加定时器</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="list u-m-t-20" v-if="list.length">
|
||||||
|
<view class="block" v-for="(item,index) in list" :key="index">
|
||||||
|
<view class="u-flex u-row-between">
|
||||||
|
<view>定时器{{index+1}}</view>
|
||||||
|
<uni-icons @click="delTimer(index)" type="trash"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-t-20 u-row-between">
|
||||||
|
<view>周期</view>
|
||||||
|
<view @click="selectAllClick(index)">全选</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-20">
|
||||||
|
<uni-data-checkbox multiple v-model="item.cycleChecked" :localdata="cycle"></uni-data-checkbox>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-20">
|
||||||
|
<view class="u-flex">
|
||||||
|
<view>上架时间:</view>
|
||||||
|
<view class="u-flex-1 u-m-l-10">
|
||||||
|
<picker mode="multiSelector" @change="listingTimeChange($event,index)"
|
||||||
|
:value="item.listingTime.index" :range="times">
|
||||||
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
|
{{item.listingTime.value}}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-t-20">
|
||||||
|
<view>下架时间:</view>
|
||||||
|
<view class="u-flex-1 u-m-l-10">
|
||||||
|
<picker mode="multiSelector" @change="offShelfChange($event,index)"
|
||||||
|
:value="item.offShelf.index" :range="times">
|
||||||
|
<view class="bg-gray u-p-l-20 u-p-t-6 u-p-b-6 u-p-r-20 ">
|
||||||
|
{{item.offShelf.value}}
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="u-flex u-row-center u-m-t-60">
|
||||||
|
<my-button width="580" shape="circle" @click="save">保存</my-button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onReady
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import myButton from '@/components/my-components/my-button.vue'
|
||||||
|
//返回一天的时间 时分格式
|
||||||
|
function returnDayTime() {
|
||||||
|
return new Array(2).fill(1).map((v, index) => {
|
||||||
|
if (index === 0) {
|
||||||
|
return new Array(24).fill(1).map((hour, index) => {
|
||||||
|
return `0${index}`.slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (index === 1) {
|
||||||
|
return new Array(60).fill(1).map((hour, index) => {
|
||||||
|
return `0${index}`.slice(-2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const times = ref(returnDayTime())
|
||||||
|
let defaultTimeIndex = ref(0)
|
||||||
|
|
||||||
|
function getTime(indexArr) {
|
||||||
|
const hour = times.value[0][indexArr[0]]
|
||||||
|
const month = times.value[1][indexArr[1]]
|
||||||
|
return `${hour}:${month}`
|
||||||
|
}
|
||||||
|
//获取$event.detail.value
|
||||||
|
function getEnentDetailValue(e) {
|
||||||
|
return e.detail.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function setListTimeValue(index, key, time) {
|
||||||
|
list.value[index][key].value = time
|
||||||
|
}
|
||||||
|
|
||||||
|
function listingTimeChange(e, index) {
|
||||||
|
const indexArr = getEnentDetailValue(e)
|
||||||
|
const time = getTime(indexArr)
|
||||||
|
setListTimeValue(index, 'listingTime', time)
|
||||||
|
}
|
||||||
|
|
||||||
|
function offShelfChange(e, index) {
|
||||||
|
const indexArr = getEnentDetailValue(e)
|
||||||
|
const time = getTime(indexArr)
|
||||||
|
setListTimeValue(index, 'offShelf', time)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const cycle = [{
|
||||||
|
value: 0,
|
||||||
|
text: '星期一'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 1,
|
||||||
|
text: '星期二'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 2,
|
||||||
|
text: '星期三'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 3,
|
||||||
|
text: '星期四'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 4,
|
||||||
|
text: '星期五'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 5,
|
||||||
|
text: '星期六'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 6,
|
||||||
|
text: '星期日'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const ListDataconstructor = {
|
||||||
|
cycleChecked: [0, 1, 2, 3, 4, 5, 6],
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnBasicTimeConstructor() {
|
||||||
|
return {
|
||||||
|
listingTime: {
|
||||||
|
value: '09:00',
|
||||||
|
index: [9, 0]
|
||||||
|
},
|
||||||
|
offShelf: {
|
||||||
|
value: '18:00',
|
||||||
|
index: [18, 0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const list = ref([returnBasicDataConstructor()])
|
||||||
|
function returnBasicDataConstructor() {
|
||||||
|
return {
|
||||||
|
...ListDataconstructor,
|
||||||
|
...returnBasicTimeConstructor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTimer() {
|
||||||
|
list.value.push(returnBasicDataConstructor())
|
||||||
|
}
|
||||||
|
function delTimer(index) {
|
||||||
|
list.value.splice(index,1)
|
||||||
|
}
|
||||||
|
function selectAllClick(index){
|
||||||
|
list.value[index].cycleChecked=ListDataconstructor.cycleChecked
|
||||||
|
}
|
||||||
|
let index=null
|
||||||
|
// 触发定时器保存事件将数据给到添加商品页面
|
||||||
|
function emitTimerSave(){
|
||||||
|
uni.$emit('timerSave',{
|
||||||
|
data:list.value.map(v=>{
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
cycleChecked:v.cycleChecked.map(index=>{
|
||||||
|
return {value:index,text:cycle[index].text}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
index:index
|
||||||
|
})
|
||||||
|
go.back()
|
||||||
|
}
|
||||||
|
function save(){
|
||||||
|
console.log(list.value);
|
||||||
|
emitTimerSave()
|
||||||
|
}
|
||||||
|
onLoad((opt)=>{
|
||||||
|
index=opt.index
|
||||||
|
const arr=uni.getStorageSync('timer')
|
||||||
|
if(arr.length){
|
||||||
|
list.value=arr
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.min-page {
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block {
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,231 @@
|
||||||
|
<template>
|
||||||
|
<view class=" goods">
|
||||||
|
<view class="u-flex u-font-24 u-col-center u-row-between u-p-b-16 border-bottom">
|
||||||
|
<view class="u-flex u-col-center">
|
||||||
|
<view class="u-font-24">
|
||||||
|
<text>排序</text>
|
||||||
|
<text class="u-m-l-12">{{data.sort}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-l-16 " @click="editSort">
|
||||||
|
<image src="/pageGoodsGroup/static/image/icon-edit.svg" class="icon-edit" mode=""></image>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex">
|
||||||
|
<view class="u-m-r-14 color-999">是否启用</view>
|
||||||
|
<up-switch :activeValue="1" :inactiveValue="0" v-model="isShow" @change="isShowChange" :size="18"></up-switch>
|
||||||
|
</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="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>
|
||||||
|
</view>
|
||||||
|
<view class="u-flex u-m-t-24">
|
||||||
|
<view class="color-666">售卖时间</view>
|
||||||
|
<view class="color-main u-m-l-32" v-if="data.saleStartTime&&data.saleEndTime">
|
||||||
|
<text>{{data.saleStartTime}}</text>
|
||||||
|
<text>-</text>
|
||||||
|
<text>{{data.saleEndTime}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="u-m-t-24 u-flex u-row-right">
|
||||||
|
<view class="btn-default btn" @click="del">删除</view>
|
||||||
|
<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
watchEffect
|
||||||
|
} from 'vue';
|
||||||
|
import mySwitch from '@/components/my-components/my-switch.vue'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import {
|
||||||
|
ColorMain
|
||||||
|
} from '@/commons/color.js'
|
||||||
|
|
||||||
|
const emits = defineEmits(['changeClick','edit', 'editName','editSort', 'del', 'isShowChange'])
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
index: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {
|
||||||
|
isShow:true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
let isShow = ref(props.data.isShow)
|
||||||
|
|
||||||
|
function isShowChange() {
|
||||||
|
console.log(isShow.value);
|
||||||
|
emits('isShowChange', {
|
||||||
|
...props.data,
|
||||||
|
isShow: isShow.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let isSellNone = ref(true)
|
||||||
|
isSellNone.value = props.isSellNone
|
||||||
|
|
||||||
|
function isSellNoneChange() {
|
||||||
|
console.log(isSellNone.value);
|
||||||
|
console.log('isSellNoneChange');
|
||||||
|
}
|
||||||
|
|
||||||
|
let checked = ref(false)
|
||||||
|
|
||||||
|
function radioClick() {
|
||||||
|
console.log(props.index);
|
||||||
|
emits('radioClick', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeClick() {
|
||||||
|
emits('changeClick', props.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
function useTypeClick() {
|
||||||
|
emits('useTypeClick', props.index)
|
||||||
|
}
|
||||||
|
function del() {
|
||||||
|
emits('del', props.index)
|
||||||
|
}
|
||||||
|
function editName() {
|
||||||
|
emits('editName', props.index)
|
||||||
|
}
|
||||||
|
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
||||||
|
function editSort() {
|
||||||
|
emits('editSort', props.index)
|
||||||
|
}
|
||||||
|
function toEdit() {
|
||||||
|
emits('edit', props.index)
|
||||||
|
// uni.setStorageSync('cateItem', props.data)
|
||||||
|
// go.to('PAGES_CATEGORY_EDIT', {
|
||||||
|
// type: 'edit',
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
$imgSize: 126rpx;
|
||||||
|
$price-color: #F02C45;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 6rpx 28rpx;
|
||||||
|
border-radius: 100rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
border-color: $my-main-color;
|
||||||
|
color: $my-main-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-default {
|
||||||
|
border-color: #999;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
color: $price-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h-100 {
|
||||||
|
height: $imgSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.img {
|
||||||
|
width: $imgSize;
|
||||||
|
height: $imgSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-arrow-right {
|
||||||
|
width: 32rpx;
|
||||||
|
height: 32rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock {
|
||||||
|
padding-right: 46rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-edit {
|
||||||
|
width: 24rpx;
|
||||||
|
height: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stock::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
right: 10rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
display: block;
|
||||||
|
width: 16rpx;
|
||||||
|
border: 2rpx solid #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goods {
|
||||||
|
border-radius: 10rpx 10rpx 10rpx 10rpx;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 24rpx 28rpx 16rpx 28rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
|
||||||
|
.skus {
|
||||||
|
background: #F9F9F9;
|
||||||
|
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||||
|
padding: 28rpx 42rpx;
|
||||||
|
|
||||||
|
.sku {
|
||||||
|
color: #000;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 6rpx 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skds {
|
||||||
|
gap: 10rpx 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skd {
|
||||||
|
padding: 14rpx 40rpx;
|
||||||
|
background: #F0F2F5;
|
||||||
|
border-radius: 4rpx;
|
||||||
|
position: relative;
|
||||||
|
color: #666;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
font-size: 12rpx;
|
||||||
|
right: 0;
|
||||||
|
padding: 2rpx 4rpx;
|
||||||
|
border-radius: 0rpx 4rpx 4rpx 4rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-primary {
|
||||||
|
background-color: $my-main-color;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
<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>修改排序:</view>
|
||||||
|
<view class="u-m-t-38">
|
||||||
|
<view class="u-m-b-32">
|
||||||
|
<view class="u-m-t-16">
|
||||||
|
<up-input v-model="sort">
|
||||||
|
</up-input>
|
||||||
|
</view>
|
||||||
|
</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>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
onMounted,
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
returnSkuSnap,
|
||||||
|
returnTypeEnum,
|
||||||
|
returnCategory
|
||||||
|
} from '@/pageProduct/util.js'
|
||||||
|
import {
|
||||||
|
$tbShopUnit
|
||||||
|
} from '@/http/yskApi/goods.js'
|
||||||
|
const props = defineProps({
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
sort:''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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 sort=ref('')
|
||||||
|
|
||||||
|
watch(()=>props.item.sort,(newval)=>{
|
||||||
|
sort.value=newval
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => props.show, (newval) => {
|
||||||
|
popShow.value = newval
|
||||||
|
if (newval) {
|
||||||
|
data.value = 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() {
|
||||||
|
emits('save', {
|
||||||
|
...data.value,
|
||||||
|
sort:sort.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.box {
|
||||||
|
width: 556rpx;
|
||||||
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number {
|
||||||
|
color: #EE4646;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
<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>修改排序:</view>
|
||||||
|
<view class="u-m-t-38">
|
||||||
|
<view class="u-m-b-32">
|
||||||
|
<view class="u-m-t-16">
|
||||||
|
<up-input v-model="sort">
|
||||||
|
</up-input>
|
||||||
|
</view>
|
||||||
|
</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>
|
||||||
|
</view>
|
||||||
|
</up-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
onMounted,
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
returnSkuSnap,
|
||||||
|
returnTypeEnum,
|
||||||
|
returnCategory
|
||||||
|
} from '@/pageProduct/util.js'
|
||||||
|
import {
|
||||||
|
$tbShopUnit
|
||||||
|
} from '@/http/yskApi/goods.js'
|
||||||
|
const props = defineProps({
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
sort:''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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 sort=ref('')
|
||||||
|
|
||||||
|
watch(()=>props.item.sort,(newval)=>{
|
||||||
|
sort.value=newval
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => props.show, (newval) => {
|
||||||
|
popShow.value = newval
|
||||||
|
if (newval) {
|
||||||
|
data.value = 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() {
|
||||||
|
emits('save', {
|
||||||
|
...data.value,
|
||||||
|
sort:sort.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.box {
|
||||||
|
width: 556rpx;
|
||||||
|
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number {
|
||||||
|
color: #EE4646;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,483 @@
|
||||||
|
<template>
|
||||||
|
<view class="safe-page">
|
||||||
|
<view class="goods-list u-p-30">
|
||||||
|
<view class="u-m-b-32" v-for="(item,index) in pageData.list" :key="index">
|
||||||
|
<my-category @del="categoryDel" @useTypeClick="categoryUseTypeClick"
|
||||||
|
@editSort="popupShow($event,'sort',true)" @edit="actionsShow" @radioClick="goodsRadioClick"
|
||||||
|
@isShowChange="isSHowChange" :index="index" :data="item" :showChecked="showChecked"
|
||||||
|
:showDetail="pageData.showGoodsDetail"></my-category>
|
||||||
|
</view>
|
||||||
|
<view class="u-m-t-44">
|
||||||
|
<my-pagination :size="pageData.query.size" :totalElements="pageData.totalElements"
|
||||||
|
@change="pageChange"></my-pagination>
|
||||||
|
<view style="height: 200rpx;"></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 删除弹窗 -->
|
||||||
|
<my-model desc="请确保此分类下没有任何商品确认删除?" ref="delModel" @confirm="delModelConfirm"></my-model>
|
||||||
|
<view class="fixed-b">
|
||||||
|
<my-button :height="80" shape="circle" showShadow @tap="toAddCategory">新建分组</my-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<edit-sort @save="updataGroup" :item="popup.selData" v-model:show="popup.sort.show"></edit-sort>
|
||||||
|
|
||||||
|
<up-action-sheet :round="10" @select="actionSelect" @close="actionsHide" cancelText="取消" :actions="actions.list"
|
||||||
|
:show="actions.show"></up-action-sheet>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
reactive,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
onShow
|
||||||
|
} from '@dcloudio/uni-app'
|
||||||
|
import go from '@/commons/utils/go.js';
|
||||||
|
import myCategory from './components/category.vue'
|
||||||
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
import editSort from './components/edit-sort.vue';
|
||||||
|
import {
|
||||||
|
tbProductGroupGet,
|
||||||
|
tbProductGroupDelete,
|
||||||
|
tbProductGroupPut,
|
||||||
|
upGroupSort,
|
||||||
|
tbProductGroupPost
|
||||||
|
} from '@/http/yskApi/shop.js'
|
||||||
|
const $productCategory = {
|
||||||
|
add: tbProductGroupPost,
|
||||||
|
del: tbProductGroupDelete,
|
||||||
|
update: tbProductGroupPut,
|
||||||
|
get: tbProductGroupGet
|
||||||
|
}
|
||||||
|
const actions = reactive({
|
||||||
|
list: [{
|
||||||
|
name: '排序',
|
||||||
|
color: '#333',
|
||||||
|
fontSize: '16'
|
||||||
|
}, {
|
||||||
|
name: '管理商品',
|
||||||
|
color: '#333',
|
||||||
|
fontSize: '16'
|
||||||
|
}],
|
||||||
|
show: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
function actionSelect(e) {
|
||||||
|
console.log(e);
|
||||||
|
if (e.name == '排序') {
|
||||||
|
return popupShow(actions.selIndex, 'sort', true)
|
||||||
|
}
|
||||||
|
if (e.name == '管理商品') {
|
||||||
|
const {id,isShow,name,sort}=actions.selData
|
||||||
|
return go.to('PAGES_GOODS_GROUP_EDIT_GOODS', {
|
||||||
|
id,isShow,name,sort
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionsHide() {
|
||||||
|
actions.show = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionsShow(e) {
|
||||||
|
console.log(e);
|
||||||
|
actions.selData = pageData.list[e]
|
||||||
|
actions.selIndex = e
|
||||||
|
actions.show = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const popup = reactive({
|
||||||
|
selIndex: -1,
|
||||||
|
selData: {
|
||||||
|
sort: ''
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function popupShow(e, key, show) {
|
||||||
|
popup.selData = pageData.list[e]
|
||||||
|
popup.selIndex = e
|
||||||
|
popup[key].show = show
|
||||||
|
}
|
||||||
|
async function updataGroup(e) {
|
||||||
|
console.log(e);
|
||||||
|
const res = await $productCategory.update(e)
|
||||||
|
popup.sort.show = false;
|
||||||
|
pageData.list[popup.selIndex] = e
|
||||||
|
infoBox.showToast('更新成功')
|
||||||
|
}
|
||||||
|
const tabsList = ['简洁', '详情']
|
||||||
|
const statesTabsList = ['在售中', '已下架']
|
||||||
|
const states1TabsList = ['全部', '已售罄']
|
||||||
|
const control = ref(null)
|
||||||
|
const delModel = ref(null)
|
||||||
|
const goodsSortModel = ref(null)
|
||||||
|
const goodsTypeModel = ref(null)
|
||||||
|
let sort = ref(0)
|
||||||
|
const goodsTypeModelData = reactive({
|
||||||
|
selCategory: '',
|
||||||
|
title: '',
|
||||||
|
index: null,
|
||||||
|
useTypes: [{
|
||||||
|
name: '堂食',
|
||||||
|
isOpen: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '自取',
|
||||||
|
isOpen: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '外卖',
|
||||||
|
isOpen: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '快递',
|
||||||
|
isOpen: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
const pageData = reactive({
|
||||||
|
stateCurrent: 0,
|
||||||
|
stateCurrent1: 0,
|
||||||
|
componentBottom: 264,
|
||||||
|
search: {
|
||||||
|
value: '',
|
||||||
|
placeholder: '输入搜索的商品'
|
||||||
|
},
|
||||||
|
showGoodsDetail: false,
|
||||||
|
query: {
|
||||||
|
page: 0,
|
||||||
|
size: 10,
|
||||||
|
sort: 'id',
|
||||||
|
shopId: uni.getStorageSync('shopId')
|
||||||
|
},
|
||||||
|
totalElements: 0,
|
||||||
|
list: [],
|
||||||
|
selCategory: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
const res = await $productCategory.get(pageData.query)
|
||||||
|
pageData.list = res.content
|
||||||
|
pageData.totalElements = res.totalElements
|
||||||
|
}
|
||||||
|
onShow(() => {
|
||||||
|
init()
|
||||||
|
})
|
||||||
|
|
||||||
|
function toAddCategory() {
|
||||||
|
go.to('PAGES_GOODS_GROUP_EDIT', {
|
||||||
|
type: 'add'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function goodsSortModelCancel() {
|
||||||
|
console.log('goodsSortModelCancel');
|
||||||
|
goodsSortModel.value.close()
|
||||||
|
}
|
||||||
|
async function goodsSortModelSave() {
|
||||||
|
console.log('goodsSortModelSave');
|
||||||
|
|
||||||
|
const res = await $productCategory.update({
|
||||||
|
...pageData.selCategory,
|
||||||
|
sort: sort.value
|
||||||
|
})
|
||||||
|
infoBox.showToast('修改成功')
|
||||||
|
goodsSortModelCancel()
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function isSHowChange(data) {
|
||||||
|
const res = await $productCategory.update({
|
||||||
|
...data
|
||||||
|
})
|
||||||
|
infoBox.showToast('修改成功')
|
||||||
|
// init()
|
||||||
|
}
|
||||||
|
|
||||||
|
function categoryUseTypeClick(index) {
|
||||||
|
goodsTypeModelData.index = index
|
||||||
|
// goodsTypeModelData.useTypes=pageData.list[index].useTypes
|
||||||
|
const cateItem = pageData.list[index]
|
||||||
|
console.log(cateItem);
|
||||||
|
goodsTypeModelData.selCategory = cateItem
|
||||||
|
goodsTypeModelData.title = cateItem.name
|
||||||
|
goodsTypeModel.value.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//点击修改按钮弹出修改商品弹窗
|
||||||
|
function goodsChangeClick(index) {
|
||||||
|
console.log(index);
|
||||||
|
const goods = pageData.list[index]
|
||||||
|
sort.value = goods.sort
|
||||||
|
pageData.selCategory = goods
|
||||||
|
goodsSortModel.value.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
function statesTableClick(index) {
|
||||||
|
pageData.stateCurrent = index
|
||||||
|
}
|
||||||
|
|
||||||
|
function states1TableClick(index) {
|
||||||
|
pageData.stateCurrent1 = index
|
||||||
|
}
|
||||||
|
|
||||||
|
let test = ref(false)
|
||||||
|
|
||||||
|
function tabsChange(i) {
|
||||||
|
console.log(i);
|
||||||
|
pageData.showGoodsDetail = i ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//改变商品的选中状态
|
||||||
|
function changeGoodsChecked(checked, index) {
|
||||||
|
if (index !== undefined) {
|
||||||
|
pageData.list[index].checked = checked
|
||||||
|
} else {
|
||||||
|
pageData.list.map(v => {
|
||||||
|
v.checked = checked
|
||||||
|
})
|
||||||
|
}
|
||||||
|
control.value.setisSelectAll(isAllChecked() ? true : false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取已经选中的商品
|
||||||
|
function getChechkedlist() {
|
||||||
|
return pageData.list.filter(v => v.checked)
|
||||||
|
}
|
||||||
|
//是否全部选中
|
||||||
|
function isAllChecked() {
|
||||||
|
return getChechkedlist().length === pageData.list.length
|
||||||
|
}
|
||||||
|
// 是否有商品选中
|
||||||
|
function isHasChekdGoods() {
|
||||||
|
return getChechkedlist().length ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchFunc() {
|
||||||
|
console.log('searchFunc');
|
||||||
|
}
|
||||||
|
|
||||||
|
let showChecked = ref(false)
|
||||||
|
|
||||||
|
//商品start
|
||||||
|
|
||||||
|
function goodsRadioClick(index) {
|
||||||
|
var checked = !pageData.list[index].checked
|
||||||
|
changeGoodsChecked(checked, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//下架
|
||||||
|
function offShelf() {
|
||||||
|
const hasCheckedArr = getChechkedlist()
|
||||||
|
const hasChecked = isHasChekdGoods()
|
||||||
|
if (!hasChecked) {
|
||||||
|
return infoBox.showToast('您还没有选中商品!')
|
||||||
|
}
|
||||||
|
model.value.open()
|
||||||
|
}
|
||||||
|
let nowCateIndex = null
|
||||||
|
|
||||||
|
function categoryDel(index) {
|
||||||
|
// nowCateIndex=index
|
||||||
|
// delModel.value.open()
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '请确保此分类下没有任何商品确认删除?',
|
||||||
|
success: res => {
|
||||||
|
if (res.confirm) {
|
||||||
|
const islast = pageData.list.length === 1
|
||||||
|
$productCategory.del([pageData.list[index].id]).then(res => {
|
||||||
|
infoBox.showToast('删除成功')
|
||||||
|
// if(islast&&pageData.query.page>=1){
|
||||||
|
// pageData.query.page--
|
||||||
|
// }
|
||||||
|
init()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
fail: () => {},
|
||||||
|
complete: () => {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//删除分类确认
|
||||||
|
function delModelConfirm() {
|
||||||
|
console.log('confirm');
|
||||||
|
pageData.list.splice(nowCateIndex, 1)
|
||||||
|
delModel.value.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
//商品end
|
||||||
|
|
||||||
|
//控制条
|
||||||
|
function controlChange(bol) {
|
||||||
|
console.log(bol);
|
||||||
|
showChecked.value = bol
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 全选
|
||||||
|
function allCheckedChange(checked) {
|
||||||
|
changeGoodsChecked(checked)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页数改变事件
|
||||||
|
function pageChange(page) {
|
||||||
|
pageData.query.page = page - 1
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//分类
|
||||||
|
const category = ref(null)
|
||||||
|
|
||||||
|
function toggleCategory() {
|
||||||
|
category.value.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
function cateClick(cate) {
|
||||||
|
console.log(cate);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.stock-btns {
|
||||||
|
padding: 0 100rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.safe-page {
|
||||||
|
background: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-guige {
|
||||||
|
width: 42rpx;
|
||||||
|
height: 42rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-fff {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myTabs {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 434rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 26rpx;
|
||||||
|
background-color: $J-bg-ff;
|
||||||
|
|
||||||
|
.input-main {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 64rpx;
|
||||||
|
|
||||||
|
image {
|
||||||
|
padding: 22rpx;
|
||||||
|
width: 26rpx;
|
||||||
|
height: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 27rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep uni-button {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $my-main-color;
|
||||||
|
background: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep.uni-easyinput {
|
||||||
|
.uni-easyinput__content {
|
||||||
|
background-color: $J-bg-f5 !important;
|
||||||
|
border-radius: $J-b-r12;
|
||||||
|
|
||||||
|
.uni-easyinput__content-input {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
|
||||||
|
.uni-input-input {
|
||||||
|
border-radius: $J-b-r12 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-input-placeholder {
|
||||||
|
font-size: 27rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-icons {
|
||||||
|
color: rgba(230, 230, 230, 1) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
background-color: transparent !important;
|
||||||
|
color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.states1 {
|
||||||
|
margin-top: 78rpx;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #666;
|
||||||
|
margin-right: 70rpx;
|
||||||
|
background: #F4F4F4;
|
||||||
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item.active {
|
||||||
|
background: #E6F0FF;
|
||||||
|
color: $my-main-color;
|
||||||
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-b {
|
||||||
|
position: fixed;
|
||||||
|
left: 110rpx;
|
||||||
|
right: 110rpx;
|
||||||
|
bottom: 110rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="11.864" height="11.592" viewBox="0 0 11.864 11.592"><defs><style>.a{fill:#64a7fe;}</style></defs><path class="a" d="M79.676,85.867H68.721a.409.409,0,0,0,0,.818h11a.407.407,0,0,0,.409-.409.534.534,0,0,0-.455-.409Zm-11-1.227H70.63A.324.324,0,0,0,70.9,84.5l6.728-6.728a.388.388,0,0,0,0-.591L75.722,75.23a.388.388,0,0,0-.591,0l-1.364,1.364L68.4,81.957a.393.393,0,0,0-.136.273v1.955a.491.491,0,0,0,.136.318.324.324,0,0,0,.273.136ZM75.4,76.093l1.364,1.364-.773.773-1.364-1.364ZM69.13,82.412l4.955-4.955,1.364,1.364-4.955,4.955H69.13Z" transform="translate(-68.267 -75.093)"/></svg>
|
||||||
|
After Width: | Height: | Size: 622 B |
Loading…
Reference in New Issue