Lind 3 лет назад
Родитель
Сommit
0d746bb646

+ 0 - 59
src/pages/system/Org/NodeTemplate/index.tsx

@@ -1,59 +0,0 @@
-import styles from '../index.less';
-import { Avatar, Dropdown } from 'antd';
-import { SmallDashOutlined, UserOutlined } from '@ant-design/icons';
-import React from 'react';
-import type { OrgItem } from '@/pages/system/Org/typings';
-import { useIntl } from '@@/plugin-locale/localeExports';
-
-declare type OverlayFunc = () => React.ReactElement;
-
-interface Props {
-  data: Partial<OrgItem>;
-  action: React.ReactElement | OverlayFunc;
-}
-
-const NodeTemplate: React.FC<Props> = (props) => {
-  const intl = useIntl();
-  const { data, action } = props;
-  return (
-    <div className={styles.node}>
-      <div className={styles.top}>
-        <span className={styles.title}>{data.name}</span>
-        <Avatar size="small" icon={<UserOutlined />} />
-      </div>
-
-      <div className={styles.content}>
-        <div className={styles.item}>
-          {data.code !== null && (
-            <div>
-              <span className={styles.mark}>
-                {intl.formatMessage({
-                  id: 'pages.system.org.encoding',
-                  defaultMessage: '编码',
-                })}
-              </span>
-              <span>{data.code}</span>
-            </div>
-          )}
-          <div>
-            <span className={styles.mark}>
-              {intl.formatMessage({
-                id: 'pages.system.org.count',
-                defaultMessage: '下级数量',
-              })}
-            </span>
-            <span>{data?.children?.length || 0}</span>
-          </div>
-        </div>
-        <div className={styles.action}>
-          <Dropdown overlay={action}>
-            <a className="ant-dropdown-link" onClick={(e) => e.preventDefault()}>
-              <SmallDashOutlined />
-            </a>
-          </Dropdown>
-        </div>
-      </div>
-    </div>
-  );
-};
-export default NodeTemplate;

+ 0 - 101
src/pages/system/Org/Save/index.tsx

@@ -1,101 +0,0 @@
-import { message, Modal } from 'antd';
-import { createForm } from '@formily/core';
-import { createSchemaField } from '@formily/react';
-import { NumberPicker, Form, Input, FormItem } from '@formily/antd';
-import { useIntl } from '@@/plugin-locale/localeExports';
-import OrgModel from '@/pages/system/Org/model';
-import { service } from '@/pages/system/Org';
-
-interface Props {
-  refresh?: () => void;
-  visible: boolean;
-}
-
-const Save = (props: Props) => {
-  const intl = useIntl();
-  const form = createForm({
-    initialValues: OrgModel.current,
-  });
-
-  const SchemaField = createSchemaField({
-    components: {
-      FormItem,
-      Input,
-      NumberPicker,
-    },
-  });
-
-  const schema = {
-    type: 'object',
-    properties: {
-      code: {
-        title: intl.formatMessage({
-          id: 'pages.system.org.encoding',
-          defaultMessage: '编码',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input',
-        name: 'id',
-        required: true,
-      },
-      name: {
-        title: intl.formatMessage({
-          id: 'pages.table.name',
-          defaultMessage: '名称',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input',
-        name: 'name',
-        required: true,
-      },
-      sortIndex: {
-        title: intl.formatMessage({
-          id: 'pages.system.org.add.orderNumber',
-          defaultMessage: '序号',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'NumberPicker',
-        name: 'name',
-        required: true,
-      },
-      describe: {
-        title: intl.formatMessage({
-          id: 'pages.table.describe',
-          defaultMessage: '描述',
-        }),
-        type: 'string',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input.TextArea',
-        name: 'describe',
-      },
-    },
-  };
-
-  const save = async () => {
-    const data: Record<string, unknown> = await form.submit!();
-    await service.update({ ...data, parentId: OrgModel.parentId });
-    message.success('保存成功');
-    OrgModel.closeEdit();
-    props.refresh?.();
-  };
-
-  return (
-    <Modal
-      onOk={() => save()}
-      title={`${OrgModel.parentId ? '添加下级' : '编辑'}`}
-      visible={props.visible}
-      onCancel={() => {
-        OrgModel.closeEdit();
-        props.refresh?.();
-      }}
-    >
-      <Form form={form} labelCol={5} wrapperCol={16}>
-        <SchemaField schema={schema} />
-      </Form>
-    </Modal>
-  );
-};
-export default Save;

+ 0 - 70
src/pages/system/Org/index.less

@@ -1,70 +0,0 @@
-.orgContainer {
-  :global {
-    .orgchart {
-      background: #fff;
-    }
-    .orgchart-container {
-      border: none;
-    }
-  }
-}
-
-.node {
-  display: flex;
-  flex-direction: column;
-  min-width: 140px;
-  border: 1px solid #4c77bf;
-  border-radius: 3px;
-  transition: 0.3s;
-}
-
-.node:hover {
-  box-shadow: 0 0 10px 10px #b1d9ff;
-}
-
-.top {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  height: 36px;
-  padding: 0 12px;
-  color: #fff;
-  font-size: 14px;
-  background: #4c77bf;
-}
-
-.title {
-  margin-right: 12px;
-  white-space: nowrap;
-}
-
-.content {
-  display: flex;
-  flex: 1 1;
-  align-items: center;
-  justify-content: space-between;
-  padding: 3px 12px;
-  background: #fff;
-}
-
-.item > div {
-  display: flex;
-}
-
-.mark {
-  display: flex;
-  justify-content: flex-start;
-  width: 50px;
-  margin-right: 10px;
-  color: rgba(0, 0, 0, 0.45);
-  font-size: 14px;
-  white-space: nowrap;
-}
-
-.action {
-  align-self: flex-end;
-  height: 100%;
-  padding-bottom: 3px;
-  vertical-align: bottom;
-  cursor: pointer;
-}

+ 0 - 179
src/pages/system/Org/index.tsx

@@ -1,179 +0,0 @@
-import { PageContainer } from '@ant-design/pro-layout';
-import OrganizationChart from '@dabeng/react-orgchart';
-import styles from './index.less';
-import { Drawer, Menu, message, Modal } from 'antd';
-import NodeTemplate from '@/pages/system/Org/NodeTemplate';
-import { observer } from '@formily/react';
-import { useEffect } from 'react';
-import Service from '@/pages/system/Org/service';
-import encodeQuery from '@/utils/encodeQuery';
-import Save from '@/pages/system/Org/Save';
-import { useIntl } from '@@/plugin-locale/localeExports';
-import autzModel from '@/components/Authorization/autz';
-import Authorization from '@/components/Authorization';
-import { BindModel } from '@/components/BindUser/model';
-import BindUser from '@/components/BindUser';
-import OrgModel from '@/pages/system/Org/model';
-
-export const service = new Service('organization');
-const Org = observer(() => {
-  const intl = useIntl();
-  const hitCenter = () => {
-    const orgChart = document.getElementsByClassName('orgchart-container')[0];
-    const { width } = orgChart.getBoundingClientRect();
-    orgChart.scrollLeft = width;
-  };
-
-  const query = async () => {
-    const response = await service.queryTree(
-      encodeQuery({
-        paging: false,
-        terms: { typeId: 'org' },
-      }),
-    );
-    OrgModel.data = {
-      id: null,
-      name: intl.formatMessage({
-        id: 'pages.system.org',
-        defaultMessage: '机构管理',
-      }),
-      title: '组织架构',
-      children: response.result,
-    };
-    hitCenter();
-    return OrgModel;
-  };
-
-  const remove = async (id: string) => {
-    await service.remove(id);
-    await query();
-    message.success(
-      intl.formatMessage({
-        id: 'pages.data.option.success',
-        defaultMessage: '操作成功!',
-      }),
-    );
-  };
-  useEffect(() => {
-    query();
-  }, []);
-
-  const menu = (nodeData: any) => {
-    const addNext = (
-      <Menu.Item key="addNext">
-        <a key="addNext" onClick={() => OrgModel.addNext(nodeData)}>
-          {intl.formatMessage({
-            id: 'pages.system.org.option.add',
-            defaultMessage: '添加下级',
-          })}
-        </a>
-      </Menu.Item>
-    );
-    return nodeData.id === null ? (
-      <Menu>{addNext}</Menu>
-    ) : (
-      <Menu>
-        <Menu.Item key="edit">
-          <a
-            key="edit"
-            onClick={() => {
-              OrgModel.update(nodeData);
-            }}
-          >
-            {intl.formatMessage({
-              id: 'pages.data.option.edit',
-              defaultMessage: '编辑',
-            })}
-          </a>
-        </Menu.Item>
-        {addNext}
-        <Menu.Item key="autz">
-          <a
-            key="autz"
-            onClick={() => {
-              autzModel.autzTarget.id = nodeData.id;
-              autzModel.autzTarget.name = nodeData.name;
-              autzModel.visible = true;
-            }}
-          >
-            {intl.formatMessage({
-              id: 'pages.system.org.option.permission',
-              defaultMessage: '权限分配',
-            })}
-          </a>
-        </Menu.Item>
-        <Menu.Item key="bindUser">
-          <a
-            key="bindUser"
-            onClick={() => {
-              BindModel.dimension = {
-                id: nodeData.id,
-                name: nodeData.name,
-                type: 'org',
-              };
-              BindModel.visible = true;
-            }}
-          >
-            {intl.formatMessage({
-              id: 'pages.system.org.option.bindUser',
-              defaultMessage: '绑定用户',
-            })}
-          </a>
-        </Menu.Item>
-        <Menu.Item key="delete">
-          <a key="delete" onClick={() => remove(nodeData.id)}>
-            {intl.formatMessage({
-              id: 'pages.data.option.remove',
-              defaultMessage: '删除',
-            })}
-          </a>
-        </Menu.Item>
-      </Menu>
-    );
-  };
-  return (
-    <PageContainer>
-      <div className={styles.orgContainer}>
-        <OrganizationChart
-          datasource={OrgModel.data}
-          pan={true}
-          NodeTemplate={(nodeData: any) => (
-            <NodeTemplate data={nodeData.nodeData} action={menu(nodeData.nodeData)} />
-          )}
-        />
-      </div>
-      <Save refresh={query} visible={OrgModel.edit} />
-      <Modal
-        visible={BindModel.visible}
-        closable={false}
-        onCancel={() => {
-          BindModel.visible = false;
-          BindModel.bind = false;
-        }}
-        width={BindModel.bind ? '90vw' : '60vw'}
-      >
-        <BindUser />
-      </Modal>
-      <Drawer
-        title={intl.formatMessage({
-          id: 'pages.data.option.authorize',
-          defaultMessage: '授权',
-        })}
-        width="50vw"
-        visible={autzModel.visible}
-        onClose={() => {
-          autzModel.visible = false;
-        }}
-      >
-        <Authorization
-          close={() => {
-            autzModel.visible = false;
-          }}
-          target={autzModel.autzTarget}
-        />
-      </Drawer>
-    </PageContainer>
-  );
-});
-
-export default Org;

+ 0 - 33
src/pages/system/Org/model.ts

@@ -1,33 +0,0 @@
-import { model } from '@formily/reactive';
-import type { OrgItem, OrgModelType } from '@/pages/system/Org/typings';
-
-const OrgModel = model<OrgModelType>({
-  edit: false,
-  parentId: '',
-  data: {},
-  current: {},
-  authorize: true,
-
-  update(data: Partial<OrgItem>) {
-    this.current = data;
-    this.edit = true;
-    this.parentId = undefined;
-  },
-
-  addNext(parentData: Partial<OrgItem>) {
-    this.parentId = parentData.id;
-    this.edit = true;
-    this.current = {};
-  },
-
-  authorized(data: Partial<OrgItem>) {
-    this.current = data;
-    this.authorize = true;
-  },
-  closeEdit() {
-    this.current = {};
-    this.edit = false;
-  },
-});
-
-export default OrgModel;

+ 0 - 11
src/pages/system/Org/service.ts

@@ -1,11 +0,0 @@
-import BaseService from '@/utils/BaseService';
-import type { OrgItem } from '@/pages/system/Org/typings';
-import { request } from '@@/plugin-request/request';
-
-class Service extends BaseService<OrgItem> {
-  queryTree(params: any): Promise<any> {
-    return request(`${this.uri}/_all/tree`, { params, method: 'GET' });
-  }
-}
-
-export default Service;

+ 0 - 32
src/pages/system/Org/typings.d.ts

@@ -1,32 +0,0 @@
-export type OrgItem = {
-  id: string;
-  parentId: string | undefined;
-  path: string;
-  sortIndex: number;
-  level: number;
-  name: string;
-  describe: string;
-  permissionExpresion: string;
-  url: string;
-  icon: string;
-  status: number;
-  code?: string;
-  children?: OrgItem[];
-};
-
-export type OrgModelType = {
-  data: Partial<{
-    id: null;
-    name: string;
-    title: string;
-    children: Partial<OrgItem>[];
-  }>;
-  current: Partial<OrgItem>;
-  parentId: string | undefined;
-  edit: boolean;
-  update: (data: Partial<OrgItem>) => void;
-  addNext: (parentData: Partial<OrgItem>) => void;
-  authorize: boolean;
-  authorized: (data: Partial<OrgItem>) => void;
-  closeEdit: () => void;
-};