|
|
@@ -17,7 +17,19 @@ export default {
|
|
|
py: "", //拼音搜索条件
|
|
|
type: "", //库存预警时,固定为waring,其他情况不传或者传空
|
|
|
autoLoad: true, //自动获取商品信息
|
|
|
- isLimit: true //选择数量不能大于库存限制
|
|
|
+ isLimit: true, //选择数量不能大于库存限制
|
|
|
+
|
|
|
+ //成品开单
|
|
|
+ suit_scroll_into_view:"",
|
|
|
+ suit_top_list:'',
|
|
|
+ suitTimeFun:"",
|
|
|
+ suitFilterProductInfo:'',
|
|
|
+ //组合开单
|
|
|
+ scroll_into_view:"",
|
|
|
+ top_list:'',
|
|
|
+ timeFun:"",
|
|
|
+ filterProductInfo:'',
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -35,16 +47,18 @@ export default {
|
|
|
if(this.isGhsProduct){
|
|
|
// this.initGhsData(id,shopId);//采购-进店下单
|
|
|
}else{
|
|
|
- this.initGoodsData();//成品
|
|
|
- this.initData();//组合
|
|
|
- this.initPxClassData();//课程
|
|
|
+ if(!this.$util.isEmpty(this.tabIndex)){
|
|
|
+ this.initData();//组合
|
|
|
+ }
|
|
|
+ // this.initGoodsData();//成品
|
|
|
+ // this.initPxClassData();//课程
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
onUnload() {},
|
|
|
computed: {
|
|
|
...mapGetters(["getSelectInfo"]),
|
|
|
- filterProductInfo() {
|
|
|
+ filterProductInfoxxxx() {
|
|
|
let list = copyObject(this.productInfo);
|
|
|
if (this.py) {
|
|
|
let commonChildList = [];
|
|
|
@@ -82,7 +96,7 @@ export default {
|
|
|
/**
|
|
|
* 搜索、初始化数据
|
|
|
* */
|
|
|
- suitFilterProductInfo() {
|
|
|
+ suitFilterProductInfoxxx() {
|
|
|
let list = copyObject(this.suitInfo);
|
|
|
if (this.py) {
|
|
|
let commonChildList = [];
|
|
|
@@ -254,6 +268,7 @@ export default {
|
|
|
});
|
|
|
this.productInfo = data;
|
|
|
this.classIndex = 0;
|
|
|
+ this.scrollPushList();
|
|
|
} catch (error) {
|
|
|
} finally {
|
|
|
uni.hideLoading();
|
|
|
@@ -279,11 +294,94 @@ export default {
|
|
|
});
|
|
|
this.productInfo = data;
|
|
|
this.classIndex = 0;
|
|
|
+ this.scrollPushList();
|
|
|
} catch (error) {
|
|
|
} finally {
|
|
|
uni.hideLoading();
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 滚动或切换分类 获取更多数据
|
|
|
+ * **/
|
|
|
+ scrollPushList(){
|
|
|
+ let list = copyObject(this.productInfo);
|
|
|
+
|
|
|
+ if(this.$util.isEmpty(this.filterProductInfo)){ //第一次进入无数据
|
|
|
+ let classList = [];
|
|
|
+ list.forEach(ele=>{
|
|
|
+ classList = [...classList,{child:[],classId:ele.classId,className:ele.className}]
|
|
|
+ })
|
|
|
+ classList[this.classIndex].child = list[this.classIndex].child;
|
|
|
+ this.filterProductInfo = classList;
|
|
|
+ let classIndex = 1;
|
|
|
+ this.timeFun = setInterval(()=>{
|
|
|
+ if(classIndex<this.filterProductInfo.length){
|
|
|
+ classList[classIndex].child = list[classIndex].child;
|
|
|
+ this.filterProductInfo = classList;
|
|
|
+ classIndex++
|
|
|
+ }else{
|
|
|
+ clearInterval(this.timeFun)
|
|
|
+ }
|
|
|
+ },600)
|
|
|
+ }else{//获取更多数据
|
|
|
+ if(this.$util.isEmpty(this.filterProductInfo[this.classIndex].child)){
|
|
|
+ this.filterProductInfo[this.classIndex].child = list[this.classIndex].child;
|
|
|
+ }
|
|
|
+ if(this.classIndex+1<this.filterProductInfo.length-1){
|
|
|
+ if(this.$util.isEmpty(this.filterProductInfo[this.classIndex+1].child)){
|
|
|
+ this.filterProductInfo[this.classIndex+1].child = list[this.classIndex+1].child;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 滚动商品监听
|
|
|
+ * **/
|
|
|
+ scroll_detail(options){
|
|
|
+ //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
|
|
|
+ if(!uni.getStorageSync("resolve")){
|
|
|
+ this.get_node_details(options);
|
|
|
+ };
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取商品节点信息
|
|
|
+ * **/
|
|
|
+ get_node_details(options){
|
|
|
+ const query = uni.createSelectorQuery().in(this); //获得实力
|
|
|
+ //获取多个节点方式
|
|
|
+ query.selectAll(".selectAll").boundingClientRect(data=>{
|
|
|
+ // console.log(data); //得到class类名为 selectAll的数组集合
|
|
|
+ this.top_list = data.map(item=>{
|
|
|
+ return Math.ceil(item.top);
|
|
|
+ });
|
|
|
+ this.async_detail_msg(options);
|
|
|
+ }).exec();
|
|
|
+ },
|
|
|
+ async_detail_msg(options){
|
|
|
+ //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
|
|
|
+ let top_page = options.detail.scrollTop + this.top_list[0];
|
|
|
+
|
|
|
+ for(let i = 0;i < this.top_list.length; i++){
|
|
|
+ let node1 = this.top_list[i];
|
|
|
+ let node2 = this.top_list[i+1];
|
|
|
+ if(node2 && top_page >= node1 && top_page < node2){
|
|
|
+ this.classIndex = i;
|
|
|
+ this.scrollPushList();
|
|
|
+ break;
|
|
|
+ }else if(node2 && top_page === node2){
|
|
|
+ this.classIndex = i + 1;
|
|
|
+ this.scrollPushList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ scroll_bottom(){
|
|
|
+ this.classIndex = this.filterProductInfo.length-1
|
|
|
+ this.scrollPushList();
|
|
|
+ },
|
|
|
/**
|
|
|
* 获取当前选中商品总价
|
|
|
*/
|
|
|
@@ -319,12 +417,49 @@ export default {
|
|
|
});
|
|
|
this.suitInfo = data;
|
|
|
this.suitClassIndex = 0;
|
|
|
+ this.suitScrollPushList();
|
|
|
} catch (error) {
|
|
|
} finally {
|
|
|
uni.hideLoading();
|
|
|
}
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 成品-滚动或切换分类 获取更多数据
|
|
|
+ * **/
|
|
|
+ suitScrollPushList(){
|
|
|
+ let list = copyObject(this.suitInfo);
|
|
|
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
/**
|
|
|
* 获取当前选中商品总价
|
|
|
*/
|
|
|
@@ -508,77 +643,97 @@ export default {
|
|
|
* 减去商品
|
|
|
*/
|
|
|
delEvent(item) {
|
|
|
- const list = this.selectList;
|
|
|
+ const list = copyObject(this.selectList);
|
|
|
let has = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
- const element = list[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 };}
|
|
|
}
|
|
|
if (element.smallCount > 0) {
|
|
|
if(this.isSmallCount){list[index] = { ...element, smallCount: --element.smallCount };}
|
|
|
}
|
|
|
-
|
|
|
- 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)
|
|
|
- ) {
|
|
|
- list[index].bigCount = Number(item.bigNum);
|
|
|
- list[index].smallCount = Number(item.smallNum);
|
|
|
- }
|
|
|
- }
|
|
|
if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
list.splice(index, 1);
|
|
|
}
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!has) {
|
|
|
- let info = { classId: item.classId, id: item.id };
|
|
|
-
|
|
|
- const classInfo =
|
|
|
- this.productInfo &&
|
|
|
- this.productInfo.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);
|
|
|
+ break;
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- // this.$forceUpdate();
|
|
|
- },
|
|
|
- //减去所有商品
|
|
|
- delAllEvent(item) {
|
|
|
- const list = this.selectList;
|
|
|
- for (let index = 0; index < list.length; index++) {
|
|
|
- const element = list[index];
|
|
|
- if (element.id == item.id ) {
|
|
|
|
|
|
- list.splice(index, 1);
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
+ // 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;
|
|
|
+ //
|
|
|
+ // if (element.bigCount > 0) {
|
|
|
+ // if(!this.isSmallCount){list[index] = { ...element, bigCount: --element.bigCount };}
|
|
|
+ // }
|
|
|
+ // if (element.smallCount > 0) {
|
|
|
+ // if(this.isSmallCount){list[index] = { ...element, smallCount: --element.smallCount };}
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // 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)
|
|
|
+ // ) {
|
|
|
+ // list[index].bigCount = Number(item.bigNum);
|
|
|
+ // list[index].smallCount = Number(item.smallNum);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
+ // list.splice(index, 1);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (!has) {
|
|
|
+ // let info = { classId: item.classId, id: item.id };
|
|
|
+ //
|
|
|
+ // const classInfo =
|
|
|
+ // this.productInfo &&
|
|
|
+ // this.productInfo.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();
|
|
|
+ // },
|
|
|
+ // //减去所有商品
|
|
|
+ // delAllEvent(item) {
|
|
|
+ // const list = this.selectList;
|
|
|
+ // for (let index = 0; index < list.length; index++) {
|
|
|
+ // const element = list[index];
|
|
|
+ // if (element.id == item.id ) {
|
|
|
+ //
|
|
|
+ // list.splice(index, 1);
|
|
|
+ //
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
},
|
|
|
/**
|
|
|
* 通过id获取当前选中的商品类别信息 左边菜单角标 当前选中该类别商品多少件
|
|
|
@@ -747,29 +902,159 @@ export default {
|
|
|
/**
|
|
|
* 切换左侧商品类别
|
|
|
*/
|
|
|
- swichClass(e) {
|
|
|
- let cur = e.currentTarget.dataset.current;
|
|
|
- if (this.classIndex == cur) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- this.classIndex = cur;
|
|
|
- }
|
|
|
+ swichClass(cur) {
|
|
|
+ this.classIndex = cur;
|
|
|
+ this.scroll_into_view = 'class_'+cur;
|
|
|
+ this.scrollPushList();
|
|
|
+ //解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
|
|
|
+ uni.setStorageSync("resolve","last");
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.removeStorageSync("resolve")
|
|
|
+ },400);
|
|
|
},
|
|
|
+
|
|
|
/**
|
|
|
- * 多风格-切换左侧商品类别
|
|
|
+ * 成品(多风格)-切换左侧商品类别
|
|
|
*/
|
|
|
- suitSwichClass(e) {
|
|
|
- let cur = e.currentTarget.dataset.current;
|
|
|
- if (this.suitClassIndex == cur) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- this.suitClassIndex = cur;
|
|
|
+ suitSwichClass(cur) {
|
|
|
+ this.suitClassIndex = cur;
|
|
|
+ this.suit_scroll_into_view = 'class_'+cur;
|
|
|
+ this.suitScrollPushList();
|
|
|
+ // this.scrollPushList();
|
|
|
+ //解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
|
|
|
+ uni.setStorageSync("resolve","last");
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.removeStorageSync("resolve")
|
|
|
+ },400);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 滚动商品监听
|
|
|
+ * **/
|
|
|
+ suit_scroll_detail(options){
|
|
|
+ //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
|
|
|
+ if(!uni.getStorageSync("resolve")){
|
|
|
+ this.suit_get_node_details(options);
|
|
|
+ };
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取商品节点信息
|
|
|
+ * **/
|
|
|
+ suit_get_node_details(options){
|
|
|
+ const query = uni.createSelectorQuery().in(this); //获得实力
|
|
|
+ //获取多个节点方式
|
|
|
+ query.selectAll(".suitSelectAll").boundingClientRect(data=>{
|
|
|
+ // console.log(data); //得到class类名为 selectAll的数组集合
|
|
|
+ this.suit_top_list = data.map(item=>{
|
|
|
+ return Math.ceil(item.top);
|
|
|
+ });
|
|
|
+ this.suit_async_detail_msg(options);
|
|
|
+ }).exec();
|
|
|
+ },
|
|
|
+ suit_async_detail_msg(options){
|
|
|
+ //options 为滚动信息。 options.detail.scrollTop 值为相对于scroll-view。
|
|
|
+ let top_page = options.detail.scrollTop + this.suit_top_list[0];
|
|
|
+
|
|
|
+ for(let i = 0;i < this.suit_top_list.length; i++){
|
|
|
+ let node1 = this.suit_top_list[i];
|
|
|
+ let node2 = this.suit_top_list[i+1];
|
|
|
+ if(node2 && top_page >= node1 && top_page < node2){
|
|
|
+ this.suitClassIndex = i;
|
|
|
+ this.suitScrollPushList();
|
|
|
+ break;
|
|
|
+ }else if(node2 && top_page === node2){
|
|
|
+ this.suitClassIndex = i + 1;
|
|
|
+ this.suitScrollPushList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+ suit_scroll_bottom(){
|
|
|
+ this.suitClassIndex = this.suitFilterProductInfo.length-1
|
|
|
+ this.suitScrollPushList();
|
|
|
+ },
|
|
|
/**
|
|
|
* 搜索对应花材
|
|
|
*/
|
|
|
- searchFn() {},
|
|
|
+ suitSearchFn() {
|
|
|
+ let list = copyObject(this.suitFilterProductInfo);
|
|
|
+ if(!this.$util.isEmpty(this.py)){
|
|
|
+ clearInterval(this.suitTimeFun)
|
|
|
+ let commonChildList = [];
|
|
|
+ list.forEach(ele => {
|
|
|
+ //过滤常用
|
|
|
+ if(ele.classId != -2){
|
|
|
+ if (!this.$util.isEmpty(ele.child)) {
|
|
|
+ ele.child.forEach(obj => {
|
|
|
+ let hasName = obj.goodsName && obj.goodsName.indexOf(this.py) >= 0;
|
|
|
+ let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
|
|
|
+ let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
|
|
|
+ if (hasName || hasPy) {
|
|
|
+ if(this.$util.isEmpty(commonChildList)){
|
|
|
+ commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];
|
|
|
+ }else{
|
|
|
+ commonChildList.forEach(res => {
|
|
|
+ if(res.classId==ele.classId){
|
|
|
+ res.child.push(obj)
|
|
|
+ }else{
|
|
|
+ commonChildList.push({classId: ele.classId, className: ele.className,child:[obj]});
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ list = this.$util.unique(commonChildList)
|
|
|
+ this.suitFilterProductInfo = list;
|
|
|
+ this.suitClassIndex = 0;
|
|
|
+ }else{
|
|
|
+ this.suitFilterProductInfo = '';
|
|
|
+ this.suitClassIndex = 0;
|
|
|
+ this.suitScrollPushList();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ searchFn() {
|
|
|
+ let list = copyObject(this.productInfo);
|
|
|
+ if(!this.$util.isEmpty(this.py)){
|
|
|
+ clearInterval(this.timeFun)
|
|
|
+ let commonChildList = [];
|
|
|
+ list.forEach(ele => {
|
|
|
+ //过滤常用
|
|
|
+ if(ele.classId != -2){
|
|
|
+ if (!this.$util.isEmpty(ele.child)) {
|
|
|
+ ele.child.forEach(obj => {
|
|
|
+ let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
|
|
|
+ let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
|
|
|
+ let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
|
|
|
+ if (hasName || hasPy) {
|
|
|
+ if(this.$util.isEmpty(commonChildList)){
|
|
|
+ commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];
|
|
|
+ }else{
|
|
|
+ commonChildList.forEach(res => {
|
|
|
+ if(res.classId==ele.classId){
|
|
|
+ res.child.push(obj)
|
|
|
+ }else{
|
|
|
+ commonChildList.push({classId: ele.classId, className: ele.className,child:[obj]});
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ list = this.$util.unique(commonChildList)
|
|
|
+ this.filterProductInfo = list;
|
|
|
+ this.suitClassIndex = 0;
|
|
|
+ }else{
|
|
|
+ this.filterProductInfo = '';
|
|
|
+ this.classIndex = 0;
|
|
|
+ this.scrollPushList();
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
|
|
|
/**
|