shish 2 ani în urmă
părinte
comite
01dc4372e9
3 a modificat fișierele cu 31 adăugiri și 3 ștergeri
  1. 22 2
      ghs/src/mixins/product2.js
  2. 8 0
      ghs/src/service/item/index.js
  3. 1 1
      ghs/src/views/order/add.vue

+ 22 - 2
ghs/src/mixins/product2.js

@@ -176,10 +176,30 @@ export default {
 			this.setSelectInfo({ selectJobType: this.selectJobType, info: selectData,selectJobId:this.selectJobId })
 			localStorage.setItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId, JSON.stringify(selectData));
 		},
-		getFromStorage(){
+		getFromStorage(sync){
 			let res = localStorage.getItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
 			let obj = JSON.parse(res)
-			this.setSelectInfo({ selectJobType: this.selectJobType, info: obj,selectJobId:this.selectJobId })
+			if(sync == true){
+				if(!this.$util.isEmpty(obj)){
+					const ids = obj.map(ele => { 
+						return { productId: ele.id}
+					})
+					//更新库存
+					this.$service.item.getNewInfo({ data: JSON.stringify(ids) }).then(data => {
+						let newItemList = data.list ? data.list : []
+						const newObj = obj.map(ele => {
+							let productId = ele.id
+							let stock = newItemList[productId] && newItemList[productId].stock ? newItemList[productId].stock : 0
+							stock = parseFloat(stock)
+							return { ...ele,stock:stock,bigNum:stock}
+						})
+						localStorage.setItem('selectList_'+this.selectJobType+'_target_'+this.selectJobId, JSON.stringify(newObj));
+						this.setSelectInfo({ selectJobType: this.selectJobType, info: newObj,selectJobId:this.selectJobId })
+					})
+				}
+			}else{
+				this.setSelectInfo({ selectJobType: this.selectJobType, info: obj,selectJobId:this.selectJobId })
+			}
 		},
 		globalChangeClass(index,item){
 			this.$refs.globalClassImgRef.close()

+ 8 - 0
ghs/src/service/item/index.js

@@ -3,6 +3,14 @@ import { BaseService, Service } from '@/cool';
 @Service('item')
 export class ItemService extends BaseService {
 
+	getNewInfo(data) {
+		return this.request({
+			url: '/get-new-info',
+			method: 'POST',
+			data: data
+		});
+	}
+
 	getItemList(data) {
 		return this.request({
 			url: '/get-item-list',

+ 1 - 1
ghs/src/views/order/add.vue

@@ -462,7 +462,7 @@ export default {
         this.form.customId = e.id
         this.form.customName = e.name
         this.selectJobId = e.id
-        this.getFromStorage()
+        this.getFromStorage(true)
         this.$nextTick(()=>{
           this.$refs['itemSearchRef'].focus()
         })