Commit 35129d7a authored by 陈浩玮's avatar 陈浩玮

组织管理

parent f7f7fddb
......@@ -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,
};
<template>
<my-table url="/api/v1/jobs" rowKey="jobId" :addBtn="addBtn" ref="table" noPage>
<template #drawer>
<Form ref="form" />
</template>
<!-- <template #search="{ query }">
<a-form-model-item label="名称">
<a-input v-model="query.jobName" />
</a-form-model-item>
</template> -->
<a-table-column title="名称" data-index="jobName" />
<a-table-column title="描述" data-index="jobDescription" />
<a-table-column title="操作">
<template #default="row">
<a @click="() => view(row, 1)">编辑</a>
<a-divider type="vertical" />
<PopconfirmDelete :url="`/api/v1/jobs/${row.jobId}`" :cb="refreshTable" />
</template>
</a-table-column>
</my-table>
</template>
<script>
import Form from './form.vue';
import PopconfirmDelete from '@/components/popconfirm_delete/index.vue';
export default {
components: { Form, PopconfirmDelete },
data() {
return {
addBtn: { width: 600, onOk: () => this.$refs['form']?.submit() },
};
},
methods: {
refreshTable() {
this.$refs['table']?.getData();
},
view(data, type) {
this.$refs['table']?.show({ type });
this.$nextTick(() => {
this.$refs['form'].setData({ ...data }, type);
});
},
},
};
</script>
\ No newline at end of file
<template>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
<a-form-model-item label="名称" prop="jobName">
<a-input v-model="form.jobName" :disabled="isView" />
</a-form-model-item>
<a-form-model-item label="描述" prop="jobDescription">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" />
</a-form-model-item>
</a-form-model>
</template>
<script>
import JobsApi from '@/api/organization';
import FormMixin from '@/components/FormMixin';
export default {
mixins: [FormMixin],
data() {
return {
rules: {
jobName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
jobDescription: [
{ required: true, message: 'Please select Activity zone', trigger: 'change' },
],
},
};
},
methods: {
add() {
return JobsApi.add({ ...this.form });
},
edit() {
return JobsApi.update({ ...this.form });
},
},
};
</script>
import JobManagement from './JobManagement';
export default JobManagement;
......@@ -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'),
},
],
},
......
......@@ -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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment