Commit ac84bd432a9a22aec7075a174c6697def93679a6

Authored by zhaofeng
2 parents 47adc9d9 8c20badf

Merge remote-tracking branch 'origin/master' into performance

build/admin.tar.gz
No preview for this file type
src/pages/approval/ApprovalSetting/components/ApproveRole.tsx
1   -import React, { useState, useEffect } from "react";
2   -import {
3   - Input,
4   - Select,
5   - Modal,
6   - Form,
7   - message,
8   - Tooltip,
9   - Tag,
10   - Button,
11   - Space,
12   - Table,
13   -} from "antd";
14   -import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
15   -import {
16   - ApprovalType,
17   - Approval_Status,
18   - transformDTO,
19   - transformFormData,
20   -} from "../entity";
21   -import _ from "lodash";
22   -import { systemListApi } from "@/pages/admin/Privilege/api";
23   -import usePagination from "@/hooks/usePagination";
24   -import { getAllRoleCodeApi } from "@/common/api";
25   -import useInitial from "@/hooks/useInitail";
26   -import { saveApproveConfig } from "../api";
  1 +import React from "react";
  2 +import { Modal, Table, } from "antd";
27 3 import toChineseBig from '@/utils/toChinease';
28 4  
29 5 const { Column } = Table;
... ... @@ -39,16 +15,17 @@ export default function CreateItem({ item, setRoleItem }: Props) {
39 15 title="审批角色"
40 16 visible={visible}
41 17 onCancel={() => setRoleItem({ visible: false })}
  18 + width={800}
42 19 footer={null}
43 20 >
44   - <Table dataSource={currentItem} rowKey={(row) => `id${row.roleCode}`}>
  21 + <Table dataSource={currentItem} rowKey={(t: any) => t.map((it: any) => it.roleName).join("; ")}>
45 22 <Column
46 23 title="级别"
47 24 render={(_, rocord, index) => (
48 25 <span>{`${toChineseBig(index+1)}级审批`}</span>
49 26 )}
50 27 />
51   - <Column title="角色" dataIndex="roleName" key="roleName" />
  28 + <Column title="角色" render={(_, t:any[]) => t.map(it => it.roleName).join("; ")} />
52 29 </Table>
53 30 </Modal>
54 31 );
... ...
src/pages/approval/ApprovalSetting/components/CreateItem.tsx
... ... @@ -162,7 +162,7 @@ export default function CreateItem({ item, setItem, setParams }: Props) {
162 162 key={key}
163 163 style={{ width: "100%" }}
164 164 {...restField}
165   - name={[name, "roleObj"]}
  165 + name={[name, "roles"]}
166 166 rules={[
167 167 { required: true, message: "请选择审批角色" },
168 168 ]}
... ... @@ -174,15 +174,16 @@ export default function CreateItem({ item, setItem, setParams }: Props) {
174 174 showSearch
175 175 showArrow
176 176 allowClear
  177 + mode="multiple"
177 178 optionFilterProp="children"
178 179 >
179 180 {data.map((item) => (
180 181 <Option
181   - value={item.roleCode}
182   - key={item.roleCode}
183   - >
184   - {item.roleName}
185   - </Option>
  182 + value={item.roleCode}
  183 + key={item.roleCode}
  184 + >
  185 + {item.roleName}
  186 + </Option>
186 187 ))}
187 188 </Select>
188 189 </Form.Item>
... ...
src/pages/approval/ApprovalSetting/entity.ts
... ... @@ -111,8 +111,8 @@ export function transformDTO(formData): ApprovalSetteing.ApprovalListItems {
111 111 _.each(formData, (value: any, key: string) => {
112 112 switch (key) {
113 113 case 'approvalRoles':
114   - const _options: { roleObj: RoleObj }[] = value || [];
115   - const _approvalRoles = _options.map((item: { roleObj: RoleObj }) => ({ roleName: item.roleObj.label, roleCode: item.roleObj.value }));
  114 + const _options: any[] = value || [];
  115 + const _approvalRoles = _options.map((item: any) => (item.roles || []).map((it: any) => ({ roleName: it.label, roleCode: it.value })));
116 116 detail.approvalRoles = _approvalRoles;
117 117 break;
118 118 default:
... ... @@ -130,7 +130,7 @@ export function transformFormData(detail: ApprovalSetteing.ApprovalListItems) {
130 130 case 'approvalRoles':
131 131 const _options: ApprovalSetteing.ApprovalRoles[] = value || [];
132 132 if (_options.length) {
133   - const _approvalRoles = _options.map((item) => ({ roleObj: { label: item.roleName, value: item.roleCode } }));
  133 + const _approvalRoles = _options.map((item:any) => ({ roles: item.map((it: any) => ({ label: it.roleName, value: it.roleCode })) }));
134 134 formData.approvalRoles = _approvalRoles;
135 135 } else {
136 136 formData.approvalRoles = [{}];
... ...
src/pages/approval/FlowSetting/components/AddRole.tsx
1 1 import React, { useState, useEffect } from "react";
2 2 import {
3   - Input,
4 3 Select,
5   - Modal,
6 4 Form,
7   - message,
8 5 Card,
9 6 Row,
10 7 Button,
11 8 Popconfirm,
12 9 } from "antd";
13 10 import {
14   - ApprovalType,
15   - Approval_Status,
16   - transformDTO,
17   - transformFormData,
18   -} from "../entity";
19   -import {
20   - MinusCircleOutlined,
21   - PlusOutlined,
22   - PlusSquareOutlined,
23 11 DeleteOutlined,
24 12 } from "@ant-design/icons";
25   -import _ from "lodash";
26   -import { systemListApi } from "@/pages/admin/Privilege/api";
27   -import usePagination from "@/hooks/usePagination";
28 13 import { getAllRoleCodeApi } from "@/common/api";
29 14 import useInitial from "@/hooks/useInitail";
30   -import { saveApproveConfig } from "../api";
31 15  
32 16 const { Option } = Select;
33   -const layout = {
34   - labelCol: { span: 4 },
35   - wrapperCol: { span: 20 },
36   -};
37 17 interface Props {
38 18 item: { visible: boolean; currentItem?: ApprovalSetteing.ApprovalListItems };
39 19 setItem: any;
... ... @@ -94,6 +74,7 @@ export default function AddRole({
94 74 rules={[{ required: true, message: "请选择审批角色" }]}
95 75 >
96 76 <Select
  77 + mode="multiple"
97 78 showArrow={styleVisible}
98 79 onFocus={() => setStyleVisible(true)}
99 80 bordered={styleVisible}
... ...
src/pages/approval/FlowSetting/components/CommonSetting.tsx
... ... @@ -30,10 +30,10 @@ export default function CommonSetting({ match }: Props) {
30 30 const { sights } = field;
31 31 let approvalRoles;
32 32 if (sights.length) {
33   - approvalRoles = sights.map((item) => ({
34   - roleCode: item.approvalRoles.value,
35   - roleName: item.approvalRoles.label,
36   - }));
  33 + approvalRoles = sights.map((item: any) => (item.approvalRoles || []).map((it: any) => ({
  34 + roleCode: it.value,
  35 + roleName: it.label,
  36 + })));
37 37 }
38 38 const pa = {
39 39 approvalConfigId: Number(approvalConfigId),
... ... @@ -54,11 +54,12 @@ export default function CommonSetting({ match }: Props) {
54 54  
55 55 useEffect(() => {
56 56 if (data.length) {
57   - const tempList = data.map((item) => ({
58   - approvalRoles: {
59   - label: item.roleName,
60   - value: item.roleCode,
61   - },
  57 + // @ts-ignore
  58 + const tempList = data.map((item: any[]) => ({
  59 + approvalRoles: item.map(it => ({
  60 + label: it.roleName,
  61 + value: it.roleCode,
  62 + })),
62 63 }));
63 64 form.setFieldsValue({
64 65 sights: tempList,
... ...
src/pages/approval/FlowSetting/components/Drage.tsx
... ... @@ -2,35 +2,19 @@ import React, { useState, useEffect } from &quot;react&quot;;
2 2 import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
3 3 import useInitial from "@/hooks/useInitail";
4 4 import { processSetApi, getNodeList } from "../api";
5   -import { Form, Input, Button, Card, Space, message } from "antd";
6   -import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
  5 +import { Form, Button, Card, message } from "antd";
  6 +import { PlusOutlined } from "@ant-design/icons";
7 7 import AddRole from "./AddRole";
8 8 import { PageHeaderWrapper } from "@ant-design/pro-layout";
9 9  
10 10 interface Props extends common.ConnectProps {}
11 11  
12   -const formItemLayout = {
13   - labelCol: {
14   - xs: { span: 24 },
15   - sm: { span: 4 },
16   - },
17   - wrapperCol: {
18   - xs: { span: 24 },
19   - sm: { span: 20 },
20   - },
21   -};
22 12 const formItemLayoutWithOutLabel = {
23 13 wrapperCol: {
24 14 xs: { span: 24, offset: 0 },
25 15 sm: { span: 20, offset: 4 },
26 16 },
27 17 };
28   -// fake data generator
29   -const getItems = (count) =>
30   - Array.from({ length: count }, (v, k) => k).map((k) => ({
31   - id: `item-${k}`,
32   - content: `item ${k}`,
33   - }));
34 18  
35 19 // a little function to help us with reordering the result
36 20 const reorder = (list, startIndex, endIndex) => {
... ... @@ -66,12 +50,12 @@ function Drage({ match }: Props) {
66 50  
67 51 useEffect(() => {
68 52 if (data.length) {
69   - const tempList = data.map((item) => ({
  53 + const tempList = data.map((it: any) => it.map((item: any) => ({
70 54 approvalRoles: {
71 55 label: item.roleName,
72 56 value: item.roleCode,
73 57 },
74   - }));
  58 + })));
75 59 form.setFieldsValue({
76 60 sights: tempList,
77 61 });
... ... @@ -105,10 +89,10 @@ function Drage({ match }: Props) {
105 89 const { sights } = field;
106 90 let approvalRoles;
107 91 if (sights.length) {
108   - approvalRoles = sights.map((item) => ({
109   - roleCode: item.approvalRoles.value,
110   - roleName: item.approvalRoles.label,
111   - }));
  92 + approvalRoles = sights.map((item: any) => (item.approvalRoles || []).map((it: any) => ({
  93 + roleCode: it.value,
  94 + roleName: it.label,
  95 + })));
112 96 }
113 97 const pa = {
114 98 approvalConfigId: Number(approvalConfigId),
... ...