shish há 2 anos atrás
pai
commit
3259cd0a03
3 ficheiros alterados com 22 adições e 47 exclusões
  1. 1 1
      ghs/src/mixins/index.js
  2. 12 40
      ghs/src/mixins/product2.js
  3. 9 6
      ghs/src/views/order/add.vue

+ 1 - 1
ghs/src/mixins/index.js

@@ -1 +1 @@
-export { default as list } from './list';
+export { default as list } from './list';

+ 12 - 40
ghs/src/mixins/product2.js

@@ -1,5 +1,4 @@
 import { mapGetters, mapActions } from "vuex";
 import { mapGetters, mapActions } from "vuex";
-import { copyObject } from "@/utils/util"
 export default {
 export default {
 	data() {
 	data() {
 		return {
 		return {
@@ -135,21 +134,6 @@ export default {
 			}
 			}
 		},
 		},
 		initData() {
 		initData() {
-			let that = this
-			// getMenu().then(res=>{
-			// 	if(res.code == 1){
-			// 		that.globalClassData = res.data.class ? res.data.class : []
-			// 		if(that.globalClassData[0]){
-			// 			that.globalClassId = that.globalClassData[0].id
-			// 			//保存到仓库
-			// 			let currentInfo = uni.getStorageSync('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
-			// 			if(!that.$util.isEmpty(currentInfo)){
-			// 				that.setSelectInfo({ selectJobType: that.selectJobType, info: currentInfo,selectJobId:that.selectJobId })
-			// 			}
-			// 			that.getGlobalProductList()
-			// 		}
-			// 	}
-			// })
 		},
 		},
 		reGetGlobalProductList(){
 		reGetGlobalProductList(){
 			this.globalGoToTop()
 			this.globalGoToTop()
@@ -162,18 +146,6 @@ export default {
                 return false
                 return false
             }
             }
             let that = this
             let that = this
-			// getItemList({classId:this.globalClassId,requestType:this.globalRequestType,page:this.globalPage,search:this.globalPy,customId:this.globalCustomId}).then(res=>{
-			// 	if(res.code == 1){
-			// 		that.globalItemData = that.globalPage == 1 ? res.data.list : that.globalItemData.concat(res.data.list)
-            //         if(res.data.moreData == 1){
-            //             that.globalPage++
-            //         }else{
-            //             that.globalFinishGetItem = 1
-            //         }
-			// 		that.globalIsRequesting = false
-			// 		that.globalRememberRefresh()
-			// 	}
-			// })
         },
         },
 		globalRememberRefresh(){
 		globalRememberRefresh(){
 			let that = this
 			let that = this
@@ -187,7 +159,7 @@ export default {
 				})
 				})
 			}
 			}
 			//修改数据需要复制一份,否则不会生效
 			//修改数据需要复制一份,否则不会生效
-			that.globalItemData = copyObject(that.globalItemData);
+			that.globalItemData = this.$util.copyObject(that.globalItemData);
 			for (let i=0;i<that.globalItemData.length;i++){
 			for (let i=0;i<that.globalItemData.length;i++){
 				let currentProduct = that.globalItemData[i]
 				let currentProduct = that.globalItemData[i]
 				let currentPId = currentProduct.id
 				let currentPId = currentProduct.id
@@ -215,7 +187,7 @@ export default {
 		},
 		},
 		pushToSave(selectData){
 		pushToSave(selectData){
 			this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
 			this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
-			uni.setStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId, selectData)
+			localStorage.setItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId, selectData);
 		},
 		},
 		globalChangeClass(index,item){
 		globalChangeClass(index,item){
 			this.$refs.globalClassImgRef.close()
 			this.$refs.globalClassImgRef.close()
@@ -231,12 +203,12 @@ export default {
 		removeFromSaveDirect(){
 		removeFromSaveDirect(){
 			let that = this
 			let that = this
 			//删除仓库
 			//删除仓库
-			uni.removeStorageSync('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
+			localStorage.removeItem('selectList_'+that.selectJobType+'_target_'+that.selectJobId)
 			that.reSetSelectInfo({selectJobType:that.selectJobType,selectJobId:that.selectJobId})
 			that.reSetSelectInfo({selectJobType:that.selectJobType,selectJobId:that.selectJobId})
 			//删除多颜色
 			//删除多颜色
 			//console.log(that.selectJobType+that.selectJobId)
 			//console.log(that.selectJobType+that.selectJobId)
 			if(that.selectJobType == 'bill'){
 			if(that.selectJobType == 'bill'){
-				uni.removeStorageSync("xj"+that.selectJobId)
+				localStorage.removeItem("xj"+that.selectJobId)
 			}
 			}
 			//删除显示
 			//删除显示
 			if(!this.$util.isEmpty(this.globalItemData)){
 			if(!this.$util.isEmpty(this.globalItemData)){
@@ -286,7 +258,7 @@ export default {
 		//multiple 0一个一个加减 1弹框方式,多个加减
 		//multiple 0一个一个加减 1弹框方式,多个加减
 		//calc 当multiple=0时,add表示加,sub表示减
 		//calc 当multiple=0时,add表示加,sub表示减
 		replaceItemFn(product,multiple=0,calc='add',scan=0) {
 		replaceItemFn(product,multiple=0,calc='add',scan=0) {
-			let item = copyObject(product)
+			let item = this.$util.copyObject(product)
 			if(multiple == 0){
 			if(multiple == 0){
 				if(Number(item.smallCount)>0){
 				if(Number(item.smallCount)>0){
 					if(calc == 'add'){
 					if(calc == 'add'){
@@ -362,7 +334,7 @@ export default {
 			this.globalRememberRefresh()
 			this.globalRememberRefresh()
 		},
 		},
 		delSelectedItem(product){
 		delSelectedItem(product){
-			let item = copyObject(product)
+			let item = this.$util.copyObject(product)
 			const list = this.selectList
 			const list = this.selectList
 			let index = list.findIndex(element => element.id == item.id)
 			let index = list.findIndex(element => element.id == item.id)
 			if(index != -1){
 			if(index != -1){
@@ -435,7 +407,7 @@ export default {
 			}
 			}
 
 
 			this.isAddModel = true;
 			this.isAddModel = true;
-			this.customData = copyObject(info)
+			this.customData = this.$util.copyObject(info)
 			this.isAddInputFocus = false;
 			this.isAddInputFocus = false;
 			this.$nextTick(()=>{
 			this.$nextTick(()=>{
 				this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
 				this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
@@ -458,31 +430,31 @@ export default {
 
 
 			//二个都不是数值
 			//二个都不是数值
 			if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
 			if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
-				uni.showToast({title:"请填写数值",icon:"none"})
+				this.$message({message: '请填写数值',type: 'warning'});
 				return;
 				return;
 			}
 			}
 
 
 			if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
 			if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
 				if(this.customData.bigCount<=0){
 				if(this.customData.bigCount<=0){
-					uni.showToast({title:"数量要大于0",icon:"none"})
+					this.$message({message: '数量要大于0',type: 'warning'});
 					return;
 					return;
 				}
 				}
 			}
 			}
 
 
 			if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
 			if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
 				if(this.customData.smallCount<=0){
 				if(this.customData.smallCount<=0){
-					uni.showToast({title:"数量要大于0",icon:"none"})
+					this.$message({message: '数量要大于0',type: 'warning'});
 					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.userPrice) == false){
 				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"})
+					this.$message({message: '金额错误',type: 'warning'});
 					return;
 					return;
 				}
 				}
 				if(this.customData.userPrice <=0){
 				if(this.customData.userPrice <=0){
-					uni.showToast({title:"金额要大于0",icon:"none"})
+					this.$message({message: '金额要大于0',type: 'warning'});
 					return;
 					return;
 				}
 				}
 			}
 			}

+ 9 - 6
ghs/src/views/order/add.vue

@@ -198,8 +198,9 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
+import productMins from "@/mixins/product2";
 export default {
 export default {
-  name: 'order-add',
+  name: 'add',
   data() {
   data() {
     return {
     return {
       printAmount:1,
       printAmount:1,
@@ -236,6 +237,7 @@ export default {
       t:null
       t:null
     };
     };
   },
   },
+	mixins: [productMins],
   created() {
   created() {
 
 
   },
   },
@@ -446,13 +448,12 @@ export default {
           this.tableData.splice(i,1)
           this.tableData.splice(i,1)
         }
         }
       }
       }
-      this.tableData.push(
-          {
+      let newItem = {
             index:currentItem.id,
             index:currentItem.id,
             id:currentItem.id,
             id:currentItem.id,
             name:currentItem.name,
             name:currentItem.name,
             cover:currentItem.cover,
             cover:currentItem.cover,
-            big:parseFloat(Number(big)),
+            bigCount:parseFloat(Number(big)),
             ratio:Number(currentItem.ratio),
             ratio:Number(currentItem.ratio),
             ratioType:currentItem.ratioType,
             ratioType:currentItem.ratioType,
             bigUnit:currentItem.bigUnit,
             bigUnit:currentItem.bigUnit,
@@ -460,8 +461,10 @@ export default {
             stock:parseFloat(Number(currentItem.stock)),
             stock:parseFloat(Number(currentItem.stock)),
             price:parseFloat(Number(currentItem.price)),
             price:parseFloat(Number(currentItem.price)),
             totalAmount:money.toFixed(2)
             totalAmount:money.toFixed(2)
-          }
-      )
+      }
+      this.replaceItemFn(newItem,1,'add')
+      return 
+      this.tableData.push(newItem)
       this.tableDataIndex = this.tableData.length-1;
       this.tableDataIndex = this.tableData.length-1;
       this.$refs.singleTable.setCurrentRow(this.tableData[this.tableData.length-1]);
       this.$refs.singleTable.setCurrentRow(this.tableData[this.tableData.length-1]);
       this.$nextTick(()=>{
       this.$nextTick(()=>{