增加商品管理编辑权限验证

This commit is contained in:
2024-10-09 17:33:22 +08:00
parent f700096359
commit fbfcfc4d82
5 changed files with 261 additions and 93 deletions

View File

@@ -87,11 +87,11 @@
<view class="u-flex">
<view class="u-flex">
<view class="u-m-r-18 color-999">售罄</view>
<my-switch v-model="isPauseSale" @change="isPauseSaleChange"></my-switch>
<my-switch disabled v-model="isPauseSale" :openDisabledClass="false" @click="isPauseSaleChange"></my-switch>
</view>
<view class="u-flex u-m-l-30">
<view class="u-m-r-18 color-999">{{data.isGrounding?'下架产品':'上架产品' }}</view>
<my-switch v-model="isGrounding" @change="isGroundingChange"></my-switch>
<my-switch disabled v-model="isGrounding" :openDisabledClass="false" @click="isGroundingChange"></my-switch>
</view>
</view>
<view class="u-flex">
@@ -117,8 +117,8 @@
$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 {hasPermission} from '@/commons/utils/hasPermission.js';
import {
ColorMain
} from '@/commons/color.js'
@@ -171,17 +171,24 @@
isGrounding.value=newval
})
function isPauseSaleChange(e) {
async function isPauseSaleChange(e) {
const res=await hasPermission('允许售罄商品')
if(!res){
return
}
upDateGoods({
key: 'pauseSale',
value: e
value: isPauseSale.value?0:1
})
}
function isGroundingChange(e) {
async function isGroundingChange(e) {
const res=await hasPermission('允许上下架商品')
if(!res){
return
}
upDateGoods({
key: 'grounding',
value: e
value: isGrounding.value?0:1
})
}
@@ -208,7 +215,11 @@
emits('del', props.index)
}
function changePrice() {
async function changePrice() {
const res=await hasPermission('允许修改商品')
if(!res){
return
}
emits('changePrice', props.index)
}
@@ -225,10 +236,11 @@
}
//携带参数type edit跳转到商品添加页面编辑与添加同一页面根据type值来判断
function toEdit() {
go.to('PAGES_PRODUCT_ADD', {
type: 'edit',
productId: props.data.id
})
emits('edit', props.data.id)
// go.to('PAGES_PRODUCT_ADD', {
// type: 'edit',
// productId: props.data.id
// })
}
</script>

View File

@@ -42,6 +42,7 @@
<template v-if="pageData.goodsList.length">
<view class="u-m-b-32" v-for="(item,index) in pageData.goodsList" :key="index">
<my-goods :key="item.id" @update="getGoodsList" @changePrice="changePriceShow" @changeClick="goodsChangeClick"
@edit="toGoodsDetail"
@editStock="changeStockShow" @guigeClick="editGuigeShow" @baosun="baosunShow"
@radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
@@ -149,6 +150,7 @@
watch
} from 'vue';
import go from '@/commons/utils/go.js';
import {hasPermission} from '@/commons/utils/hasPermission.js';
import myGoods from './components/goods.vue'
import myControl from './components/control.vue'
import myCategory from './components/category.vue'
@@ -285,7 +287,11 @@
// 修改库存弹窗展示
function changeStockShow(index) {
async function changeStockShow(index) {
const res= await hasPermission('允许修改商品库存')
if(!res){
return
}
pageData.selGoodsIndex = index
const goods = pageData.goodsList[index]
goods.skuList = goods.skuList.map(v => {
@@ -387,8 +393,15 @@
pageData.totalElements = res.totalElements
})
}
function watchEmitInit(){
uni.$off('update:productIndex')
uni.$on('update:productIndex',(data)=>{
getGoodsList()
})
}
onShow(() => {
// getGoodsList()
watchEmitInit()
})
onLoad(() => {
getGoodsList()
@@ -484,7 +497,18 @@
pageData.totalElements=0;
pageData.query.page=0;
}
async function toGoodsDetail(id){
const res= await hasPermission('允许修改商品')
if(!res){
return
}
go.to('PAGES_PRODUCT_ADD', {
type: 'edit',
productId: id
})
}
function statesTableClick(index) {
pageData.stateCurrent = index;
resetQuery()