增加商品管理编辑权限验证
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="u-p-30 safe-page min-page">
|
<view class="u-p-30 safe-page min-page">
|
||||||
<up-sticky v-if="option.type==='edit'" offset-top="20" zIndex="99">
|
<up-sticky v-if="option.type==='edit'" offset-top="20" zIndex="99">
|
||||||
<myTabs :list="tabsList" v-model="tabsCurrent"></myTabs>
|
<my-tabs :list="tabsList" v-model="tabsCurrent"></my-tabs>
|
||||||
</up-sticky>
|
</up-sticky>
|
||||||
<view class="box">
|
<view class="box">
|
||||||
|
|
||||||
@@ -11,8 +11,7 @@
|
|||||||
err-show-type="toast" validateTrigger="submit" label-width="350" ref="Forms">
|
err-show-type="toast" validateTrigger="submit" label-width="350" ref="Forms">
|
||||||
<view class="block">
|
<view class="block">
|
||||||
<uni-forms-item label="商品类型" required showRequired>
|
<uni-forms-item label="商品类型" required showRequired>
|
||||||
<up-radio-group :disabled="option.type=='edit'" v-model="FormData.typeEnum"
|
<up-radio-group v-model="FormData.typeEnum" placement="row">
|
||||||
placement="row">
|
|
||||||
<up-radio :customStyle="{marginRight: '30px'}"
|
<up-radio :customStyle="{marginRight: '30px'}"
|
||||||
v-for="(item, index) in pageData.types" :key="index" :label="item.name"
|
v-for="(item, index) in pageData.types" :key="index" :label="item.name"
|
||||||
:name="item.value">
|
:name="item.value">
|
||||||
@@ -40,21 +39,28 @@
|
|||||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="FormData.name" placeholder="请输入商品名称" />
|
:inputBorder="inputBorder" v-model="FormData.name" placeholder="请输入商品名称" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<template v-if="FormData.typeEnum!='group'">
|
|
||||||
<uni-forms-item label="所属分类" required showRequired name="categoryId">
|
|
||||||
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
|
||||||
placeholder="请选择分类" popup-title="请选择分类" :localdata="pageData.category"
|
|
||||||
v-model="FormData.categoryId">
|
|
||||||
</uni-data-picker>
|
|
||||||
</uni-forms-item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<view class="border-top-0">
|
<view class="border-top-0">
|
||||||
<uni-forms-item label="商品描述">
|
<uni-forms-item label="商品描述">
|
||||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
type="textarea" v-model="FormData.shortTitle" placeholder="请填写商品简述" />
|
type="textarea" v-model="FormData.shortTitle" placeholder="请填写商品简述" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
</view>
|
</view>
|
||||||
|
<template v-if="FormData.typeEnum!='group'">
|
||||||
|
<view class="u-relative">
|
||||||
|
<uni-forms-item label="所属分类" required showRequired name="categoryId">
|
||||||
|
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
||||||
|
placeholder="请选择分类" popup-title="请选择分类" :localdata="pageData.category"
|
||||||
|
v-model="FormData.categoryId">
|
||||||
|
</uni-data-picker>
|
||||||
|
</uni-forms-item>
|
||||||
|
<view class="zhezhao u-absolute position-all" @click="canEditGoodsCategory(true)" v-if="option.type=='edit'&&disabledChangeCategory">
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="border-top-0">
|
<view class="border-top-0">
|
||||||
<uni-forms-item label="单位" required showRequired name="categoryId">
|
<uni-forms-item label="单位" required showRequired name="categoryId">
|
||||||
@@ -115,13 +121,13 @@
|
|||||||
<template v-if="skuList.list.length">
|
<template v-if="skuList.list.length">
|
||||||
<view class="u-text-center">
|
<view class="u-text-center">
|
||||||
<view class="u-flex font-bold u-m-b-12">
|
<view class="u-flex font-bold u-m-b-12">
|
||||||
<view class="u-flex-1">组合名称</view>
|
<view class="u-flex-1 u-text-left">组合名称</view>
|
||||||
<view class="u-flex-1">售价</view>
|
<view class="u-flex-1">售价</view>
|
||||||
<view class="u-flex-1">库存数量</view>
|
<view class="u-flex-1">库存数量</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex u-p-b-12 u-p-t-12" v-for="(item,index) in skuList.list"
|
<view class="u-flex u-p-b-12 u-p-t-12" v-for="(item,index) in skuList.list"
|
||||||
:key="index">
|
:key="index">
|
||||||
<view class="u-flex-1">{{item.specSnap}}</view>
|
<view class="u-flex-1 u-text-left">{{item.specSnap}}</view>
|
||||||
<view class="u-flex-1">¥{{item.salePrice}}</view>
|
<view class="u-flex-1">¥{{item.salePrice}}</view>
|
||||||
<view class="u-flex-1">{{item.stockNumber}}</view>
|
<view class="u-flex-1">{{item.stockNumber}}</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -207,7 +213,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="FormData.typeEnum!='sku'">
|
<template v-if="FormData.typeEnum!='sku'">
|
||||||
<view class="u-m-t-32 u-font-32 u-m-l-10 u-m-b-32">规格属性</view>
|
<!-- <view class="u-m-t-32 u-font-32 u-m-l-10 u-m-b-32">规格属性</view> -->
|
||||||
<view class="block" v-for="(sku,index) in skuList.list" :key="index">
|
<view class="block" v-for="(sku,index) in skuList.list" :key="index">
|
||||||
<view class="border-top-0">
|
<view class="border-top-0">
|
||||||
<uni-forms-item label="售价">
|
<uni-forms-item label="售价">
|
||||||
@@ -224,7 +230,7 @@
|
|||||||
:inputBorder="inputBorder" v-model="sku.memberPrice" type="digit"
|
:inputBorder="inputBorder" v-model="sku.memberPrice" type="digit"
|
||||||
placeholder="请输入会员价(元)" />
|
placeholder="请输入会员价(元)" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<!-- <uni-forms-item label="成本价(元)">
|
<!-- <uni-forms-item label="成本价(元)">
|
||||||
<uni-easyinput @blur="priceFormat(sku,'costPrice')" :paddingNone="inputPaddingNone"
|
<uni-easyinput @blur="priceFormat(sku,'costPrice')" :paddingNone="inputPaddingNone"
|
||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="sku.costPrice" type="digit" placeholder="请输入成本价(元)" />
|
v-model="sku.costPrice" type="digit" placeholder="请输入成本价(元)" />
|
||||||
@@ -240,12 +246,12 @@
|
|||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="sku.suit" type="digit" placeholder="请输入起售数量" />
|
v-model="sku.suit" type="digit" placeholder="请输入起售数量" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="库存数量">
|
<!-- <uni-forms-item label="库存数量">
|
||||||
<uni-easyinput @blur="priceFormat(sku,'stockNumber')"
|
<uni-easyinput @blur="priceFormat(sku,'stockNumber')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="sku.stockNumber" type="digit"
|
:inputBorder="inputBorder" v-model="sku.stockNumber" type="digit"
|
||||||
placeholder="请输入库存数量" />
|
placeholder="请输入库存数量" />
|
||||||
</uni-forms-item>
|
</uni-forms-item> -->
|
||||||
<uni-forms-item label="分销金额">
|
<uni-forms-item label="分销金额">
|
||||||
<uni-easyinput :paddingNone="inputPaddingNone"
|
<uni-easyinput :paddingNone="inputPaddingNone"
|
||||||
@blur="priceFormat(sku,'firstShared')" :placeholderStyle="placeholderStyle"
|
@blur="priceFormat(sku,'firstShared')" :placeholderStyle="placeholderStyle"
|
||||||
@@ -384,7 +390,7 @@
|
|||||||
|
|
||||||
<template v-if="FormData.typeEnum!='group'">
|
<template v-if="FormData.typeEnum!='group'">
|
||||||
<view class="block">
|
<view class="block">
|
||||||
<view class="border-top-0">
|
<!-- <view class="border-top-0">
|
||||||
<uni-forms-item label="上架区域">
|
<uni-forms-item label="上架区域">
|
||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
<view class="u-m-r-30">
|
<view class="u-m-r-30">
|
||||||
@@ -393,6 +399,15 @@
|
|||||||
<my-radio text="小程序商城" v-model="FormData.isShowMall"></my-radio>
|
<my-radio text="小程序商城" v-model="FormData.isShowMall"></my-radio>
|
||||||
</view>
|
</view>
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
|
</view> -->
|
||||||
|
<view class="border-top-0">
|
||||||
|
<uni-forms-item label="">
|
||||||
|
<view class="u-flex u-row-between">
|
||||||
|
<view class="label-title">上架</view>
|
||||||
|
<my-switch disabled :openDisabledClass="false" @click="isGroundingChange"
|
||||||
|
v-model="FormData.isGrounding"></my-switch>
|
||||||
|
</view>
|
||||||
|
</uni-forms-item>
|
||||||
</view>
|
</view>
|
||||||
<uni-forms-item label="">
|
<uni-forms-item label="">
|
||||||
<view class="u-flex u-row-between">
|
<view class="u-flex u-row-between">
|
||||||
@@ -401,6 +416,21 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="color-999 u-m-t-16 u-font-24">注:关闭则不计算出入库数据</view>
|
<view class="color-999 u-m-t-16 u-font-24">注:关闭则不计算出入库数据</view>
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
|
<template v-if="FormData.isStock">
|
||||||
|
<uni-forms-item label="库存数量">
|
||||||
|
<uni-easyinput :paddingNone="inputPaddingNone"
|
||||||
|
:disabled="disabledStock"
|
||||||
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
|
v-model="FormData.stockNumber" type="digit" placeholder="请输入库存数量" />
|
||||||
|
</uni-forms-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<uni-forms-item label="">
|
||||||
|
<view class="u-flex u-row-between">
|
||||||
|
<view class="label-title">设为推荐</view>
|
||||||
|
<my-switch v-model="FormData.isHot"></my-switch>
|
||||||
|
</view>
|
||||||
|
</uni-forms-item>
|
||||||
<uni-forms-item label="">
|
<uni-forms-item label="">
|
||||||
<view class="u-flex u-row-between">
|
<view class="u-flex u-row-between">
|
||||||
<view class="label-title">标签打印</view>
|
<view class="label-title">标签打印</view>
|
||||||
@@ -414,12 +444,12 @@
|
|||||||
:inputBorder="inputBorder" v-model="FormData.packFee" type="digit"
|
:inputBorder="inputBorder" v-model="FormData.packFee" type="digit"
|
||||||
placeholder="请输入打包费" />
|
placeholder="请输入打包费" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="虚拟销量">
|
<!-- <uni-forms-item label="虚拟销量">
|
||||||
<uni-easyinput @blur="priceFormat(FormData,'baseSalesNumber')"
|
<uni-easyinput @blur="priceFormat(FormData,'baseSalesNumber')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="FormData.baseSalesNumber" type="digit"
|
:inputBorder="inputBorder" v-model="FormData.baseSalesNumber" type="digit"
|
||||||
placeholder="请输入虚拟销量" />
|
placeholder="请输入虚拟销量" />
|
||||||
</uni-forms-item>
|
</uni-forms-item> -->
|
||||||
<template v-if="option.type==='edit'">
|
<template v-if="option.type==='edit'">
|
||||||
<uni-forms-item label="排序">
|
<uni-forms-item label="排序">
|
||||||
<uni-easyinput @blur="priceFormat(FormData,'sort')"
|
<uni-easyinput @blur="priceFormat(FormData,'sort')"
|
||||||
@@ -448,7 +478,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="tabsCurrent===1">
|
<template v-if="tabsCurrent===1">
|
||||||
<edit-haocai @updateGoods="updateGoodsDetail" :goods="FormData" @cancel="changeTabsCurrent(0)"></edit-haocai>
|
<edit-haocai @updateGoods="updateGoodsDetail" :goods="FormData"
|
||||||
|
@cancel="changeTabsCurrent(0)"></edit-haocai>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -489,17 +520,15 @@
|
|||||||
import go from '@/commons/utils/go.js';
|
import go from '@/commons/utils/go.js';
|
||||||
import color from '@/commons/color.js';
|
import color from '@/commons/color.js';
|
||||||
|
|
||||||
import myModel from '@/components/my-components/my-model'
|
|
||||||
import chooseGoods from './components/choose-goods'
|
import chooseGoods from './components/choose-goods'
|
||||||
import editHaocai from './components/edit-haocai.vue'
|
import editHaocai from './components/edit-haocai.vue'
|
||||||
import chooseGroupCategory from './components/choose-coupon-category'
|
import chooseGroupCategory from './components/choose-coupon-category'
|
||||||
import myRadio from '@/components/my-components/my-radio'
|
|
||||||
import myUploadFile from '@/components/my-components/my-upload-file'
|
|
||||||
import myTabs from '@/components/my-components/my-tabs'
|
|
||||||
import myButton from '@/components/my-components/my-button'
|
|
||||||
import mySwitch from '@/components/my-components/my-switch.vue'
|
|
||||||
import infoBox from "@/commons/utils/infoBox.js"
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
|
|
||||||
|
import {
|
||||||
|
hasPermission
|
||||||
|
} from '@/commons/utils/hasPermission.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
$types,
|
$types,
|
||||||
$defaultSku
|
$defaultSku
|
||||||
@@ -513,7 +542,10 @@
|
|||||||
$delProduct,
|
$delProduct,
|
||||||
$productSpec,
|
$productSpec,
|
||||||
$updateProductStatus,
|
$updateProductStatus,
|
||||||
$updateGrounding
|
$updateGrounding,
|
||||||
|
$goodsIsHot,
|
||||||
|
$tbProskuConV2,
|
||||||
|
$updateProductData
|
||||||
} from '@/http/yskApi/goods.js'
|
} from '@/http/yskApi/goods.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -535,6 +567,50 @@
|
|||||||
nextTick
|
nextTick
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
|
async function upDateGoods(par) {
|
||||||
|
const res = await $updateProductData([{
|
||||||
|
id: FormData.id,
|
||||||
|
isSku: 0,
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
...par
|
||||||
|
}])
|
||||||
|
uni.showToast({
|
||||||
|
title: '修改成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function isPauseSaleChange(e) {
|
||||||
|
if (option.type == 'add') {
|
||||||
|
FormData.isPauseSale = FormData.isPauseSale ? 0 : 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const res = await hasPermission('允许售罄商品')
|
||||||
|
if (!res) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await upDateGoods({
|
||||||
|
key: 'pauseSale',
|
||||||
|
value: FormData.isPauseSale ? 0 : 1
|
||||||
|
})
|
||||||
|
FormData.isPauseSale = FormData.isPauseSale ? 0 : 1
|
||||||
|
}
|
||||||
|
|
||||||
|
async function isGroundingChange(e) {
|
||||||
|
if (option.type == 'add') {
|
||||||
|
FormData.isGrounding = FormData.isGrounding ? 0 : 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const res = await hasPermission('允许上下架商品')
|
||||||
|
if (!res) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await upDateGoods({
|
||||||
|
key: 'grounding',
|
||||||
|
value: FormData.isGrounding ? 0 : 1
|
||||||
|
})
|
||||||
|
FormData.isGrounding = FormData.isGrounding ? 0 : 1
|
||||||
|
}
|
||||||
|
|
||||||
function toRecoders() {
|
function toRecoders() {
|
||||||
go.to('PAGES_PRODUCT_INVOICING_LIST', {
|
go.to('PAGES_PRODUCT_INVOICING_LIST', {
|
||||||
productId: FormData.id
|
productId: FormData.id
|
||||||
@@ -932,9 +1008,11 @@
|
|||||||
isShowMall: 1,
|
isShowMall: 1,
|
||||||
isShowCash: 1,
|
isShowCash: 1,
|
||||||
isStock: 0,
|
isStock: 0,
|
||||||
|
isStock: 0,
|
||||||
|
isHot: 0,
|
||||||
packFee: 0,
|
packFee: 0,
|
||||||
specId: "",
|
specId: "",
|
||||||
baseSalesNumber: 0,
|
// baseSalesNumber: 0,
|
||||||
sort: 0,
|
sort: 0,
|
||||||
groupSnap: [],
|
groupSnap: [],
|
||||||
specInfo: [],
|
specInfo: [],
|
||||||
@@ -942,6 +1020,8 @@
|
|||||||
specTableHeaders: [],
|
specTableHeaders: [],
|
||||||
skuSnap: "",
|
skuSnap: "",
|
||||||
groupCategoryId: [],
|
groupCategoryId: [],
|
||||||
|
isGrounding: 1,
|
||||||
|
stockNumber: 0,
|
||||||
notices: {
|
notices: {
|
||||||
availableTime: "",
|
availableTime: "",
|
||||||
bookingType: "",
|
bookingType: "",
|
||||||
@@ -1001,14 +1081,14 @@
|
|||||||
url: v
|
url: v
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
for(let i in res.conInfos){
|
for (let i in res.conInfos) {
|
||||||
const con=res.conInfos[i]
|
const con = res.conInfos[i]
|
||||||
const item=res.skuList.find(v=>v.id==con.productSkuId)
|
const item = res.skuList.find(v => v.id == con.productSkuId)
|
||||||
if(item){
|
if (item) {
|
||||||
if(item.hasOwnProperty('haoCaiList')){
|
if (item.hasOwnProperty('haoCaiList')) {
|
||||||
item.haoCaiList.push(con)
|
item.haoCaiList.push(con)
|
||||||
}else{
|
} else {
|
||||||
item.haoCaiList=[con]
|
item.haoCaiList = [con]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1054,7 +1134,7 @@
|
|||||||
},
|
},
|
||||||
names,
|
names,
|
||||||
specSnap: v.specSnap,
|
specSnap: v.specSnap,
|
||||||
coverImg:v.coverImg
|
coverImg: v.coverImg
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
specList: [],
|
specList: [],
|
||||||
@@ -1161,9 +1241,10 @@
|
|||||||
pageData.skuList = res
|
pageData.skuList = res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function updateGoodsDetail(){
|
|
||||||
|
function updateGoodsDetail() {
|
||||||
getGoodsDetail()
|
getGoodsDetail()
|
||||||
getProductSku()
|
// getProductSku()
|
||||||
}
|
}
|
||||||
onLoad((params) => {
|
onLoad((params) => {
|
||||||
if (isEmpty(params)) {
|
if (isEmpty(params)) {
|
||||||
@@ -1173,14 +1254,13 @@
|
|||||||
// getGoodsDetail()
|
// getGoodsDetail()
|
||||||
// getProductSku()
|
// getProductSku()
|
||||||
}
|
}
|
||||||
|
canEditGoodsCategory()
|
||||||
console.log(option.type);
|
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title: option.type === 'add' ? '添加商品' : '编辑商品'
|
title: option.type === 'add' ? '添加商品' : '编辑商品'
|
||||||
})
|
})
|
||||||
if (option.type === 'edit') {
|
if (option.type === 'edit') {
|
||||||
getGoodsDetail()
|
getGoodsDetail()
|
||||||
getProductSku()
|
// getProductSku()
|
||||||
}
|
}
|
||||||
defaultValueInit()
|
defaultValueInit()
|
||||||
getCategory()
|
getCategory()
|
||||||
@@ -1212,12 +1292,18 @@
|
|||||||
function settimeoutBack(time) {
|
function settimeoutBack(time) {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
|
uni.$emit('update:productIndex')
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, time)
|
}, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
//保存
|
//保存
|
||||||
function save() {
|
async function save() {
|
||||||
|
const bol = await hasPermission('允许修改商品')
|
||||||
|
if (!bol) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Forms.value.validate().then(res => {
|
Forms.value.validate().then(res => {
|
||||||
const {
|
const {
|
||||||
typeEnum,
|
typeEnum,
|
||||||
@@ -1231,7 +1317,7 @@
|
|||||||
// return infoBox.showErrorToast('请选择规格')
|
// return infoBox.showErrorToast('请选择规格')
|
||||||
// }
|
// }
|
||||||
const images = refFile.value.getFileList()
|
const images = refFile.value.getFileList()
|
||||||
if(images.length<=0){
|
if (images.length <= 0) {
|
||||||
return infoBox.showToast('请上传商品图片')
|
return infoBox.showToast('请上传商品图片')
|
||||||
}
|
}
|
||||||
const skuSnap = []
|
const skuSnap = []
|
||||||
@@ -1239,8 +1325,8 @@
|
|||||||
...$defaultSku,
|
...$defaultSku,
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||||
}];
|
}];
|
||||||
if(typeEnum=='normal'){
|
if (typeEnum == 'normal') {
|
||||||
submitSkuList=skuList.list ;
|
submitSkuList = skuList.list;
|
||||||
}
|
}
|
||||||
console.log(submitSkuList);
|
console.log(submitSkuList);
|
||||||
if (FormData.specificationsGroup) {
|
if (FormData.specificationsGroup) {
|
||||||
@@ -1253,6 +1339,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(FormData.specificationsGroup);
|
||||||
|
const selectSpec = FormData.typeEnum != 'sku' ? '' : JSON.stringify(FormData.specificationsGroup
|
||||||
|
.selectSpec.map(spe => {
|
||||||
|
return {
|
||||||
|
...spe,
|
||||||
|
value: spe.value.map(v => {
|
||||||
|
return typeof v === 'string' ? v : v.text || v.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}))
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...FormData,
|
...FormData,
|
||||||
images: images,
|
images: images,
|
||||||
@@ -1261,13 +1357,7 @@
|
|||||||
specInfo: JSON.stringify(submitSkuList),
|
specInfo: JSON.stringify(submitSkuList),
|
||||||
lowPrice: submitSkuList[0].salePrice,
|
lowPrice: submitSkuList[0].salePrice,
|
||||||
specificationsGroup: undefined,
|
specificationsGroup: undefined,
|
||||||
selectSpec: JSON.stringify(FormData.specificationsGroup.selectSpec.map(spe=>{
|
selectSpec,
|
||||||
return {
|
|
||||||
...spe,value:spe.value.map(v=>{
|
|
||||||
return typeof v==='string'?v:v.text||v.value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
skuSnap: JSON.stringify(skuSnap)
|
skuSnap: JSON.stringify(skuSnap)
|
||||||
}
|
}
|
||||||
//编辑
|
//编辑
|
||||||
@@ -1420,15 +1510,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限start
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 允许修改商品库存
|
||||||
|
let disabledStock=ref(false)
|
||||||
|
async function canEditGoodsStock() {
|
||||||
|
if (option.type === 'edit') {
|
||||||
|
const res=await hasPermission({text:'允许修改商品库存',tips:false})
|
||||||
|
disabledStock.value=!res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
watch(() => FormData.isStock, (newval) => {
|
||||||
|
if (newval) {
|
||||||
|
canEditGoodsStock()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 允许修改商品分类
|
||||||
|
let disabledChangeCategory=ref(false)
|
||||||
|
async function canEditGoodsCategory(tips=false) {
|
||||||
|
if (option.type === 'edit') {
|
||||||
|
const res=await hasPermission({text:'允许修改分类',tips})
|
||||||
|
disabledChangeCategory.value=!res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 权限end
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
watch(() => pageData.types, (newval) => {
|
||||||
|
Forms.value.setRules(rules)
|
||||||
|
})
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
watchSpecificationsSave()
|
watchSpecificationsSave()
|
||||||
})
|
})
|
||||||
onReady(() => {
|
onReady(() => {
|
||||||
Forms.value && Forms.value.setRules(rules)
|
Forms.value && Forms.value.setRules(rules)
|
||||||
})
|
})
|
||||||
watch(() => pageData.types, (newval) => {
|
|
||||||
Forms.value.setRules(rules)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
page {
|
page {
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-32 color-666">
|
<view class="u-m-t-32 color-666">
|
||||||
<view class="u-m-t-24" v-for="(item,haocaiIndex) in sku.haoCaiList"
|
<view class="u-m-t-24" v-for="(item,haocaiIndex) in sku.haoCaiList" :key="haocaiIndex">
|
||||||
:key="haocaiIndex">
|
|
||||||
<view class=" u-flex">
|
<view class=" u-flex">
|
||||||
<view class="xuhao">{{haocaiIndex+1}}</view>
|
<view class="xuhao">{{haocaiIndex+1}}</view>
|
||||||
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
<view class="u-flex u-flex-1 u-p-l-32 gap-20">
|
||||||
@@ -42,8 +41,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="u-flex input">
|
<view class="u-flex input">
|
||||||
<up-input border="none" v-model="item.surplusStock"></up-input>
|
<up-input border="none" v-model="item.surplusStock"></up-input>
|
||||||
<up-icon @click="delGuigeHaocao(index,haocaiIndex)" color="#EB4F4F" :size="16"
|
<up-icon @click="delGuigeHaocao(index,haocaiIndex)" color="#EB4F4F"
|
||||||
name="minus-circle-fill"></up-icon>
|
:size="16" name="minus-circle-fill"></up-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -178,7 +177,13 @@
|
|||||||
import {
|
import {
|
||||||
$tbProskuConV2
|
$tbProskuConV2
|
||||||
} from '@/http/yskApi/goods.js'
|
} from '@/http/yskApi/goods.js'
|
||||||
import { cloneWith } from 'lodash';
|
import {
|
||||||
|
cloneWith
|
||||||
|
} from 'lodash';
|
||||||
|
|
||||||
|
import {
|
||||||
|
hasPermission
|
||||||
|
} from '@/commons/utils/hasPermission.js';
|
||||||
const emits = defineEmits(['cancel', 'updateGoods'])
|
const emits = defineEmits(['cancel', 'updateGoods'])
|
||||||
|
|
||||||
function cancel() {
|
function cancel() {
|
||||||
@@ -276,7 +281,7 @@ import { cloneWith } from 'lodash';
|
|||||||
content: '是否删除该耗材',
|
content: '是否删除该耗材',
|
||||||
success(res) {
|
success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
if (item&&item.id) {
|
if (item && item.id) {
|
||||||
deletetbProskuCon([item.id]).then(res1 => {
|
deletetbProskuCon([item.id]).then(res1 => {
|
||||||
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
skuList.value[guigeIndex].haoCaiList.splice(haocaiIndex, 1)
|
||||||
})
|
})
|
||||||
@@ -298,19 +303,25 @@ import { cloneWith } from 'lodash';
|
|||||||
isBindGuige.value = isSku.value
|
isBindGuige.value = isSku.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
|
const bol = await hasPermission('允许修改商品')
|
||||||
|
if (!bol) {
|
||||||
|
return
|
||||||
|
}
|
||||||
console.log('save');
|
console.log('save');
|
||||||
let isPas=false
|
let isPas = false
|
||||||
if(!isBindGuige.value){
|
if (!isBindGuige.value) {
|
||||||
//绑定至商品
|
//绑定至商品
|
||||||
isPas = conInfos.value.every(v => {
|
isPas = conInfos.value.every(v => {
|
||||||
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
||||||
})
|
})
|
||||||
}else{
|
} else {
|
||||||
//绑定至规格
|
//绑定至规格
|
||||||
isPas = skuList.value.filter(v=>v.haoCaiList&&v.haoCaiList.length).every(sku => {
|
isPas = skuList.value.filter(v => v.haoCaiList && v.haoCaiList.length).every(sku => {
|
||||||
console.log(sku.haoCaiList);
|
console.log(sku.haoCaiList);
|
||||||
return sku.haoCaiList.every(v=>{
|
return sku.haoCaiList.every(v => {
|
||||||
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
return v.conInfoId && v.conUnit && v.surplusStock > 0
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -337,10 +348,10 @@ import { cloneWith } from 'lodash';
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
for(let i in skuList.value){
|
for (let i in skuList.value) {
|
||||||
const haocaiList=skuList.value[i].haoCaiList||[]
|
const haocaiList = skuList.value[i].haoCaiList || []
|
||||||
for(let k in haocaiList){
|
for (let k in haocaiList) {
|
||||||
const v=haocaiList[k]
|
const v = haocaiList[k]
|
||||||
ajaxData.cons.push({
|
ajaxData.cons.push({
|
||||||
id: v.id || '',
|
id: v.id || '',
|
||||||
conInfoId: v.conInfoId,
|
conInfoId: v.conInfoId,
|
||||||
|
|||||||
@@ -548,7 +548,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
margin-top: 70rpx;
|
// margin-top: 70rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
|
|||||||
@@ -87,11 +87,11 @@
|
|||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
<view class="u-m-r-18 color-999">售罄</view>
|
<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>
|
||||||
<view class="u-flex u-m-l-30">
|
<view class="u-flex u-m-l-30">
|
||||||
<view class="u-m-r-18 color-999">{{data.isGrounding?'下架产品':'上架产品' }}</view>
|
<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>
|
</view>
|
||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
@@ -117,8 +117,8 @@
|
|||||||
$goodsIsHot,
|
$goodsIsHot,
|
||||||
$tbProskuConV2,$updateProductData
|
$tbProskuConV2,$updateProductData
|
||||||
} from '@/http/yskApi/goods.js'
|
} from '@/http/yskApi/goods.js'
|
||||||
import mySwitch from '@/components/my-components/my-switch.vue'
|
|
||||||
import go from '@/commons/utils/go.js';
|
import go from '@/commons/utils/go.js';
|
||||||
|
import {hasPermission} from '@/commons/utils/hasPermission.js';
|
||||||
import {
|
import {
|
||||||
ColorMain
|
ColorMain
|
||||||
} from '@/commons/color.js'
|
} from '@/commons/color.js'
|
||||||
@@ -171,17 +171,24 @@
|
|||||||
isGrounding.value=newval
|
isGrounding.value=newval
|
||||||
})
|
})
|
||||||
|
|
||||||
function isPauseSaleChange(e) {
|
async function isPauseSaleChange(e) {
|
||||||
|
const res=await hasPermission('允许售罄商品')
|
||||||
|
if(!res){
|
||||||
|
return
|
||||||
|
}
|
||||||
upDateGoods({
|
upDateGoods({
|
||||||
key: 'pauseSale',
|
key: 'pauseSale',
|
||||||
value: e
|
value: isPauseSale.value?0:1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
async function isGroundingChange(e) {
|
||||||
function isGroundingChange(e) {
|
const res=await hasPermission('允许上下架商品')
|
||||||
|
if(!res){
|
||||||
|
return
|
||||||
|
}
|
||||||
upDateGoods({
|
upDateGoods({
|
||||||
key: 'grounding',
|
key: 'grounding',
|
||||||
value: e
|
value: isGrounding.value?0:1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +215,11 @@
|
|||||||
emits('del', props.index)
|
emits('del', props.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePrice() {
|
async function changePrice() {
|
||||||
|
const res=await hasPermission('允许修改商品')
|
||||||
|
if(!res){
|
||||||
|
return
|
||||||
|
}
|
||||||
emits('changePrice', props.index)
|
emits('changePrice', props.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,10 +236,11 @@
|
|||||||
}
|
}
|
||||||
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
//携带参数type edit跳转到商品添加页面,编辑与添加同一页面,根据type值来判断
|
||||||
function toEdit() {
|
function toEdit() {
|
||||||
go.to('PAGES_PRODUCT_ADD', {
|
emits('edit', props.data.id)
|
||||||
type: 'edit',
|
// go.to('PAGES_PRODUCT_ADD', {
|
||||||
productId: props.data.id
|
// type: 'edit',
|
||||||
})
|
// productId: props.data.id
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
<template v-if="pageData.goodsList.length">
|
<template v-if="pageData.goodsList.length">
|
||||||
<view class="u-m-b-32" v-for="(item,index) in pageData.goodsList" :key="index">
|
<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"
|
<my-goods :key="item.id" @update="getGoodsList" @changePrice="changePriceShow" @changeClick="goodsChangeClick"
|
||||||
|
@edit="toGoodsDetail"
|
||||||
@editStock="changeStockShow" @guigeClick="editGuigeShow" @baosun="baosunShow"
|
@editStock="changeStockShow" @guigeClick="editGuigeShow" @baosun="baosunShow"
|
||||||
@radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
|
@radioClick="goodsRadioClick" :index="index" :data="item" @del="goodsDel"
|
||||||
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
|
:showChecked="showChecked" :showDetail="pageData.showGoodsDetail"></my-goods>
|
||||||
@@ -149,6 +150,7 @@
|
|||||||
watch
|
watch
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import go from '@/commons/utils/go.js';
|
import go from '@/commons/utils/go.js';
|
||||||
|
import {hasPermission} from '@/commons/utils/hasPermission.js';
|
||||||
import myGoods from './components/goods.vue'
|
import myGoods from './components/goods.vue'
|
||||||
import myControl from './components/control.vue'
|
import myControl from './components/control.vue'
|
||||||
import myCategory from './components/category.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
|
pageData.selGoodsIndex = index
|
||||||
const goods = pageData.goodsList[index]
|
const goods = pageData.goodsList[index]
|
||||||
goods.skuList = goods.skuList.map(v => {
|
goods.skuList = goods.skuList.map(v => {
|
||||||
@@ -387,8 +393,15 @@
|
|||||||
pageData.totalElements = res.totalElements
|
pageData.totalElements = res.totalElements
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function watchEmitInit(){
|
||||||
|
uni.$off('update:productIndex')
|
||||||
|
uni.$on('update:productIndex',(data)=>{
|
||||||
|
getGoodsList()
|
||||||
|
})
|
||||||
|
}
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
// getGoodsList()
|
// getGoodsList()
|
||||||
|
watchEmitInit()
|
||||||
})
|
})
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
getGoodsList()
|
getGoodsList()
|
||||||
@@ -485,6 +498,17 @@
|
|||||||
pageData.query.page=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) {
|
function statesTableClick(index) {
|
||||||
pageData.stateCurrent = index;
|
pageData.stateCurrent = index;
|
||||||
resetQuery()
|
resetQuery()
|
||||||
|
|||||||
Reference in New Issue
Block a user