代码更新
This commit is contained in:
@@ -3,33 +3,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref, warn, watch, watchEffect,
|
||||
onMounted,reactive
|
||||
} from 'vue';
|
||||
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||
import { ref, watch, onMounted,reactive } from 'vue';
|
||||
import { categoryPage } from '@/api/cateGory.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
|
||||
@@ -38,54 +15,35 @@
|
||||
|
||||
let show = ref(props.isShow)
|
||||
|
||||
const category=reactive({
|
||||
list:[],
|
||||
})
|
||||
onMounted(()=>{
|
||||
categoryPage({
|
||||
page:1,size:200
|
||||
}).then(res=>{
|
||||
res.records.unshift({
|
||||
name:'全部',
|
||||
id:'',
|
||||
})
|
||||
category.list = [res.records]
|
||||
})
|
||||
})
|
||||
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>
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
<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>
|
||||
@@ -2,27 +2,7 @@
|
||||
<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-24 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>
|
||||
@@ -31,11 +11,6 @@
|
||||
<view class="u-flex">
|
||||
<text class="u-m-r-24">{{data.name}}</text>
|
||||
</view>
|
||||
<view class="u-font-32 u-m-r-8">
|
||||
<!-- <text v-if="data.typeEnum=='单规格'||data.typeEnum=='normal'">¥</text> -->
|
||||
<text >¥</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>
|
||||
@@ -58,24 +33,9 @@
|
||||
</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'
|
||||
])
|
||||
import { ColorMain } from '@/commons/color.js'
|
||||
const emits = defineEmits(['goodsClick', 'del'])
|
||||
|
||||
const props = defineProps({
|
||||
isBind: {
|
||||
type: Boolean,
|
||||
@@ -92,10 +52,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
showChecked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showDetail: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -105,69 +61,15 @@
|
||||
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;
|
||||
@@ -175,62 +77,16 @@
|
||||
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;
|
||||
@@ -254,34 +110,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
@@ -2,9 +2,7 @@
|
||||
<view class="safe-page min-page">
|
||||
<up-sticky>
|
||||
<view class="bg-fff u-p-l-30 u-p-b-24">
|
||||
<!-- <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)">
|
||||
@@ -39,8 +37,8 @@
|
||||
<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 :index="index" :data="item" @del="goodsDel"
|
||||
:showDetail="pageData.showGoodsDetail"></my-goods>
|
||||
</view>
|
||||
</template>
|
||||
<template v-if="pageData.hasAjax&&!pageData.bindGoodsList.length">
|
||||
@@ -54,8 +52,7 @@
|
||||
<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"
|
||||
<my-goods @goodsClick="goodsClick" :index="index" :data="item"
|
||||
:showDetail="pageData.showGoodsDetail"></my-goods>
|
||||
</view>
|
||||
</template>
|
||||
@@ -67,15 +64,9 @@
|
||||
<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>
|
||||
@@ -83,64 +74,22 @@
|
||||
</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 { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
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 {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js';
|
||||
|
||||
import {
|
||||
returnAllCategory
|
||||
} from '@/pageProduct/util.js'
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js';
|
||||
|
||||
import { categoryPage } from '@/api/cateGory.js'
|
||||
import { getProductList,getProdGroupDetail,updateProdGroup } from '@/api/product.js'
|
||||
|
||||
const pageData = reactive({
|
||||
modelDesc: '是否下架',
|
||||
stateCurrent: 0,
|
||||
componentBottom: 45,
|
||||
search: {
|
||||
value: '',
|
||||
placeholder: '输入搜索的商品'
|
||||
},
|
||||
showGoodsDetail: false,
|
||||
selGoodsIndex: '',
|
||||
selGoods: {},
|
||||
totalElements: 0,
|
||||
totalPage: 0,
|
||||
bindGoodsList: [],
|
||||
goodsList: [],
|
||||
query: {
|
||||
@@ -148,9 +97,7 @@
|
||||
size: 999,
|
||||
categoryId: '',
|
||||
name: '',
|
||||
createdAt: [],
|
||||
id: "",
|
||||
sort: "createdAt,desc"
|
||||
},
|
||||
category: '',
|
||||
categoryList: [], //分类列表
|
||||
@@ -159,262 +106,22 @@
|
||||
hasAjax: false
|
||||
})
|
||||
|
||||
|
||||
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
|
||||
console.log(pageData.query.categoryId );
|
||||
pageData.categoryName = category.name
|
||||
}
|
||||
|
||||
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 => {
|
||||
return {
|
||||
...v,
|
||||
checked: false
|
||||
}
|
||||
})
|
||||
setGoodsList()
|
||||
|
||||
})
|
||||
}
|
||||
onShow(() => {
|
||||
// getGoodsList()
|
||||
})
|
||||
async function getGroupBindGoods() {
|
||||
const res = await productListGet(option.id)
|
||||
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() {
|
||||
await getGroupBindGoods()
|
||||
getGoodsList()
|
||||
}
|
||||
onLoad((opt) => {
|
||||
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() {
|
||||
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)
|
||||
]
|
||||
})
|
||||
pageData.stateCurrent = 0
|
||||
}
|
||||
|
||||
|
||||
function updateGroup() {
|
||||
|
||||
}
|
||||
|
||||
//删除商品
|
||||
async function goodsDel(index) {
|
||||
const res = await hasPermission('允许修改分组')
|
||||
if (!res) {
|
||||
return
|
||||
}
|
||||
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
|
||||
console.log(pageData.stateCurrent);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
let isSearch=ref(false)
|
||||
async function searchFunc() {
|
||||
isSearch.value=true
|
||||
console.log('searchFunc');
|
||||
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)
|
||||
|
||||
//商品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 statesTabsList = ['已添加', '未添加']
|
||||
const control = ref(null)
|
||||
const model = ref(null)
|
||||
const option = reactive({})
|
||||
//分类
|
||||
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()
|
||||
}
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
init()
|
||||
})
|
||||
onShow(() => {
|
||||
|
||||
})
|
||||
watch(() => pageData.query.categoryId, (newval) => {
|
||||
if(pageData.stateCurrent==1){
|
||||
getGoodsList()
|
||||
@@ -430,6 +137,131 @@
|
||||
getGroupBindGoods()
|
||||
}
|
||||
})
|
||||
async function init() {
|
||||
await getGroupBindGoods()
|
||||
getGoodsList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
async function searchFunc() {
|
||||
isSearch.value=true
|
||||
if (pageData.stateCurrent) {
|
||||
getGoodsList()
|
||||
} else {
|
||||
const res = await getProdGroupDetail(option.id)
|
||||
pageData.bindGoodsList = res.productList.filter(v=>{
|
||||
return v.name.includes(pageData.query.name)&&(pageData.query.categoryId==''?true:v.categoryId==pageData.query.categoryId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
*/
|
||||
function getGoodsList() {
|
||||
getProductList(pageData.query).then(res => {
|
||||
pageData.hasAjax = true
|
||||
let goodsList = res.records.map(v => {
|
||||
return {
|
||||
...v,
|
||||
checked: false
|
||||
}
|
||||
})
|
||||
pageData.goodsList = goodsList.filter(v => {
|
||||
return !pageData.bindGoodsList.find(bindGoods => bindGoods.id == v.id)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组详情
|
||||
*/
|
||||
async function getGroupBindGoods() {
|
||||
let res = await getProdGroupDetail(option.id)
|
||||
console.log(res)
|
||||
pageData.bindGoodsList = res.productList.filter(v=>{
|
||||
return pageData.query.categoryId === '' ? true : (v.categoryId==pageData.query.categoryId)&&(v.name.includes(pageData.query.name))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 已添加/未添加切换
|
||||
* @param {Object} index
|
||||
*/
|
||||
function statesTableClick(index) {
|
||||
pageData.stateCurrent = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类选择
|
||||
* @param {Object} show
|
||||
*/
|
||||
function onCategoryShowChange(show) {
|
||||
pageData.categoryShow = show
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类选择确定
|
||||
* @param {Object} category
|
||||
*/
|
||||
function setCategory(category) {
|
||||
pageData.query.categoryId = category.id
|
||||
console.log(pageData.query.categoryId );
|
||||
pageData.categoryName = category.name
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定商品
|
||||
*/
|
||||
async function save() {
|
||||
const res = await hasPermission('允许修改分组')
|
||||
if (!res) {
|
||||
return
|
||||
}
|
||||
console.log(pageData.goodsList);
|
||||
await updateProdGroup({
|
||||
...option,
|
||||
productIds: [...pageData.bindGoodsList.map(v => v.id), ...pageData.goodsList.filter(v => v.checked)
|
||||
.map(v => v.id)
|
||||
]
|
||||
})
|
||||
pageData.stateCurrent = 0
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param {Object} index
|
||||
*/
|
||||
async function goodsDel(index) {
|
||||
const res = await hasPermission('允许修改分组')
|
||||
if (!res) {
|
||||
return
|
||||
}
|
||||
const goods = pageData.bindGoodsList[index]
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否确认将' + goods.name + '从该分组中移除',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
pageData.bindGoodsList.splice(index, 1)
|
||||
updateProdGroup({
|
||||
...option,
|
||||
productIds: pageData.bindGoodsList.map(v => v.id)
|
||||
})
|
||||
} else if (res.cancel) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function goodsClick(e) {
|
||||
pageData.goodsList[e].checked = !pageData.goodsList[e].checked
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
page {
|
||||
|
||||
Reference in New Issue
Block a user