|
|
@@ -4,7 +4,8 @@ import { copyObject } from "@/utils/util";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- pageType: "bill", //选择商品页面类别 用于区分不同功能的数据
|
|
|
+ selectJobType: "bill",//业务类型,开单、采购、报损、盘点
|
|
|
+ selectJobId:0,//业务类型对应的主体ID等
|
|
|
isCut:false,
|
|
|
productInfoList: [], //商品信息
|
|
|
classIndex: 0, //当前商品类别下标
|
|
|
@@ -26,9 +27,9 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- const { pageType } = options;
|
|
|
- if (pageType) {
|
|
|
- this.pageType = pageType;
|
|
|
+ const { selectJobType } = options;
|
|
|
+ if (selectJobType) {
|
|
|
+ this.selectJobType = selectJobType;
|
|
|
}
|
|
|
},
|
|
|
onUnload() {},
|
|
|
@@ -36,7 +37,8 @@ export default {
|
|
|
...mapGetters(["getSelectInfo"]),
|
|
|
//当前页面选中的商品列表
|
|
|
selectList() {
|
|
|
- return this.getSelectInfo[this.pageType] || [];
|
|
|
+ let selectInfo = this.getSelectInfo;
|
|
|
+ return selectInfo[this.selectJobType+'_'+this.selectJobId] || []
|
|
|
},
|
|
|
scrollClassId() {
|
|
|
const curClass = this.productInfoList[this.classIndex];
|
|
|
@@ -104,64 +106,35 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onShow(){
|
|
|
- //修改花材
|
|
|
- if(this.option.modifyProductKey){
|
|
|
- if(uni.getStorageSync('selectList_'+this.option.modifyProductKey)){
|
|
|
- //由于价格会变化,所以在initData()重新载入已经选择的花材
|
|
|
- }
|
|
|
- }else if(this.pageType == 'bill' && !this.$util.isEmpty(this.option.customId)){
|
|
|
- if(uni.getStorageSync('selectList_'+this.pageType+'_target_'+this.option.customId)){
|
|
|
- //由于价格会变化,所以在initData()重新载入已经选择的花材
|
|
|
- }
|
|
|
- }else if(this.pageType == 'purchase' && !this.$util.isEmpty(this.option.ghsId)){
|
|
|
- if(uni.getStorageSync('selectList_'+this.pageType+'_target_'+this.option.ghsId)){
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: uni.getStorageSync('selectList_'+this.pageType+'_target_'+this.option.ghsId) })
|
|
|
- }
|
|
|
- }else{
|
|
|
- //盘点和报损等不需要考虑价格
|
|
|
- if(uni.getStorageSync('selectList_'+this.pageType)){
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: uni.getStorageSync('selectList_'+this.pageType) })
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
|
|
|
+ ...mapActions(["setSelectInfo", "reSetSelectInfo"]),
|
|
|
init(){
|
|
|
if (this.autoLoad) {
|
|
|
this.initData();
|
|
|
}
|
|
|
},
|
|
|
- //记忆已选的花材
|
|
|
- rememberProduct(){
|
|
|
- if(this.pageType == 'bill' && !this.$util.isEmpty(this.option.customId)){
|
|
|
- //开单根据客户记住已选的花材
|
|
|
- uni.setStorageSync('selectList_'+this.pageType+'_target_'+this.option.customId, this.selectList)
|
|
|
- }else if(this.pageType == 'purchase' && !this.$util.isEmpty(this.option.ghsId)){
|
|
|
- //采购根据供应商记住已选的花材
|
|
|
- uni.setStorageSync('selectList_'+this.pageType+'_target_'+this.option.ghsId, this.selectList)
|
|
|
- }else{
|
|
|
- uni.setStorageSync('selectList_'+this.pageType, this.selectList)
|
|
|
- }
|
|
|
+ //放到仓库
|
|
|
+ pushToSave(selectData){
|
|
|
+ this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
|
|
|
+ uni.setStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId, selectData)
|
|
|
},
|
|
|
- //清除记忆花材
|
|
|
- removeMemory(customId=0){
|
|
|
+ //询问是否删除缓存
|
|
|
+ removeFromSave(){
|
|
|
let that = this
|
|
|
-
|
|
|
that.$util.confirmModal({content:'确认清除花材?'},() => {
|
|
|
- that.removeMemoryDirect(customId)
|
|
|
+ that.removeFromSaveDirect()
|
|
|
that.$msg('已清除')
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
- //直接清除记忆花材不提示
|
|
|
- removeMemoryDirect(targetId=0){
|
|
|
+ //直接删除缓存
|
|
|
+ removeFromSaveDirect(){
|
|
|
let that = this
|
|
|
- if(targetId!=0){
|
|
|
- uni.removeStorageSync('selectList_'+that.pageType+'_target_'+targetId)
|
|
|
- }else{
|
|
|
- uni.removeStorageSync('selectList_'+that.pageType)
|
|
|
- }
|
|
|
- that.resetSelectInfoByType(that.pageType)
|
|
|
+
|
|
|
+ uni.removeStorageSync('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
|
|
|
+ that.reSetSelectInfo({selectJobType:that.selectJobType,selectJobId:that.selectJobId})
|
|
|
+
|
|
|
if(!this.$util.isEmpty(this.globalClassItemList)){
|
|
|
this.globalClassItemList.forEach((item,index,arr) =>{
|
|
|
if(!this.$util.isEmpty(arr[index].child)){
|
|
|
@@ -197,37 +170,17 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
this.productInfoList = data;
|
|
|
- if(this.option.modifyProductKey){
|
|
|
- //修改花材
|
|
|
- if(uni.getStorageSync('selectList_'+this.option.modifyProductKey)){
|
|
|
- let currentInfo = uni.getStorageSync('selectList_'+this.option.modifyProductKey)
|
|
|
- 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
|
|
|
- }
|
|
|
- })
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: currentInfo})
|
|
|
- uni.removeStorageSync('selectList_'+this.option.modifyProductKey)
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(this.pageType == 'bill' && !this.$util.isEmpty(this.option.customId)){
|
|
|
- //开单记忆花材取出到selectList
|
|
|
- if(uni.getStorageSync('selectList_'+this.pageType+'_target_'+this.option.customId)){
|
|
|
- let currentInfo = uni.getStorageSync('selectList_'+this.pageType+'_target_'+this.option.customId)
|
|
|
- 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
|
|
|
- }
|
|
|
- })
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: currentInfo })
|
|
|
+
|
|
|
+ let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
|
|
|
+ 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
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
+ this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
|
|
|
}
|
|
|
|
|
|
this.classIndex = 0;
|
|
|
@@ -406,13 +359,13 @@ export default {
|
|
|
if(this.kdType == 'HIT' && multiple ==0){
|
|
|
this.$util.hitRemind()
|
|
|
}
|
|
|
+
|
|
|
+ //数据放到仓库永久存放
|
|
|
+ this.pushToSave(list)
|
|
|
|
|
|
- this.setSelectInfoByType({ type: this.pageType, info: list })
|
|
|
+ this.itemNumPriceRefresh()
|
|
|
|
|
|
- this.itemListRefresh()
|
|
|
|
|
|
- //记忆已经选择的花材
|
|
|
- this.rememberProduct()
|
|
|
},
|
|
|
//显示可以修改花材的弹框
|
|
|
showAddModelFn(info) {
|
|
|
@@ -429,7 +382,7 @@ export default {
|
|
|
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.pageType == 'bill'){
|
|
|
+ if(this.selectJobType == 'bill'){
|
|
|
if(this.customData.userPrice == null || this.customData.userPrice == 0){
|
|
|
this.customData.userPrice = this.customData.bigPrice;
|
|
|
}
|
|
|
@@ -465,7 +418,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
//只有开单和采购需要使用价格
|
|
|
- if(this.pageType == 'bill' || this.pageType == '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.userPrice) == false){
|
|
|
uni.showToast({title:"金额错误",icon:"none"})
|
|
|
return;
|
|
|
@@ -482,7 +435,7 @@ export default {
|
|
|
this.isAddModel = false;
|
|
|
this.customData = {};
|
|
|
},
|
|
|
- itemListRefresh(){
|
|
|
+ itemNumPriceRefresh(){
|
|
|
//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
|
|
|
//将已选的花材按classId_productId键名组合
|
|
|
let selectListData = []
|