瀏覽代碼

数据大盘,显示数据升降比值

zhuxinbo 5 年之前
父節點
當前提交
d819cdb526
共有 5 個文件被更改,包括 683 次插入542 次删除
  1. 75 74
      src/permission.js
  2. 129 128
      src/store/modules/user.js
  3. 148 126
      src/views/dashboard/Analysis.vue
  4. 143 28
      src/views/modules/Statistics/Statistics.vue
  5. 188 186
      src/views/system/PermissionList.vue

+ 75 - 74
src/permission.js

@@ -1,74 +1,75 @@
-import Vue from 'vue'
-import router from './router'
-import store from './store'
-import NProgress from 'nprogress' // progress bar
-import 'nprogress/nprogress.css' // progress bar style
-import notification from 'ant-design-vue/es/notification'
-import {ACCESS_TOKEN} from '@/store/mutation-types'
-import {generateIndexRouter} from "@/utils/util"
-
-NProgress.configure({showSpinner: false}) // NProgress Configuration
-
-
-const whiteList = ['/user/login', '/user/register', '/user/register-result', '/user/alteration'] // no redirect whitelist
-
-router.beforeEach((to, from, next) => {
-  NProgress.start() // start progress bar
-
-  if (Vue.ls.get(ACCESS_TOKEN)) {
-    /* has token */
-    if (to.path === '/user/login') {
-      next({path: '/dashboard/workplace'})
-      NProgress.done()
-    } else {
-      if (store.getters.permissionList.length === 0) {
-        store.dispatch('GetPermissionList').then(res => {
-          const menuData = res.result.menu;
-          console.log(res.message)
-          if (menuData === null || menuData === "" || menuData === undefined) {
-            return;
-          }
-          let constRoutes = [];
-          constRoutes = generateIndexRouter(menuData);
-          // 添加主界面路由
-          store.dispatch('UpdateAppRouter', {constRoutes}).then(() => {
-            // 根据roles权限生成可访问的路由表
-            // 动态添加可访问路由表
-            router.addRoutes(store.getters.addRouters)
-            const redirect = decodeURIComponent(from.query.redirect || to.path)
-            if (to.path === redirect) {
-              // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
-              next({...to, replace: true})
-            } else {
-              // 跳转到目的路由
-              next({path: redirect})
-            }
-          })
-        })
-          .catch(() => {
-            /* notification.error({
-               message: '系统提示',
-               description: '请求用户信息失败,请重试!'
-             })*/
-            store.dispatch('Logout').then(() => {
-              next({path: '/user/login', query: {redirect: to.fullPath}})
-            })
-          })
-      } else {
-        next()
-      }
-    }
-  } else {
-    if (whiteList.indexOf(to.path) !== -1) {
-      // 在免登录白名单,直接进入
-      next()
-    } else {
-      next({path: '/user/login', query: {redirect: to.fullPath}})
-      NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
-    }
-  }
-})
-
-router.afterEach(() => {
-  NProgress.done() // finish progress bar
-})
+import Vue from 'vue'
+import router from './router'
+import store from './store'
+import NProgress from 'nprogress' // progress bar
+import 'nprogress/nprogress.css' // progress bar style
+import notification from 'ant-design-vue/es/notification'
+import {ACCESS_TOKEN} from '@/store/mutation-types'
+import {generateIndexRouter} from "@/utils/util"
+
+NProgress.configure({showSpinner: false}) // NProgress Configuration
+
+
+const whiteList = ['/user/login', '/user/register', '/user/register-result', '/user/alteration'] // no redirect whitelist
+
+router.beforeEach((to, from, next) => {
+  NProgress.start() // start progress bar
+
+  if (Vue.ls.get(ACCESS_TOKEN)) {
+    /* has token */
+    if (to.path === '/user/login') {
+      next({path: '/dashboard/workplace'})
+      NProgress.done()
+    } else {
+      if (store.getters.permissionList.length === 0) {
+        store.dispatch('GetPermissionList').then(res => {
+          const menuData = res.result.menu;
+          localStorage.setItem("roleCode",res.result.roleCode)
+          console.log(res.message)
+          if (menuData === null || menuData === "" || menuData === undefined) {
+            return;
+          }
+          let constRoutes = [];
+          constRoutes = generateIndexRouter(menuData);
+          // 添加主界面路由
+          store.dispatch('UpdateAppRouter', {constRoutes}).then(() => {
+            // 根据roles权限生成可访问的路由表
+            // 动态添加可访问路由表
+            router.addRoutes(store.getters.addRouters)
+            const redirect = decodeURIComponent(from.query.redirect || to.path)
+            if (to.path === redirect) {
+              // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
+              next({...to, replace: true})
+            } else {
+              // 跳转到目的路由
+              next({path: redirect})
+            }
+          })
+        })
+          .catch(() => {
+            /* notification.error({
+               message: '系统提示',
+               description: '请求用户信息失败,请重试!'
+             })*/
+            store.dispatch('Logout').then(() => {
+              next({path: '/user/login', query: {redirect: to.fullPath}})
+            })
+          })
+      } else {
+        next()
+      }
+    }
+  } else {
+    if (whiteList.indexOf(to.path) !== -1) {
+      // 在免登录白名单,直接进入
+      next()
+    } else {
+      next({path: '/user/login', query: {redirect: to.fullPath}})
+      NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
+    }
+  }
+})
+
+router.afterEach(() => {
+  NProgress.done() // finish progress bar
+})

+ 129 - 128
src/store/modules/user.js

@@ -1,129 +1,130 @@
-import Vue from 'vue'
-import {login, logout, phoneLogin} from "@/api/login"
-import {ACCESS_TOKEN, USER_NAME, USER_INFO, USER_AUTH, SYS_BUTTON_AUTH} from "@/store/mutation-types"
-import {welcome} from "@/utils/util"
-import {queryPermissionsByUser} from '@/api/api'
-
-const user = {
-  state: {
-    token: '',
-    username: '',
-    realname: '',
-    welcome: '',
-    avatar: '',
-    orgcode : '',
-    permissionList: [],
-    info: {}
-  },
-
-  mutations: {
-    SET_TOKEN: (state, token) => {
-      state.token = token
-    },
-    SET_NAME: (state, {username, realname, welcome}) => {
-      state.username = username
-      state.realname = realname
-      state.welcome = welcome
-    },
-    SET_AVATAR: (state, avatar) => {
-      state.avatar = avatar
-    },
-    SET_PERMISSIONLIST: (state, permissionList) => {
-      state.permissionList = permissionList
-    },
-    SET_INFO: (state, info) => {
-      state.info = info
-    },
-  },
-
-  actions: {
-    // 登录
-    Login({commit}, userInfo) {
-      return new Promise((resolve, reject) => {
-        login(userInfo).then(response => {
-          if (response.code == '200') {
-            const result = response.result
-            const userInfo = result.userInfo
-            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
-            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
-            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
-            commit('SET_TOKEN', result.token)
-            commit('SET_INFO', userInfo)
-            commit('SET_NAME', {username: userInfo.username, realname: userInfo.realname, welcome: welcome()})
-            commit('SET_AVATAR', userInfo.avatar)
-            resolve(response)
-          } else {
-            reject(response)
-          }
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-    //手机号登录
-    PhoneLogin({commit}, userInfo) {
-      return new Promise((resolve, reject) => {
-        phoneLogin(userInfo).then(response => {
-          if (response.code == '200') {
-            const result = response.result
-            const userInfo = result.userInfo
-            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
-            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
-            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
-            commit('SET_TOKEN', result.token)
-            commit('SET_INFO', userInfo)
-            commit('SET_NAME', {username: userInfo.username, realname: userInfo.realname, welcome: welcome()})
-            commit('SET_AVATAR', userInfo.avatar)
-            resolve(response)
-          } else {
-            reject(response)
-          }
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-    // 获取用户信息
-    GetPermissionList({commit}) {
-      return new Promise((resolve, reject) => {
-        let v_token = Vue.ls.get(ACCESS_TOKEN);
-        let params = {token: v_token};
-        queryPermissionsByUser(params).then(response => {
-          const menuData = response.result.menu;
-          const authData = response.result.auth;
-          const allAuthData = response.result.allAuth;
-          //Vue.ls.set(USER_AUTH,authData);
-          sessionStorage.setItem(USER_AUTH, JSON.stringify(authData));
-          sessionStorage.setItem(SYS_BUTTON_AUTH, JSON.stringify(allAuthData));
-          if (menuData && menuData.length > 0) {
-            commit('SET_PERMISSIONLIST', menuData)
-          } else {
-            reject('getPermissionList: permissions must be a non-null array !')
-          }
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-
-    // 登出
-    Logout({commit, state}) {
-      return new Promise((resolve) => {
-        let logoutToken = state.token;
-        commit('SET_TOKEN', '')
-        commit('SET_PERMISSIONLIST', [])
-        Vue.ls.remove(ACCESS_TOKEN)
-        //console.log('logoutToken: '+ logoutToken)
-        logout(logoutToken).then(() => {
-          resolve()
-        }).catch(() => {
-          resolve()
-        })
-      })
-    },
-
-  }
-}
-
+import Vue from 'vue'
+import {login, logout, phoneLogin} from "@/api/login"
+import {ACCESS_TOKEN, USER_NAME, USER_INFO, USER_AUTH, SYS_BUTTON_AUTH} from "@/store/mutation-types"
+import {welcome} from "@/utils/util"
+import {queryPermissionsByUser} from '@/api/api'
+
+const user = {
+  state: {
+    token: '',
+    username: '',
+    realname: '',
+    welcome: '',
+    avatar: '',
+    orgcode : '',
+    permissionList: [],
+    info: {}
+  },
+
+  mutations: {
+    SET_TOKEN: (state, token) => {
+      state.token = token
+    },
+    SET_NAME: (state, {username, realname, welcome}) => {
+      state.username = username
+      state.realname = realname
+      state.welcome = welcome
+    },
+    SET_AVATAR: (state, avatar) => {
+      state.avatar = avatar
+    },
+    SET_PERMISSIONLIST: (state, permissionList) => {
+      state.permissionList = permissionList
+    },
+    SET_INFO: (state, info) => {
+      state.info = info
+    },
+  },
+
+  actions: {
+    // 登录
+    Login({commit}, userInfo) {
+      return new Promise((resolve, reject) => {
+        login(userInfo).then(response => {
+          if (response.code == '200') {
+            const result = response.result
+            const userInfo = result.userInfo
+            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+            commit('SET_TOKEN', result.token)
+            commit('SET_INFO', userInfo)
+            commit('SET_NAME', {username: userInfo.username, realname: userInfo.realname, welcome: welcome()})
+            commit('SET_AVATAR', userInfo.avatar)
+            resolve(response)
+          } else {
+            reject(response)
+          }
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+    //手机号登录
+    PhoneLogin({commit}, userInfo) {
+      return new Promise((resolve, reject) => {
+        phoneLogin(userInfo).then(response => {
+          if (response.code == '200') {
+            const result = response.result
+            const userInfo = result.userInfo
+            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+            commit('SET_TOKEN', result.token)
+            commit('SET_INFO', userInfo)
+            commit('SET_NAME', {username: userInfo.username, realname: userInfo.realname, welcome: welcome()})
+            commit('SET_AVATAR', userInfo.avatar)
+            resolve(response)
+          } else {
+            reject(response)
+          }
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+    // 获取用户信息
+    GetPermissionList({commit}) {
+      return new Promise((resolve, reject) => {
+        let v_token = Vue.ls.get(ACCESS_TOKEN);
+        let params = {token: v_token};
+        queryPermissionsByUser(params).then(response => {
+          const menuData = response.result.menu;
+          const authData = response.result.auth;
+          const allAuthData = response.result.allAuth;
+          //Vue.ls.set(USER_AUTH,authData);
+          sessionStorage.setItem(USER_AUTH, JSON.stringify(authData));
+          sessionStorage.setItem(SYS_BUTTON_AUTH, JSON.stringify(allAuthData));
+          if (menuData && menuData.length > 0) {
+            commit('SET_PERMISSIONLIST', menuData)
+          } else {
+            reject('getPermissionList: permissions must be a non-null array !')
+          }
+          resolve(response)
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+
+    // 登出
+    Logout({commit, state}) {
+      return new Promise((resolve) => {
+        let logoutToken = state.token;
+        commit('SET_TOKEN', '')
+        commit('SET_PERMISSIONLIST', [])
+        Vue.ls.remove(ACCESS_TOKEN)
+        localStorage.removeItem("roleCode")
+        //console.log('logoutToken: '+ logoutToken)
+        logout(logoutToken).then(() => {
+          resolve()
+        }).catch(() => {
+          resolve()
+        })
+      })
+    },
+
+  }
+}
+
 export default user

+ 148 - 126
src/views/dashboard/Analysis.vue

@@ -1,143 +1,164 @@
 <template>
   <div class="page-header-index-wide">
-    <!-- <a-row :gutter="24">
-      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
-        <chart-card :loading="loading" title="总销售额" total="¥126,560">
-          <a-tooltip title="指标说明" slot="action">
-            <a-icon type="info-circle-o"/>
-          </a-tooltip>
-          <div>
-            <trend flag="up" style="margin-right: 16px;">
-              <span slot="term">周同比</span>
-              12%
-            </trend>
-            <trend flag="down">
-              <span slot="term">日同比</span>
-              11%
-            </trend>
-          </div>
-          <template slot="footer">日均销售额<span>¥ 234.56</span></template>
-        </chart-card>
-      </a-col>
-      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
-        <chart-card :loading="loading" title="访问量" :total="8846 | NumberFormat">
-          <a-tooltip title="指标说明" slot="action">
-            <a-icon type="info-circle-o"/>
-          </a-tooltip>
-          <div>
-            <mini-area/>
-          </div>
-          <template slot="footer">日访问量<span> {{ '1234' | NumberFormat }}</span></template>
-        </chart-card>
-      </a-col>
-      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
-        <chart-card :loading="loading" title="支付笔数" :total="6560 | NumberFormat">
-          <a-tooltip title="指标说明" slot="action">
-            <a-icon type="info-circle-o"/>
-          </a-tooltip>
-          <div>
-            <mini-bar :height="40"/>
-          </div>
-          <template slot="footer">转化率 <span>60%</span></template>
-        </chart-card>
-      </a-col>
-      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
-        <chart-card :loading="loading" title="运营活动效果" total="78%">
-          <a-tooltip title="指标说明" slot="action">
-            <a-icon type="info-circle-o"/>
-          </a-tooltip>
-          <div>
-            <mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" :height="8"/>
-          </div>
-          <template slot="footer">
-            <trend flag="down" style="margin-right: 16px;">
-              <span slot="term">同周比</span>
-              12%
-            </trend>
-            <trend flag="up">
-              <span slot="term">日环比</span>
-              80%
-            </trend>
-          </template>
-        </chart-card>
-      </a-col>
-    </a-row>
+    <div v-if="roleCode == 'operator'">
+      <a-row :gutter="24">
+        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
+          <chart-card :loading="loading" title="总销售额" total="¥126,560">
+            <a-tooltip title="指标说明" slot="action">
+              <a-icon type="info-circle-o" />
+            </a-tooltip>
+            <div>
+              <trend flag="up" style="margin-right: 16px;">
+                <span slot="term">周同比</span>
+                12%
+              </trend>
+              <trend flag="down">
+                <span slot="term">日同比</span>
+                11%
+              </trend>
+            </div>
+            <template slot="footer">
+              日均销售额
+              <span>¥ 234.56</span>
+            </template>
+          </chart-card>
+        </a-col>
+        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
+          <chart-card :loading="loading" title="访问量" :total="8846 | NumberFormat">
+            <a-tooltip title="指标说明" slot="action">
+              <a-icon type="info-circle-o" />
+            </a-tooltip>
+            <div>
+              <mini-area />
+            </div>
+            <template slot="footer">
+              日访问量
+              <span>{{ '1234' | NumberFormat }}</span>
+            </template>
+          </chart-card>
+        </a-col>
+        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
+          <chart-card :loading="loading" title="支付笔数" :total="6560 | NumberFormat">
+            <a-tooltip title="指标说明" slot="action">
+              <a-icon type="info-circle-o" />
+            </a-tooltip>
+            <div>
+              <mini-bar :height="40" />
+            </div>
+            <template slot="footer">
+              转化率
+              <span>60%</span>
+            </template>
+          </chart-card>
+        </a-col>
+        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
+          <chart-card :loading="loading" title="运营活动效果" total="78%">
+            <a-tooltip title="指标说明" slot="action">
+              <a-icon type="info-circle-o" />
+            </a-tooltip>
+            <div>
+              <mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" :height="8" />
+            </div>
+            <template slot="footer">
+              <trend flag="down" style="margin-right: 16px;">
+                <span slot="term">同周比</span>
+                12%
+              </trend>
+              <trend flag="up">
+                <span slot="term">日环比</span>
+                80%
+              </trend>
+            </template>
+          </chart-card>
+        </a-col>
+      </a-row>
 
-    <a-card :loading="loading" :bordered="false" :body-style="{padding: '0'}">
-      <div class="salesCard">
-        <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
-          <div class="extra-wrapper" slot="tabBarExtraContent">
-            <div class="extra-item">
-              <a>今日</a>
-              <a>本周</a>
-              <a>本月</a>
-              <a>本年</a>
+      <a-card :loading="loading" :bordered="false" :body-style="{padding: '0'}">
+        <div class="salesCard">
+          <a-tabs
+            default-active-key="1"
+            size="large"
+            :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}"
+          >
+            <div class="extra-wrapper" slot="tabBarExtraContent">
+              <div class="extra-item">
+                <a>今日</a>
+                <a>本周</a>
+                <a>本月</a>
+                <a>本年</a>
+              </div>
+              <a-range-picker :style="{width: '256px'}" />
             </div>
-            <a-range-picker :style="{width: '256px'}"/>
-          </div>
-          <a-tab-pane loading="true" tab="销售额" key="1">
+            <a-tab-pane loading="true" tab="销售额" key="1">
+              <a-row>
+                <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
+                  <bar title="销售额排行" :dataSource="barData" />
+                </a-col>
+                <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
+                  <rank-list title="门店销售排行榜" :list="rankList" />
+                </a-col>
+              </a-row>
+            </a-tab-pane>
+            <a-tab-pane tab="访问量" key="2">
+              <a-row>
+                <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
+                  <bar title="销售额趋势" :dataSource="barData" />
+                </a-col>
+                <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
+                  <rank-list title="门店销售排行榜" :list="rankList" />
+                </a-col>
+              </a-row>
+            </a-tab-pane>
+          </a-tabs>
+        </div>
+      </a-card>
+
+      <a-row>
+        <a-col :span="24">
+          <a-card
+            :loading="loading"
+            :bordered="false"
+            title="最近一周访问次数统计"
+            :style="{ marginTop: '24px' }"
+          >
             <a-row>
-              <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
-                <bar title="销售额排行" :dataSource="barData"/>
+              <a-col :span="6">
+                <head-info title="今日访问IP数" :content="loginfo.todayIp"></head-info>
               </a-col>
-              <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
-                <rank-list title="门店销售排行榜" :list="rankList"/>
+              <a-col :span="2">
+                <a-spin class="circle-cust">
+                  <a-icon slot="indicator" type="environment" style="font-size: 24px" />
+                </a-spin>
               </a-col>
-            </a-row>
-          </a-tab-pane>
-          <a-tab-pane tab="访问量" key="2">
-            <a-row>
-              <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
-                <bar title="销售额趋势" :dataSource="barData"/>
+              <a-col :span="6">
+                <head-info title="今日访问次数" :content="loginfo.todayVisitCount"></head-info>
+              </a-col>
+              <a-col :span="2">
+                <a-spin class="circle-cust">
+                  <a-icon slot="indicator" type="team" style="font-size: 24px" />
+                </a-spin>
               </a-col>
-              <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
-                <rank-list title="门店销售排行榜" :list="rankList"/>
+              <a-col :span="6">
+                <head-info title="访问总次数" :content="loginfo.totalVisitCount"></head-info>
+              </a-col>
+              <a-col :span="2">
+                <a-spin class="circle-cust">
+                  <a-icon slot="indicator" type="rise" style="font-size: 24px" />
+                </a-spin>
               </a-col>
             </a-row>
-          </a-tab-pane>
-        </a-tabs>
-      </div>
-    </a-card>
+            <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
+          </a-card>
+        </a-col>
+      </a-row>
+    </div>
 
-    <a-row>
-      <a-col :span="24">
-        <a-card :loading="loading" :bordered="false" title="最近一周访问次数统计" :style="{ marginTop: '24px' }">
-          <a-row>
-            <a-col :span="6">
-              <head-info title="今日访问IP数" :content="loginfo.todayIp"></head-info>
-            </a-col>
-            <a-col :span="2">
-              <a-spin class='circle-cust'>
-                <a-icon slot="indicator" type="environment" style="font-size: 24px"/>
-              </a-spin>
-            </a-col>
-            <a-col :span="6">
-              <head-info title="今日访问次数" :content="loginfo.todayVisitCount"></head-info>
-            </a-col>
-            <a-col :span="2">
-              <a-spin class='circle-cust'>
-                <a-icon slot="indicator" type="team" style="font-size: 24px"/>
-              </a-spin>
-            </a-col>
-            <a-col :span="6">
-              <head-info title="访问总次数" :content="loginfo.totalVisitCount"></head-info>
-            </a-col>
-            <a-col :span="2">
-              <a-spin class='circle-cust'>
-                <a-icon slot="indicator" type="rise" style="font-size: 24px"/>
-              </a-spin>
-            </a-col>
-          </a-row>
-          <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
-        </a-card>
-      </a-col>
-    </a-row>-->
-    <statistics />
+    <statistics v-else-if="roleCode == 'kuaishouOperationManager'" />
+    <statistics v-else-if="roleCode == 'admin'" />
   </div>
 </template>
 
 <script>
-
 import ChartCard from '@/components/ChartCard'
 import ACol from 'ant-design-vue/es/grid/Col'
 import ATooltip from 'ant-design-vue/es/tooltip/Tooltip'
@@ -192,7 +213,8 @@ export default {
       loginfo: {},
       visitFields: ['ip', 'visit'],
       visitInfo: [],
-      indicator: <a-icon type="loading" style="font-size: 24px" spin />
+      indicator: <a-icon type="loading" style="font-size: 24px" spin />,
+      roleCode: localStorage.getItem('roleCode')
     }
   },
   created() {

+ 143 - 28
src/views/modules/Statistics/Statistics.vue

@@ -19,7 +19,7 @@
 .search-box .ant-card-body {
   padding: 5px 15px;
 }
-.search-box  p {
+.search-box p {
   display: inline-block;
   border: 1px solid #f2f2f2;
   border-radius: 5px;
@@ -369,7 +369,7 @@
             :activeTabKey="noTitleKeyTableTwo"
             @tabChange="key => onTabChange(key, 'noTitleKeyTableTwo')"
           >
-            <a-table :columns="columns" :dataSource="dataTableTwo" :pagination="false"></a-table>
+            <a-table :columns="columnsDb" :dataSource="dataTableTwo" :pagination="false"></a-table>
           </a-card>
         </a-col>
       </a-row>
@@ -419,6 +419,14 @@ export default {
     return {
       columns: [
         { title: '时间', dataIndex: 'statDate' },
+        { title: '升降值', dataIndex: 'proportion' },
+        { title: '总消耗', dataIndex: 'cost' },
+        { title: '封面点击数', dataIndex: 'photoClick' },
+        { title: '封面曝光数', dataIndex: 'photoShow' },
+        { title: '素材曝光数', dataIndex: 'aclick' }
+      ],
+      columnsDb: [
+        { title: '时间', dataIndex: 'statDate' },
         { title: '总消耗', dataIndex: 'cost' },
         { title: '封面点击数', dataIndex: 'photoClick' },
         { title: '封面曝光数', dataIndex: 'photoShow' },
@@ -428,6 +436,7 @@ export default {
       dataTableTwo: [],
       dataAllTableTwo: null,
       dataAllTable: null,
+      dataAllTableYester: null,
       title: '快手大盘',
       visible: false,
       statistics: [],
@@ -579,18 +588,48 @@ export default {
         params.startDate = dateValue[0]
         params.endDate = dateValue[1]
       }
-      getReportList(params).then(res => {
-        if (this.active == 1) {
-          this.dataAllTable = res[0]
-          this.dataTable = res[0].now.map((item, index) => {
-            return {
-              key: index,
-              ...item,
-              statDate:
-                this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
+      //   proportion
+      if (this.active == 1) {
+        getKsDetail(params).then(res => {
+          var nDate = res.filter(item => {
+            if (item.now) {
+              return item.now.statDate
             }
           })
-        } else {
+          console.log(nDate)
+          this.dataTable = res.map((item, index) => {
+            if (item.now) {
+              console.log(item.now)
+              return {
+                key: index,
+                ...item.now,
+                statDate:
+                  this.active == 1 || this.active == 2
+                    ? item.now.statDate + ' ' + item.now.statHour + '时'
+                    : item.now.statDate,
+                proportion: (item.now.proportion * 100).toFixed(2) + '%'
+              }
+            } else {
+              return {
+                key: index,
+                cost: 0,
+                photoClick: 0,
+                photoShow: 0,
+                aclick: 0,
+                statDate:
+                  this.active == 1 || this.active == 2
+                    ? nDate[0].now.statDate + ' ' + item.statHour + '时'
+                    : nDate[0].now.statDate,
+                proportion: 0
+              }
+            }
+          })
+          this.dataAllTable = this.dataTable
+          this.dataAllTableYester = res
+          console.log(this.dataTable)
+        })
+      } else {
+        getReportList(params).then(res => {
           this.dataTable = res.map((item, index) => {
             return {
               key: index,
@@ -599,8 +638,9 @@ export default {
                 this.active == 1 || this.active == 2 ? item.statDate + ' ' + item.statHour + '时' : item.statDate
             }
           })
-        }
-      })
+          //   }
+        })
+      }
     },
     drawPieAll(data) {
       var colorList = ['#afa3f5', '#00d488', '#3feed4', '#3bafff', '#f1bb4c', 'rgba(250,250,250,0.5)']
@@ -860,15 +900,24 @@ export default {
       } else if (type == 'noTitleKeyTable') {
         this.dataTable = []
         if (key == 'now') {
-          this.dataTable = this.dataAllTable.now.map((item, index) => {
-            return {
-              key: index,
-              ...item,
-              statDate: item.statDate + ' ' + item.statHour + '时'
-            }
-          })
+          this.columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '升降值', dataIndex: 'proportion' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
+          this.dataTable = this.dataAllTable
         } else {
-          this.dataTable = this.dataAllTable.yesterday.map((item, index) => {
+          this.columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
+          this.dataTable = this.dataAllTableYester.map((item, index) => {
             return {
               key: index,
               ...item,
@@ -928,6 +977,7 @@ export default {
           tab: '昨天'
         }
       ]
+      var columns = []
       switch (checked) {
         case 1:
           arr = [
@@ -940,6 +990,14 @@ export default {
               tab: '昨天'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '升降值', dataIndex: 'proportion' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 2:
           arr = [
@@ -948,6 +1006,13 @@ export default {
               tab: '昨天'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 3:
           arr = [
@@ -956,6 +1021,13 @@ export default {
               tab: '近一周'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 4:
           arr = [
@@ -964,6 +1036,13 @@ export default {
               tab: '近十五天'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 5:
           arr = [
@@ -972,6 +1051,13 @@ export default {
               tab: '近一月'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 6:
           arr = [
@@ -980,6 +1066,13 @@ export default {
               tab: '近三月'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 7:
           arr = [
@@ -988,6 +1081,13 @@ export default {
               tab: '近半年'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 8:
           arr = [
@@ -996,6 +1096,13 @@ export default {
               tab: '所有'
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
         case 9:
           arr = [
@@ -1004,9 +1111,17 @@ export default {
               tab: this.allValue[1] + ' ~ ' + this.allValue[0]
             }
           ]
+          columns = [
+            { title: '时间', dataIndex: 'statDate' },
+            { title: '总消耗', dataIndex: 'cost' },
+            { title: '封面点击数', dataIndex: 'photoClick' },
+            { title: '封面曝光数', dataIndex: 'photoShow' },
+            { title: '素材曝光数', dataIndex: 'aclick' }
+          ]
           break
       }
       this.tableNowCard = arr
+      this.columns = columns
       this.getReportList(checked, this.allValue)
       this.drawLine(checked, this.allValue)
       this.getKsDetail(checked, this.allValue).then(res => {
@@ -1060,16 +1175,16 @@ export default {
       var dataDate = []
       var that = this
       if (this.active == 1 || this.active == 2) {
-        data.sort(function(a, b) {
-          return a.statHour - b.statHour
-        })
+        // data.sort(function(a, b) {
+        //   return a.statHour - b.statHour
+        // })
         dataDate = data.map(item => {
           return item.statHour
         })
       } else {
-        data.sort(function(a, b) {
-          return a.statDate - b.statDate
-        })
+        // data.sort(function(a, b) {
+        //   return a.statDate - b.statDate
+        // })
         dataDate = data.map(item => {
           return item.statDate
         })

+ 188 - 186
src/views/system/PermissionList.vue

@@ -1,187 +1,189 @@
-<template>
-  <a-card :bordered="false">
-
-    <!-- 操作按钮区域 -->
-    <div class="table-operator">
-      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
-      <a-button
-        @click="batchDel"
-        v-if="selectedRowKeys.length > 0"
-        ghost
-        type="primary"
-        icon="delete">批量删除
-      </a-button>
-    </div>
-
-    <!-- table区域-begin -->
-    <div>
-
-      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
-        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
-        selectedRowKeys.length }}</a>项&nbsp;&nbsp;
-        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
-      </div>
-
-      <a-table
-        :columns="columns"
-        size="middle"
-        :pagination="false"
-        :dataSource="dataSource"
-        :loading="loading"
-        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
-
-        <span slot="action" slot-scope="text, record">
-          <a @click="handleEdit(record)">编辑</a>
-
-          <a-divider type="vertical"/>
-          <a-dropdown>
-            <a class="ant-dropdown-link">
-              更多 <a-icon type="down"/>
-            </a>
-            <a-menu slot="overlay">
-              <a-menu-item>
-                <a href="javascript:;" @click="handleDetail(record)">详情</a>
-              </a-menu-item>
-              <a-menu-item>
-                <a href="javascript:;" @click="handleAddSub(record)">添加子菜单</a>
-              </a-menu-item>
-              <a-menu-item>
-                <a href="javascript:;" @click="handleDataRule(record)">数据规则</a>
-              </a-menu-item>
-
-              <a-menu-item>
-                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
-                  <a>删除</a>
-                </a-popconfirm>
-              </a-menu-item>
-            </a-menu>
-          </a-dropdown>
-        </span>
-        <!-- 字符串超长截取省略号显示 -->
-        <span slot="url" slot-scope="text">
-          <j-ellipsis :value="text" :length="25"/>
-        </span>
-        <!-- 字符串超长截取省略号显示-->
-        <span slot="component" slot-scope="text">
-          <j-ellipsis :value="text"/>
-        </span>
-      </a-table>
-
-    </div>
-    <!-- table区域-end -->
-
-    <permission-modal ref="modalForm" @ok="modalFormOk"></permission-modal>
-    <permission-data-rule-list ref="PermissionDataRuleList" @ok="modalFormOk"></permission-data-rule-list>
-
-  </a-card>
-</template>
-
-<script>
-  import PermissionModal from './modules/PermissionModal'
-  import {getPermissionList} from '@/api/api'
-  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
-  import PermissionDataRuleList from './PermissionDataRuleList'
-  import JEllipsis from '@/components/jeecg/JEllipsis'
-
-  const columns = [
-    {
-      title: '菜单名称',
-      dataIndex: 'name',
-      key: 'name'
-    }, {
-      title: '菜单类型',
-      dataIndex: 'menuType',
-      key: 'menuType',
-      customRender: function (text) {
-        if (text == 0) {
-          return '菜单'
-        } else if (text == 1) {
-          return '菜单'
-        } else if (text == 2) {
-          return '按钮'
-        } else {
-          return text
-        }
-      }
-    },/*{
-      title: '权限编码',
-      dataIndex: 'perms',
-      key: 'permissionCode',
-    },*/{
-      title: 'icon',
-      dataIndex: 'icon',
-      key: 'icon'
-    },
-    {
-      title: '组件',
-      dataIndex: 'component',
-      key: 'component',
-      scopedSlots: {customRender: 'component'}
-    },
-    {
-      title: '路径',
-      dataIndex: 'url',
-      key: 'url',
-      scopedSlots: {customRender: 'url'}
-    },
-    {
-      title: '排序',
-      dataIndex: 'sortNo',
-      key: 'sortNo'
-    },
-    {
-      title: '操作',
-      dataIndex: 'action',
-      scopedSlots: {customRender: 'action'},
-      align: 'center',
-      width: 150
-    }
-  ]
-
-  export default {
-    name: 'PermissionList',
-    mixins: [JeecgListMixin],
-    components: {
-      PermissionDataRuleList,
-      PermissionModal,
-      JEllipsis
-    },
-    data() {
-      return {
-        description: '这是菜单管理页面',
-        // 表头
-        columns: columns,
-        loading: false,
-        url: {
-          list: '/sys/permission/list',
-          delete: '/sys/permission/delete',
-          deleteBatch: '/sys/permission/deleteBatch'
-        }
-      }
-    },
-    methods: {
-      loadData() {
-        this.dataSource = []
-        getPermissionList().then((res) => {
-          if (res.success) {
-            console.log(res.result)
-            this.dataSource = res.result
-          }
-        })
-      },
-      // 打开数据规则编辑
-      handleDataRule(record) {
-        this.$refs.PermissionDataRuleList.edit(record)
-      },
-      handleAddSub(record) {
-        this.$refs.modalForm.title = "添加子菜单";
-        this.$refs.modalForm.localMenuType = 1;
-        this.$refs.modalForm.disableSubmit = false;
-        this.$refs.modalForm.edit({status: '1', permsType: '1', route: true, 'parentId': record.id});
-      }
-    }
-  }
-</script>
-<style scoped>
-  @import '~@assets/less/common.less'
+<template>
+  <a-card :bordered="false">
+
+    <!-- 操作按钮区域 -->
+    <div class="table-operator">
+      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
+      <a-button
+        @click="batchDel"
+        v-if="selectedRowKeys.length > 0"
+        ghost
+        type="primary"
+        icon="delete">批量删除
+      </a-button>
+    </div>
+
+    <!-- table区域-begin -->
+    <div>
+
+      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
+        selectedRowKeys.length }}</a>项&nbsp;&nbsp;
+        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+      </div>
+
+      <a-table
+        :columns="columns"
+        size="middle"
+        :pagination="false"
+        :dataSource="dataSource"
+        :loading="loading"
+        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
+
+        <span slot="action" slot-scope="text, record">
+          <a @click="handleEdit(record)">编辑</a>
+
+          <a-divider type="vertical"/>
+          <a-dropdown>
+            <a class="ant-dropdown-link">
+              更多 <a-icon type="down"/>
+            </a>
+            <a-menu slot="overlay">
+              <a-menu-item>
+                <a href="javascript:;" @click="handleDetail(record)">详情</a>
+              </a-menu-item>
+              <a-menu-item>
+                <a href="javascript:;" @click="handleAddSub(record)">添加子菜单</a>
+              </a-menu-item>
+              <a-menu-item>
+                <a href="javascript:;" @click="handleDataRule(record)">数据规则</a>
+              </a-menu-item>
+
+              <a-menu-item>
+                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+                  <a>删除</a>
+                </a-popconfirm>
+              </a-menu-item>
+            </a-menu>
+          </a-dropdown>
+        </span>
+        <!-- 字符串超长截取省略号显示 -->
+        <span slot="url" slot-scope="text">
+          <j-ellipsis :value="text" :length="25"/>
+        </span>
+        <!-- 字符串超长截取省略号显示-->
+        <span slot="component" slot-scope="text">
+          <j-ellipsis :value="text"/>
+        </span>
+      </a-table>
+
+    </div>
+    <!-- table区域-end -->
+
+    <permission-modal ref="modalForm" @ok="modalFormOk"></permission-modal>
+    <permission-data-rule-list ref="PermissionDataRuleList" @ok="modalFormOk"></permission-data-rule-list>
+
+  </a-card>
+</template>
+
+<script>
+  import PermissionModal from './modules/PermissionModal'
+  import {getPermissionList} from '@/api/api'
+  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
+  import PermissionDataRuleList from './PermissionDataRuleList'
+  import JEllipsis from '@/components/jeecg/JEllipsis'
+
+  const columns = [
+    {
+      title: '菜单名称',
+      dataIndex: 'name',
+      key: 'name'
+    }, {
+      title: '菜单类型',
+      dataIndex: 'menuType',
+      key: 'menuType',
+      customRender: function (text) {
+        if (text == 0) {
+          return '菜单'
+        } else if (text == 1) {
+          return '菜单'
+        } else if (text == 2) {
+          return '按钮'
+        } else {
+          return text
+        }
+      }
+    },/*{
+      title: '权限编码',
+      dataIndex: 'perms',
+      key: 'permissionCode',
+    },*/{
+      title: 'icon',
+      dataIndex: 'icon',
+      key: 'icon'
+    },
+    {
+      title: '组件',
+      dataIndex: 'component',
+      key: 'component',
+      scopedSlots: {customRender: 'component'}
+    },
+    {
+      title: '路径',
+      dataIndex: 'url',
+      key: 'url',
+      scopedSlots: {customRender: 'url'}
+    },
+    {
+      title: '排序',
+      dataIndex: 'sortNo',
+      key: 'sortNo'
+    },
+    {
+      title: '操作',
+      dataIndex: 'action',
+      scopedSlots: {customRender: 'action'},
+      align: 'center',
+      width: 150
+    }
+  ]
+
+  export default {
+    name: 'PermissionList',
+    mixins: [JeecgListMixin],
+    components: {
+      PermissionDataRuleList,
+      PermissionModal,
+      JEllipsis
+    },
+    data() {
+      return {
+        description: '这是菜单管理页面',
+        // 表头
+        columns: columns,
+        loading: false,
+        url: {
+          list: '/sys/permission/list',
+          delete: '/sys/permission/delete',
+          deleteBatch: '/sys/permission/deleteBatch'
+        }
+      }
+    },
+    methods: {
+      loadData() {
+        this.dataSource = []
+        getPermissionList().then((res) => {
+          if (res.success) {
+            console.log(res.result)
+            this.dataSource = res.result
+            alert(1)
+            
+          }
+        })
+      },
+      // 打开数据规则编辑
+      handleDataRule(record) {
+        this.$refs.PermissionDataRuleList.edit(record)
+      },
+      handleAddSub(record) {
+        this.$refs.modalForm.title = "添加子菜单";
+        this.$refs.modalForm.localMenuType = 1;
+        this.$refs.modalForm.disableSubmit = false;
+        this.$refs.modalForm.edit({status: '1', permsType: '1', route: true, 'parentId': record.id});
+      }
+    }
+  }
+</script>
+<style scoped>
+  @import '~@assets/less/common.less'
 </style>