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 b73e9da7e2402c6fd4f8af197f280667523194dc..ebee3a6a7f37c54ef11358bec9d1c475d362db79 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -1,8 +1,10 @@ @@ -109,6 +109,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 33a056725e399e56cb0f5c7acdce56f8ddeb8ed4..948d40d589b99f9b9e1f42ab46464a2bb0a21e4a 100644 --- a/src/router/config.js +++ b/src/router/config.js @@ -78,7 +78,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 2bb55c6ffa5be5c967364db2b1547f09ee8df883..0df8d96076a14e38543650a4bbbb63e624e967bb 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -31,3 +31,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; +}