|
@@ -1,4 +1,4 @@
|
|
|
-import { getProductDataApi,getPxClassDataApi } from "@/api/product/index";
|
|
|
|
|
|
|
+import { getGoodsDataApi,getProductDataApi,getPxClassDataApi } from "@/api/product/index";
|
|
|
import { mapGetters, mapActions } from "vuex";
|
|
import { mapGetters, mapActions } from "vuex";
|
|
|
import { copyObject } from "@/utils/util";
|
|
import { copyObject } from "@/utils/util";
|
|
|
export default {
|
|
export default {
|
|
@@ -6,6 +6,9 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
pageType: "bill", //选择商品页面类别 用于区分不同功能的数据
|
|
pageType: "bill", //选择商品页面类别 用于区分不同功能的数据
|
|
|
|
|
|
|
|
|
|
+ suitInfo: [], //成品-商品信息
|
|
|
|
|
+ suitClassIndex: 0, //成品-当前商品类别下标
|
|
|
|
|
+
|
|
|
productInfo: [], //商品信息
|
|
productInfo: [], //商品信息
|
|
|
pxClassInfo: [], //培训班开单列表
|
|
pxClassInfo: [], //培训班开单列表
|
|
|
classIndex: 0, //当前商品类别下标
|
|
classIndex: 0, //当前商品类别下标
|
|
@@ -20,9 +23,10 @@ export default {
|
|
|
if (pageType) {
|
|
if (pageType) {
|
|
|
this.pageType = pageType;
|
|
this.pageType = pageType;
|
|
|
}
|
|
}
|
|
|
- this.initPxClassData();
|
|
|
|
|
if (this.autoLoad) {
|
|
if (this.autoLoad) {
|
|
|
- this.initData();
|
|
|
|
|
|
|
+ this.initGoodsData();//成品
|
|
|
|
|
+ this.initData();//组合
|
|
|
|
|
+ this.initPxClassData();//课程
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onUnload() {},
|
|
onUnload() {},
|
|
@@ -53,6 +57,34 @@ export default {
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 搜索、初始化数据
|
|
|
|
|
+ * */
|
|
|
|
|
+ suitFilterProductInfo() {
|
|
|
|
|
+ let list = copyObject(this.suitInfo);
|
|
|
|
|
+ if (this.py) {
|
|
|
|
|
+ let commonList = list.find(ele => {
|
|
|
|
|
+ //在常用中过滤
|
|
|
|
|
+ return ele.classId == -2;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (commonList) {
|
|
|
|
|
+ let commonChildList = [];
|
|
|
|
|
+ if (!this.$util.isEmpty(commonList.child)) {
|
|
|
|
|
+ commonList.child.forEach(ele => {
|
|
|
|
|
+ let hasName = ele.itemName && ele.itemName.indexOf(this.py) >= 0;
|
|
|
|
|
+ let elePy = (ele.py && ele.py.toLocaleUpperCase()) || "";
|
|
|
|
|
+ let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
|
|
|
|
|
+ if (hasName || hasPy) {
|
|
|
|
|
+ commonChildList.push(ele);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ commonList.child = commonChildList;
|
|
|
|
|
+ list = [commonList];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 当前页面选中的商品列表
|
|
* 当前页面选中的商品列表
|
|
|
*/
|
|
*/
|
|
@@ -92,6 +124,45 @@ export default {
|
|
|
// console.log(444444, this.selectList);
|
|
// console.log(444444, this.selectList);
|
|
|
return this.selectList.length;
|
|
return this.selectList.length;
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 描点-定位分类
|
|
|
|
|
+ * */
|
|
|
|
|
+ suitScrollClassId() {
|
|
|
|
|
+ const curClass = this.suitInfo[this.suitClassIndex];
|
|
|
|
|
+ if (curClass) {
|
|
|
|
|
+ return `class_${curClass.classId}`;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return "";
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-选择商品总价
|
|
|
|
|
+ * */
|
|
|
|
|
+ allGoodsPrice() {
|
|
|
|
|
+ let price = 0;
|
|
|
|
|
+ if (this.selectList.goodsStyleList) {
|
|
|
|
|
+ for (const item of this.selectList) {
|
|
|
|
|
+ if(item.goodsStyle==0){
|
|
|
|
|
+ price += item.bigCount * Number(item.price);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ price += item.bigCount * Number(item.goodsStyleList[item.goodsStyleSelectIndex].price);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return Math.round(price * 100) / 100;
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-选择商品总数
|
|
|
|
|
+ * */
|
|
|
|
|
+ allGoodsCount() {
|
|
|
|
|
+ let length = 0;
|
|
|
|
|
+ this.selectList.forEach(element => {
|
|
|
|
|
+ length += Number(element.bigCount)
|
|
|
|
|
+ })
|
|
|
|
|
+ return length;
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 当前选中商品列表中是否有没有库存的商品
|
|
* 当前选中商品列表中是否有没有库存的商品
|
|
|
*/
|
|
*/
|
|
@@ -163,6 +234,53 @@ export default {
|
|
|
price = Math.round(sum * 100) / 100;
|
|
price = Math.round(sum * 100) / 100;
|
|
|
return price;
|
|
return price;
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 成品-请求商品数据
|
|
|
|
|
+ */
|
|
|
|
|
+ async initGoodsData(extendInfo) {
|
|
|
|
|
+ //extendInfo调用时的扩展参数 如 shopId
|
|
|
|
|
+ try {
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ py: this.py,
|
|
|
|
|
+ type: this.type
|
|
|
|
|
+ };
|
|
|
|
|
+ if (extendInfo) {
|
|
|
|
|
+ params = { ...params, ...extendInfo };
|
|
|
|
|
+ }
|
|
|
|
|
+ const { data } = await getGoodsDataApi(params);
|
|
|
|
|
+ data.forEach(element => {
|
|
|
|
|
+ element.child &&
|
|
|
|
|
+ element.child.forEach(child => {
|
|
|
|
|
+ child.classId = element.classId;
|
|
|
|
|
+ child.className = element.className;
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ this.suitInfo = data;
|
|
|
|
|
+ this.suitClassIndex = 0;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取当前选中商品总价
|
|
|
|
|
+ */
|
|
|
|
|
+ getSelectGoodsPrice(item) {
|
|
|
|
|
+ let price = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if(item.goodsStyle==0){
|
|
|
|
|
+ price = item.bigCount * Number(item.price);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ price = item.bigCount * Number(item.goodsStyleList[item.goodsStyleSelectIndex].price);
|
|
|
|
|
+ }
|
|
|
|
|
+ // let sum = 0;
|
|
|
|
|
+ // if()
|
|
|
|
|
+ // Number(bigCount) * Number(bigPrice) +
|
|
|
|
|
+ // Number(smallCount) * Number(smallPrice);
|
|
|
|
|
+ // price = Math.round(sum * 100) / 100;
|
|
|
|
|
+ return price;
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 通过id获取当前选中的商品信息
|
|
* 通过id获取当前选中的商品信息
|
|
|
*/
|
|
*/
|
|
@@ -393,6 +511,136 @@ export default {
|
|
|
}
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通过id获取当前选中的商品类别信息 左边菜单角标 当前选中该类别商品多少件
|
|
|
|
|
+ */
|
|
|
|
|
+ getSuitSelectClassById(classId) {
|
|
|
|
|
+ let info = {
|
|
|
|
|
+ bigCount: 0, //扎数
|
|
|
|
|
+ smallCount: 0 //支数
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const productItem =
|
|
|
|
|
+ this.suitInfo &&
|
|
|
|
|
+ this.suitInfo.find(ele => {
|
|
|
|
|
+ return ele.classId == classId;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (productItem && productItem.child) {
|
|
|
|
|
+ for (const item of productItem.child) {
|
|
|
|
|
+ for (const selectItem of this.selectList) {
|
|
|
|
|
+ if (item.id == selectItem.id && item.classId == selectItem.classId) {
|
|
|
|
|
+ info.bigCount += Number(selectItem.bigCount);
|
|
|
|
|
+ info.smallCount += Number(selectItem.smallCount);
|
|
|
|
|
+ info.itemPrice += selectItem.itemPrice?Number(selectItem.itemPrice):'';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return info;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-添加商品
|
|
|
|
|
+ */
|
|
|
|
|
+ addGoodsEvent(item) {
|
|
|
|
|
+ const list = this.selectList;
|
|
|
|
|
+ //过滤空数据
|
|
|
|
|
+ if(item.bigCount==0||!item.bigCount){return}
|
|
|
|
|
+ let has = false;
|
|
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
|
|
+ const element = list[index];
|
|
|
|
|
+ if (element.id == item.id && element.classId == item.classId) {
|
|
|
|
|
+ has = true;
|
|
|
|
|
+ list[index] = { ...element, bigCount: item.bigCount,goodsStyleSelectIndex: item.goodsStyleSelectIndex };
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!has) {
|
|
|
|
|
+ let info = { classId: item.classId, id: item.id };
|
|
|
|
|
+
|
|
|
|
|
+ const classInfo =
|
|
|
|
|
+ this.suitInfo &&
|
|
|
|
|
+ this.suitInfo.find(element => {
|
|
|
|
|
+ return element.classId == item.classId && element.child;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (classInfo) {
|
|
|
|
|
+ info = classInfo.child.find(ele => {
|
|
|
|
|
+ return ele.id == item.id;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ ...info,
|
|
|
|
|
+ bigCount: item.bigCount, //扎数
|
|
|
|
|
+ goodsStyleSelectIndex: item.goodsStyleSelectIndex, //选中的风格
|
|
|
|
|
+ };
|
|
|
|
|
+ list.push(params);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
|
|
+ // this.$forceUpdate();
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-添加商品
|
|
|
|
|
+ */
|
|
|
|
|
+ addGoods(item) {
|
|
|
|
|
+ const list = this.selectList;
|
|
|
|
|
+ let has = false;
|
|
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
|
|
+ const element = list[index];
|
|
|
|
|
+ if (element.id == item.id && element.classId == item.classId) {
|
|
|
|
|
+ has = true;
|
|
|
|
|
+ list[index] = { ...element, bigCount: ++element.bigCount };
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!has) {
|
|
|
|
|
+ let info = { classId: item.classId, id: item.id };
|
|
|
|
|
+
|
|
|
|
|
+ const classInfo =
|
|
|
|
|
+ this.suitInfo &&
|
|
|
|
|
+ this.suitInfo.find(element => {
|
|
|
|
|
+ return element.classId == item.classId && element.child;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (classInfo) {
|
|
|
|
|
+ info = classInfo.child.find(ele => {
|
|
|
|
|
+ return ele.id == item.id;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ ...info,
|
|
|
|
|
+ bigCount: 1, //扎数
|
|
|
|
|
+ smallCount: 0, //支数
|
|
|
|
|
+ autoPrice: 0 //调价价格
|
|
|
|
|
+ };
|
|
|
|
|
+ list.push(params);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
|
|
+ // this.$forceUpdate();
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-减去商品
|
|
|
|
|
+ */
|
|
|
|
|
+ delGoodsEvent(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) {
|
|
|
|
|
+
|
|
|
|
|
+ if (element.bigCount > 0) {
|
|
|
|
|
+ list[index] = { ...element, bigCount: --element.bigCount };
|
|
|
|
|
+ }
|
|
|
|
|
+ if (element.bigCount == 0 || !element.bigCount) {
|
|
|
|
|
+ list.splice(index, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 更新商品
|
|
* 更新商品
|
|
|
*/
|
|
*/
|
|
@@ -440,6 +688,17 @@ export default {
|
|
|
this.classIndex = cur;
|
|
this.classIndex = cur;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 多风格-切换左侧商品类别
|
|
|
|
|
+ */
|
|
|
|
|
+ suitSwichClass(e) {
|
|
|
|
|
+ let cur = e.currentTarget.dataset.current;
|
|
|
|
|
+ if (this.suitClassIndex == cur) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.suitClassIndex = cur;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 搜索对应花材
|
|
* 搜索对应花材
|
|
|
*/
|
|
*/
|