diff --git a/package.json b/package.json index 39247c2..86b1ed9 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,13 @@ "emittery": "^0.8.1", "file-saver": "2.0.5", "js-cookie": "^3.0.5", + "nprogress": "0.2.0", "less": "^4.1.3", "less-loader": "^11.1.3", "lodash.debounce": "^4.0.8", "logt": "^1.4.1", "vue": "^2.6.14", + "vuex": "3.6.0", "vue-router": "^3.1.3" }, "devDependencies": { diff --git a/public/css/largeScreenStyle.css b/public/css/largeScreenStyle.css index 70d9409..24cdb95 100644 --- a/public/css/largeScreenStyle.css +++ b/public/css/largeScreenStyle.css @@ -69,7 +69,7 @@ table{ -webkit-text-fill-color:transparent; } .head-title-tab{ - width: 40% ; + max-width: 40% ; padding-top: 23px; display: flex; } @@ -165,8 +165,7 @@ table{ width: 45%; text-align: center; } -.head-title-weather{ - width: 55%; +.head-title-weather{ display: flex; align-items: center; } diff --git a/public/index.html b/public/index.html index e88b950..d6ffb57 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,7 @@ 北跨泾河-产发工程数字管理平台-大屏 - + diff --git a/src/api/login/index.js b/src/api/login/index.js new file mode 100644 index 0000000..e6835aa --- /dev/null +++ b/src/api/login/index.js @@ -0,0 +1,47 @@ +import request from '@/utils/request' + +// 登录方法 +function login(username, password, code, uuid) { + const data = { + username, + password, + code, + uuid + } + return request({ + url: '/login', + headers: { + isToken: false + }, + method: 'post', + data: data + }) +} + + +// 获取用户详细信息 +function getInfo() { + return request({ + url: '/getInfo', + method: 'get' + }) + } + +// 退出方法 +function logout() { + return request({ + url: '/logout', + method: 'post' + }) + } + +export { + login, + logout, + getInfo +} +export default { + login, + logout, + getInfo +} \ No newline at end of file diff --git a/src/assets/images/profile.png b/src/assets/images/profile.png new file mode 100644 index 0000000..8e5b56e Binary files /dev/null and b/src/assets/images/profile.png differ diff --git a/src/assets/images/profile1.png b/src/assets/images/profile1.png new file mode 100644 index 0000000..b08edec Binary files /dev/null and b/src/assets/images/profile1.png differ diff --git a/src/components/header.vue b/src/components/header.vue index 51ad6b2..04da826 100644 --- a/src/components/header.vue +++ b/src/components/header.vue @@ -1,259 +1,381 @@ \ No newline at end of file +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index b411d44..0f9ef81 100644 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,14 @@ import Vue from 'vue' import App from './App.vue' +import store from './store' import router from './router' +import './permission' import './pages/init.js' Vue.config.productionTip = false new Vue({ router, + store, render: h => h(App) }).$mount('#app') diff --git a/src/pages/index.vue b/src/pages/index.vue index 4e8f47b..ccba7e5 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -463,7 +463,10 @@ export default { }, mounted() { window.xapp = this; - this.$nextTick(() => { + this.$nextTick(() => { + if(this.$root.isTypeBuser){ + this.$router.push("/detail"); + } this.loading = true; }); this.$bus.$on("loadProjects", debounce(prjs => { diff --git a/src/pages/projectSafety.vue b/src/pages/projectSafety.vue index ab2b45a..015cbc3 100644 --- a/src/pages/projectSafety.vue +++ b/src/pages/projectSafety.vue @@ -485,22 +485,50 @@ export default { } }); } else { - //查询出勤人数 - this.$api.attendance.getWorkAttendanceList(this.dept?.id||0,this.projectInfo?.id||0).then(d => { - this.laborPersonnelTotal=0; - this.laborPersonnelData=[{text: "劳务人员", value: 0},{text: "监理人员", value: 0},{text: "总包人员", value: 0}]; - if(d.rows.length>0 && d.rows[0]!=null){ - this.laborPersonnelData=[]; - this.laborPersonnelTotal += d.rows[0].servicePersonnel; - this.laborPersonnelData.push({text: "劳务人员", value: d.rows[0].servicePersonnel}); - this.laborPersonnelTotal += d.rows[0].supervisorPersonnel; - this.laborPersonnelData.push({text: "监理人员", value: d.rows[0].supervisorPersonnel}); - this.laborPersonnelTotal += d.rows[0].contractorPersonnel; - this.laborPersonnelData.push({text: "总包人员", value: d.rows[0].contractorPersonnel}); - } - }); + this.loadAttendanceData(); } }, + getProjectId(cb) { + let func = () => { + let prjId = this.projectInfo?.id||0; + if (prjId == 0) { + if (!this.projects||this.projects.length == 0) { + setTimeout(func, 100); + } else { + cb && cb(this.projects[1].id); + } + } else { + cb && cb(prjId); + } + } + func(); + }, + loadAttendanceData(){ + this.getProjectId(id => { + let data={ + subDeptId:this.dept.id||0, + projectId:id||0, + attendanceTime: this.$dt(new Date()).format("YYYY-MM-DD") + } + this.$api.attendance.groupByComany(data).then(d=>{ + let tmps=d.data||[]; + const func=(ids)=>{ + let sum=0; + tmps.filter(it=>ids.includes(it.companyTypeId)).map(it=>it.id).forEach(it=>{ + sum+=it*1; + }) + return sum; + } + + this.laborPersonnelTotal = 0; + this.laborPersonnelData = [{ text: "劳务人员", value: func(["2","3"]) }, { text: "监理人员", value: func(["8"]) }, { text: "总包人员", value: func(["1"]) }]; + this.laborPersonnelData.forEach(it=>{ + this.laborPersonnelTotal += it.value; + }) + this.elDeptWorks++; + }); + }); + }, getProjectInsuranceList(){ this.$api.insurance.getProjectInsuranceList(this.dept?.id||0,this.projectInfo?.id||0).then(d => { this.insuranceDataList=[]; diff --git a/src/pages/quality/checkDetectionDlg.vue b/src/pages/quality/checkDetectionDlg.vue index 41affe3..d6c442b 100644 --- a/src/pages/quality/checkDetectionDlg.vue +++ b/src/pages/quality/checkDetectionDlg.vue @@ -89,7 +89,7 @@ 送检时间: -
{{ it.checkTime|dateFormat }}
+
{{ it.checkTime|formatDate }}
检测结果: @@ -107,7 +107,7 @@ 提交时间: -
{{ it.createTime|dateFormat }}
+
{{ it.createTime|formatDate }}
登记结果用户: @@ -115,7 +115,7 @@ 登记结果时间: -
{{ it.updateTime|dateFormat }}
+
{{ it.updateTime|formatDate }}
diff --git a/src/pages/quality/measuredDlg.vue b/src/pages/quality/measuredDlg.vue index 3fbb7c9..39d25a2 100644 --- a/src/pages/quality/measuredDlg.vue +++ b/src/pages/quality/measuredDlg.vue @@ -70,7 +70,7 @@ 测量时间: -
{{ it.measureTime|dateFormat }}
+
{{ it.measureTime|formatDate }}
测量点位: @@ -97,7 +97,7 @@ 提交时间: -
{{ it.createTime|dateFormat }}
+
{{ it.createTime|formatDate }}
登记结果用户: @@ -105,7 +105,7 @@ 登记结果时间: -
{{ it.updateTime|dateFormat }}
+
{{ it.updateTime|formatDate }}
diff --git a/src/pages/style/index.less b/src/pages/style/index.less index 7322c67..9ca4b79 100644 --- a/src/pages/style/index.less +++ b/src/pages/style/index.less @@ -131,4 +131,20 @@ } } } +} +.el-message-box{ + background-color: rgba(1, 169, 255,0.5); + border: solid 1px rgba(1, 169, 255,1); +} +.el-message-box__title{ + color: #000; +} +.el-message-box__btns{ + text-align: center; +} +.el-message-box__content{ + color: #fff; +} +.head-title-tab{ + white-space: nowrap; } \ No newline at end of file diff --git a/src/permission.js b/src/permission.js new file mode 100644 index 0000000..1e7f593 --- /dev/null +++ b/src/permission.js @@ -0,0 +1,57 @@ +import router from './router' +import store from './store' +import { Message } from 'element-ui' +import NProgress from 'nprogress' +import 'nprogress/nprogress.css' +import { getToken } from '@/utils/auth' +import { isRelogin } from '@/utils/request' + +NProgress.configure({ showSpinner: false }) + +const whiteList = [] + +router.beforeEach((to, from, next) => { + NProgress.start() + if (getToken()) { + to.meta.title && store.dispatch('settings/setTitle', to.meta.title) + /* has token*/ + if (to.path === '/login') { + next({ path: '/' }) + NProgress.done() + } else { + if (store.getters.roles.length === 0) { + isRelogin.show = true + // 判断当前用户是否已拉取完user_info信息 + store.dispatch('GetInfo').then(() => { + isRelogin.show = false + next(); + }).catch(err => { + store.dispatch('LogOut').then(() => { + Message.error(err) + next({ path: '/' }) + }) + }) + } else { + next() + } + } + } else { + // 没有token + if (whiteList.indexOf(to.path) !== -1) { + // 在免登录白名单,直接进入 + next() + } else { + //next(`/login?redirect=#/index`) // 否则全部重定向到登录页 + let base="/"; + if(location.host.indexOf("localhost")>=0){ + base="/jhapp/" + } + location.href=base+"#/login?redirect=/jhbs/#/"; + NProgress.done() + } + } +}) + +router.afterEach(() => { + NProgress.done() +}) diff --git a/src/store/getters.js b/src/store/getters.js new file mode 100644 index 0000000..e73b3b7 --- /dev/null +++ b/src/store/getters.js @@ -0,0 +1,13 @@ +const getters = { + token: state => state.user.token, + avatar: state => state.user.avatar, + userId: state => state.user.userId, + name: state => state.user.name, + dept:state=>state.user.dept, + introduction: state => state.user.introduction, + roles: state => state.user.roles, + nickName:state=>state.user.nickName, + roleId:state=>state.user.roleId, + permissions: state => state.user.permissions, +} +export default getters diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..3ca1427 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import Vuex from 'vuex' +import user from './modules/user' +import getters from './getters' + +Vue.use(Vuex) + +const store = new Vuex.Store({ + modules: { + user + }, + getters + }) + + export default store + + \ No newline at end of file diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..ed1b349 --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,118 @@ +import { login, logout, getInfo } from '@/api/login' +import { getToken, setToken, removeToken } from '@/utils/auth' + + +const user = { + state: { + token: getToken(), + userId:'', + name: '', + nickName:'', + roleId:0, + avatar: '', + dept:null, + roles: [], + permissions: [] + }, + + mutations: { + SET_TOKEN: (state, token) => { + state.token = token + }, + SET_USER_ID: (state, id) => { + state.userId = id + }, + SET_NAME: (state, name) => { + state.name = name + }, + SET_NICKNAME: (state, nickName) => { + state.nickName = nickName + }, + SET_ROLEID: (state, roleId) => { + state.roleId = roleId + }, + SET_AVATAR: (state, avatar) => { + state.avatar = avatar + }, + SET_ROLES: (state, roles) => { + state.roles = roles + }, + SET_PERMISSIONS: (state, permissions) => { + state.permissions = permissions + }, + SET_DEPT: (state, dept) => { + state.dept = dept + } + }, + + actions: { + // 登录 + Login({ commit }, userInfo) { + const username = userInfo.username.trim() + const password = userInfo.password + const code = userInfo.code + const uuid = userInfo.uuid + return new Promise((resolve, reject) => { + login(username, password, code, uuid).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 获取用户信息 + GetInfo({ commit, state }) { + return new Promise(async (resolve, reject) => { + getInfo().then(res=>{ + const user = res.user + const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.png") : process.env.VUE_APP_BASE_API + user.avatar; + if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 + commit('SET_ROLES', res.roles) + commit('SET_PERMISSIONS', res.permissions) + } else { + commit('SET_ROLES', ['ROLE_DEFAULT']) + } + commit('SET_USER_ID', user.userId) + commit('SET_NAME', user.userName) + commit('SET_NICKNAME', user.nickName) + commit('SET_ROLEID', res.roleId) + commit("SET_DEPT",user.dept); + commit('SET_AVATAR', avatar) + resolve(res) + }).catch(error => { + reject(error) + }) + }); + }, + // 退出系统 + LogOut({ commit, state }) { + return new Promise((resolve, reject) => { + logout(state.token).then(() => { + commit('SET_TOKEN', '') + commit("SET_DEPT",null); + commit('SET_ROLES', []) + commit('SET_PERMISSIONS', []) + removeToken() + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 前端 登出 + FedLogOut({ commit }) { + return new Promise(resolve => { + commit('SET_TOKEN', '') + removeToken() + resolve() + }) + } + } + } + + export default user + \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index b73bbbe..d8a1b81 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,7 +5,7 @@ import errorCode from '@/utils/errorCode' import { tansParams, blobValidate } from "@/utils/ruoyi"; import cache from '@/plugins/cache' import { saveAs } from 'file-saver' - +import Cookies from 'js-cookie' let downloadLoadingInstance; // 是否显示重新登录 export let isRelogin = { show: false }; @@ -20,7 +20,7 @@ const service = axios.create({ }) // request拦截器 -service.interceptors.request.use(config => { +service.interceptors.request.use(config => { // 是否需要设置 token const isToken = (config.headers || {}).isToken === false // 是否需要防止数据重复提交 @@ -35,7 +35,7 @@ service.interceptors.request.use(config => { config.params = {}; config.url = url; } - if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { + if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { const requestObj = { url: config.url, data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, @@ -51,7 +51,6 @@ service.interceptors.request.use(config => { const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { const message = '数据正在处理,请勿重复提交'; - //console.warn(`[${s_url}]: ` + message+",",config,s_url) console.warn("--->",s_data,requestObj.data,s_url) return Promise.reject(new Error(message)) } else { @@ -81,7 +80,7 @@ service.interceptors.response.use(res => { MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => { isRelogin.show = false; if(location.href.indexOf("localhost")>=0){ - //location.href = `/#/login?redirect=${encodeURIComponent("http://localhost:3000/jhbs/")}`; + //location.href = `/#/login?redirect=${encodeURIComponent("/jhbs/")}`; location.href=`http://localhost/#/login?redirect=${encodeURI('http://localhost:3000/jhbs/')}` }else{ location.href = `/#/login?redirect=${encodeURIComponent("/jhbs/")}`; diff --git a/vue.config.js b/vue.config.js index 9c06642..1dd7088 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,7 +1,7 @@ const { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, - publicPath :'./' , + publicPath :'/jhbs' , productionSourceMap:false, devServer: { host: '0.0.0.0', @@ -15,6 +15,13 @@ module.exports = defineConfig({ '^/jhapi/profile':'/' } }, + '/jhapp':{ + target: `http://62.234.3.186/`, + changeOrigin: true, + pathRewrite: { + '^/jhapp':'/' + } + }, '/cesium':{ target: `http://62.234.3.186/cesium/`, changeOrigin: true, @@ -23,8 +30,8 @@ module.exports = defineConfig({ } }, '/jhapi':{ - target: `http://62.234.3.186/jhapi/`, - //target: `http://127.0.0.1:8090/jhapi/`, + //target: `http://62.234.3.186/jhapi/`, + target: `http://127.0.0.1:8090/jhapi/`, changeOrigin: true, pathRewrite: { '^/jhapi':'/' diff --git a/yarn.lock b/yarn.lock index 29ac13d..a11cc65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4450,6 +4450,11 @@ npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" +nprogress@0.2.0: + version "0.2.0" + resolved "https://registry.npmmirror.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1" + integrity sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA== + nth-check@^2.0.1: version "2.1.1" resolved "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz" @@ -6001,6 +6006,11 @@ vue@^2.6.14: "@vue/compiler-sfc" "2.7.14" csstype "^3.1.0" +vuex@3.6.0: + version "3.6.0" + resolved "https://registry.npmmirror.com/vuex/-/vuex-3.6.0.tgz#95efa56a58f7607c135b053350833a09e01aa813" + integrity sha512-W74OO2vCJPs9/YjNjW8lLbj+jzT24waTo2KShI8jLvJW8OaIkgb3wuAMA7D+ZiUxDOx3ubwSZTaJBip9G8a3aQ== + watchpack@^2.4.0: version "2.4.0" resolved "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.0.tgz"