张涛 před 1 rokem
rodič
revize
9cf68eaaa1
3 změnil soubory, kde provedl 109 přidání a 50 odebrání
  1. 29
    5
      src/pages/org/components/Form.jsx
  2. 70
    39
      src/pages/org/index.jsx
  3. 10
    6
      src/service/sysuser.js

+ 29
- 5
src/pages/org/components/Form.jsx Zobrazit soubor

@@ -5,12 +5,13 @@ import { postSysOrg, putSysOrg, getSysOrgById } from "@/service/sysorg";
5 5
 import { formItemLayout, tailFormItemLayout } from "@/utils/form";
6 6
 
7 7
 export default (props) => {
8
-  const { org, list, parentId, onChange } = props;
8
+  const { org, list, parentId, queryUserList, onChange } = props;
9 9
 
10 10
   const [submiting, startSubmit, cancelSubmit] = useBool();
11 11
   const [form] = Form.useForm();
12 12
 
13 13
   const onFinish = (values) => {
14
+    console.log(values);
14 15
     startSubmit();
15 16
     if (org?.orgId) {
16 17
       // 修改
@@ -43,10 +44,21 @@ export default (props) => {
43 44
       form.setFieldValue("orgPId", parentId);
44 45
       form.setFieldValue("isResponsible", true);
45 46
     }
46
-
47
-    console.log(org, parentId);
48 47
   }, [org, parentId]);
49 48
 
49
+  const ArrayToString = {
50
+    valuePropName: "value",
51
+    getValueProps: (val) => {
52
+      return { value: val ? val.split(",") : [] };
53
+    },
54
+    getValueFromEvent: (value) => {
55
+      if (value.length > 2) {
56
+        value.pop();
57
+      }
58
+      return value ? value.join(",") : "";
59
+    },
60
+  };
61
+
50 62
   return (
51 63
     <Form
52 64
       onFinish={onFinish}
@@ -64,7 +76,6 @@ export default (props) => {
64 76
       <Form.Item name="orgPId" label="上级单位">
65 77
         <Select>
66 78
           {(list || []).map((x) => (
67
-            console.log(x),
68 79
             <Select.Option key={x.orgId}>{x.name}</Select.Option>
69 80
           ))}
70 81
         </Select>
@@ -76,7 +87,20 @@ export default (props) => {
76 87
           <Radio value={false}>否</Radio>
77 88
         </Radio.Group>
78 89
       </Form.Item>
79
-
90
+      <Form.Item name="smsPson" label="短信接收者" {...ArrayToString}>
91
+        <Select
92
+          mode="multiple"
93
+          clearIcon
94
+          style={{ width: "100%" }}
95
+          placeholder="请选择接受者"
96
+        >
97
+          {(queryUserList || []).map((x) => (
98
+            <Select.Option key={x.userId} value={x.phone}>
99
+              {x.name}
100
+            </Select.Option>
101
+          ))}
102
+        </Select>
103
+      </Form.Item>
80 104
       <Form.Item name="sortNo" label="排序">
81 105
         <Input />
82 106
       </Form.Item>

+ 70
- 39
src/pages/org/index.jsx Zobrazit soubor

@@ -1,60 +1,67 @@
1
-import React from 'react';
2
-import {
3
-  PlusOutlined,
4
-  DeleteOutlined,
5
-} from '@ant-design/icons';
1
+import React, { useEffect, useMemo, useState } from "react";
2
+import { PlusOutlined, DeleteOutlined } from "@ant-design/icons";
6 3
 import { Button, Card, Row, Col, Tree, Tooltip, Popconfirm } from "antd";
7
-import Page from '@/components/Page';
4
+import Page from "@/components/Page";
8 5
 import { getSysOrg, deleteSysOrg } from "@/service/sysorg";
9
-import { arr2Tree } from '@/utils/array';
10
-import useBool from '@/utils/hooks/useBool';
11
-import Form from './components/Form';
6
+import { arr2Tree } from "@/utils/array";
12 7
 
13
-export default (props) => {
8
+import { getSysUser } from "@/service/sysuser";
9
+import useBool from "@/utils/hooks/useBool";
10
+import Form from "./components/Form";
14 11
 
12
+export default (props) => {
15 13
   const [loading, startLoading, stopLoading] = useBool();
16 14
   const [list, setList] = React.useState([]);
17 15
   const [current, setCurrernt] = React.useState();
18
-  const [parentId, setParentId] = React.useState('-1');
16
+  const [parentId, setParentId] = React.useState("-1");
17
+  const [queryUserList, setQueryUserList] = useState([]);
19 18
 
20 19
   const [parentList, treeData] = React.useMemo(() => {
21
-    const plist = [{orgId: '-1', name: '根节点'}].concat(list);
22
-    const [tree] = arr2Tree((list || []).map(x => ({
23
-      title: x.name,
24
-      key: x.orgId,
25
-      parentId: x.orgPId,
26
-      raw: x,
27
-    })));
20
+    const plist = [{ orgId: "-1", name: "根节点" }].concat(list);
21
+    const [tree] = arr2Tree(
22
+      (list || []).map((x) => ({
23
+        title: x.name,
24
+        key: x.orgId,
25
+        parentId: x.orgPId,
26
+        raw: x,
27
+      }))
28
+    );
28 29
 
29 30
     return [plist, tree];
30
-  }, [list])
31
+  }, [list]);
32
+
33
+  useEffect(() => {
34
+    getSysUser({ current: 1, pageSize: 500, pageNum: 1 }).then((res) =>
35
+      setQueryUserList(res.records || [])
36
+    );
37
+  }, []);
31 38
 
32 39
   const changeCurrent = (org) => {
33 40
     setCurrernt(org);
34
-    setParentId(org?.orgPId || '-1');
35
-  }
41
+    setParentId(org?.orgPId || "-1");
42
+  };
36 43
 
37 44
   const onSelect = (selectedKeys, e) => {
38
-    changeCurrent(e.node.raw)
39
-  }
45
+    changeCurrent(e.node.raw);
46
+  };
40 47
 
41 48
   const onClick = (org) => {
42 49
     changeCurrent(org);
43
-  }
50
+  };
44 51
 
45
-  const onAdd = (parent = '-1') => {
52
+  const onAdd = (parent = "-1") => {
46 53
     setParentId(parent);
47 54
     setCurrernt();
48
-  }
55
+  };
49 56
 
50 57
   const onDelete = (org) => {
51 58
     deleteSysOrg(org.orgId).then(() => {
52
-      setList(list.filter(x => x.orgId !== org.orgId))
59
+      setList(list.filter((x) => x.orgId !== org.orgId));
53 60
     });
54
-  }
61
+  };
55 62
 
56 63
   const queryList = React.useCallback(() => {
57
-    getSysOrg({pageSize: 500}).then(res => {
64
+    getSysOrg({ pageSize: 500 }).then((res) => {
58 65
       setList(res.records || []);
59 66
       changeCurrent();
60 67
     });
@@ -63,7 +70,7 @@ export default (props) => {
63 70
   const onFormChange = () => {
64 71
     // 重新查一次数据
65 72
     queryList();
66
-  }
73
+  };
67 74
 
68 75
   React.useEffect(() => {
69 76
     queryList();
@@ -76,27 +83,45 @@ export default (props) => {
76 83
           <Card
77 84
             title="单位"
78 85
             onSelect={onSelect}
79
-            extra={<Button type='link' onClick={() => onAdd()}>新增</Button>}
86
+            extra={
87
+              <Button type="link" onClick={() => onAdd()}>
88
+                新增
89
+              </Button>
90
+            }
80 91
           >
81 92
             <Tree
82 93
               blockNode
83 94
               treeData={treeData}
84 95
               // onSelect={onSelect}
85 96
               titleRender={(node) => (
86
-                <div style={{display: 'flex'}} onClick={e => e.stopPropagation()}>
87
-                  <div style={{lineHeight: '32px', flex: 1}} onClick={() => onClick(node.raw)}>
97
+                <div
98
+                  style={{ display: "flex" }}
99
+                  onClick={(e) => e.stopPropagation()}
100
+                >
101
+                  <div
102
+                    style={{ lineHeight: "32px", flex: 1 }}
103
+                    onClick={() => onClick(node.raw)}
104
+                  >
88 105
                     {node.title}
89 106
                   </div>
90
-                  <div style={{width: '80px', flex: 'none'}}>
107
+                  <div style={{ width: "80px", flex: "none" }}>
91 108
                     <Tooltip title="新增子节点">
92
-                      <Button type='link' icon={<PlusOutlined />} onClick={() => onAdd(node.raw.orgId)}></Button>
109
+                      <Button
110
+                        type="link"
111
+                        icon={<PlusOutlined />}
112
+                        onClick={() => onAdd(node.raw.orgId)}
113
+                      ></Button>
93 114
                     </Tooltip>
94 115
                     <Tooltip title="删除节点">
95 116
                       <Popconfirm
96 117
                         title="确认进行删除操作?"
97 118
                         onConfirm={() => onDelete(node.raw)}
98 119
                       >
99
-                        <Button type='link' danger icon={<DeleteOutlined />}></Button>
120
+                        <Button
121
+                          type="link"
122
+                          danger
123
+                          icon={<DeleteOutlined />}
124
+                        ></Button>
100 125
                       </Popconfirm>
101 126
                     </Tooltip>
102 127
                   </div>
@@ -107,10 +132,16 @@ export default (props) => {
107 132
         </Col>
108 133
         <Col span={16}>
109 134
           <Card>
110
-            <Form org={current} parentId={parentId} list={parentList} onChange={onFormChange} />
135
+            <Form
136
+              org={current}
137
+              parentId={parentId}
138
+              list={parentList}
139
+              queryUserList={queryUserList}
140
+              onChange={onFormChange}
141
+            />
111 142
           </Card>
112 143
         </Col>
113 144
       </Row>
114 145
     </Page>
115
-  )
116
-}
146
+  );
147
+};

+ 10
- 6
src/service/sysuser.js Zobrazit soubor

@@ -1,14 +1,15 @@
1
-import request from '@/utils/request';
1
+import request from "@/utils/request";
2 2
 
3 3
 /*
4 4
  * 分页查询
5 5
  */
6
-export const getSysUser = (params) => request('/api/sysUser', { params });
6
+export const getSysUser = (params) => request("/api/sysUser", { params });
7 7
 
8 8
 /*
9 9
  * 新增数据
10 10
  */
11
-export const postSysUser = (data) => request('/api/sysUser', { data, method: 'post' });
11
+export const postSysUser = (data) =>
12
+  request("/api/sysUser", { data, method: "post" });
12 13
 
13 14
 /*
14 15
  * 通过ID查询单条数据
@@ -23,14 +24,17 @@ export const currentUser = () => request(`/api/sysUser/current`);
23 24
 /*
24 25
  * 更新数据
25 26
  */
26
-export const putSysUser = (id, data) => request(`/api/sysUser/${id}`, { data, method: 'put' });
27
+export const putSysUser = (id, data) =>
28
+  request(`/api/sysUser/${id}`, { data, method: "put" });
27 29
 
28 30
 /*
29 31
  * 通过主键删除数据
30 32
  */
31
-export const deleteSysUser = (id) => request(`/api/sysUser/${id}`, { method: 'delete' });
33
+export const deleteSysUser = (id) =>
34
+  request(`/api/sysUser/${id}`, { method: "delete" });
32 35
 
33 36
 /*
34 37
  * 更新状态
35 38
  */
36
-export const updateUserStatus = (id, status) => request(`/api/sysUser/${id}?status=${status}`, { method: 'put' });
39
+export const updateUserStatus = (id, status) =>
40
+  request(`/api/sysUser/${id}?status=${status}`, { method: "put" });