e 4 rokov pred
rodič
commit
2df871abb3

+ 3 - 1
src/main.js

@@ -11,11 +11,13 @@ import './assets/css/reset.scss'
 import 'default-passive-events'  // ( https://www.jianshu.com/p/23850d4cade8 )
 import echarts from "echarts";
 import moment from 'moment'
-import VueAMap from 'vue-amap'
+import VueAMap from 'vue-amap';
+import axios from 'axios';
 
 moment.locale('zh-cn');  // 汉化
 Vue.prototype.$echarts = echarts
 Vue.prototype.$moment = moment;
+Vue.prototype.$axios = axios;
 
 Vue.use(VueAMap)
 Vue.use(vueModuleLoader, { store }).use(ElementUI);

+ 4 - 2
src/store/index.js

@@ -1,6 +1,7 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
-import publicType from './publicType.js' // 公共的类型 
+import publicType from './publicType.js' // 公共的类型
+import axios from 'axios';
 
 import { reqSlaughterBatchIdList } from "@/api/slaughterManagment.js";
 
@@ -9,6 +10,7 @@ Vue.use(Vuex)
 export default new Vuex.Store({
 	strict: true,
 	state: {
+		typeCode: '屠宰管理菜单',
 		...publicType,
 		slaughterBatchIdList: [] // 屠宰批次 id 列表
 	},
@@ -17,7 +19,7 @@ export default new Vuex.Store({
 	mutations: {
 		setState(state, [key, val]) {
 			state[key] = val
-		}
+		},
 	},
 	actions: {
 		/* 获取屠宰批次 登录后再 home时调用了*/

+ 50 - 71
src/views/Home/Home.vue

@@ -24,18 +24,18 @@
                         </el-dropdown-menu>
                     </el-dropdown>
                 </span>
-                <span>
-                    <el-dropdown @command="onLogOut">
-                        <span class="el-dropdown-link">
-                            权限切换
-                            <i class="el-icon-arrow-down el-icon--right"></i>
-                        </span>
-                        <el-dropdown-menu slot="dropdown">
-                            <el-dropdown-item disabled>权限一</el-dropdown-item>
-                            <el-dropdown-item divided>权限二</el-dropdown-item>
-                        </el-dropdown-menu>
-                    </el-dropdown>
-                </span>
+<!--                <span>-->
+<!--                    <el-dropdown @command="onLogOut">-->
+<!--                        <span class="el-dropdown-link">-->
+<!--                            权限切换-->
+<!--                            <i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
+<!--                        </span>-->
+<!--                        <el-dropdown-menu slot="dropdown">-->
+<!--                            <el-dropdown-item disabled>权限一</el-dropdown-item>-->
+<!--                            <el-dropdown-item divided>权限二</el-dropdown-item>-->
+<!--                        </el-dropdown-menu>-->
+<!--                    </el-dropdown>-->
+<!--                </span>-->
             </div>
         </header>
         <section class="section">
@@ -54,32 +54,32 @@
                         text-color="#fff"
                         active-text-color="#ffd04b"
                     >
-                        <div v-for="(item, index1) in menuData " :key="index1">
+                        <div v-for="(item, index1) in menu " :key="index1">
                             <el-submenu
-                                v-if="item.childList && item.childList.length > 0"
+                                v-if="item.children && item.children.length > 0"
                                 :index="`${index1}`"
                             >
                                 <template slot="title">
-                                    <i :class="item.iconClassName"></i>
-                                    <span slot="title">{{ !menuCollapse? item.optionName : '' }}</span>
+<!--                                    <i :class="item.iconClassName"></i>-->
+                                    <span slot="title">{{ !menuCollapse? item.menuName : '' }}</span>
                                 </template>
                                 <el-menu-item
-                                    v-for="(item1, index2) in item.childList"
+                                    v-for="(item1, index2) in item.children"
                                     :key="`${index1}-${index2}`"
                                     :index="`${index1}-${index2}`"
-                                    :routerName="item1.routerName"
+                                    :routerName="item1.url"
                                     @click="onClickMenu(item1)"
-                                >{{ item1.optionName }}</el-menu-item>
+                                >{{ item1.menuName }}</el-menu-item>
                             </el-submenu>
                             <el-menu-item
                                 v-else
                                 :index="`${index1}`"
                                 :disabled="item.disabled"
-                                :routerName="item.routerName"
+                                :routerName="item.url"
                                 @click="onClickMenu(item)"
                             >
-                                <i :class="item.iconClassName"></i>
-                                <span slot="title">{{ !menuCollapse? item.optionName : '' }}</span>
+<!--                                <i :class="item.iconClassName"></i>-->
+                                <span slot="title">{{ !menuCollapse? item.menuName : '' }}</span>
                             </el-menu-item>
                         </div>
                     </el-menu>
@@ -97,15 +97,16 @@
 </template>
 
 <script>
-import { menuData } from "./mencCofig.js";
+// import { menuData } from "./mencCofig.js";
+import { mapState } from 'vuex';
 
 export default {
     data() {
         return {
             // 菜单配置
-            menuData,
+            menuData: [],
             menuCollapse: false, //是否水平折叠收起菜单
-            defaultUnfoldedMenu: [menuData[0].index], // 默认展开第一项
+            defaultUnfoldedMenu: '', // 默认展开第一项
             mainTitle: ''
         };
     },
@@ -126,53 +127,14 @@ export default {
         } else {
             target = localStorage.getItem("target");
         }
-        // this.filterMenu(target);
     },
-    watch: {
-        // "$route.query.target"(v) {
-        //     if (v) {
-        //         localStorage.setItem("target", v);
-        //         this.filterMenu(v);
-        //     }
-        // }
+    computed: {
+        ...mapState(['typeCode',]),
+        menu() {
+            return this.menuData;
+        }
     },
     methods: {
-        /*
-        http://hzsheep.ifarmcloud.com/butcher/#/home?target=定点屠宰智能管控
-        http://hzsheep.ifarmcloud.com/butcher/#/home?target=产品制作智能监控
-        http://hzsheep.ifarmcloud.com/butcher/#/home?target=鲜肉储运智能管控
-        http://hzsheep.ifarmcloud.com/yield/#/home/firmInfo
-        */
-        /* 筛选菜单 */
-        /*
-            http://localhost:8080/#/home?target=定点屠宰智能管控
-            http://localhost:8080/#/home?target=产品制作智能监控
-            http://localhost:8080/#/home?target=鲜肉储运智能管控
-        */
-        // filterMenu(target) {
-        //     let path;
-        //     switch (target) {
-        //         case "定点屠宰智能管控":
-        //             var func = (item, index) => index == 0 || index == 1;
-        //             path = "firmBuy";
-        //             this.mainTitle = '湖羊屠宰智能管控'
-        //             break;
-        //         case "产品制作智能监控":
-        //             var func = (item, index) => index == 2;
-        //             path = "productInfo";
-        //             this.mainTitle = '产品制作智能监控'
-        //             break;
-        //         case "鲜肉储运智能管控":
-        //             var func = (item, index) => index == 3;
-        //             path = "dispatching";
-        //             this.mainTitle = '鲜肉储运智能管控'
-        //             break;
-        //     }
-        //     this.menuData = menuData.filter(func);
-        //     if (path && path != this.$route.name) {
-        //         this.$router.push({ name: path });
-        //     }
-        // },
         // 收取菜单按钮
         onMenuCollapse() {
             this.menuCollapse = !this.menuCollapse;
@@ -191,14 +153,31 @@ export default {
         // 点击菜单项
         onClickMenu(item) {
             // 如果要跳转的路由和当前路由一致就 return
-            if (this.$router.history.current.name == item.routerName) return;
+            if (this.$router.history.current.name == item.menuName) return;
             this.$router.push({
-                name: item.routerName
+                name: item.url
             });
         },
         onLogOut() {
             this.$router.replace("login");
+        },
+        init() {
+            let accountName = localStorage.getItem('accountName');
+            let that = this;
+            this.$axios.post(`http://121.37.169.186:8081/auth/getMyMenu?accountName=${accountName}`)
+                    .then(res => {
+                        if(res.data.code === 10000) {
+                            res.data.data.forEach(item => {
+                                if(item.menuName === that.typeCode) {
+                                    that.menuData  = item.children;
+                                }
+                            });
+                        }
+                    });
         }
+    },
+    mounted() {
+        this.init();
     }
 };
 </script>

+ 3 - 3
src/views/Home/mencCofig.js

@@ -80,7 +80,7 @@ export const menuData = [
                 routerName: "sellRegister"
             },
             {
-                optionName: '屠宰直销',
+                    optionName: '屠宰直销',
                 routerName: "directSell"
             },
             {
@@ -89,7 +89,7 @@ export const menuData = [
             },
             {
                 optionName: '分割销售',
-                routerName: "splitSell"
+                    routerName: "splitSell"
             },
             {
                 optionName: '其他销售',
@@ -122,7 +122,7 @@ export const menuData = [
                 optionName: '羊杂登记',
                 routerName: "goatHasletLog"
             },
-            
+
         ]
     },
 

+ 20 - 10
src/views/Login/Login.vue

@@ -73,6 +73,15 @@ export default {
                 .catch(err => {
                     console.log("登录失败", err);
                 });
+            this.$axios.post(`http://121.37.169.186:8081/my/login?accountName=${this.form.userName}&password=${this.form.userPwd}`)
+                    .then(res => {
+                        loading.close();
+                        if(res.data.code === 10000) {
+                            localStorage.setItem('accountName', res.data.accountName);
+                        } else {
+                            this.$message.error(res.data.message);
+                        }
+                    })
         },
         handleSet: function() {
             if (!this.orgSelected) {
@@ -103,16 +112,17 @@ export default {
             this.loading = true;
             reqOrganizationId({orgId: id}).then(res => {
                 this.isShowDialog = false;
+                this.$router.replace ("/home/dashboard");
                     //导航到 正式页面
-                    console.log(999999)
-                    this.$router.push({
-                        path: "/home",
-                        query: {
-                            target: "定点屠宰智能管控"
-                            // target: "产品制作智能监控"
-                            // target: "鲜肉储运智能管控"
-                        }
-                    });
+                    // console.log(999999)
+                    // this.$router.push({
+                    //     path: "/home",
+                    //     query: {
+                    //         target: "定点屠宰智能管控"
+                    //         // target: "产品制作智能监控"
+                    //         // target: "鲜肉储运智能管控"
+                    //     }
+                    // });
             }).catch(err => {
                 if (err.errMsg) this.$message.error(err.errMsg);
                     else this.$message.error("服务器发生异常");
@@ -167,4 +177,4 @@ export default {
         }
     }
 }
-</style>
+</style>

+ 27 - 5
src/views/systemAdmin/authAdmin.vue

@@ -75,7 +75,7 @@
             <el-input v-model="form.groupName"></el-input>
           </el-form-item>
           <el-form-item label="备注">
-            <el-input v-model="form.remark"></el-input>
+            <el-input v-model="form.remark" disabled></el-input>
           </el-form-item>
         </el-form>
       </div>
@@ -143,6 +143,7 @@
 
 <script>
   import TableFooter from "../../components/TableFooter";
+  import { mapState } from 'vuex';
   export default {
     name: "authAdmin",
     components: {
@@ -157,7 +158,7 @@
         form: {
           id: '',
           groupName: '',
-          remark: '',
+          remark: '屠宰管理菜单',
         },
         dialogLimits: false,
         // 权限分配list
@@ -180,6 +181,9 @@
         userSelect: [],
       }
     },
+    computed: {
+      ...mapState(['typeCode'])
+    },
     methods: {
       // 搜索
       search() {
@@ -224,6 +228,10 @@
         .then(res => {
           if(res.data.code === 10006) {
             this.userSelect = [];
+            this.$nextTick(() => {
+              this.$refs.multipleTable.clearSelection();
+              this.$forceUpdate();
+            });
           } else {
             let arr = res.data.data.split(',');
             this.$nextTick(() => {
@@ -277,6 +285,7 @@
       // 权限分配
       limitSave() {
         let menuIds = this.selectList.join(',');
+        menuIds += ',136';
         this.$axios.post(`http://121.37.169.186:8081/auth/saveGroupMenu?groupId=${this.selectId}&menuIds=${menuIds}`)
         .then(res => {
           if(res.data.code === 10001) {
@@ -290,13 +299,21 @@
       init() {
         this.$axios.post(`http://121.37.169.186:8081/group/list?pageNum=${this.pageNum}&pageSize=${this.size}&searchStr=${this.keyword}`)
         .then(res => {
-          this.tableData = res.data.content;
+          let arr = [];
+          res.data.content.forEach(item => {
+            if(item.remark === this.typeCode) {
+              arr.push(item);
+            }
+          });
+          this.tableData = arr;
           this.total = res.data.totalElements;
         })
       },
       // 重置
       reset(){
-        this.form = {};
+        this.form.id = '';
+        this.form.groupName = '';
+        this.form.remark = '屠宰管理菜单';
         this.pageNum = 1;
         this.keyword = '';
         this.showType = false;
@@ -338,7 +355,12 @@
       authInit() {
         this.$axios.post('http://121.37.169.186:8081/menu/list')
           .then(res => {
-            this.limitList = res.data;
+            res.data.forEach(item => {
+              if(item.menuName === this.typeCode) {
+                this.limitList = item.children;
+              }
+            });
+            // this.limitList = res.data;
           })
       },
       // 用户列表

+ 20 - 20
src/views/systemAdmin/menuAdmin.vue

@@ -66,6 +66,7 @@
 </template>
 
 <script>
+  import { mapState } from 'vuex';
   export default {
     name: "menuAdmin",
     data() {
@@ -75,7 +76,7 @@
         dialogFormVisible: false,
         form: {
           name: '',
-          parentId: 0,
+          parentId: 136,
           url: '',
           id: '',
           remark: '',
@@ -85,6 +86,9 @@
         rules: []
       }
     },
+    computed: {
+      ...mapState(['typeCode'])
+    },
     methods: {
       add() {
         this.dialogFormVisible = false;
@@ -95,22 +99,14 @@
           remark: this.form.remark,
           sort: this.form.sort
         };
-        this.$axios.post('http://121.37.169.186:8081/menu/add', params)
-          .then(res => {
-              if(res.data.code === 10000) {
-                this.init();
-                this.reset();
-              }
-            this.$message(res.data.message);
-            this.dialogFormVisible = false;
-        // this.$axios.post(`http://192.168.1.6:8081/menu/add?parentId=${this.form.parentId}&menuName=${this.form.name}&url=${this.form.url}&remark=${this.form.remark}`)
-        //       .then(res => {
-        //         if(res.data.code === 10000) {
-        //           this.init();
-        //           this.reset();
-        //         }
-        //   this.$message(res.data.message);
-        //   this.dialogFormVisible = false;
+        this.$axios.post(`http://121.37.169.186:8081/menu/add?parentId=${this.form.parentId}&menuName=${this.form.name}&url=${this.form.url}&remark=${this.form.remark}`)
+              .then(res => {
+                if(res.data.code === 10000) {
+                  this.init();
+                  this.reset();
+                }
+          this.$message(res.data.message);
+          this.dialogFormVisible = false;
         })
       },
       setEdit(data) {
@@ -121,6 +117,7 @@
         this.form.url = data.url;
         this.form.parentId = data.parentId;
         this.form.remark = data.remark;
+        this.form.sort = data.sort;
       },
       addMenu() {
         this.dialogFormVisible = true;
@@ -132,7 +129,6 @@
       del(data) {
         let arr = [];
         arr.push(data.id);
-        console.log(arr.toString());
         this.$axios.post(`http://121.37.169.186:8081/menu/remove?menuId=${arr}`)
         .then(res => {
           if(res.data.code == 10000) {
@@ -155,7 +151,7 @@
       // 重置
       reset() {
         this.form.name = '';
-        this.form.parentId = 0;
+        this.form.parentId = 136;
         this.form.url = '';
         this.form.id = '';
         this.form.remark = '';
@@ -165,7 +161,11 @@
       init() {
         this.$axios.post('http://121.37.169.186:8081/menu/list')
         .then(res => {
-          this.tableData = res.data;
+          res.data.forEach(item => {
+            if(item.menuName === this.typeCode) {
+              this.tableData = item.children;
+            }
+          })
         })
       }
     },

+ 0 - 1
src/views/systemAdmin/userAdmin.vue

@@ -201,7 +201,6 @@
         this.form = data;
         this.showType = true;
         this.dialogVisible = true;
-        console.log(this.form);
       },
       // 用户删除
       del(data) {