diff --git a/src/api/organization.js b/src/api/organization.js index a7ba9d7e74af3a54ff5bff6f289539a81fc137eb..be858d7967cac040926bfe62f7b87eb6a5d5f1d5 100644 --- a/src/api/organization.js +++ b/src/api/organization.js @@ -8,7 +8,12 @@ function updateJobsApi(data) { return putReq('/api/v1/jobs', data); } +function getOrganizationList(data) { + return getReq('/api/v1/organizations', data); +} + export default { - add: addJobsApi, - update: updateJobsApi, + addJobs: addJobsApi, + updateJobs: updateJobsApi, + getOrganizationList: getOrganizationList, }; diff --git a/src/components/table/index.vue b/src/components/table/index.vue index c07d24f1d996b1e218ae8290079b6a996adeb682..19513c95b14325a1eebdac35750c8b34422b8e64 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -1,8 +1,10 @@ @@ -104,6 +104,10 @@ export default { flexDirection: 'column', }, noFooter: false, + layout: { + labelCol: { span: 4 }, + wrapperCol: { span: 20 }, + }, total: 0, }; }, diff --git a/src/components/table/my_item.vue b/src/components/table/my_item.vue new file mode 100644 index 0000000000000000000000000000000000000000..398a17818de8bbe87cdfbe6f8bd703aaf0e59ba3 --- /dev/null +++ b/src/components/table/my_item.vue @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/src/pages/system/view/organization/components/OrganizationTree.vue b/src/pages/system/view/organization/components/OrganizationTree.vue new file mode 100644 index 0000000000000000000000000000000000000000..cf0d023d194af0540672ff19acd4a7875b2e04c6 --- /dev/null +++ b/src/pages/system/view/organization/components/OrganizationTree.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/pages/system/view/organization/jobmanagement/index.js b/src/pages/system/view/organization/jobmanagement/index.js deleted file mode 100644 index 199f40f1434ec22234692d530c4fdedcc141cc70..0000000000000000000000000000000000000000 --- a/src/pages/system/view/organization/jobmanagement/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import JobManagement from './JobManagement'; - -export default JobManagement; diff --git a/src/pages/system/view/organization/jobmanagement/JobManagement.vue b/src/pages/system/view/organization/jobsmanagement/Jobs.vue similarity index 100% rename from src/pages/system/view/organization/jobmanagement/JobManagement.vue rename to src/pages/system/view/organization/jobsmanagement/Jobs.vue diff --git a/src/pages/system/view/organization/jobmanagement/form.vue b/src/pages/system/view/organization/jobsmanagement/form.vue similarity index 90% rename from src/pages/system/view/organization/jobmanagement/form.vue rename to src/pages/system/view/organization/jobsmanagement/form.vue index fb91fd58820f9a0421b27ee60e5e97baffc83990..7b8a493fe11a49ccf06d45305af2b6c0f8c476b6 100644 --- a/src/pages/system/view/organization/jobmanagement/form.vue +++ b/src/pages/system/view/organization/jobsmanagement/form.vue @@ -26,10 +26,10 @@ export default { }, methods: { add() { - return JobsApi.add({ ...this.form }); + return JobsApi.addJobs({ ...this.form }); }, edit() { - return JobsApi.update({ ...this.form }); + return JobsApi.updateJobs({ ...this.form }); }, }, }; diff --git a/src/pages/system/view/organization/jobsmanagement/index.js b/src/pages/system/view/organization/jobsmanagement/index.js new file mode 100644 index 0000000000000000000000000000000000000000..64f0518a82a5e0b6ea7229b08c1d390668d7967b --- /dev/null +++ b/src/pages/system/view/organization/jobsmanagement/index.js @@ -0,0 +1,3 @@ +import Jobs from './Jobs'; + +export default Jobs; diff --git a/src/pages/system/view/organization/usermanagement/User.vue b/src/pages/system/view/organization/usermanagement/User.vue new file mode 100644 index 0000000000000000000000000000000000000000..2c2a29a9f2456b2b645dc227d202b5bbbf9789c7 --- /dev/null +++ b/src/pages/system/view/organization/usermanagement/User.vue @@ -0,0 +1,56 @@ + + \ No newline at end of file diff --git a/src/pages/system/view/organization/usermanagement/form.vue b/src/pages/system/view/organization/usermanagement/form.vue new file mode 100644 index 0000000000000000000000000000000000000000..7b8a493fe11a49ccf06d45305af2b6c0f8c476b6 --- /dev/null +++ b/src/pages/system/view/organization/usermanagement/form.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/pages/system/view/organization/usermanagement/index.js b/src/pages/system/view/organization/usermanagement/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b6916d834ab0de1dd74cd29601094275376ac566 --- /dev/null +++ b/src/pages/system/view/organization/usermanagement/index.js @@ -0,0 +1,3 @@ +import User from './User'; + +export default User; diff --git a/src/router/config.js b/src/router/config.js index 1301fd149c6c8c50ac48762a1f21eec32ddd273c..83135bc8776c68d770537ba08617ae1bf391dd34 100644 --- a/src/router/config.js +++ b/src/router/config.js @@ -85,7 +85,14 @@ const options = { { path: 'job_management', name: '岗位管理', - component: () => import('@/pages/system/view/organization/jobmanagement'), + component: () => + import('@/pages/system/view/organization/jobsmanagement'), + }, + { + path: 'user_management', + name: '用户管理', + component: () => + import('@/pages/system/view/organization/usermanagement'), }, ], }, diff --git a/src/utils/index.js b/src/utils/index.js index e0bae7d63790292c8a0861c7c2b3c8c3786b5fcb..0e9fd4a49e9560bbf8d66b3155f9eb71fd327fa8 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -34,3 +34,60 @@ export function convertListToTree(menuList, filterMenu = false) { export function EMPTY_FUN() {} export const isFunction = val => typeof val === 'function'; +export function arrayToTree(options) { + options = JSON.parse(JSON.stringify(options)); + this.data = options.data || []; + this.parentKey = options.parentKey || 'parent_code'; + this.childrenKey = options.childrenKey || 'children'; + this.key = options.key || 'code'; + this.maping = options.maping || undefined; + this.rootValue = options.rootValue || '0'; + this.treeData = []; + this.indexStorage = {}; + this.getDataBykey = function(key) { + return this.indexStorage[key]; + }; + this.setMapping = function() { + for (let i = 0; i < this.data.length; i++) { + var item = this.data[i]; + for (const x in this.maping) { + item[this.maping[x]] = item[x]; + } + } + }; + if (this.maping) { + this.setMapping(); + } + this.setIndexStorage = function() { + for (let i = 0; i < this.data.length; i++) { + this.indexStorage[this.data[i][this.key]] = this.data[i]; // 以id作为索引存储元素,可以无需遍历直接定位元素 + } + }; + this.setIndexStorage(); + // 利用数组浅拷贝 + this.toTree = function() { + const THISDATA = JSON.parse(JSON.stringify(this.data)); + for (let i = 0; i < this.data.length; i++) { + let currentElement = this.data[i]; + let tempCurrentElementParent = this.indexStorage[currentElement[this.parentKey]]; // 临时变量里面的当前元素的父元素 + if (tempCurrentElementParent) { + // 如果存在父元素 + if (!tempCurrentElementParent[this.childrenKey]) { + // 如果父元素没有chindren键 + tempCurrentElementParent[this.childrenKey] = []; // 设上父元素的children键 + } + tempCurrentElementParent[this.childrenKey].push(currentElement); // 给父元素加上当前元素作为子元素 + } else { + // 不存在父元素,意味着当前元素是一级元素 + if (this.rootValue != undefined && currentElement[this.key] === this.rootValue) { + this.treeData.push(currentElement); + } else { + this.treeData.push(currentElement); + } + } + } + return this.treeData; + }; + this.toTree(); + return this; +}