Commit be882268 authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 人员管理完成

parent 27fb1103
......@@ -70,3 +70,11 @@ export function updateMajorApi(data) {
export function getMajorInfoApi(id) {
return getReq(`/ranger/inspection/api/v1/specialities/${id}`);
}
export function getOrganizationUserApi(id) {
return getReq(`/api/v1/users/organizations/${id}`);
}
export function addSpecialitiesStaffsApi(data) {
return postReq(`/ranger/inspection/api/v1/specialities/staffs`, data);
}
......@@ -12,10 +12,11 @@
@change="onChange"
/>
</template>
<!-- v-on="$listeners" -->
<script>
import api from '@/api/organization';
import { arrayToTree } from '@/utils';
export default {
model: {
prop: 'value',
......
<template>
<Wraper :hidden="hidden" :onOk="submit" :refresh="refresh">
<OrganizationTree v-model="value" style="margin-bottom: 10px" @change="organizationChange" />
<a-table
:data-source="data"
:row-selection="rowSelection"
:pagination="false"
rowKey="userId"
:loading="loading"
>
<a-table-column title="姓名" data-index="userName" />
</a-table>
</Wraper>
</template>
<script>
import Wraper from '@/components/table/wraper.vue';
import OrganizationTree from '@/pages/oceanus/equipment/Left/OrganizationTree.vue';
import { getOrganizationUserApi, addSpecialitiesStaffsApi } from '@/api';
export default {
components: { Wraper, OrganizationTree },
props: {
hidden: Function,
row: Object,
specialityId: Number,
refresh: Function,
},
data() {
return {
value: undefined,
loading: false,
data: [],
form: {
specialityId: this.specialityId,
staffOrgCommands: [],
},
selectedRowKeys: [],
};
},
computed: {
rowSelection() {
const { selectedRowKeys, onSelectChange } = this;
return {
selectedRowKeys,
onChange: onSelectChange,
};
},
},
methods: {
submit() {
this.form.staffOrgCommands = this.selectedRowKeys.map((staffId) => ({
orgId: this.value,
staffId,
}));
return addSpecialitiesStaffsApi(this.form);
},
onSelectChange(selectedRowKeys) {
this.selectedRowKeys = selectedRowKeys;
},
async organizationChange(val) {
this.loading = true;
this.data = await this.getTableData(val);
this.loading = false;
},
getTableData(id) {
return getOrganizationUserApi(id);
},
},
};
</script>
......@@ -21,7 +21,8 @@
</template>
<template #drawer="drawer">
<AddAndEdit v-bind="drawer" />
<Member v-if="drawer.type === 'member'" v-bind="drawer" />
<AddAndEdit v-bind="drawer" v-else />
</template>
<a-table-column title="专业名称" data-index="specialityName" />
......@@ -36,15 +37,16 @@ import Table from '@/components/table/table.vue';
import UrlSelect from '@/components/MySelect/url_select.vue';
import MoreItem from '@/components/table/more_item.vue';
import AddAndEdit from './add_edit.vue';
import Member from './member.vue';
export default {
components: { Table, UrlSelect, MoreItem, AddAndEdit },
components: { Table, UrlSelect, MoreItem, AddAndEdit, Member },
data() {
return {
buttons: [
{ label: '编辑', click: this.edit },
{ label: '详情', click: this.view },
{ label: '人员', click: this.view },
{ label: '人员', click: this.showMember },
{
type: 'confirm',
url: (row) => `/ranger/inspection/api/v1/specialities/${row.specialityId}`,
......@@ -63,6 +65,9 @@ export default {
view(row) {
this.$refs.table.show({ row, title: '详情', type: 'view' });
},
showMember(row) {
this.$refs.table.show({ row, title: '人员', type: 'member' });
},
},
};
</script>
<template>
<Wraper :hidden="hidden" noFooter>
<Table
:url="tableUrl"
rowKey="staffId"
noPadding
:addBtn="addBtn"
:buttons="buttons"
:width="400"
ref="table"
>
<template #drawer="drawer">
<AddMember v-bind="drawer" :specialityId="row.specialityId" />
</template>
<a-table-column title="部门" data-index="orgName" />
<a-table-column title="用户姓名" data-index="staffName" />
</Table>
</Wraper>
</template>
<script>
import Wraper from '@/components/table/wraper.vue';
import Table from '@/components/table/table.vue';
import AddMember from './add_member.vue';
export default {
components: { Wraper, Table, AddMember },
props: {
hidden: Function,
row: Object,
},
data() {
return {
addBtn: {
text: '添加',
title: '添加',
},
buttons: [
{
type: 'confirm',
url: (row) => ({
url: `/ranger/inspection/api/v1/specialities/staffs`,
method: 'del',
data: { staffBindIds: [row.staffBindId] },
}),
after: this.refreshTable,
},
],
};
},
computed: {
tableUrl() {
return `/ranger/inspection/api/v1/specialities/staffs?specialityId=${this.row.specialityId}`;
},
},
methods: {
refreshTable() {
this.$refs['table'].getData();
},
},
};
</script>
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