From adc2e374dcfd87431b28042e0f0d07b1fd1821a0 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 5 Jan 2024 14:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E7=89=88=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 + src/api/chart.js | 16 ++++ src/axios.js | 33 ++++++++ src/components/ViewDialog.vue | 72 +++++++++++++++++ src/main.js | 1 + src/router/router.js | 3 + src/utils/custom.js | 25 ++++++ src/views/organization-chart.vue | 128 +++++++++++++++++++++++++++++++ src/views/resource-chart.vue | 57 ++++++-------- vite.config.js | 17 ++++ yarn.lock | 62 +++++++++++++++ 11 files changed, 383 insertions(+), 33 deletions(-) create mode 100644 src/axios.js create mode 100644 src/components/ViewDialog.vue create mode 100644 src/utils/custom.js create mode 100644 src/views/organization-chart.vue diff --git a/package.json b/package.json index 3e1886d..e07bef9 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,11 @@ "preview": "vite preview" }, "dependencies": { + "axios": "^1.6.4", "dom-to-image": "^2.6.0", "element-plus": "^2.4.4", "html2pdf.js": "^0.10.1", + "js-cookie": "^3.0.5", "vue": "^3.3.11", "vue-router": "^4.2.5", "vue3-tree-org": "^4.2.2" diff --git a/src/api/chart.js b/src/api/chart.js index e69de29..8678ef9 100644 --- a/src/api/chart.js +++ b/src/api/chart.js @@ -0,0 +1,16 @@ +import request from "@/axios"; + + +//人员组织架构图 +export function selectResourceChart(){ + return request.get('/sship/organization/chart/resource-tree') +} + +//人员信息 +export function selectPerson(params){ + return request.get('/sship/organization/chart/person',{ + params + }) +} + +//机能组织 \ No newline at end of file diff --git a/src/axios.js b/src/axios.js new file mode 100644 index 0000000..76c89fd --- /dev/null +++ b/src/axios.js @@ -0,0 +1,33 @@ +import axios from 'axios' +import Cookies from 'js-cookie' +import { tansParams } from "@/utils/custom" +axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' +const TokenKey = 'ecology_JSessionid=aaaTjPF0rg2oWfJEKdiZy; JSESSIONID=aaaTjPF0rg2oWfJEKdiZy; Systemlanguid=7; languageidweaver=7; loginuuids=1; loginidweaver=sysadmin;' + +// 创建axios实例 +const service = axios.create({ + baseURL: '/api', + // 超时 + timeout: 10000 +}) + +// request拦截器 +service.interceptors.request.use(config => { + // 是否需要设置 token + const isToken = (config.headers || {}).isToken === false + if (!isToken) { + //config.headers['Cookie'] = TokenKey // 让每个请求携带自定义token 请根据实际情况自行修改 + } + // get请求映射params参数 + if (config.method === 'get' && config.params) { + let url = config.url + '?' + tansParams(config.params); + url = url.slice(0, -1); + config.params = {}; + config.url = url; + } + return config +}, error => { + Promise.reject(error) +}) + +export default service diff --git a/src/components/ViewDialog.vue b/src/components/ViewDialog.vue new file mode 100644 index 0000000..6576461 --- /dev/null +++ b/src/components/ViewDialog.vue @@ -0,0 +1,72 @@ + + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 9225bdc..821dd6b 100644 --- a/src/main.js +++ b/src/main.js @@ -9,6 +9,7 @@ import 'element-plus/dist/index.css' //document.title = 'org-chart'; + const app = createApp(App) app.use(router); app.use(vue3TreeOrg); diff --git a/src/router/router.js b/src/router/router.js index d61a455..bdd1dbb 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -1,7 +1,10 @@ import { createRouter, createWebHashHistory } from "vue-router"; import ResourceChart from "../views/resource-chart.vue"; +import OrganizationChart from "../views/organization-chart.vue"; + const routes = [ { name: 'resource-chart', path: "/resource-chart", component: ResourceChart }, + { name: 'organization-chart', path: "/organization-chart", component: OrganizationChart } ]; // 初始化路由 diff --git a/src/utils/custom.js b/src/utils/custom.js new file mode 100644 index 0000000..d354fae --- /dev/null +++ b/src/utils/custom.js @@ -0,0 +1,25 @@ +/** +* 参数处理 +* @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 && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && 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/src/views/organization-chart.vue b/src/views/organization-chart.vue new file mode 100644 index 0000000..a973b42 --- /dev/null +++ b/src/views/organization-chart.vue @@ -0,0 +1,128 @@ + + + \ No newline at end of file diff --git a/src/views/resource-chart.vue b/src/views/resource-chart.vue index d4859c4..e95fe02 100644 --- a/src/views/resource-chart.vue +++ b/src/views/resource-chart.vue @@ -4,65 +4,52 @@
导出PDF
导出图片
-
+
-
+
+ +