From 97eb0150435b2d46ab5bab294345872ce2293fd0 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 12 Aug 2022 10:36:33 +0800
Subject: [PATCH] 农资库存管理,已出库待使用农资,根据农场变化数据变化

---
 src/views/soldrecord/soldrecord.vue   |   15 +++++++
 src/views/stock/stockmanage.vue       |   20 ++++++++--
 src/views/stockrecord/stockrecord.vue |   15 +++++++
 src/views/stock/stockout.vue          |   13 ++++++
 4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/src/views/soldrecord/soldrecord.vue b/src/views/soldrecord/soldrecord.vue
index 5adb66c..f917d28 100644
--- a/src/views/soldrecord/soldrecord.vue
+++ b/src/views/soldrecord/soldrecord.vue
@@ -42,6 +42,7 @@
     data () {
         return {
             form: {},
+            farm:{},
             query: {},
             loading: true,
             page: {
@@ -127,7 +128,7 @@
         }
     },
     computed: {
-        ...mapGetters(["permission"]),
+        ...mapGetters(["permission","$farmId"]),
         permissionList () {
             return {
                 addBtn: this.vaildData(this.permission.soldrecord_add, false),
@@ -143,6 +144,17 @@
             })
             return ids.join(",")
         }
+    },
+    watch: {
+        '$farmId':{
+        handler (newName, oldName) {
+            this.farm.id = newName
+            this.onLoad(this.page)
+        }
+      }
+    },
+    created () {
+      this.farm.id = this.$farmId
     },
     methods: {
         rowSave (row, done, loading) {
@@ -248,6 +260,7 @@
             this.loading = true
             var datas = this.$route.query
             params.stockId1 = datas.sid
+            params["deptId"] = this.farm.id
             getListbg(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
                 const data = res.data.data
                 this.page.total = data.total
diff --git a/src/views/stock/stockmanage.vue b/src/views/stock/stockmanage.vue
index 2e559b0..c58f7ce 100644
--- a/src/views/stock/stockmanage.vue
+++ b/src/views/stock/stockmanage.vue
@@ -193,6 +193,7 @@
       formC: {},
       formR: {},
       formK: {},
+      farm:{},
       specsValue1: "",
       query: {},
       loading: true,
@@ -698,7 +699,7 @@
     };
   },
   computed: {
-    ...mapGetters(["permission","userInfo"]),
+    ...mapGetters(["permission","userInfo","$farmId"]),
     permissionList() {
       return {
         addBtn: this.vaildData(this.permission.stock_add, false),
@@ -717,8 +718,18 @@
   },
   created() {
     //初始化页面数据
+    this.farm.id = this.$farmId
     this.onLoad(this.page);
   },
+  watch: {
+      '$farmId':{
+      handler (newName, oldName) {
+          this.farm.id = newName
+          //地块页面
+          this.onLoad(this.page)
+      }
+    }
+  },  
   methods: {
     //库存明细
     kc(item) {
@@ -757,7 +768,7 @@
     },
     //农资入库按钮
     submitK(row, done, loading) {
-      row.deptId=this.userInfo.dept_id;
+      row.deptId=this.farm.id;
       if(row.amount<0 || row.specs <0){
         this.$message({
           type:"warning",
@@ -782,7 +793,7 @@
     },
 //入库
     submitR(row, done, loading) {
-      row.deptId=this.userInfo.dept_id;
+      row.deptId=this.farm.id;
       var that = this;
       if(row.amount1<0){
         this.$message({
@@ -813,7 +824,7 @@
 //出库
     submitC(row, done, loading) {
       var that = this;
-      row.deptId=this.userInfo.dept_id;
+      row.deptId=this.farm.id;
       if(row.amount1<0 || row.num<row.amount1){
         this.$message({
           type:"warning",
@@ -994,6 +1005,7 @@
       // var type = this.$route.query.type;
       params.sid=datas;
       // params.stype=type;
+      params['deptId'] = this.farm.id
       getList(
         page.currentPage,
         page.pageSize,
diff --git a/src/views/stock/stockout.vue b/src/views/stock/stockout.vue
index 4aaca74..4f16d73 100644
--- a/src/views/stock/stockout.vue
+++ b/src/views/stock/stockout.vue
@@ -112,6 +112,7 @@
         state: "0",
         keyword: "",
       },
+      farm:{},
       specsValue1: "",
       query: {},
       loading: true,
@@ -158,7 +159,7 @@
     };
   },
   computed: {
-    ...mapGetters(["permission"]),
+    ...mapGetters(["permission","$farmId"]),
     permissionList() {
       return {
         addBtn: this.vaildData(this.permission.stock_add, false),
@@ -176,9 +177,18 @@
     },
   },
   created() {
+    this.farm.id = this.$farmId
     //初始化页面数据
     this.onLoad(this.page);
   },
+  watch: {
+      '$farmId':{
+      handler (newName, oldName) {
+          this.farm.id = newName
+          this.onLoad(this.page)
+      }
+      }
+  },  
   methods: {
     kc(item) {
       this.$router.push({
@@ -407,6 +417,7 @@
     },
     onLoad(page, params = {}) {
       this.loading = true;
+      params["deptId"] = this.farm.id
       getList(
         page.currentPage,
         page.pageSize,
diff --git a/src/views/stockrecord/stockrecord.vue b/src/views/stockrecord/stockrecord.vue
index aa8ee29..2c28de4 100644
--- a/src/views/stockrecord/stockrecord.vue
+++ b/src/views/stockrecord/stockrecord.vue
@@ -39,6 +39,7 @@
     data() {
       return {
         form: {},
+        farm:{},
         query: {},
         loading: true,
         page: {
@@ -122,7 +123,7 @@
       };
     },
     computed: {
-      ...mapGetters(["permission"]),
+      ...mapGetters(["permission","$farmId"]),
       permissionList() {
         return {
           addBtn: this.vaildData(this.permission.stockrecord_add, false),
@@ -138,6 +139,17 @@
         });
         return ids.join(",");
       }
+    },
+    watch: {
+        '$farmId':{
+        handler (newName, oldName) {
+            this.farm.id = newName
+            this.onLoad(this.page)
+        }
+      }
+    },
+    created () {
+      this.farm.id = this.$farmId
     },
     methods: {
       // rowSave(row, done, loading) {
@@ -241,6 +253,7 @@
       },
       onLoad(page, params = {}) {
         this.loading = true;
+        params['deptId'] = this.farm.id
         getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
           const data = res.data.data;
           this.page.total = data.total;

--
Gitblit v1.9.3