商品管理编辑更新,修复单规格多规格切换保存报错问题,增加部分必填项验证
This commit is contained in:
parent
24f34e8f8c
commit
a5091f8f2d
|
|
@ -47,17 +47,18 @@
|
||||||
</view>
|
</view>
|
||||||
<template v-if="FormData.typeEnum!='group'">
|
<template v-if="FormData.typeEnum!='group'">
|
||||||
<view class="u-relative">
|
<view class="u-relative">
|
||||||
<uni-forms-item label="所属分类" required showRequired name="categoryId">
|
<uni-forms-item label="所属分类" required showRequired name="categoryId">
|
||||||
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
||||||
placeholder="请选择分类" popup-title="请选择分类" :localdata="pageData.category"
|
placeholder="请选择分类" popup-title="请选择分类" :localdata="pageData.category"
|
||||||
v-model="FormData.categoryId">
|
v-model="FormData.categoryId">
|
||||||
</uni-data-picker>
|
</uni-data-picker>
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<view class="zhezhao u-absolute position-all" @click="canEditGoodsCategory(true)" v-if="option.type=='edit'&&disabledChangeCategory">
|
<view class="zhezhao u-absolute position-all" @click="canEditGoodsCategory(true)"
|
||||||
|
v-if="option.type=='edit'&&disabledChangeCategory">
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -129,7 +130,7 @@
|
||||||
:key="index">
|
:key="index">
|
||||||
<view class="u-flex-1 u-text-left">{{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||0}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -216,7 +217,7 @@
|
||||||
<!-- <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="售价" required showRequired >
|
||||||
<uni-easyinput :paddingNone="inputPaddingNone"
|
<uni-easyinput :paddingNone="inputPaddingNone"
|
||||||
@blur="priceFormat(sku,'salePrice')" :placeholderStyle="placeholderStyle"
|
@blur="priceFormat(sku,'salePrice')" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="sku.salePrice" type="digit"
|
:inputBorder="inputBorder" v-model="sku.salePrice" type="digit"
|
||||||
|
|
@ -241,7 +242,7 @@
|
||||||
:inputBorder="inputBorder" v-model="sku.originPrice" type="digit"
|
:inputBorder="inputBorder" v-model="sku.originPrice" type="digit"
|
||||||
placeholder="请输入原价(元)" />
|
placeholder="请输入原价(元)" />
|
||||||
</uni-forms-item> -->
|
</uni-forms-item> -->
|
||||||
<uni-forms-item label="起售数量">
|
<uni-forms-item label="起售数量" required showRequired >
|
||||||
<uni-easyinput @blur="priceFormat(sku,'suit')" :paddingNone="inputPaddingNone"
|
<uni-easyinput @blur="priceFormat(sku,'suit')" :paddingNone="inputPaddingNone"
|
||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="sku.suit" type="digit" placeholder="请输入起售数量" />
|
v-model="sku.suit" type="digit" placeholder="请输入起售数量" />
|
||||||
|
|
@ -418,8 +419,7 @@
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<template v-if="FormData.isStock">
|
<template v-if="FormData.isStock">
|
||||||
<uni-forms-item label="库存数量">
|
<uni-forms-item label="库存数量">
|
||||||
<uni-easyinput :paddingNone="inputPaddingNone"
|
<uni-easyinput :paddingNone="inputPaddingNone" :disabled="disabledStock"
|
||||||
:disabled="disabledStock"
|
|
||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="FormData.stockNumber" type="digit" placeholder="请输入库存数量" />
|
v-model="FormData.stockNumber" type="digit" placeholder="请输入库存数量" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
|
|
@ -1092,10 +1092,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
res.skuList = (res.skuList.length ? res.skuList : [])
|
||||||
$goodsData = res
|
$goodsData = res
|
||||||
console.log(res);
|
skuList.list = res.skuList
|
||||||
Object.assign(FormData, res)
|
Object.assign(FormData, res)
|
||||||
skuList.list = res.skuList || []
|
|
||||||
//多规格
|
//多规格
|
||||||
if (res.typeEnum === 'sku') {
|
if (res.typeEnum === 'sku') {
|
||||||
const selectSpec = JSON.parse(res.selectSpec)
|
const selectSpec = JSON.parse(res.selectSpec)
|
||||||
|
|
@ -1139,8 +1139,12 @@
|
||||||
}),
|
}),
|
||||||
specList: [],
|
specList: [],
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 单规格
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1321,14 +1325,23 @@
|
||||||
return infoBox.showToast('请上传商品图片')
|
return infoBox.showToast('请上传商品图片')
|
||||||
}
|
}
|
||||||
const skuSnap = []
|
const skuSnap = []
|
||||||
let submitSkuList = FormData.specificationsGroup ? skuList.list : [{
|
let submitSkuList = skuList.list || []
|
||||||
...$defaultSku,
|
if(option.type=='edit'){
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
submitSkuList=submitSkuList.map(v=>{
|
||||||
}];
|
return{
|
||||||
if (typeEnum == 'normal') {
|
...v,productId:FormData.id,shopId:uni.getStorageSync('shopId')
|
||||||
submitSkuList = skuList.list;
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
console.log(submitSkuList);
|
// if(typeEnum!=$goodsData.typeEnum){
|
||||||
|
// if(typeEnum=='normal'){
|
||||||
|
// submitSkuList = skuList.list;
|
||||||
|
// }else{
|
||||||
|
// submitSkuList = skuList.list;
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// submitSkuList = skuList.list;
|
||||||
|
// }
|
||||||
if (FormData.specificationsGroup) {
|
if (FormData.specificationsGroup) {
|
||||||
for (let i of FormData.specificationsGroup.selectSpec) {
|
for (let i of FormData.specificationsGroup.selectSpec) {
|
||||||
if (i.selectSpecResult.length) {
|
if (i.selectSpecResult.length) {
|
||||||
|
|
@ -1340,22 +1353,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(FormData.specificationsGroup);
|
console.log(FormData.specificationsGroup);
|
||||||
const selectSpec = FormData.typeEnum != 'sku' ? '' : JSON.stringify(FormData.specificationsGroup
|
const selectSpec = FormData.typeEnum != 'sku' ? '[]' : JSON.stringify((FormData.specificationsGroup
|
||||||
.selectSpec.map(spe => {
|
.selectSpec || []).map(spe => {
|
||||||
return {
|
return {
|
||||||
...spe,
|
...spe,
|
||||||
value: spe.value.map(v => {
|
value: spe.value.map(v => {
|
||||||
return typeof v === 'string' ? v : v.text || v.value
|
return typeof v === 'string' ? v : v.text || v.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
const lowPrice = submitSkuList[0] ? submitSkuList[0].salePrice : FormData.salePrice
|
||||||
|
// const lowPrice = submitSkuList[0] ? submitSkuList[0].salePrice : FormData.salePrice
|
||||||
|
const suit = submitSkuList[0] ? submitSkuList[0].suit : 0
|
||||||
|
if(typeEnum=='normal'){
|
||||||
|
if(lowPrice===''){
|
||||||
|
return infoBox.showToast('请输入售价')
|
||||||
|
}
|
||||||
|
if(lowPrice===''){
|
||||||
|
return infoBox.showToast('请输入售价')
|
||||||
|
}
|
||||||
|
if(suit<=0){
|
||||||
|
return infoBox.showToast('起售数量不能小于0!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...FormData,
|
...FormData,
|
||||||
images: images,
|
images: images,
|
||||||
coverImg: images[0] || '',
|
coverImg: images[0] || '',
|
||||||
skuList: submitSkuList,
|
skuList: submitSkuList,
|
||||||
specInfo: JSON.stringify(submitSkuList),
|
specInfo: JSON.stringify(submitSkuList),
|
||||||
lowPrice: submitSkuList[0].salePrice,
|
lowPrice,
|
||||||
specificationsGroup: undefined,
|
specificationsGroup: undefined,
|
||||||
selectSpec,
|
selectSpec,
|
||||||
skuSnap: JSON.stringify(skuSnap)
|
skuSnap: JSON.stringify(skuSnap)
|
||||||
|
|
@ -1402,6 +1430,7 @@
|
||||||
uni.$off('emitspecificationsSave')
|
uni.$off('emitspecificationsSave')
|
||||||
uni.$on('emitspecificationsSave', function(data) {
|
uni.$on('emitspecificationsSave', function(data) {
|
||||||
FormData.specificationsGroup = data
|
FormData.specificationsGroup = data
|
||||||
|
FormData.specId = data.specId
|
||||||
skuList.list = data.result.map(v => {
|
skuList.list = data.result.map(v => {
|
||||||
return {
|
return {
|
||||||
...v.skus,
|
...v.skus,
|
||||||
|
|
@ -1499,35 +1528,50 @@
|
||||||
|
|
||||||
|
|
||||||
watch(() => FormData.typeEnum, (newval) => {
|
watch(() => FormData.typeEnum, (newval) => {
|
||||||
if (option.type === 'add') {
|
if (option.type == 'edit') {
|
||||||
if (newval === 'sku') {
|
FormData.specId = newval == 'normal' ? '' : ($goodsData.specId || '')
|
||||||
skuList.list = []
|
if (newval == $goodsData.typeEnum) {
|
||||||
|
skuList.list = $goodsData.skuList
|
||||||
} else {
|
} else {
|
||||||
skuList.list[0] = {
|
if (newval == 'normal') {
|
||||||
...$defaultSku,
|
skuList.list = [{
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
...$defaultSku,
|
||||||
|
productId: FormData.id,
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||||
|
}]
|
||||||
|
} else {
|
||||||
|
skuList.list = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
//编辑
|
FormData.specId = ''
|
||||||
if (newval === 'sku') {
|
if (newval == 'normal') {
|
||||||
skuList.list = []
|
skuList.list = [{
|
||||||
|
...$defaultSku,
|
||||||
|
shopId: uni.getStorageSync('shopId'),
|
||||||
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||||
|
}]
|
||||||
} else {
|
} else {
|
||||||
skuList.list=$goodsData.skuList
|
skuList.list = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限start
|
* 权限start
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 允许修改商品库存
|
// 允许修改商品库存
|
||||||
let disabledStock=ref(false)
|
let disabledStock = ref(false)
|
||||||
async function canEditGoodsStock() {
|
async function canEditGoodsStock() {
|
||||||
if (option.type === 'edit') {
|
if (option.type === 'edit') {
|
||||||
const res=await hasPermission({text:'允许修改商品库存',tips:false})
|
const res = await hasPermission({
|
||||||
disabledStock.value=!res
|
text: '允许修改商品库存',
|
||||||
|
tips: false
|
||||||
|
})
|
||||||
|
disabledStock.value = !res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(() => FormData.isStock, (newval) => {
|
watch(() => FormData.isStock, (newval) => {
|
||||||
|
|
@ -1536,18 +1580,21 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 允许修改商品分类
|
// 允许修改商品分类
|
||||||
let disabledChangeCategory=ref(false)
|
let disabledChangeCategory = ref(false)
|
||||||
async function canEditGoodsCategory(tips=false) {
|
async function canEditGoodsCategory(tips = false) {
|
||||||
if (option.type === 'edit') {
|
if (option.type === 'edit') {
|
||||||
const res=await hasPermission({text:'允许修改分类',tips})
|
const res = await hasPermission({
|
||||||
disabledChangeCategory.value=!res
|
text: '允许修改分类',
|
||||||
|
tips
|
||||||
|
})
|
||||||
|
disabledChangeCategory.value = !res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 权限end
|
* 权限end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
watch(() => pageData.types, (newval) => {
|
watch(() => pageData.types, (newval) => {
|
||||||
Forms.value.setRules(rules)
|
Forms.value.setRules(rules)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="u-relative choose-haocai">
|
<view class="u-relative choose-haocai">
|
||||||
<view class="input u-flex" @click="toggle" >
|
<!-- <view class="input u-flex" @click="toggle" >
|
||||||
<up-input @blur="blur" @change="filterHaocaiList" border="none" v-model="text" placeholder="请选择"></up-input>
|
<up-input @blur="blur" @change="filterHaocaiList" border="none" v-model="text" placeholder="请选择"></up-input>
|
||||||
<up-icon :size="10" name="arrow-down-fill"></up-icon>
|
<up-icon :size="10" name="arrow-down-fill"></up-icon>
|
||||||
|
</view> -->
|
||||||
|
<view class="input u-flex" >
|
||||||
|
<up-input @blur="blur" disabled="true" @change="filterHaocaiList" border="none" v-model="text" placeholder="请选择"></up-input>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-absolute" v-if="popShow">
|
<view class="u-absolute" v-if="popShow">
|
||||||
<scroll-view scroll-y="true" class="scroll">
|
<scroll-view scroll-y="true" class="scroll">
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="u-m-t-32" v-for="(item,index) in FormData.selectSpec" :key="index">
|
<view class="u-m-t-32" v-for="(item,index) in FormData.selectSpec" :key="index">
|
||||||
|
|
||||||
<view class="font-bold">
|
<view class="font-bold">
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="u-m-t-24">
|
<view class="u-m-t-24">
|
||||||
<uni-data-checkbox @change="createResult" multiple :selectedColor="color.ColorMain"
|
<uni-data-checkbox @change="createResult" multiple :selectedColor="color.ColorMain"
|
||||||
v-model="item.selectSpecResult" :localdata="item.value"></uni-data-checkbox>
|
v-model="item.selectSpecResult" :localdata="item.value"></uni-data-checkbox>
|
||||||
|
|
@ -29,22 +29,15 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <view class="block u-m-b-32 u-p-30">
|
|
||||||
<view class="font-bold">批量修改</view>
|
</uni-forms>
|
||||||
<view class="u-flex fast-edit u-flex-wrap gap-20 u-m-t-12">
|
|
||||||
<view class="color-main item u-flex u-row-center u-col-center" v-for="(item,index) in fastEdit.list" :key="index">
|
<view>
|
||||||
<view class="u-flex u-col-center">
|
<view class="block u-m-b-32" v-for="(item,index) in FormData.result" :key="index">
|
||||||
<view class="u-m-r-12">{{item.text}}</view>
|
<uni-forms :model="item.skus" :rules="rules" :ref="setFormRef(index)" err-show-type="undertext"
|
||||||
<up-icon size="16" :color="color.ColorMain" name="edit-pen"></up-icon>
|
validateTrigger="blur" :border="true" :label-width="130">
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
</view>
|
|
||||||
</view> -->
|
|
||||||
<view>
|
|
||||||
<view class="block u-m-b-32" v-for="(item,index) in FormData.result" :key="index">
|
|
||||||
|
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="u-m-t-16" v-for="(val,key) in item.names" :key="key">
|
<view class="u-m-t-16" v-for="(val,key) in item.names" :key="key">
|
||||||
<text class="font-bold u-m-r-12">
|
<text class="font-bold u-m-r-12">
|
||||||
|
|
@ -54,21 +47,19 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-24">
|
<view class="u-m-t-24">
|
||||||
<view label="">
|
<view label="">
|
||||||
<view class="font-bold">
|
<view class="font-bold">
|
||||||
图片
|
图片
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-24">
|
<view class="u-m-t-24">
|
||||||
<my-upload-file @change="changeResultCover($event,index)" :limit="1" :ref="setRefFile(index)" :images="item.coverImg"></my-upload-file>
|
<my-upload-file @change="changeResultCover($event,index)" :limit="1"
|
||||||
</view>
|
:ref="setRefFile(index)" :images="item.coverImg"></my-upload-file>
|
||||||
<!-- <uni-file-picker v-model="FormData.images" file-mediatype="image" mode="grid"
|
</view>
|
||||||
:limit="10" @progress="FileUploadprogress" @success="FileUploadsuccess"
|
|
||||||
@fail="FileUploadail" @select="FileUploadselect" /> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="skus u-m-t-32">
|
<view class="skus u-m-t-32">
|
||||||
<view class="">
|
<view class="">
|
||||||
<uni-forms-item label="售价" required>
|
<uni-forms-item label="售价" required name="salePrice">
|
||||||
<uni-easyinput @blur="priceFormat(item.skus,'salePrice')"
|
<uni-easyinput @blur="priceFormat(item.skus,'salePrice')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="item.skus.salePrice" type="digit"
|
:inputBorder="inputBorder" v-model="item.skus.salePrice" type="digit"
|
||||||
|
|
@ -76,25 +67,25 @@
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<uni-forms-item label="会员价(元)" required>
|
<uni-forms-item label="会员价(元)" required name="memberPrice">
|
||||||
<uni-easyinput @blur="priceFormat(item.skus,'memberPrice')"
|
<uni-easyinput @blur="priceFormat(item.skus,'memberPrice')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="item.skus.memberPrice" type="digit"
|
:inputBorder="inputBorder" v-model="item.skus.memberPrice" type="digit"
|
||||||
placeholder="请输入会员价(元)" />
|
placeholder="请输入会员价(元)" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="成本价(元)" required>
|
<uni-forms-item label="成本价(元)" required name="costPrice">
|
||||||
<uni-easyinput @blur="priceFormat(item.skus,'costPrice')"
|
<uni-easyinput @blur="priceFormat(item.skus,'costPrice')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="item.skus.costPrice" type="digit"
|
:inputBorder="inputBorder" v-model="item.skus.costPrice" type="digit"
|
||||||
placeholder="请输入成本价(元)" />
|
placeholder="请输入成本价(元)" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="原价(元)" required>
|
<uni-forms-item label="原价(元)" required name="originPrice">
|
||||||
<uni-easyinput @blur="priceFormat(item.skus,'originPrice')"
|
<uni-easyinput @blur="priceFormat(item.skus,'originPrice')"
|
||||||
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
:paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||||
:inputBorder="inputBorder" v-model="item.skus.originPrice" type="digit"
|
:inputBorder="inputBorder" v-model="item.skus.originPrice" type="digit"
|
||||||
placeholder="请输入原价(元)" />
|
placeholder="请输入原价(元)" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="起售数量" required>
|
<uni-forms-item label="起售数量" required name="suit">
|
||||||
<uni-easyinput @blur="priceFormat(item.skus,'suit')" :paddingNone="inputPaddingNone"
|
<uni-easyinput @blur="priceFormat(item.skus,'suit')" :paddingNone="inputPaddingNone"
|
||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="item.skus.suit" type="digit" placeholder="请输入起售数量" />
|
v-model="item.skus.suit" type="digit" placeholder="请输入起售数量" />
|
||||||
|
|
@ -116,10 +107,11 @@
|
||||||
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
|
||||||
v-model="item.skus.barCode" placeholder="请输入商品条码" />
|
v-model="item.skus.barCode" placeholder="请输入商品条码" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</uni-forms>
|
||||||
</view>
|
</view>
|
||||||
</uni-forms>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="save-btn-box">
|
<view class="save-btn-box">
|
||||||
|
|
@ -132,20 +124,20 @@
|
||||||
</view>
|
</view>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="bottom" ref="bottom"></view>
|
<view class="bottom" ref="bottom"></view>
|
||||||
|
|
||||||
<pop-fast-edit @update="updateSkuKey" v-model:show="fastEdit.show"></pop-fast-edit>
|
<pop-fast-edit @update="updateSkuKey" v-model:show="fastEdit.show"></pop-fast-edit>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import myUploadFile from '@/components/my-components/my-upload-file'
|
|
||||||
import {
|
import {
|
||||||
formatPrice
|
formatPrice
|
||||||
} from "@/commons/utils/format.js";
|
} from "@/commons/utils/format.js";
|
||||||
import popFastEdit from "./components/fast-edit.vue"
|
import popFastEdit from "./components/fast-edit.vue"
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
const refFiles = ref([]);
|
const refFiles = ref([]);
|
||||||
//绑定文件上传元素
|
//绑定文件上传元素
|
||||||
function setRefFile(index) {
|
function setRefFile(index) {
|
||||||
|
|
@ -156,27 +148,51 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const fastEdit=reactive({
|
const fastEdit = reactive({
|
||||||
show:false,
|
show: false,
|
||||||
list:[
|
list: [{
|
||||||
{text:'会员价',key:'memberPrice',value:''},
|
text: '会员价',
|
||||||
{text:'成本价',key:'costPrice',value:''},
|
key: 'memberPrice',
|
||||||
{text:'原价',key:'originPrice',value:''},
|
value: ''
|
||||||
{text:'起售数量',key:'suit',value:''},
|
},
|
||||||
{text:'库存数量',key:'stockNumber',value:''},
|
{
|
||||||
{text:'分销金额',key:'firstShared',value:''}
|
text: '成本价',
|
||||||
|
key: 'costPrice',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '原价',
|
||||||
|
key: 'originPrice',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '起售数量',
|
||||||
|
key: 'suit',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '库存数量',
|
||||||
|
key: 'stockNumber',
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '分销金额',
|
||||||
|
key: 'firstShared',
|
||||||
|
value: ''
|
||||||
|
}
|
||||||
],
|
],
|
||||||
sel:''
|
sel: ''
|
||||||
})
|
})
|
||||||
function fastEditShow(){
|
|
||||||
fastEdit.show=true
|
function fastEditShow() {
|
||||||
|
fastEdit.show = true
|
||||||
}
|
}
|
||||||
//上个页面传来的参数
|
//上个页面传来的参数
|
||||||
let option={}
|
let option = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//number类型数据限制
|
//number类型数据限制
|
||||||
function priceFormat(item, key) {
|
function priceFormat(item, key) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
|
@ -218,22 +234,22 @@
|
||||||
watch
|
watch
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
function updateSkuKey(arr){
|
function updateSkuKey(arr) {
|
||||||
for(let i in FormData.result){
|
for (let i in FormData.result) {
|
||||||
const sku=FormData.result[i].skus
|
const sku = FormData.result[i].skus
|
||||||
for(let k in arr){
|
for (let k in arr) {
|
||||||
const item=arr[k]
|
const item = arr[k]
|
||||||
if(sku.hasOwnProperty(item.key)){
|
if (sku.hasOwnProperty(item.key)) {
|
||||||
sku[item.key]=item.value
|
sku[item.key] = item.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputPaddingNone = ref(true)
|
const inputPaddingNone = ref(true)
|
||||||
const form = ref(null)
|
const form = ref(null)
|
||||||
const originSpecMap={}
|
const originSpecMap = {}
|
||||||
const FormData = reactive({
|
const FormData = reactive({
|
||||||
specId: '',
|
specId: '',
|
||||||
specItem: '',
|
specItem: '',
|
||||||
|
|
@ -241,11 +257,20 @@
|
||||||
selectSpec: [],
|
selectSpec: [],
|
||||||
})
|
})
|
||||||
//表单相关事件
|
//表单相关事件
|
||||||
function changeResultCover(val,index) {
|
function changeResultCover(val, index) {
|
||||||
FormData.result[index].coverImg=val
|
FormData.result[index].coverImg = val
|
||||||
console.log(FormData.result[index]);
|
console.log(FormData.result[index]);
|
||||||
}
|
}
|
||||||
|
const formRefs = ref([]);
|
||||||
|
//绑定表单元素
|
||||||
|
function setFormRef(index) {
|
||||||
|
formRefs.value[index] = null;
|
||||||
|
return (el) => {
|
||||||
|
if (el) {
|
||||||
|
formRefs.value[index] = el;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
watch(() => FormData.specId, (newval) => {
|
watch(() => FormData.specId, (newval) => {
|
||||||
FormData.result = []
|
FormData.result = []
|
||||||
})
|
})
|
||||||
|
|
@ -276,21 +301,21 @@
|
||||||
};
|
};
|
||||||
const defaultSku = reactive({
|
const defaultSku = reactive({
|
||||||
...$defaultSku,
|
...$defaultSku,
|
||||||
shopId:uni.getStorageSync('shopId'),
|
shopId: uni.getStorageSync('shopId'),
|
||||||
coverImg:'',
|
coverImg: '',
|
||||||
productId:option.productId,
|
productId: option.productId,
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
|
||||||
})
|
})
|
||||||
|
|
||||||
function returnDefaultSku(){
|
function returnDefaultSku() {
|
||||||
const randomNumber=Math.floor(Math.random()*1000)
|
const randomNumber = Math.floor(Math.random() * 1000)
|
||||||
return {
|
return {
|
||||||
...defaultSku,
|
...defaultSku,
|
||||||
productId:option.productId,
|
productId: option.productId,
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()-randomNumber}`
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()-randomNumber}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createResult() {
|
function createResult() {
|
||||||
let arr = []
|
let arr = []
|
||||||
for (let k of FormData.selectSpec) {
|
for (let k of FormData.selectSpec) {
|
||||||
|
|
@ -305,20 +330,20 @@
|
||||||
FormData.result = spes.filter(v => {
|
FormData.result = spes.filter(v => {
|
||||||
return !Array.isArray(v)
|
return !Array.isArray(v)
|
||||||
}).map(v => {
|
}).map(v => {
|
||||||
const specSnap=returnSpecSnap(v)
|
const specSnap = returnSpecSnap(v)
|
||||||
const data= originSpecMap[specSnap]
|
const data = originSpecMap[specSnap]
|
||||||
const skus=returnDefaultSku()
|
const skus = returnDefaultSku()
|
||||||
const newdata={
|
const newdata = {
|
||||||
names: v,
|
names: v,
|
||||||
specSnap,
|
specSnap,
|
||||||
skus
|
skus
|
||||||
}
|
}
|
||||||
return data||newdata
|
return data || newdata
|
||||||
})
|
})
|
||||||
console.log(FormData.result);
|
console.log(FormData.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function specIdChange(e) {
|
function specIdChange(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
@ -356,7 +381,31 @@
|
||||||
|
|
||||||
//表单验证
|
//表单验证
|
||||||
const rules = {
|
const rules = {
|
||||||
optionPrice: {
|
salePrice: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '必填'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
memberPrice: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '必填'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
costPrice: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '必填'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
originPrice: {
|
||||||
|
rules: [{
|
||||||
|
required: true,
|
||||||
|
errorMessage: '必填'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
suit: {
|
||||||
rules: [{
|
rules: [{
|
||||||
required: true,
|
required: true,
|
||||||
errorMessage: '必填'
|
errorMessage: '必填'
|
||||||
|
|
@ -388,27 +437,27 @@
|
||||||
uni.$emit(emitName, data)
|
uni.$emit(emitName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//生成name
|
//生成name
|
||||||
function returnSpecSnap(names){
|
function returnSpecSnap(names) {
|
||||||
const specSnap=Object.keys(names).reduce((prve,cur)=>{
|
const specSnap = Object.keys(names).reduce((prve, cur) => {
|
||||||
return prve+names[cur]+','
|
return prve + names[cur] + ','
|
||||||
},'')
|
}, '')
|
||||||
return specSnap.substring(0,specSnap.length-1)
|
return specSnap.substring(0, specSnap.length - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onLoad(opt => {
|
onLoad(opt => {
|
||||||
getTbProductSpec()
|
getTbProductSpec()
|
||||||
const obj = uni.getStorageSync('guige')
|
const obj = uni.getStorageSync('guige')
|
||||||
if (obj&&JSON.stringify(obj) !== '{}') {
|
if (obj && JSON.stringify(obj) !== '{}') {
|
||||||
console.log(obj.selectSpec);
|
console.log(obj.selectSpec);
|
||||||
option.productId=opt.productId
|
option.productId = opt.productId
|
||||||
Object.assign(FormData, obj)
|
Object.assign(FormData, obj)
|
||||||
for(let i of obj.result){
|
for (let i of obj.result) {
|
||||||
const key=returnSpecSnap(i.names)
|
const key = returnSpecSnap(i.names)
|
||||||
originSpecMap[key]=i
|
originSpecMap[key] = i
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
FormData.result = obj.result
|
FormData.result = obj.result
|
||||||
|
|
@ -433,7 +482,6 @@
|
||||||
function returnPromise(prosise) {
|
function returnPromise(prosise) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
prosise.then(res => {
|
prosise.then(res => {
|
||||||
console.log(res);
|
|
||||||
resolve({
|
resolve({
|
||||||
sucees: true
|
sucees: true
|
||||||
})
|
})
|
||||||
|
|
@ -446,14 +494,21 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async function save() {
|
async function save() {
|
||||||
let isAllPassForm = 0
|
if (!FormData.result.length) {
|
||||||
const res = await returnPromise(form.value.validate())
|
return infoBox.showToast('清先选择规格!')
|
||||||
//判断验证是否通过
|
|
||||||
if (res.sucees) {
|
|
||||||
console.log('pass');
|
|
||||||
console.log(FormData);
|
|
||||||
emitspecificationsSave()
|
|
||||||
}
|
}
|
||||||
|
let isAllPassForm = 0
|
||||||
|
for (let i in FormData.result) {
|
||||||
|
const res = await returnPromise(formRefs.value[i].validate(), i)
|
||||||
|
isAllPassForm += res.sucees ? 1 : 0
|
||||||
|
}
|
||||||
|
if (isAllPassForm < FormData.result.length) {
|
||||||
|
return infoBox.showToast('清完善规格属性的参数!')
|
||||||
|
}
|
||||||
|
//判断验证是否通过
|
||||||
|
console.log('pass');
|
||||||
|
console.log(FormData);
|
||||||
|
emitspecificationsSave()
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -591,12 +646,14 @@
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
.edit-btn{
|
|
||||||
|
.edit-btn {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #333;
|
color: #333;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-hover-class {
|
.btn-hover-class {
|
||||||
opacity: .6;
|
opacity: .6;
|
||||||
}
|
}
|
||||||
|
|
@ -607,18 +664,21 @@
|
||||||
padding-left: 42rpx;
|
padding-left: 42rpx;
|
||||||
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
border-radius: 14rpx 14rpx 14rpx 14rpx;
|
||||||
}
|
}
|
||||||
.fast-edit{
|
|
||||||
.item{
|
.fast-edit {
|
||||||
|
.item {
|
||||||
color: #333;
|
color: #333;
|
||||||
border: 1px solid #bbb;
|
border: 1px solid #bbb;
|
||||||
padding: 4rpx 10rpx 8rpx 10rpx;
|
padding: 4rpx 10rpx 8rpx 10rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
min-width: 186rpx;
|
min-width: 186rpx;
|
||||||
&.active{
|
|
||||||
|
&.active {
|
||||||
color: $my-main-color;
|
color: $my-main-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .uni-input-placeholder {
|
::v-deep .uni-input-placeholder {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,17 @@ export const $types = [{
|
||||||
|
|
||||||
// 商品默认sku
|
// 商品默认sku
|
||||||
export const $defaultSku = {
|
export const $defaultSku = {
|
||||||
salePrice: 0,
|
salePrice: '',
|
||||||
memberPrice: 0,
|
memberPrice: '',
|
||||||
costPrice: 0,
|
costPrice: '',
|
||||||
originPrice: 0,
|
originPrice: '',
|
||||||
stockNumber: 0,
|
stockNumber: '',
|
||||||
firstShared: 0,
|
firstShared: '',
|
||||||
suit: 0,
|
suit: 1,
|
||||||
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,
|
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 库存记录筛选类型
|
// 库存记录筛选类型
|
||||||
export const $invoicingType = [{
|
export const $invoicingType = [{
|
||||||
text: '全部',
|
text: '全部',
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-24">
|
<view class="u-m-t-24">
|
||||||
<template v-if="data.skuList.length>=2">
|
<template v-if="data.skuList.length>=2">
|
||||||
<view class="u-flex u-flex-wrap w-full gap-10 u-col-top">
|
<view class="u-flex u-flex-wrap w-full gap-10 u-col-top" :style="skuStyle">
|
||||||
<view class="u-font-24 info-p-l u-m-t-6">规格:</view>
|
<view class="u-font-24 info-p-l u-m-t-6">规格:</view>
|
||||||
<view class="skd" v-for="(item,index) in data.skuList" :key="index"
|
<view class="skd" v-for="(item,index) in data.skuList" :key="index"
|
||||||
@click="guigeClick(index)">
|
@click="guigeClick(index)">
|
||||||
|
|
@ -63,6 +63,18 @@
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<template v-if="skuIsNotOne">
|
||||||
|
<view class="u-flex u-row-center">
|
||||||
|
<view class="u-flex u-flex-y-center" @click="toggleIsShowSkuAll" >
|
||||||
|
<view class="u-font-28 u-m-r-10 u-m-t-10 color-666">{{isShowSkuAll?'收起':'展开'}}</view>
|
||||||
|
<view class="u-flex u-flex-y-center">
|
||||||
|
<up-icon :size="14" name="arrow-down" v-if="!isShowSkuAll"></up-icon>
|
||||||
|
<up-icon :size="14" name="arrow-up" v-else></up-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view style="height: 44rpx;">
|
<view style="height: 44rpx;">
|
||||||
|
|
@ -90,7 +102,7 @@
|
||||||
<my-switch disabled v-model="isPauseSale" :openDisabledClass="false" @click="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">上架产品</view>
|
||||||
<my-switch disabled v-model="isGrounding" :openDisabledClass="false" @click="isGroundingChange"></my-switch>
|
<my-switch disabled v-model="isGrounding" :openDisabledClass="false" @click="isGroundingChange"></my-switch>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -109,6 +121,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
|
computed,
|
||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
watchEffect
|
watchEffect
|
||||||
|
|
@ -145,8 +158,36 @@
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let isShowSkuAll=ref(false)
|
||||||
|
const skuStyle=computed(()=>{
|
||||||
|
if(isShowSkuAll.value){
|
||||||
|
return ''
|
||||||
|
}else{
|
||||||
|
return 'height: 30px;overflow: hidden'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const skuIsNotOne=computed(()=>{
|
||||||
|
let isOne=true;
|
||||||
|
let width=0;
|
||||||
|
const fontSize=12;
|
||||||
|
const gap=5;
|
||||||
|
const boxWith=40;
|
||||||
|
const max=247;
|
||||||
|
for(let i in props.data.skuList){
|
||||||
|
const sku=props.data.skuList[i]
|
||||||
|
width+=(fontSize*sku.name.length+boxWith+gap)
|
||||||
|
if(width>max){
|
||||||
|
isOne=false
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !isOne
|
||||||
|
})
|
||||||
|
|
||||||
|
function toggleIsShowSkuAll(){
|
||||||
|
isShowSkuAll.value=!isShowSkuAll.value
|
||||||
|
}
|
||||||
|
|
||||||
async function upDateGoods(par) {
|
async function upDateGoods(par) {
|
||||||
const res = await $updateProductData([{
|
const res = await $updateProductData([{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue