|
|
@@ -50,15 +50,12 @@ export default {
|
|
|
this.initData();
|
|
|
|
|
|
if(this.isGhsProduct){
|
|
|
- console.log(111)
|
|
|
// this.initGhsData(id,shopId);//采购-进店下单
|
|
|
}else{
|
|
|
console.log(222)
|
|
|
if(!this.$util.isEmpty(this.tabIndex)){
|
|
|
this.initData();//组合
|
|
|
}
|
|
|
- // this.initGoodsData();//成品
|
|
|
- // this.initPxClassData();//课程
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -105,11 +102,7 @@ export default {
|
|
|
if (this.list) {
|
|
|
for (const item of this.list) {
|
|
|
const itemInfo = this.getSelectItemById(item.id, item.classId);
|
|
|
- if (
|
|
|
- itemInfo &&
|
|
|
- !this.$util.isEmpty(itemInfo.bigPrice) &&
|
|
|
- !this.$util.isEmpty(itemInfo.smallPrice)
|
|
|
- ) {
|
|
|
+ if ( itemInfo && !this.$util.isEmpty(itemInfo.bigPrice) && !this.$util.isEmpty(itemInfo.smallPrice) ) {
|
|
|
price += item.bigCount * Number(itemInfo.bigPrice);
|
|
|
price += item.smallCount * Number(itemInfo.smallPrice);
|
|
|
}
|
|
|
@@ -209,7 +202,6 @@ export default {
|
|
|
return has;
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
onShow(){
|
|
|
if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.id)){
|
|
|
//在initGhsData()获取记忆的花材,保证价格有变时取到最新价格
|
|
|
@@ -219,15 +211,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
|
|
|
//记忆已选的花材
|
|
|
rememberProduct(){
|
|
|
//采购或预订的记忆花材
|
|
|
if(this.pageType == 'cg' || this.pageType == 'bookCg' ){
|
|
|
- if(!this.$util.isEmpty(this.option.id)){
|
|
|
- uni.setStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id, this.selectList)
|
|
|
+ if(!this.$util.isEmpty(this.option.account)){
|
|
|
+ uni.setStorageSync('selectList'+this.pageType+'_hd_'+this.option.account, this.selectList)
|
|
|
}
|
|
|
}else{
|
|
|
uni.setStorageSync('selectList'+this.pageType, this.selectList)
|
|
|
@@ -236,7 +227,7 @@ export default {
|
|
|
//清除已记忆花材
|
|
|
removeMemory(ghsId){
|
|
|
if(ghsId){
|
|
|
- uni.removeStorageSync('selectList'+this.pageType+'_ghs_'+ghsId);
|
|
|
+ uni.removeStorageSync('selectList'+this.pageType+'_hd_'+ghsId);
|
|
|
//删除小菊的记忆
|
|
|
uni.removeStorageSync("ghsXj"+ghsId)
|
|
|
}else{
|
|
|
@@ -274,8 +265,8 @@ export default {
|
|
|
this.productInfo = data;
|
|
|
|
|
|
if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.id)){
|
|
|
- if(uni.getStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id)){
|
|
|
- let currentInfo = uni.getStorageSync('selectList'+this.pageType+'_ghs_'+this.option.id)
|
|
|
+ if(uni.getStorageSync('selectList'+this.pageType+'_hd_'+this.option.id)){
|
|
|
+ let currentInfo = uni.getStorageSync('selectList'+this.pageType+'_hd_'+this.option.id)
|
|
|
if(!this.$util.isEmpty(currentInfo)){
|
|
|
currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
|
|
|
let currentId = currentItem.id
|
|
|
@@ -436,9 +427,7 @@ export default {
|
|
|
uni.hideLoading();
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 成品-滚动或切换分类 获取更多数据
|
|
|
- * **/
|
|
|
+ //成品-滚动或切换分类 获取更多数据
|
|
|
suitScrollPushList(){
|
|
|
let list = copyObject(this.suitInfo);
|
|
|
let classList = [];
|
|
|
@@ -450,41 +439,8 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.suitFilterProductInfo = classList
|
|
|
- return
|
|
|
- if(this.$util.isEmpty(this.suitFilterProductInfo)){ //第一次进入无数据
|
|
|
- let classList = [];
|
|
|
- list.forEach(ele=>{
|
|
|
- classList = [...classList,{child:[],classId:ele.classId,className:ele.className}]
|
|
|
- })
|
|
|
- classList[this.suitClassIndex].child = list[this.suitClassIndex].child;
|
|
|
- this.suitFilterProductInfo = classList;
|
|
|
- let classIndex = 1;
|
|
|
- this.suitTimeFun = setInterval(()=>{
|
|
|
- if(classIndex<this.suitFilterProductInfo.length){
|
|
|
- classList[classIndex].child = list[classIndex].child;
|
|
|
- this.suitFilterProductInfo = classList;
|
|
|
- classIndex++
|
|
|
- }else{
|
|
|
- clearInterval(this.suitTimeFun)
|
|
|
- }
|
|
|
- },600)
|
|
|
- }else{//获取更多数据
|
|
|
- if(this.$util.isEmpty(this.suitFilterProductInfo[this.suitClassIndex].child)){
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex].child = list[this.suitClassIndex].child;
|
|
|
- }
|
|
|
- if(this.suitClassIndex+1<this.suitFilterProductInfo.length-1){
|
|
|
- if(this.$util.isEmpty(this.suitFilterProductInfo[this.suitClassIndex+1].child)){
|
|
|
- this.suitFilterProductInfo[this.suitClassIndex+1].child = list[this.suitClassIndex+1].child;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
- /**
|
|
|
- * 获取当前选中商品总价
|
|
|
- */
|
|
|
+ //获取当前选中商品总价
|
|
|
getSelectGoodsPrice(item) {
|
|
|
let price = 0;
|
|
|
|
|
|
@@ -495,9 +451,7 @@ export default {
|
|
|
}
|
|
|
return price;
|
|
|
},
|
|
|
- /**
|
|
|
- * 通过id获取当前选中的商品信息
|
|
|
- */
|
|
|
+ //通过id获取当前选中的商品信息
|
|
|
getSelectItemById(id, classId) {
|
|
|
let info = {
|
|
|
bigCount: 0, //扎数
|
|
|
@@ -521,9 +475,7 @@ export default {
|
|
|
}
|
|
|
return info;
|
|
|
},
|
|
|
- /**
|
|
|
- * 通过id获取当前选中的商品类别信息 左边菜单角标 当前选中该类别商品多少件
|
|
|
- */
|
|
|
+ //通过id获取当前选中的商品类别信息 左边菜单角标 当前选中该类别商品多少件
|
|
|
getSelectClassById(classId) {
|
|
|
let info = {
|
|
|
bigCount: 0, //扎数
|
|
|
@@ -551,32 +503,22 @@ export default {
|
|
|
//添加商品
|
|
|
addEvent(item) {
|
|
|
const list = this.selectList;
|
|
|
- let has = false;
|
|
|
+ console.log(list)
|
|
|
+ console.log(item)
|
|
|
+ let hasItem = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
const element = list[index];
|
|
|
if (element.id == item.id && element.classId == item.classId) {
|
|
|
- has = true;
|
|
|
- if(this.offVerifyRepertory){//去除库存验证
|
|
|
- if(this.isSmallCount){
|
|
|
- list[index] = { ...element, smallCount: ++element.smallCount };
|
|
|
- }else{
|
|
|
- list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
- }
|
|
|
+ hasItem = true;
|
|
|
+ //盘点等页面不需要验证库存
|
|
|
+ if(this.offVerifyRepertory){
|
|
|
+ list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
}else {
|
|
|
- if(!this.isSmallCount){
|
|
|
- list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
- }
|
|
|
- if(this.isSmallCount){
|
|
|
- list[index] = { ...element, smallCount: ++element.smallCount };
|
|
|
- }
|
|
|
+ list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
if (this.isLimit) {
|
|
|
const {bigCount, smallCount} = list[index];
|
|
|
- //超过库存时 设置为库存最大值
|
|
|
const ratio = Number(item.ratio);
|
|
|
- if (
|
|
|
- Number(bigCount) * ratio + Number(smallCount) >
|
|
|
- Number(item.bigNum) * ratio + Number(item.smallNum)
|
|
|
- ) {
|
|
|
+ if ( Number(bigCount) * ratio + Number(smallCount) > Number(item.bigNum) * ratio + Number(item.smallNum) ) {
|
|
|
list[index].bigCount = Number(item.bigNum);
|
|
|
list[index].smallCount = Number(item.smallNum);
|
|
|
this.$msg("库存还剩"+item.bigNum);
|
|
|
@@ -584,13 +526,11 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (!has) {
|
|
|
+ if (hasItem == false) {
|
|
|
let info = { classId: item.classId, id: item.id };
|
|
|
-
|
|
|
const classInfo =
|
|
|
this.productInfo &&
|
|
|
this.productInfo.find(element => {
|
|
|
@@ -601,20 +541,15 @@ export default {
|
|
|
return ele.id == item.id;
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- let params = {
|
|
|
- ...info,
|
|
|
- bigCount: this.isSmallCount?0:1, //扎数
|
|
|
- smallCount: this.isSmallCount?1:0, //支数
|
|
|
- autoPrice: 0 //调价价格
|
|
|
- };
|
|
|
+ let params = { ...info, bigCount: this.isSmallCount?0:1, smallCount: this.isSmallCount?1:0, autoPrice: 0 }
|
|
|
if (info.bigNum && info.bigNum > 0) {
|
|
|
list.push(params);
|
|
|
} else {
|
|
|
- if(this.offVerifyRepertory){//盘点页面没有库存验证
|
|
|
+ //盘点等页面不需要验证库存
|
|
|
+ if(this.offVerifyRepertory){
|
|
|
list.push(params);
|
|
|
}else{
|
|
|
- this.$msg("库存不足");
|
|
|
+ this.$msg("库存不足哦");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -660,13 +595,10 @@ export default {
|
|
|
},
|
|
|
//减去商品
|
|
|
delEvent(item) {
|
|
|
-
|
|
|
- const list = copyObject(this.selectList);
|
|
|
- let has = false;
|
|
|
+ const list = copyObject(this.selectList)
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
let element = list[index];
|
|
|
if (element.id == item.id && element.classId == item.classId) {
|
|
|
- has = true;
|
|
|
if (element.bigCount > 0) {
|
|
|
if (!this.isSmallCount) {
|
|
|
list[index] = {...element, bigCount: --element.bigCount};
|
|
|
@@ -727,10 +659,7 @@ export default {
|
|
|
}
|
|
|
return info;
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 多风格-添加商品
|
|
|
- */
|
|
|
+ //多风格-添加商品
|
|
|
addGoodsEvent(item) {
|
|
|
console.log(item,'itemitem')
|
|
|
const list = this.selectList;
|
|
|
@@ -771,9 +700,7 @@ export default {
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
// this.$forceUpdate();
|
|
|
},
|
|
|
- /**
|
|
|
- * 多风格-添加商品
|
|
|
- */
|
|
|
+ //多风格-添加商品
|
|
|
addGoods(item) {
|
|
|
const list = this.selectList;
|
|
|
let has = false;
|
|
|
@@ -811,9 +738,7 @@ export default {
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
// this.$forceUpdate();
|
|
|
},
|
|
|
- /**
|
|
|
- * 多风格-减去商品
|
|
|
- */
|
|
|
+ //多风格-减去商品
|
|
|
delGoodsEvent(item) {
|
|
|
const list = this.selectList;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
@@ -831,23 +756,52 @@ export default {
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
},
|
|
|
- /**
|
|
|
- * 更新商品
|
|
|
- */
|
|
|
+ //添加商品
|
|
|
+ addItemEvent(item) {
|
|
|
+ const list = this.selectList;
|
|
|
+ if(!this.$util.isEmpty(list)){
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
+ const element = list[index];
|
|
|
+ if (element.id == item.id && element.classId == item.classId) {
|
|
|
+ const { bigCount, smallCount } = list[index];
|
|
|
+ //超过库存时 设置为库存最大值
|
|
|
+ const ratio = Number(item.ratio);
|
|
|
+ if (this.isLimit) {
|
|
|
+ if (
|
|
|
+ Number(bigCount) * ratio + Number(smallCount) >
|
|
|
+ Number(item.bigNum) * ratio + Number(item.smallNum)
|
|
|
+ ) {
|
|
|
+ list[index].bigCount = Number(item.bigNum);
|
|
|
+ list[index].smallCount = Number(item.smallNum);
|
|
|
+ list[index].itemPrice = item.itemPrice?Number(item.itemPrice):'';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list[index] = {
|
|
|
+ ...element,
|
|
|
+ bigCount: Number(item.bigCount),
|
|
|
+ smallCount: Number(item.smallCount),
|
|
|
+ itemPrice: item.itemPrice?Number(item.itemPrice):''
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ list[0] = item
|
|
|
+ }
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
+ //记忆已经选择的花材
|
|
|
+ this.rememberProduct()
|
|
|
+ },
|
|
|
+ //更新商品
|
|
|
updateItemEvent(item) {
|
|
|
const list = this.selectList;
|
|
|
-
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
const element = list[index];
|
|
|
if (element.id == item.id && element.classId == item.classId) {
|
|
|
const { bigCount, smallCount } = list[index];
|
|
|
- //超过库存时 设置为库存最大值
|
|
|
const ratio = Number(item.ratio);
|
|
|
if (this.isLimit) {
|
|
|
- if (
|
|
|
- Number(bigCount) * ratio + Number(smallCount) >
|
|
|
- Number(item.bigNum) * ratio + Number(item.smallNum)
|
|
|
- ) {
|
|
|
+ if ( Number(bigCount) * ratio + Number(smallCount) > Number(item.bigNum) * ratio + Number(item.smallNum) ) {
|
|
|
list[index].bigCount = Number(item.bigNum);
|
|
|
list[index].smallCount = Number(item.smallNum);
|
|
|
list[index].itemPrice = item.itemPrice?Number(item.itemPrice):'';
|
|
|
@@ -863,14 +817,10 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
-
|
|
|
//记忆已经选择的花材
|
|
|
this.rememberProduct()
|
|
|
-
|
|
|
},
|
|
|
- /**
|
|
|
- * 切换左侧商品类别
|
|
|
- */
|
|
|
+ //切换左侧商品类别
|
|
|
swichClass(cur) {
|
|
|
// clearInterval(this.timeFun)
|
|
|
console.log(cur,'---',this.filterProductInfo)
|
|
|
@@ -1081,11 +1031,7 @@ export default {
|
|
|
this.scrollPushList();
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 请求课程数据
|
|
|
- */
|
|
|
+ //请求课程数据
|
|
|
async initPxClassData() {
|
|
|
try {
|
|
|
const { data } = await getPxClassDataApi({pageSize:50});
|