diff --git a/api/oa/dept.js b/api/oa/dept.js new file mode 100644 index 0000000..1f8482e --- /dev/null +++ b/api/oa/dept.js @@ -0,0 +1,52 @@ +import request from "@/util/oaRequest" + +// 查询部门列表 +export function listDept(query) { + return request({ + url: '/system/dept/list', + method: 'get', + params: query + }) +} + +// 查询部门列表(排除节点) +export function listDeptExcludeChild(deptId) { + return request({ + url: '/system/dept/list/exclude/' + deptId, + method: 'get' + }) +} + +// 查询部门详细 +export function getDept(deptId) { + return request({ + url: '/system/dept/' + deptId, + method: 'get' + }) +} + +// 新增部门 +export function addDept(data) { + return request({ + url: '/system/dept', + method: 'post', + data: data + }) +} + +// 修改部门 +export function updateDept(data) { + return request({ + url: '/system/dept', + method: 'put', + data: data + }) +} + +// 删除部门 +export function delDept(deptId) { + return request({ + url: '/system/dept/' + deptId, + method: 'delete' + }) +} diff --git a/api/oa/login.js b/api/oa/login.js new file mode 100644 index 0000000..26a0383 --- /dev/null +++ b/api/oa/login.js @@ -0,0 +1,53 @@ +import service from "@/util/oaRequest" +import { setToken } from "../../util/auth" + +// 获取oa系统的验证码(走个形式) +export const getSMSCodeFromOa = async (phoneNumber) => { + const option = { + url: '/fadapp/auth/send-code', + data: { + phone: phoneNumber + }, + headers: { + isToken: false + }, + method: 'post' + } + const result = await service(option) + console.log('验证码获取结果') + return result +} + +// 通过手机号自动登录oa系统 +export const loginOaByPhone = async (phoneNumber) => { + try { + // 准备登录oa + const data = { + url: '/fadapp/auth/login-by-code', + data: { + phone: phoneNumber, + code: '666666' + }, + headers: { + isToken: false + }, + method: 'post' + } + const response = await service(data) + console.log(response) + // 响应拦截器已经处理了响应,直接返回 res.data + if (response && response.data.token) { + setToken(response.data.token) + // localStorage.setItem('oaToken', response.data.token) + return { + token: response.data.token, + userInfo: response.data + } + } + + throw new Error('登录失败:未获取到token') + } catch (error) { + console.error('OA系统登录失败:', error) + throw error + } +} diff --git a/api/oa/project.js b/api/oa/project.js new file mode 100644 index 0000000..c4600ef --- /dev/null +++ b/api/oa/project.js @@ -0,0 +1,133 @@ +import request from "@/util/oaRequest" + +// 查询项目管理列表 +export function listProject(query) { + return request({ + url: '/oa/project/list', + method: 'get', + params: query + }) +} + + +// 查询项目管理列表 +export function listWareProject(query) { + return request({ + url: '/oa/project/ware-list', + method: 'get', + params: query + }) +} + + +// 查询项目管理列表 +export function filesProject(query) { + return request({ + url: '/oa/project/files', + method: 'get', + params: query + }) +} + +// 查询项目管理详细 +export function getProject(projectId) { + return request({ + url: '/oa/project/' + projectId, + method: 'get' + }) +} +// 查询项目管理详细 +export function projectData(date) { + return request({ + url: '/oa/project/projectDataByMonth/'+date, + method: 'get', + }) +} + +export function projectData2(date){ + return request({ + url: '/oa/project/projectData', + method: 'get', + params: { date } + }); +} + +// 查询项目管理详细 +export function projectDataByMonthAndDate() { + return request({ + url: '/oa/project/projectDataByMonthAndDate', + method: 'get' + }) +} + +// 新增项目管理 +export function addProject(data) { + return request({ + url: '/oa/project', + method: 'post', + data: data + }) +} + +// 修改项目管理 +export function updateProject(data) { + return request({ + url: '/oa/project', + method: 'put', + data: data + }) +} + +// 删除项目管理 +export function delProject(projectId) { + return request({ + url: '/oa/project/' + projectId, + method: 'delete' + }) +} + +export function getProjectList(query) { + return request({ + url: '/oa/project/progress-list', + method: 'get', + params: query + }) +} + + + +/** + * 获取外贸中心仪表盘四项指标 + * @param {Object} query 传参示例:{ start: '2024/01/01', end: '2024/01/18' } + */ +export function getDashboardMetrics(query) { + return request({ + url: '/oa/project/metrics', + method: 'get', + params: query + }) +} + +/** + * 获取外贸中心三张图表数据(折线、饼图、柱状) + * @param {Object} query 传参示例:{ start: '2024/01/01', end: '2024/01/18' } + */ +export function getDashboardCharts(query) { + return request({ + url: '/oa/project/charts', + method: 'get', + params: query + }) +} + +/** + * 获取外贸中心临期项目列表 + * @param {Object} query 传参示例:{ days: 7 } + */ +export function listExpiringProjects(query) { + return request({ + url: '/oa/project/expiring', + method: 'get', + params: query + }) +} diff --git a/api/oa/projectReport.js b/api/oa/projectReport.js new file mode 100644 index 0000000..ff93b75 --- /dev/null +++ b/api/oa/projectReport.js @@ -0,0 +1,130 @@ +import request from "@/util/oaRequest" + +// 查询项目报工列表 +export function listProjectReport(query) { + return request({ + url: '/oa/projectReport/list', + method: 'get', + params: query + }) +} + +// 查询项目报工详细 +export function getProjectReport(reportId) { + return request({ + url: '/oa/projectReport/' + reportId, + method: 'get' + }) +} + +// 查询项目报工详细 +export function getCardData() { + return request({ + url: '/oa/projectReport/card', + method: 'get' + }) +} + +// 查询项目报工详细 +export function getTrendData(start,end) { + return request({ + url: '/oa/projectReport/trend', + method: 'get', + params: { + start:start, + end:end + } + }) +} + +// 查询项目报工详细 +export function getRankData(start,end) { + return request({ + url: '/oa/projectReport/rank', + method: 'get', + params: { + start:start, + end:end + } + }) +}// 查询项目报工详细 +export function getSummaryList(start,end) { + return request({ + url: '/oa/projectReport/summary', + method: 'get', + params: { + start:start, + end:end + } + }) +} + +// 查询项目报工详细 +export function getProjectData(start,end) { + return request({ + url: '/oa/projectReport/projects', + method: 'get', + params: { + start:start, + end:end + } + }) +} +// 查询项目报工详细 +export function listClearProjectReport(start,end) { + return request({ + url: '/oa/projectReport/report', + method: 'get', + params: { + start:start, + end:end + } + }) +} +// 查询项目报工详细 +export function getPieData(start,end) { + return request({ + url: '/oa/projectReport/distribution', + method: 'get', + params: { + start:start, + end:end + } + }) +} + +// 新增项目报工 +export function addProjectReport(data) { + return request({ + url: '/oa/projectReport', + method: 'post', + data: data + }) +} + +// 修改项目报工 +export function updateProjectReport(data) { + return request({ + url: '/oa/projectReport', + method: 'put', + data: data + }) +} + +// 删除项目报工 +export function delProjectReport(reportId) { + return request({ + url: '/oa/projectReport/' + reportId, + method: 'delete' + }) +} + +// 导出项目报工数据 +export function exportProjectReport(params) { + return request({ + url: '/oa/projectReport/export', + method: 'post', + data: params, + responseType: 'blob' + }) +} diff --git a/pages.json b/pages.json index 44b0197..8d9fb30 100644 --- a/pages.json +++ b/pages.json @@ -242,9 +242,25 @@ { "path": "pages/workbench/index/index", "style": { - "navigationBarTitleText": "", + "navigationBarTitleText": "工作台", "enablePullDownRefresh": false } + }, + { + "path" : "pages/workbench/reportWork/reportWork", + "style" : + { + "navigationBarTitleText": "每日报工", + "navigationStyle": "default" + } + }, + { + "path" : "pages/workbench/construction/construction", + "style" : + { + "navigationBarTitleText" : "施工进度", + "navigationStyle": "default" + } } ], "tabBar": { @@ -266,7 +282,12 @@ "selectedIconPath": "static/images/tabbar_contacts_active.png", "text": "通讯录" }, - + { + "pagePath": "pages/workbench/index/index", + "iconPath": "/static/images/tabbar_workbench.png", + "selectedIconPath": "/static/images/tabbar_workbench_active.png", + "text": "工作台" + }, { "pagePath": "pages/profile/index/index", "iconPath": "./static/images/tabbar_profile.png", diff --git a/pages/login/index.vue b/pages/login/index.vue index 300da83..09c3263 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -109,6 +109,7 @@ import AreaPicker from "@/components/AreaPicker"; import { checkLoginError } from "@/util/common"; import { SmsUserFor } from "@/constant"; import IMSDK from "openim-uniapp-polyfill"; +import { getSMSCodeFromOa, loginOaByPhone } from "../../api/oa/login"; let timer; @@ -219,6 +220,8 @@ export default { uni.switchTab({ url: "/pages/conversation/conversationList/index", }); + await getSMSCodeFromOa(this.loginInfo.phoneNumber); + await loginOaByPhone(this.loginInfo.phoneNumber) this.loginInfo.password = ""; this.loading = false; diff --git a/pages/workbench/construction/construction.vue b/pages/workbench/construction/construction.vue new file mode 100644 index 0000000..8183fd0 --- /dev/null +++ b/pages/workbench/construction/construction.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/pages/workbench/index/index.vue b/pages/workbench/index/index.vue index 171df21..9558eda 100644 --- a/pages/workbench/index/index.vue +++ b/pages/workbench/index/index.vue @@ -1,31 +1,84 @@ - + diff --git a/pages/workbench/reportWork/reportWork.vue b/pages/workbench/reportWork/reportWork.vue new file mode 100644 index 0000000..71d9375 --- /dev/null +++ b/pages/workbench/reportWork/reportWork.vue @@ -0,0 +1,498 @@ + + + + + diff --git a/static/images/baogong.png b/static/images/baogong.png new file mode 100644 index 0000000..14901e1 Binary files /dev/null and b/static/images/baogong.png differ diff --git a/static/images/shigong.png b/static/images/shigong.png new file mode 100644 index 0000000..0c45595 Binary files /dev/null and b/static/images/shigong.png differ diff --git a/util/auth.js b/util/auth.js new file mode 100644 index 0000000..07c50cd --- /dev/null +++ b/util/auth.js @@ -0,0 +1,13 @@ +const TokenKey = 'oaToken' + +export function getToken() { + return uni.getStorageSync(TokenKey) +} + +export function setToken(token) { + return uni.setStorageSync(TokenKey, token) +} + +export function removeToken() { + return uni.removeStorageSync(TokenKey) +} \ No newline at end of file diff --git a/util/common.js b/util/common.js index 789f2d3..5866ea3 100644 --- a/util/common.js +++ b/util/common.js @@ -210,4 +210,59 @@ export const checkLoginError = (error) => { default: return "操作失败"; } -}; \ No newline at end of file +}; + +/** +* 显示消息提示框 +* @param content 提示的标题 +*/ +export function toast(content) { + uni.showToast({ + icon: 'none', + title: content + }) +} + +/** +* 显示模态弹窗 +* @param content 提示的标题 +*/ +export function showConfirm(content) { + return new Promise((resolve, reject) => { + uni.showModal({ + title: '提示', + content: content, + cancelText: '取消', + confirmText: '确定', + success: function(res) { + resolve(res) + } + }) + }) +} + +/** +* 参数处理 +* @param params 参数 +*/ +export function tansParams(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName] + var part = encodeURIComponent(propName) + "=" + if (value !== null && value !== "" && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']' + var subPart = encodeURIComponent(params) + "=" + result += subPart + encodeURIComponent(value[key]) + "&" + } + } + } else { + result += part + encodeURIComponent(value) + "&" + } + } + } + return result +} \ No newline at end of file diff --git a/util/errorCode.js b/util/errorCode.js new file mode 100644 index 0000000..256a2c6 --- /dev/null +++ b/util/errorCode.js @@ -0,0 +1,6 @@ +export default { + '401': '认证失败,无法访问系统资源', + '403': '当前操作没有权限', + '404': '访问资源不存在', + 'default': '系统未知错误,请反馈给管理员' + } \ No newline at end of file diff --git a/util/oaRequest.js b/util/oaRequest.js new file mode 100644 index 0000000..561514b --- /dev/null +++ b/util/oaRequest.js @@ -0,0 +1,73 @@ +import { getToken } from './auth' +import errorCode from './errorCode' +import { toast, showConfirm, tansParams } from './common' + +let timeout = 10000 +const baseUrl = 'http://110.41.139.73:8080' +// const baseUrl = 'http://localhost:8080' + +const request = config => { + // 是否需要设置 token + const isToken = (config.headers || {}).isToken === false + config.header = config.header || {} + if (getToken() && !isToken) { + config.header['Authorization'] = 'Bearer ' + getToken() + } + // get请求映射params参数 + if (config.params) { + let url = config.url + '?' + tansParams(config.params) + url = url.slice(0, -1) + config.url = url + } + return new Promise((resolve, reject) => { + uni.request({ + method: config.method || 'get', + timeout: config.timeout || timeout, + url: config.baseUrl || baseUrl + config.url, + data: config.data, + header: config.header, + dataType: 'json' + }).then(response => { + let [error, res] = response + if (error) { + console.log(error) + toast('后端接口连接异常') + reject('后端接口连接异常') + return + } + const code = res.data.code || 200 + const msg = errorCode[code] || res.data.msg || errorCode['default'] + if (code === 401) { + showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => { + if (res.confirm) { + // store.dispatch('LogOut').then(res => { + // uni.reLaunch({ url: '/pages/login' }) + // }) + } + }) + reject('无效的会话,或者会话已过期,请重新登录。') + } else if (code === 500) { + toast(msg) + reject('500') + } else if (code !== 200) { + toast(msg) + reject(code) + } + resolve(res.data) + }) + .catch(error => { + let { message } = error + if (message === 'Network Error') { + message = '后端接口连接异常' + } else if (message.includes('timeout')) { + message = '系统接口请求超时' + } else if (message.includes('Request failed with status code')) { + message = '系统接口' + message.substr(message.length - 3) + '异常' + } + toast(message) + reject(error) + }) + }) +} + +export default request \ No newline at end of file