diff --git a/pageProduct/add-Product/add-Product.vue b/pageProduct/add-Product/add-Product.vue
index e6b3a11..c2bd2a6 100644
--- a/pageProduct/add-Product/add-Product.vue
+++ b/pageProduct/add-Product/add-Product.vue
@@ -47,17 +47,18 @@
-
-
+
-
-
+
+
-
+
@@ -129,7 +130,7 @@
:key="index">
{{item.specSnap}}
¥{{item.salePrice}}
- {{item.stockNumber}}
+ {{item.stockNumber||0}}
@@ -216,7 +217,7 @@
-
+
-->
-
+
@@ -418,8 +419,7 @@
-
@@ -1092,10 +1092,10 @@
}
}
}
+ res.skuList = (res.skuList.length ? res.skuList : [])
$goodsData = res
- console.log(res);
+ skuList.list = res.skuList
Object.assign(FormData, res)
- skuList.list = res.skuList || []
//多规格
if (res.typeEnum === 'sku') {
const selectSpec = JSON.parse(res.selectSpec)
@@ -1139,8 +1139,12 @@
}),
specList: [],
}
+ } else {
+ // 单规格
+
}
+
})
}
@@ -1321,14 +1325,23 @@
return infoBox.showToast('请上传商品图片')
}
const skuSnap = []
- let submitSkuList = FormData.specificationsGroup ? skuList.list : [{
- ...$defaultSku,
- barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
- }];
- if (typeEnum == 'normal') {
- submitSkuList = skuList.list;
+ let submitSkuList = skuList.list || []
+ if(option.type=='edit'){
+ submitSkuList=submitSkuList.map(v=>{
+ return{
+ ...v,productId:FormData.id,shopId:uni.getStorageSync('shopId')
+ }
+ })
}
- console.log(submitSkuList);
+ // if(typeEnum!=$goodsData.typeEnum){
+ // if(typeEnum=='normal'){
+ // submitSkuList = skuList.list;
+ // }else{
+ // submitSkuList = skuList.list;
+ // }
+ // }else{
+ // submitSkuList = skuList.list;
+ // }
if (FormData.specificationsGroup) {
for (let i of FormData.specificationsGroup.selectSpec) {
if (i.selectSpecResult.length) {
@@ -1340,22 +1353,37 @@
}
}
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 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 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 = {
...FormData,
images: images,
coverImg: images[0] || '',
skuList: submitSkuList,
specInfo: JSON.stringify(submitSkuList),
- lowPrice: submitSkuList[0].salePrice,
+ lowPrice,
specificationsGroup: undefined,
selectSpec,
skuSnap: JSON.stringify(skuSnap)
@@ -1402,6 +1430,7 @@
uni.$off('emitspecificationsSave')
uni.$on('emitspecificationsSave', function(data) {
FormData.specificationsGroup = data
+ FormData.specId = data.specId
skuList.list = data.result.map(v => {
return {
...v.skus,
@@ -1499,35 +1528,50 @@
watch(() => FormData.typeEnum, (newval) => {
- if (option.type === 'add') {
- if (newval === 'sku') {
- skuList.list = []
+ if (option.type == 'edit') {
+ FormData.specId = newval == 'normal' ? '' : ($goodsData.specId || '')
+ if (newval == $goodsData.typeEnum) {
+ skuList.list = $goodsData.skuList
} else {
- skuList.list[0] = {
- ...$defaultSku,
- barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
+ if (newval == 'normal') {
+ skuList.list = [{
+ ...$defaultSku,
+ productId: FormData.id,
+ shopId: uni.getStorageSync('shopId'),
+ barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
+ }]
+ } else {
+ skuList.list = []
}
}
- }else{
- //编辑
- if (newval === 'sku') {
- skuList.list = []
+ } else {
+ FormData.specId = ''
+ if (newval == 'normal') {
+ skuList.list = [{
+ ...$defaultSku,
+ shopId: uni.getStorageSync('shopId'),
+ barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`
+ }]
} else {
- skuList.list=$goodsData.skuList
+ skuList.list = []
}
}
+
})
-
+
/**
* 权限start
*/
-
+
// 允许修改商品库存
- let disabledStock=ref(false)
+ let disabledStock = ref(false)
async function canEditGoodsStock() {
if (option.type === 'edit') {
- const res=await hasPermission({text:'允许修改商品库存',tips:false})
- disabledStock.value=!res
+ const res = await hasPermission({
+ text: '允许修改商品库存',
+ tips: false
+ })
+ disabledStock.value = !res
}
}
watch(() => FormData.isStock, (newval) => {
@@ -1536,18 +1580,21 @@
}
})
// 允许修改商品分类
- let disabledChangeCategory=ref(false)
- async function canEditGoodsCategory(tips=false) {
+ let disabledChangeCategory = ref(false)
+ async function canEditGoodsCategory(tips = false) {
if (option.type === 'edit') {
- const res=await hasPermission({text:'允许修改分类',tips})
- disabledChangeCategory.value=!res
+ const res = await hasPermission({
+ text: '允许修改分类',
+ tips
+ })
+ disabledChangeCategory.value = !res
}
}
/**
* 权限end
*/
-
-
+
+
watch(() => pageData.types, (newval) => {
Forms.value.setRules(rules)
})
diff --git a/pageProduct/add-Product/components/choose-danwei.vue b/pageProduct/add-Product/components/choose-danwei.vue
index 7fdf82a..baa07d0 100644
--- a/pageProduct/add-Product/components/choose-danwei.vue
+++ b/pageProduct/add-Product/components/choose-danwei.vue
@@ -1,8 +1,11 @@
-
+
+
+
diff --git a/pageProduct/add-specifications/choose-specifications.vue b/pageProduct/add-specifications/choose-specifications.vue
index 3472799..d2d4298 100644
--- a/pageProduct/add-specifications/choose-specifications.vue
+++ b/pageProduct/add-specifications/choose-specifications.vue
@@ -15,11 +15,11 @@
-
+
{{item.name}}
-
+
@@ -29,22 +29,15 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -54,21 +47,19 @@
-
+
图片
-
+
-
-
-
+
+
-
+
-
+
-
+
-
+
-
+
@@ -116,10 +107,11 @@
:placeholderStyle="placeholderStyle" :inputBorder="inputBorder"
v-model="item.skus.barCode" placeholder="请输入商品条码" />
+
-
+
-
+
@@ -132,20 +124,20 @@
-
+
-
-
+
+
@@ -591,12 +646,14 @@
border-radius: 12rpx;
font-size: 28rpx;
}
- .edit-btn{
+
+ .edit-btn {
background-color: #fff;
color: #333;
border-radius: 12rpx;
font-size: 28rpx;
}
+
.btn-hover-class {
opacity: .6;
}
@@ -607,18 +664,21 @@
padding-left: 42rpx;
border-radius: 14rpx 14rpx 14rpx 14rpx;
}
- .fast-edit{
- .item{
+
+ .fast-edit {
+ .item {
color: #333;
border: 1px solid #bbb;
padding: 4rpx 10rpx 8rpx 10rpx;
border-radius: 10rpx;
min-width: 186rpx;
- &.active{
+
+ &.active {
color: $my-main-color;
}
}
}
+
::v-deep .uni-input-placeholder {
font-size: 28rpx;
}
diff --git a/pageProduct/goodsData.js b/pageProduct/goodsData.js
index 16c1dcc..e74b5b7 100644
--- a/pageProduct/goodsData.js
+++ b/pageProduct/goodsData.js
@@ -28,16 +28,17 @@ export const $types = [{
// 商品默认sku
export const $defaultSku = {
- salePrice: 0,
- memberPrice: 0,
- costPrice: 0,
- originPrice: 0,
- stockNumber: 0,
- firstShared: 0,
- suit: 0,
+ salePrice: '',
+ memberPrice: '',
+ costPrice: '',
+ originPrice: '',
+ stockNumber: '',
+ firstShared: '',
+ suit: 1,
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,
}
+
// 库存记录筛选类型
export const $invoicingType = [{
text: '全部',
diff --git a/pageProduct/index/components/goods.vue b/pageProduct/index/components/goods.vue
index 4ad555f..0598bfd 100644
--- a/pageProduct/index/components/goods.vue
+++ b/pageProduct/index/components/goods.vue
@@ -46,7 +46,7 @@
-
+
规格:
@@ -63,6 +63,18 @@
+
+
+
+ {{isShowSkuAll?'收起':'展开'}}
+
+
+
+
+
+
+
+
@@ -90,7 +102,7 @@
- {{data.isGrounding?'下架产品':'上架产品' }}
+ 上架产品
@@ -109,6 +121,7 @@