parent
e10730d9cf
commit
671c7e303a
File diff suppressed because one or more lines are too long
@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<div class="jnpf-content-wrapper">
|
||||
<div class="jnpf-content-wrapper-center">
|
||||
<div class="jnpf-content-wrapper-content">
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<a-dropdown>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleAdd">
|
||||
<a-menu-item key="company">新建公司</a-menu-item>
|
||||
<!-- <a-menu-item key="department">新建部门</a-menu-item> -->
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button type="primary" preIcon="icon-ym icon-ym-btn-add">{{ t('common.addText') }}<DownOutlined /></a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'fullName'"><i :class="'mr-6px ' + record.icon"></i>{{ record.fullName }}</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownActions(record)" />
|
||||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</div>
|
||||
</div>
|
||||
<Form @register="registerForm" @reload="reload" />
|
||||
<DepForm @register="registerDepForm" @reload="reload" />
|
||||
<Member @register="registerMember" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { getOrganizeList, delOrganize, getEnterpriseList } from '/@/api/permission/organize';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn, FormProps, ActionItem } from '/@/components/Table';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { usePopup } from '/@/components/Popup';
|
||||
import { useOrganizeStore } from '/@/store/modules/organize';
|
||||
import Form from './Form.vue';
|
||||
import DepForm from './DepForm.vue';
|
||||
import Member from './Member.vue';
|
||||
import { DownOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
defineOptions({ name: 'permission-organize' });
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const organizeStore = useOrganizeStore();
|
||||
const [registerDepForm, { openModal: openDepFormModal }] = useModal();
|
||||
const [registerMember, { openModal: openMemberModal }] = useModal();
|
||||
const [registerForm, { openPopup: openFormPopup }] = usePopup();
|
||||
|
||||
const columns: BasicColumn[] = [
|
||||
{ title: '名称', dataIndex: 'fullName' },
|
||||
{ title: '编码', dataIndex: 'enCode' },
|
||||
{ title: '层级', dataIndex: 'index', width: 100, align: 'center' },
|
||||
{ title: '类型', dataIndex: 'type', width: 100, align: 'center', customRender: ({ record }) => (record.type === 'company' ? '公司' : '部门') },
|
||||
{ title: '创建时间', dataIndex: 'creatorTime', width: 150, format: 'date|YYYY-MM-DD HH:mm' },
|
||||
{ title: '排序', dataIndex: 'sortCode', width: 70, align: 'center' },
|
||||
];
|
||||
const [registerTable, { reload }] = useTable({
|
||||
api: getEnterpriseList,
|
||||
columns,
|
||||
isTreeTable: true,
|
||||
useSearchForm: true,
|
||||
pagination: false,
|
||||
formConfig: getFormConfig(),
|
||||
actionColumn: {
|
||||
width: 150,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
},
|
||||
afterFetch: data => setTableIndex(data),
|
||||
});
|
||||
// 树形列表index层级
|
||||
function setTableIndex(arr, index = 0) {
|
||||
arr.forEach(item => {
|
||||
item.index = 1;
|
||||
if (index) item.index = index + 1;
|
||||
if (item.children) setTableIndex(item.children, item.index);
|
||||
});
|
||||
}
|
||||
function getFormConfig(): Partial<FormProps> {
|
||||
return {
|
||||
schemas: [
|
||||
{
|
||||
field: 'keyword',
|
||||
label: t('common.keyword'),
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: t('common.enterKeyword'),
|
||||
submitOnPressEnter: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
function getTableActions(record): ActionItem[] {
|
||||
return [
|
||||
{
|
||||
label: t('common.editText'),
|
||||
onClick: addOrUpdateHandle.bind(null, record.id, record.type, record.parentId),
|
||||
},
|
||||
{
|
||||
label: t('common.delText'),
|
||||
color: 'error',
|
||||
modelConfirm: {
|
||||
onOk: handleDelete.bind(null, record.id),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
function getDropDownActions(record): ActionItem[] {
|
||||
return [
|
||||
{
|
||||
label: '查看成员',
|
||||
onClick: viewMember.bind(null, record.id, record.fullName),
|
||||
},
|
||||
];
|
||||
}
|
||||
function handleAdd({ key }) {
|
||||
addOrUpdateHandle('', key);
|
||||
}
|
||||
function addOrUpdateHandle(id = '', type, parentId = '') {
|
||||
const openMethod = type === 'company' ? openFormPopup : openDepFormModal;
|
||||
openMethod(true, { id, parentId });
|
||||
}
|
||||
function handleDelete(id) {
|
||||
delOrganize(id).then(res => {
|
||||
createMessage.success(res.msg);
|
||||
organizeStore.resetState();
|
||||
reload();
|
||||
});
|
||||
}
|
||||
function viewMember(id, fullName) {
|
||||
openMemberModal(true, { id, fullName });
|
||||
}
|
||||
</script>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
// 获取列表
|
||||
export function getList(data) {
|
||||
return defHttp.post({ url: '/api/scm/BusinessLine/getList', data });
|
||||
}
|
||||
// 新建
|
||||
export function create(data) {
|
||||
return defHttp.post({ url:'/api/scm/BusinessLine', data });
|
||||
}
|
||||
// 修改
|
||||
export function update(data) {
|
||||
return defHttp.put({ url: '/api/scm/BusinessLine/'+ data.id, data });
|
||||
}
|
||||
// 详情(无转换数据)
|
||||
export function getInfo(id) {
|
||||
return defHttp.get({ url: '/api/scm/BusinessLine/' + id });
|
||||
}
|
||||
// 获取(转换数据)
|
||||
export function getDetailInfo(id) {
|
||||
return defHttp.get({ url: '/api/scm/BusinessLine/detail/' + id });
|
||||
}
|
||||
// 删除
|
||||
export function del(id) {
|
||||
return defHttp.delete({ url: '/api/scm/BusinessLine/' + id });
|
||||
}
|
||||
// 批量删除数据
|
||||
export function batchDelete(data) {
|
||||
return defHttp.delete({ url: '/api/scm/BusinessLine/batchRemove', data });
|
||||
}
|
||||
// 导出
|
||||
export function exportData(data) {
|
||||
return defHttp.post({ url: '/api/scm/BusinessLine/Actions/Export', data });
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue