From 8136dab83c6323e0f45ba97c193f5f42c1336abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9=E7=8E=AE?= Date: Tue, 6 Jul 2021 14:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/oceanus.js | 13 +++ src/components/FormMixin/index.js | 11 ++- .../category/components/OceanusTree.vue | 41 +++++++++ src/pages/oceanus/category/index.vue | 91 +++++++++++++++++++ src/pages/oceanus/equipment/index.vue | 7 ++ .../components/OrganizationTree.vue | 8 +- .../view/organization/orgmanagement/Org.vue | 7 +- src/router/config.js | 20 ++++ src/utils/index.js | 1 - src/utils/requestUtil.js | 2 + vue.config.js | 8 +- 11 files changed, 200 insertions(+), 9 deletions(-) create mode 100644 src/api/oceanus.js create mode 100644 src/pages/oceanus/category/components/OceanusTree.vue create mode 100644 src/pages/oceanus/category/index.vue create mode 100644 src/pages/oceanus/equipment/index.vue diff --git a/src/api/oceanus.js b/src/api/oceanus.js new file mode 100644 index 0000000..60aa291 --- /dev/null +++ b/src/api/oceanus.js @@ -0,0 +1,13 @@ +import { delReq, getReq, postReq, putReq } from '@/utils'; + +function getOceanusTreeApi(data) { + return getReq('/oceanus/api/v1/categories', data); +} +function addOceanusTreeApi(data) { + return postReq('/oceanus/api/v1/categories', data); +} + +export default { + getOceanusTree: getOceanusTreeApi, + addOceanusTree: addOceanusTreeApi, +}; diff --git a/src/components/FormMixin/index.js b/src/components/FormMixin/index.js index 370edc9..e48125d 100644 --- a/src/components/FormMixin/index.js +++ b/src/components/FormMixin/index.js @@ -3,6 +3,7 @@ export default { return { type: 0, form: {}, + title: '', }; }, computed: { @@ -29,7 +30,15 @@ export default { setData(data, type) { this.form = { ...data }; this.type = type; - console.log(data, type); + if (type === 0) { + this.title = '新增'; + } else if (type === 1) { + this.title = '编辑'; + } else if (type === 2) { + this.title = '查看'; + } else { + this.title = ''; + } }, }, }; diff --git a/src/pages/oceanus/category/components/OceanusTree.vue b/src/pages/oceanus/category/components/OceanusTree.vue new file mode 100644 index 0000000..1723ec8 --- /dev/null +++ b/src/pages/oceanus/category/components/OceanusTree.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/pages/oceanus/category/index.vue b/src/pages/oceanus/category/index.vue new file mode 100644 index 0000000..b2c0440 --- /dev/null +++ b/src/pages/oceanus/category/index.vue @@ -0,0 +1,91 @@ + + + + diff --git a/src/pages/oceanus/equipment/index.vue b/src/pages/oceanus/equipment/index.vue new file mode 100644 index 0000000..c699d32 --- /dev/null +++ b/src/pages/oceanus/equipment/index.vue @@ -0,0 +1,7 @@ + + + diff --git a/src/pages/system/view/organization/components/OrganizationTree.vue b/src/pages/system/view/organization/components/OrganizationTree.vue index 89cad82..14ab59d 100644 --- a/src/pages/system/view/organization/components/OrganizationTree.vue +++ b/src/pages/system/view/organization/components/OrganizationTree.vue @@ -37,9 +37,13 @@ export default { }; }, async mounted() { - this.rawData = await api.getOrganizationList(); + const rawData = await api.getOrganizationList(); + const newData = rawData.map((i) => ({ + ...i, + selectable: i.orgType === 'DEPARTMENT', + })); const newArr = new arrayToTree({ - data: this.rawData, + data: newData, rootValue: 0, parentKey: 'parentOrgId', key: 'orgId', diff --git a/src/pages/system/view/organization/orgmanagement/Org.vue b/src/pages/system/view/organization/orgmanagement/Org.vue index e3c4dbc..82b1b23 100644 --- a/src/pages/system/view/organization/orgmanagement/Org.vue +++ b/src/pages/system/view/organization/orgmanagement/Org.vue @@ -52,8 +52,13 @@ export default { }); }, formatData(data) { + const newData = data.map((i) => ({ + ...i, + selectable: i.orgType === 'DEPARTMENT', + })); + const newArr = new arrayToTree({ - data: data, + data: newData, rootValue: 0, parentKey: 'parentOrgId', key: 'orgId', diff --git a/src/router/config.js b/src/router/config.js index 2e676be..79a061c 100644 --- a/src/router/config.js +++ b/src/router/config.js @@ -143,6 +143,26 @@ const hasAuthorityRoutes = [ }, ], }, + { + path: 'oceanus', + name: '设备管理', + meta: { + icon: 'control', + }, + component: PageTemplateView, + children: [ + { + path: 'category', + name: '分类配置', + component: () => import('@/pages/oceanus/category/index.vue'), + }, + { + path: 'equipment', + name: '设备台账', + component: () => import('@/pages/oceanus/equipment/index.vue'), + }, + ], + }, { path: 'user', name: '个人中心', diff --git a/src/utils/index.js b/src/utils/index.js index e8fc267..dbd57c2 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -85,7 +85,6 @@ export function arrayToTree(options) { const THISDATA = JSON.parse(JSON.stringify(this.data)); for (let i = 0; i < this.data.length; i++) { let currentElement = this.data[i]; - currentElement.selectable = currentElement.orgType === 'DEPARTMENT'; let tempCurrentElementParent = this.indexStorage[currentElement[this.parentKey]]; // 临时变量里面的当前元素的父元素 if (tempCurrentElementParent) { // 如果存在父元素 diff --git a/src/utils/requestUtil.js b/src/utils/requestUtil.js index f961ef0..fca6e63 100644 --- a/src/utils/requestUtil.js +++ b/src/utils/requestUtil.js @@ -11,6 +11,8 @@ axios.defaults.withCredentials = true; axios.defaults.xsrfHeaderName = xsrfHeaderName; axios.defaults.xsrfCookieName = xsrfHeaderName; +axios.defaults.baseURL = '/api'; + /** * @param {*} info 提示函数 */ diff --git a/vue.config.js b/vue.config.js index 663d87d..7b2497a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -193,14 +193,14 @@ const assetsCDN = { module.exports = { devServer: { proxy: { - '/api': { + '/api/': { //此处要与 /services/api.js 中的 API_PROXY_PREFIX 值保持一致 // target: process.env.VUE_APP_API_BASE_URL, target: 'http://platform.kuopu.net:9300', changeOrigin: true, - // pathRewrite: { - // '^/api': '' - // } + pathRewrite: { + '^/api/': '', + }, }, }, }, -- GitLab