|
@@ -14,14 +14,8 @@ export default {
|
|
|
autoLoad: true, //自动获取商品信息
|
|
autoLoad: true, //自动获取商品信息
|
|
|
allFilterProductInfo:'',
|
|
allFilterProductInfo:'',
|
|
|
globalClassItemList:'',
|
|
globalClassItemList:'',
|
|
|
- top_list:'',
|
|
|
|
|
- //id动态切换
|
|
|
|
|
- scroll_into_view:"",
|
|
|
|
|
- timeFun:"",
|
|
|
|
|
kdType:'HIT',//点击和扫码开单,HIT SCAN
|
|
kdType:'HIT',//点击和扫码开单,HIT SCAN
|
|
|
checkStock:true,// 考虑库存,盘点不需要考虑库存
|
|
checkStock:true,// 考虑库存,盘点不需要考虑库存
|
|
|
- isAddModel:false,
|
|
|
|
|
- isAddInputFocus:false,
|
|
|
|
|
customData: { buyNum: 0, unitPrice: 0,unitType:0 },
|
|
customData: { buyNum: 0, unitPrice: 0,unitType:0 },
|
|
|
globalItemList:[]
|
|
globalItemList:[]
|
|
|
};
|
|
};
|
|
@@ -35,74 +29,33 @@ export default {
|
|
|
onUnload() {},
|
|
onUnload() {},
|
|
|
computed: {
|
|
computed: {
|
|
|
...mapGetters(["getSelectInfo"]),
|
|
...mapGetters(["getSelectInfo"]),
|
|
|
- //当前页面选中的商品列表
|
|
|
|
|
selectList() {
|
|
selectList() {
|
|
|
let selectInfo = this.getSelectInfo;
|
|
let selectInfo = this.getSelectInfo;
|
|
|
return selectInfo[this.selectJobType+'_'+this.selectJobId] || []
|
|
return selectInfo[this.selectJobType+'_'+this.selectJobId] || []
|
|
|
},
|
|
},
|
|
|
- scrollClassId() {
|
|
|
|
|
- const curClass = this.productInfoList[this.classIndex];
|
|
|
|
|
- if (curClass) {
|
|
|
|
|
- return `class_${curClass.classId}`;
|
|
|
|
|
- }
|
|
|
|
|
- return "";
|
|
|
|
|
- },
|
|
|
|
|
allPrice() {
|
|
allPrice() {
|
|
|
let price = 0;
|
|
let price = 0;
|
|
|
if (this.selectList) {
|
|
if (this.selectList) {
|
|
|
for (const item of this.selectList) {
|
|
for (const item of this.selectList) {
|
|
|
- const itemInfo = this.getSelectItemById(item.id, item.classId);
|
|
|
|
|
- if (itemInfo && !this.$util.isEmpty(itemInfo.bigPrice) && !this.$util.isEmpty(itemInfo.smallPrice)) {
|
|
|
|
|
- if(item.userPrice>0){
|
|
|
|
|
- price += Number(item.bigCount) * Number(itemInfo.userPrice);
|
|
|
|
|
- let currentSmallPrice = (itemInfo.userPrice/itemInfo.ratio).toFixed(2)
|
|
|
|
|
- price += Number(item.smallCount)*Number(currentSmallPrice)
|
|
|
|
|
- }else{
|
|
|
|
|
- price += item.bigCount * Number(itemInfo.bigPrice);
|
|
|
|
|
- price += item.smallCount * Number(itemInfo.smallPrice);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let currentPrice = this.$util.mul(item.unitPrice,item.buyNum)
|
|
|
|
|
+ price = this.$util.add(currentPrice,price)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return Math.round(price * 100) / 100;
|
|
|
|
|
|
|
+ return parseFloat(price)
|
|
|
},
|
|
},
|
|
|
- //选择商品总数
|
|
|
|
|
allCount() {
|
|
allCount() {
|
|
|
- let bigLength = 0;
|
|
|
|
|
- let smallLength = 0;
|
|
|
|
|
|
|
+ let bigNum = 0;
|
|
|
|
|
+ let smallNum = 0;
|
|
|
if (this.selectList) {
|
|
if (this.selectList) {
|
|
|
for (const item of this.selectList) {
|
|
for (const item of this.selectList) {
|
|
|
- bigLength += Number(item.bigCount)
|
|
|
|
|
- smallLength += Number(item.smallCount)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return {bigLength:bigLength,smallLength:smallLength,};
|
|
|
|
|
- },
|
|
|
|
|
- //当前选中商品列表中是否有没有库存的商品
|
|
|
|
|
- hasNoStock() {
|
|
|
|
|
- let has = false;
|
|
|
|
|
- if (this.selectList) {
|
|
|
|
|
- for (const item of this.selectList) {
|
|
|
|
|
- const {
|
|
|
|
|
- bigCount,
|
|
|
|
|
- smallCount,
|
|
|
|
|
- bigNum,
|
|
|
|
|
- bigUnit,
|
|
|
|
|
- smallNum,
|
|
|
|
|
- smallUnit,
|
|
|
|
|
- ratio
|
|
|
|
|
- } = item;
|
|
|
|
|
- const ratioNum = Number(ratio);
|
|
|
|
|
- if (
|
|
|
|
|
- Number(bigCount) * ratioNum + Number(smallCount) >
|
|
|
|
|
- Number(bigNum) * ratioNum + Number(smallNum)
|
|
|
|
|
- ) {
|
|
|
|
|
- has = true;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if(item.unitType == 0){
|
|
|
|
|
+ bigNum = this.$util.add(bigNum,item.buyNum)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ smallNum = this.$util.add(smallNum,item.buyNum)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return has;
|
|
|
|
|
|
|
+ return {bigNum,smallNum}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onShow(){
|
|
onShow(){
|
|
@@ -112,7 +65,7 @@ export default {
|
|
|
...mapActions(["setSelectInfo", "reSetSelectInfo"]),
|
|
...mapActions(["setSelectInfo", "reSetSelectInfo"]),
|
|
|
init(){
|
|
init(){
|
|
|
if (this.autoLoad) {
|
|
if (this.autoLoad) {
|
|
|
- this.initData();
|
|
|
|
|
|
|
+ this.initStorageData();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
//放到仓库
|
|
//放到仓库
|
|
@@ -148,23 +101,10 @@ export default {
|
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- //请求商品数据
|
|
|
|
|
- initData() {
|
|
|
|
|
- console.log('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
|
|
|
|
|
|
|
+ //取出缓存数据
|
|
|
|
|
+ initStorageData() {
|
|
|
let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
|
|
let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
|
|
|
if(!this.$util.isEmpty(currentInfo)){
|
|
if(!this.$util.isEmpty(currentInfo)){
|
|
|
- currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
|
|
|
|
|
- let currentId = currentItem.id
|
|
|
|
|
- if(this.globalItemList[currentId]){
|
|
|
|
|
- currentArray[currentIndex].bigPrice = this.globalItemList[currentId].bigPrice
|
|
|
|
|
- currentArray[currentIndex].smallPrice = this.globalItemList[currentId].smallPrice
|
|
|
|
|
- //已经记住的花材,价格修改之后,被记住的价格也要同步修改
|
|
|
|
|
- //不能放开会造成采购单已经填好的,也会变动 shish 20220114
|
|
|
|
|
- // if(!this.$util.isEmpty(currentArray[currentIndex].userPrice)){
|
|
|
|
|
- // currentArray[currentIndex].userPrice = this.globalItemList[currentId].bigPrice
|
|
|
|
|
- // }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
|
|
this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -178,15 +118,6 @@ export default {
|
|
|
price = Math.round(sum * 100) / 100;
|
|
price = Math.round(sum * 100) / 100;
|
|
|
return price;
|
|
return price;
|
|
|
},
|
|
},
|
|
|
- //通过id获取当前选中的商品信息
|
|
|
|
|
- getSelectItemById(id, classId) {
|
|
|
|
|
- let info = { bigCount: null, smallCount: null, autoPrice: null, itemPrice: null }
|
|
|
|
|
- const item = this.selectList && this.selectList.find(ele => { return ele.id == id && ele.classId == classId })
|
|
|
|
|
- if (item) {
|
|
|
|
|
- info = { ...item, bigCount: Number(item.bigCount), smallCount: Number(item.smallCount), autoPrice: Number(item.autoPrice), itemPrice: Number(item.itemPrice)}
|
|
|
|
|
- }
|
|
|
|
|
- return info;
|
|
|
|
|
- },
|
|
|
|
|
//添加删除和修改花材
|
|
//添加删除和修改花材
|
|
|
//multiple 0单个加减 1弹框方式多个加减
|
|
//multiple 0单个加减 1弹框方式多个加减
|
|
|
//calc 当multiple=0时,add表示加,sub表示减
|
|
//calc 当multiple=0时,add表示加,sub表示减
|
|
@@ -238,17 +169,14 @@ export default {
|
|
|
}else{
|
|
}else{
|
|
|
list[index].buyNum = item.buyNum
|
|
list[index].buyNum = item.buyNum
|
|
|
list[index].unitPrice = item.unitPrice
|
|
list[index].unitPrice = item.unitPrice
|
|
|
|
|
+ list[index].unitType = item.unitType
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if(this.kdType == 'HIT' && multiple ==0){
|
|
if(this.kdType == 'HIT' && multiple ==0){
|
|
|
this.$util.hitRemind()
|
|
this.$util.hitRemind()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//数据放到仓库永久存放
|
|
//数据放到仓库永久存放
|
|
|
this.pushToSave(list)
|
|
this.pushToSave(list)
|
|
|
-
|
|
|
|
|
- this.itemNumPriceRefresh()
|
|
|
|
|
},
|
|
},
|
|
|
//显示可以修改花材的弹框
|
|
//显示可以修改花材的弹框
|
|
|
showAddModelFn(info) {
|
|
showAddModelFn(info) {
|
|
@@ -261,86 +189,44 @@ export default {
|
|
|
}
|
|
}
|
|
|
this.$refs.kdSelectNumPriceRef.open('center')
|
|
this.$refs.kdSelectNumPriceRef.open('center')
|
|
|
this.customData = copyObject(info)
|
|
this.customData = copyObject(info)
|
|
|
- this.isAddInputFocus = false;
|
|
|
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
|
- this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
|
|
|
|
|
- this.customData.bigCount = this.customData.bigCount==0?null:this.customData.bigCount;
|
|
|
|
|
if(this.selectJobType == 'bill'){
|
|
if(this.selectJobType == 'bill'){
|
|
|
- if(this.customData.userPrice == null || this.customData.userPrice == 0){
|
|
|
|
|
- this.customData.userPrice = this.customData.bigPrice;
|
|
|
|
|
- }
|
|
|
|
|
- }else{
|
|
|
|
|
- this.customData.userPrice = this.customData.userPrice==0?null:this.customData.userPrice;
|
|
|
|
|
|
|
+ this.customData.unitPrice = this.customData.bigPrice;
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- confirmAddItemModel(val) {
|
|
|
|
|
- if (val.index === 0) {
|
|
|
|
|
|
|
+ confirmAddItemModel(item) {
|
|
|
|
|
+ if (item.index === 0) {
|
|
|
this.addItemModelHidden();
|
|
this.addItemModelHidden();
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if(/(^[1-9]\d*$)/.test(this.customData.buyNum) == false){
|
|
|
|
|
|
|
+ if(/(^[1-9]\d*$)/.test(item.buyNum) == false){
|
|
|
uni.showToast({title:"请填写数值",icon:"none"})
|
|
uni.showToast({title:"请填写数值",icon:"none"})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if(/(^[1-9]\d*$)/.test(this.customData.buyNum)){
|
|
|
|
|
- if(this.customData.bigCount<=0){
|
|
|
|
|
|
|
+ if(/(^[1-9]\d*$)/.test(item.buyNum)){
|
|
|
|
|
+ if(item.bigCount<=0){
|
|
|
uni.showToast({title:"数量要大于0",icon:"none"})
|
|
uni.showToast({title:"数量要大于0",icon:"none"})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//只有开单和采购需要使用价格
|
|
//只有开单和采购需要使用价格
|
|
|
if(this.selectJobType == 'bill' || this.selectJobType == 'purchase'){
|
|
if(this.selectJobType == 'bill' || this.selectJobType == 'purchase'){
|
|
|
- if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.unitPrice) == false){
|
|
|
|
|
|
|
+ if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(item.unitPrice) == false){
|
|
|
uni.showToast({title:"金额错误",icon:"none"})
|
|
uni.showToast({title:"金额错误",icon:"none"})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if(this.customData.unitPrice <=0){
|
|
|
|
|
|
|
+ if(item.unitPrice <=0){
|
|
|
uni.showToast({title:"金额要大于0",icon:"none"})
|
|
uni.showToast({title:"金额要大于0",icon:"none"})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- this.replaceItemFn(this.customData,1)
|
|
|
|
|
|
|
+ this.replaceItemFn(item,1)
|
|
|
this.addItemModelHidden()
|
|
this.addItemModelHidden()
|
|
|
},
|
|
},
|
|
|
addItemModelHidden() {
|
|
addItemModelHidden() {
|
|
|
this.$refs.kdSelectNumPriceRef.close()
|
|
this.$refs.kdSelectNumPriceRef.close()
|
|
|
this.customData = {};
|
|
this.customData = {};
|
|
|
- },
|
|
|
|
|
- itemNumPriceRefresh(){
|
|
|
|
|
- //涉及记住花材的代码和流程,请全项目搜索关键词remember_item
|
|
|
|
|
- //将已选的花材按classId_productId键名组合
|
|
|
|
|
- let selectListData = []
|
|
|
|
|
- if(!this.$util.isEmpty(this.selectList)){
|
|
|
|
|
- this.selectList.forEach((i)=>{
|
|
|
|
|
- selectListData[i.id] = i
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- let upList = this.globalClassItemList;
|
|
|
|
|
- for (let i=0;i<upList.length;i++){
|
|
|
|
|
- //将已选的花材数量和价格组合到总列表里
|
|
|
|
|
- if(!this.$util.isEmpty(upList[i].child)){
|
|
|
|
|
- let currentChildren = upList[i].child
|
|
|
|
|
- for(let x=0;x<currentChildren.length;x++){
|
|
|
|
|
- let currentProduct = currentChildren[x]
|
|
|
|
|
- let currentPId = currentProduct.id
|
|
|
|
|
- let selectProduct = selectListData[currentPId] || []
|
|
|
|
|
- if(!this.$util.isEmpty(selectProduct)){
|
|
|
|
|
- upList[i].child[x].bigCount = selectProduct.bigCount || 0
|
|
|
|
|
- upList[i].child[x].userPrice = selectProduct.userPrice || 0
|
|
|
|
|
- upList[i].child[x].smallCount = selectProduct.smallCount || 0
|
|
|
|
|
- }else{
|
|
|
|
|
- upList[i].child[x].bigCount = 0
|
|
|
|
|
- upList[i].child[x].userPrice = 0
|
|
|
|
|
- upList[i].child[x].smallCount = 0
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- this.globalClassItemList = upList
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|