From a8b76a8b91cc0034aa05b50520ed8dcf74bedb21 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 06 四月 2022 15:11:09 +0800
Subject: [PATCH] #1

---
 static/js/app.js               |    1 
 static/js/object/StaTask.js    |    6 --
 static/js/object/StoreGoods.js |   69 +++++++++++++++++++++-------------
 3 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/static/js/app.js b/static/js/app.js
index 4da6b6d..d3c5c04 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -369,7 +369,6 @@
 				for (let staData of StaDatas) {
 					let staTask = getArrVal(this.staTasks, "no", staData.no);
 					if (null == staTask) {
-						console.log(staTask)
 						this.staTasks.push(new StaTask(staData, this));
 					} else {
 						if(!staTask.run) {
diff --git a/static/js/object/StaTask.js b/static/js/object/StaTask.js
index 8361935..0f79d58 100644
--- a/static/js/object/StaTask.js
+++ b/static/js/object/StaTask.js
@@ -1,6 +1,4 @@
-
-
-
+import {StoreGoods} from './StoreGoods.js';
 
 // 杈撻�佺嚎褰撳墠杩愯鐘舵�佸璞�
 function StaTask(staData, object) {
@@ -25,13 +23,11 @@
             console.error(staData.no + "鍙疯緭閫佺嚎鏇存柊澶辫触");
             return;
         }
-
         if (that.loaded === 0 && staData.loaded === 1) {
             // 鏃犺揣 ===>> 鏈夎揣
 
             // 1.鍏ュ簱绗竴绔� 銆愭柊澧炪��
             if (that.inlet === 1) {
-
 
             // 2.鏉ヨ嚜鍏朵粬绔欑偣鐨勮揣鐗� 銆愮Щ鍔ㄣ��
             } else {
diff --git a/static/js/object/StoreGoods.js b/static/js/object/StoreGoods.js
index 70b25a5..9621405 100644
--- a/static/js/object/StoreGoods.js
+++ b/static/js/object/StoreGoods.js
@@ -10,24 +10,7 @@
 const goodsY = 5;
 const goodsZ = -6;
 
-function StoreGoods(object, data, shelf) {
-    let that = this;
-    that.data = data;
-    that.object = object;
-    that.shelf = shelf;
-    let palletList = [];
-    let goodsList = [];
-
-    for (let i=0;i<that.data.length;i++) {
-        let obj = that.data[i];
-        if (obj.loc_sts === 'D') {
-            palletList.push(obj);
-        } else if (obj.loc_sts === 'F') {
-            palletList.push(obj);
-            goodsList.push(obj);
-        }
-    }
-
+function InitPallet(scene, palletList, ref, type) {
     const manager = new THREE.LoadingManager();
     new OBJLoader( manager )
         .setPath( '../static/model/obj/' )
@@ -44,18 +27,21 @@
 
             palletList.map(item => {
                 let clone = obj.clone();
-                let positionX = that.shelf.positionX || 0;
-                let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0;
-                let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0;
+                let positionX = ref.positionX || 0;
+                let positionY = ref.bottomHight + (item.lev1-1)*ref.binHeight || 0;
+                let positionZ = (item.bay1-1)*-ref.binHeight || 0;
 
                 clone.name = item.loc_no + "-" + "Pallet";
                 clone.position.x = palletX + positionX;
                 clone.position.y = palletY + positionY;
                 clone.position.z = palletZ + positionZ;
-                that.object.addObject(clone);
+                scene.addObject(clone);
             })
         });
+}
 
+function InitGoods(scene, goodsList, ref, type) {
+    const manager = new THREE.LoadingManager();
     const goodsWrapImg = new THREE.TextureLoader( manager ).load( '../static/img/goodsWrap.jpg' );
     const goodsImg = new THREE.TextureLoader( manager ).load( '../static/img/goods.jpg' );
     new OBJLoader( manager ).load( '../static/model/obj/goods.obj', function ( obj ) {
@@ -73,17 +59,46 @@
 
         goodsList.map(item => {
             let clone = obj.clone();
-            let positionX = that.shelf.positionX || 0;
-            let positionY = that.shelf.bottomHight + (item.lev1-1)*that.shelf.binHeight || 0;
-            let positionZ = (item.bay1-1)*-that.shelf.binHeight || 0;
+            let positionX = ref.positionX || 0;
+            let positionY = ref.bottomHight + (item.lev1-1)*ref.binHeight || 0;
+            let positionZ = (item.bay1-1)*-ref.binHeight || 0;
 
             clone.name = item.loc_no + "-" + "Goods";
             clone.position.x = goodsX + positionX;
             clone.position.y = goodsY + positionY;
             clone.position.z = goodsZ + positionZ;
-            that.object.addObject(clone);
+            scene.addObject(clone);
         })
     });
 }
 
-export {StoreGoods}
+function StoreGoods(object, data, shelf) {
+    let that = this;
+    that.data = data;
+    that.object = object;
+    that.shelf = shelf;
+    let palletList = [];
+    let goodsList = [];
+
+    let init = function () {
+        for (let i=0;i<that.data.length;i++) {
+            let obj = that.data[i];
+            if (obj.loc_sts === 'D') {
+                palletList.push(obj);
+            } else if (obj.loc_sts === 'F') {
+                palletList.push(obj);
+                goodsList.push(obj);
+            }
+        }
+        if (palletList.length > 0) {
+            InitPallet(that.object, palletList, that.shelf);
+        }
+        if (goodsList.length > 0) {
+            InitGoods(that.object, goodsList, that.shelf);
+        }
+    }
+    init();
+
+}
+
+export {StoreGoods, InitPallet, InitGoods}

--
Gitblit v1.9.1