فهرست منبع

Merge branch 'master' of http://121.40.253.172:3000/longyong/jsh_erp_app

hi 3 روز پیش
والد
کامیت
2fbf1a01ed
3فایلهای تغییر یافته به همراه108 افزوده شده و 109 حذف شده
  1. 15 1
      common/request/apis/inventoryInquiry.js
  2. 2 2
      components/leo-tree/tree-node.vue
  3. 91 106
      pages/inventory-inquiry/index.vue

+ 15 - 1
common/request/apis/inventoryInquiry.js

@@ -3,5 +3,19 @@ export const inventoryInquiry = (
   params,
   config = { custom: { auth: true } }
 ) => {
-  return uni.$u.http.get(`/pda/inventoryInquiry/1/2`, { params }, config);
+  return uni.$u.http.post(`/pda/inventoryInquiry`, params, config);
+};
+//库位
+export const inventoryPositionTree = (
+  params,
+  config = { custom: { auth: true } }
+) => {
+  return uni.$u.http.get(`/pda/inventoryPositionTree`, config);
+};
+//分类
+export const materialCategoryTree = (
+  params,
+  config = { custom: { auth: true } }
+) => {
+  return uni.$u.http.get(`/pda/inventoryTypeTree`, config);
 };

+ 2 - 2
components/leo-tree/tree-node.vue

@@ -3,7 +3,7 @@
     <view
       class="head"
       @click.stop="changeShow"
-      style="padding-left: 10rpx"
+      style="padding-left: 20rpx"
       :class="{ active: isItemActive(item) }"
     >
       <text class="txt">{{ item[defaultProps.label] }}</text>
@@ -22,7 +22,7 @@
         <view
           class="head"
           @click.stop="toggleNode(index)"
-          :style="{ paddingLeft: (node._level + 1) * 10 + 10 + 'rpx' }"
+          :style="{ paddingLeft: (node._level + 1) * 20 + 20 + 'rpx' }"
           :class="{ active: isItemActive(node) }"
         >
           <text class="txt">{{ node[defaultProps.label] }}</text>

+ 91 - 106
pages/inventory-inquiry/index.vue

@@ -14,8 +14,10 @@
           <u-search
             placeholder="请输入单据编号"
             shape="square"
-            v-model="searchKey"
             :showAction="false"
+            @search="handleSearch"
+            @clear="handleSearch"
+            v-model="queryParams.keyword"
           ></u-search>
           <view class="scan-icon flex_box flex_row_center">
             <image src="@/static/image/scan-icon-2.png" mode=""></image>
@@ -48,19 +50,19 @@
               }"
             >
               <leo-tree
+                v-if="typeName === '按库位展示'"
                 :data="treeData"
+                :defaultProps="defaultProps"
                 @node-click="nodeClick"
-                v-model="typeId"
+                v-model="queryParams.position"
+              ></leo-tree>
+              <leo-tree
+                v-if="typeName === '按分类展示'"
+                :data="treeData2"
+                :defaultProps="defaultProps2"
+                @node-click="nodeClick2"
+                v-model="queryParams.categoryId"
               ></leo-tree>
-              <!-- <view
-                class="type-item"
-                :class="item.id == typeId ? 'active-item' : ''"
-                v-for="(item, i) in typeList"
-                :key="i"
-                @click="chooseType(item)"
-              >
-                {{ item.name }}
-              </view> -->
             </scroll-view>
           </view>
           <view class="goods-cont-right">
@@ -93,7 +95,11 @@
 
 <script>
 import leoTree from "@/components/leo-tree/leo-tree.vue";
-import { inventoryInquiry } from "@/common/request/apis/inventoryInquiry";
+import {
+  inventoryInquiry,
+  inventoryPositionTree,
+  materialCategoryTree,
+} from "@/common/request/apis/inventoryInquiry";
 import goodItem from "@/components/good-item/good-item.vue";
 export default {
   components: {
@@ -103,114 +109,48 @@ export default {
   data() {
     return {
       offsetTop: 0,
-      searchKey: "",
       current: 0,
       typeShow: false,
       defaultIndex: [],
       typeName: "按分类展示",
       scrollH: 0,
       columnsList: [["按分类展示", "按库位展示"]],
-      typeId: "",
-      treeData: [
-        {
-          id: "1",
-          label: "1",
-          children: [
-            {
-              id: "1-1",
-              label: "1-1",
-              children: [
-                {
-                  id: "1-1-1",
-                  label: "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈",
-                },
-                {
-                  id: "1-1-2",
-                  label: "1-1-2",
-                },
-                {
-                  id: "1-1-3",
-                  label: "1-1-3",
-                },
-                {
-                  id: "1-1-4",
-                  label: "1-1-4",
-                },
-              ],
-            },
-            {
-              id: "1-2",
-              label: "1-2",
-              children: [
-                {
-                  id: "1-2-1",
-                  label: "1-2-1",
-                },
-                {
-                  id: "1-2-2",
-                  label: "1-2-2",
-                },
-                {
-                  id: "1-2-3",
-                  label: "1-2-3",
-                },
-                {
-                  id: "1-2-4",
-                  label: "1-2-4",
-                },
-              ],
-            },
-          ],
-        },
-        {
-          id: "2",
-          label: "2",
-          children: [
-            {
-              id: "2-1",
-              label: "2-1",
-              children: [
-                {
-                  id: "2-1-1",
-                  label: "2-1-1",
-                },
-                {
-                  id: "2-1-2",
-                  label: "2-1-2",
-                },
-                {
-                  id: "2-1-3",
-                  label: "2-1-3",
-                },
-                {
-                  id: "2-1-4",
-                  label: "2-1-4",
-                },
-              ],
-            },
-          ],
-        },
-      ],
+      treeData: [],
+      treeData2: [],
       tabList: [
         {
-          index: 0,
+          value: "have",
           name: "有库存",
         },
         {
-          index: 1,
+          value: "none",
           name: "无库存",
         },
         {
-          index: 2,
+          value: "all",
           name: "全部",
         },
       ],
-
+      defaultProps: {
+        id: "value",
+        children: "children",
+        label: "label",
+      },
+      defaultProps2: {
+        id: "id",
+        children: "children",
+        label: "title",
+      },
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
       goodsList: [],
       pageSize: 10,
       pageNum: 1,
-      query: {},
+      queryParams: {
+        type: "have",
+        categoryId: "",
+        position: "",
+        keyword: "",
+      },
     };
   },
   mounted() {
@@ -226,13 +166,42 @@ export default {
       })
       .exec();
   },
+
   onLoad() {
     // let systemInfo = uni.getSystemInfoSync();
     // let statusBarHeight = systemInfo.statusBarHeight;
     // this.offsetTop = statusBarHeight + 40
+    this.getTreeData();
+    this.getMaterialCategoryTree();
     this.loadData();
   },
+  onShow() {
+    uni.$on("scanFinish", (data) => {
+      this.params.keyword = data;
+      this.onRefresh();
+    });
+  },
+  onHide() {
+    uni.$off("scanFinish");
+  },
+  onUnload() {
+    uni.$off("scanFinish");
+  },
   methods: {
+    async getTreeData() {
+      try {
+        const res = await inventoryPositionTree();
+        console.log("res=====", res);
+        this.treeData = res.data;
+      } catch (error) {}
+    },
+    async getMaterialCategoryTree() {
+      try {
+        const res = await materialCategoryTree();
+        console.log("res=====", res);
+        this.treeData2 = res.data;
+      } catch (error) {}
+    },
     async onRefresh() {
       try {
         await this.loadData(true);
@@ -261,7 +230,7 @@ export default {
         const params = {
           pageNum,
           pageSize,
-          ...this.query,
+          ...this.queryParams,
         };
         const res = await inventoryInquiry(params);
         console.log("res====", res);
@@ -281,12 +250,24 @@ export default {
         }
       } catch (error) {}
     },
+    handleSearch() {
+      this.loadData(true);
+    },
     nodeClick(e) {
       console.log("nodeClick======", e);
-      console.log("this.typeId======", this.typeId);
-      // this.typeId = e.id;
+      this.queryParams.position = e.value;
+      this.loadData(true);
+    },
+    nodeClick2(e) {
+      console.log("nodeClick======", e);
+      this.queryParams.categoryId = e.id;
+      this.loadData(true);
+    },
+    tabClick(e) {
+      console.log(e);
+      this.queryParams.type = e.value;
+      this.loadData(true);
     },
-    tabClick() {},
     typeClick() {
       let index = this.columnsList[0].findIndex(
         (item) => item == this.typeName
@@ -295,12 +276,16 @@ export default {
       this.typeShow = true;
     },
     pickerConfirm(val) {
+      console.log("val===========", val);
       this.typeName = val.value[0];
+      if (this.typeName === "按分类展示") {
+        this.queryParams.position = "";
+      }
+      if (this.typeName === "按库位展示") {
+        this.queryParams.categoryId = "";
+      }
       this.typeShow = false;
     },
-    chooseType(item) {
-      this.typeId = item.id;
-    },
   },
 };
 </script>