fangmingyue 2 lat temu
rodzic
commit
a24fa2f578

+ 2615
- 0
package-lock.json
Plik diff jest za duży
Wyświetl plik


+ 113
- 0
src/pages/org/edit/index.jsx Wyświetl plik

@@ -0,0 +1,113 @@
1
+import React, { useEffect, useState } from 'react';
2
+import { Button, Card, Form, Input, Select } from 'antd';
3
+import useBool from '@/utils/hooks/useBool';
4
+import { postSysOrg, putSysOrg, getSysOrgById } from "@/service/sysorg";
5
+import { useSearchParams, useNavigate } from 'react-router-dom';
6
+
7
+const formItemLayout = {
8
+  labelCol: {
9
+    xs: { span: 24 },
10
+    sm: { span: 8 },
11
+  },
12
+  wrapperCol: {
13
+    xs: { span: 24 },
14
+    sm: { span: 16 },
15
+  },
16
+};
17
+const tailFormItemLayout = {
18
+  wrapperCol: {
19
+    xs: {
20
+      span: 24,
21
+      offset: 0,
22
+    },
23
+    sm: {
24
+      span: 16,
25
+      offset: 8,
26
+    },
27
+  },
28
+};
29
+
30
+const { Option } = Select;
31
+
32
+export default (props) => {
33
+
34
+  const [loading, startLoading, cancelLoading] = useBool();
35
+  const [submiting, startSubmit, cancelSubmit] = useBool();
36
+  const [form] = Form.useForm();
37
+  const navigate = useNavigate();
38
+  const [searchParams, setSearchParams] = useSearchParams();
39
+  const id = searchParams.get("id");
40
+  const [data, setDate] = useState();
41
+
42
+  useEffect(() => {
43
+    if (id) {
44
+      getSysOrgById(id).then((res) => {
45
+        form.setFieldsValue(res);
46
+        setDate(res);
47
+      });
48
+    }
49
+  }, [id]);
50
+
51
+  const onFinish = (values) => {
52
+    if (id) {
53
+      startLoading();
54
+      // 修改
55
+      putTaOrgConfig(id, values).then((res) => {
56
+        navigate(-1);
57
+      });
58
+    } else {
59
+      // 新增
60
+      postTaOrgConfig(values).then((res) => {
61
+        navigate(-1);
62
+      });
63
+    }
64
+  }
65
+
66
+
67
+  return (
68
+    <Card loading={loading}>
69
+      <Form onFinish={onFinish} form={form} {...formItemLayout} scrollToFirstError style={{ maxWidth: '1000px' }}>
70
+        <Form.Item
71
+          name="orgId"
72
+          label="机构ID"
73
+        >
74
+          <Input />
75
+        </Form.Item>
76
+        <Form.Item
77
+          name="configCode"
78
+          label="配置编码"
79
+        >
80
+          <Input />
81
+        </Form.Item>
82
+        <Form.Item
83
+          name="configValue"
84
+          label="配置项值"
85
+        >
86
+          <Input />
87
+        </Form.Item>
88
+        <Form.Item
89
+          name="status"
90
+          label="状态"
91
+        >
92
+          <Select
93
+            style={{ width: '100%' }}
94
+            placeholder="请选择状态"
95
+          >
96
+            <Option key={0}>不正常</Option>
97
+            <Option key={1}>正常</Option>
98
+          </Select>
99
+        </Form.Item>
100
+        <Form.Item {...tailFormItemLayout}>
101
+          <Button loading={submiting} type="primary" htmlType="submit">
102
+            保存
103
+          </Button>
104
+          <Button style={{ marginLeft: '2em' }} onClick={() => navigate(-1)}>
105
+            返回
106
+          </Button>
107
+        </Form.Item>
108
+      </Form>
109
+    </Card>
110
+  )
111
+}
112
+
113
+

+ 137
- 0
src/pages/org/list/index.jsx Wyświetl plik

@@ -0,0 +1,137 @@
1
+import React from "react";
2
+import { useNavigate } from "react-router-dom";
3
+import { queryTable } from "@/utils/request";
4
+import { ProTable } from "@ant-design/pro-components";
5
+import { Button, message, Popconfirm } from "antd";
6
+import { getSysOrg, deleteSysOrg } from "@/service/sysorg";
7
+
8
+const querySysOrgList = queryTable(getSysOrg);
9
+
10
+export default (props) => {
11
+  const actionRef = React.useRef();
12
+  const navigate = useNavigate();
13
+
14
+  // const updateStatus = (user) => {
15
+  //   const status = user.status === 1 ? 0 : 1;
16
+  //   const hide = message.loading("请稍候...", 0);
17
+  //   updateUserStatus(user.id, status)
18
+  //     .then((res) => {
19
+  //       hide();
20
+  //       actionRef.current.reload();
21
+  //     })
22
+  //     .catch(() => {
23
+  //       hide();
24
+  //     });
25
+  // };
26
+  const handleDelete = (id) => {
27
+    if (id) {
28
+      deleteSysOrg(id).then((res) => {
29
+        actionRef.current.reload();
30
+      });
31
+    }
32
+  };
33
+
34
+  const columns = [
35
+    {
36
+      title: "机构ID",
37
+      dataIndex: "orgId",
38
+    },
39
+    {
40
+      title: "机构编码",
41
+      dataIndex: "orgCode",
42
+    },
43
+    {
44
+      title: "机构名称",
45
+      dataIndex: "name",
46
+    },
47
+    {
48
+      title: "上级单位",
49
+      dataIndex: "orgPId",
50
+    },
51
+
52
+    {
53
+      title: "排序",
54
+      dataIndex: "sortNo",
55
+    },
56
+
57
+    {
58
+      title: "状态",
59
+      dataIndex: "status",
60
+      valueEnum: {
61
+        1: {
62
+          text: "正常",
63
+          status: "Processing",
64
+        },
65
+        0: {
66
+          text: "禁用",
67
+          status: "Error",
68
+        },
69
+      },
70
+    },
71
+    {
72
+      title: "创建人",
73
+      dataIndex: "createUser",
74
+    },
75
+    {
76
+      title: "操作",
77
+      valueType: "option",
78
+      width: 200,
79
+      render: (_, record) => [
80
+        // <Button
81
+        //   key={1}
82
+        //   style={{ padding: 0 }}
83
+        //   type="link"
84
+        //   onClick={() => {
85
+        //     updateStatus(record);
86
+        //   }}
87
+        // >
88
+        //   {record.status === 1 ? "禁用" : "启用"}
89
+        // </Button>,
90
+        <Button
91
+          key={2}
92
+          style={{ padding: 0 }}
93
+          type="link"
94
+          onClick={() => {
95
+            console.log(record, "]]");
96
+            navigate(`/system/org/edit?id=${record.id}`);
97
+          }}
98
+        >
99
+          编辑
100
+        </Button>,
101
+        <Popconfirm
102
+          key={3}
103
+          title="您是否确认删除 ?"
104
+          onConfirm={() => handleDelete(record.id)}
105
+          okText="确定"
106
+          cancelText="取消"
107
+        >
108
+          {/* manualPush */}
109
+          <Button style={{ padding: 0 }} type="link">
110
+            删除
111
+          </Button>
112
+        </Popconfirm>,
113
+      ],
114
+    },
115
+  ];
116
+
117
+  return (
118
+    <ProTable
119
+      actionRef={actionRef}
120
+      rowKey="orgId"
121
+      search={false}
122
+      toolBarRender={() => [
123
+        <Button
124
+          key="1"
125
+          type="primary"
126
+          onClick={() => {
127
+            navigate("/system/org/edit");
128
+          }}
129
+        >
130
+          新增
131
+        </Button>,
132
+      ]}
133
+      request={querySysOrgList}
134
+      columns={columns}
135
+    />
136
+  );
137
+};

+ 115
- 0
src/pages/position/edit/index.jsx Wyświetl plik

@@ -0,0 +1,115 @@
1
+import React from 'react';
2
+import { Button, Card, Form, Input, Select } from 'antd';
3
+import useBool from '@/utils/hooks/useBool';
4
+import { postSysPosition, putSysPosition } from "@/service/sysposition";
5
+import { useSearchParams, useNavigate } from 'react-router-dom';
6
+
7
+const formItemLayout = {
8
+  labelCol: {
9
+    xs: { span: 24 },
10
+    sm: { span: 8 },
11
+  },
12
+  wrapperCol: {
13
+    xs: { span: 24 },
14
+    sm: { span: 16 },
15
+  },
16
+};
17
+const tailFormItemLayout = {
18
+  wrapperCol: {
19
+    xs: {
20
+      span: 24,
21
+      offset: 0,
22
+    },
23
+    sm: {
24
+      span: 16,
25
+      offset: 8,
26
+    },
27
+  },
28
+};
29
+
30
+const { Option } = Select;
31
+export default (props) => {
32
+
33
+  const [loading, startLoading, cancelLoading] = useBool();
34
+  const [submiting, startSubmit, cancelSubmit] = useBool();
35
+  const [form] = Form.useForm();
36
+  const navigate = useNavigate();
37
+  const [searchParams, setSearchParams] = useSearchParams();
38
+  const id = searchParams.get("id");
39
+
40
+
41
+  const onFinish = async (values) => {
42
+    if (id) {
43
+      // 修改
44
+      putSysPosition(id, values).then((res) => {
45
+        navigate(-1);
46
+      });
47
+    } else {
48
+      // 新增
49
+      postSysPosition({ ...values }).then((res) => {
50
+        navigate(-1);
51
+      });
52
+    }
53
+    return false;
54
+  }
55
+
56
+
57
+  return (
58
+    <Card loading={loading}>
59
+      <Form onFinish={onFinish} form={form} {...formItemLayout} scrollToFirstError style={{ maxWidth: '1000px' }}>
60
+        <Form.Item
61
+          name="name"
62
+          label="岗位名称"
63
+        >
64
+          <Input />
65
+        </Form.Item>
66
+        <Form.Item
67
+          name="positionPId"
68
+          label="上级岗位"
69
+        >
70
+          <Input />
71
+        </Form.Item>
72
+        <Form.Item
73
+          name="orgId"
74
+          label="所属单位"
75
+        >
76
+          <Input />
77
+        </Form.Item>
78
+        <Form.Item
79
+          name="sortNum"
80
+          label="排序"
81
+        >
82
+          <Input />
83
+        </Form.Item>
84
+        <Form.Item
85
+          name="status"
86
+          label="状态"
87
+        >
88
+          <Select
89
+            style={{ width: '100%' }}
90
+            placeholder="请选择状态"
91
+          >
92
+            <Option key={0}>不正常</Option>
93
+            <Option key={1}>正常</Option>
94
+          </Select>
95
+        </Form.Item>
96
+        <Form.Item
97
+          name="createUser"
98
+          label="创建人"
99
+        >
100
+          <Input />
101
+        </Form.Item>
102
+        <Form.Item {...tailFormItemLayout}>
103
+          <Button loading={submiting} type="primary" htmlType="submit">
104
+            保存
105
+          </Button>
106
+          <Button style={{ marginLeft: '2em' }} onClick={() => navigate(-1)}>
107
+            返回
108
+          </Button>
109
+        </Form.Item>
110
+      </Form>
111
+    </Card>
112
+  )
113
+}
114
+
115
+

+ 136
- 0
src/pages/position/list/index.jsx Wyświetl plik

@@ -0,0 +1,136 @@
1
+import React from "react";
2
+import { useNavigate } from "react-router-dom";
3
+import { queryTable } from "@/utils/request";
4
+import { ProTable } from "@ant-design/pro-components";
5
+import { Button, message, Popconfirm } from "antd";
6
+import { getSysPosition, deleteSysPosition } from "@/service/sysposition";
7
+
8
+const querySysPositionList = queryTable(getSysPosition);
9
+
10
+export default (props) => {
11
+  const actionRef = React.useRef();
12
+  const navigate = useNavigate();
13
+
14
+  // const updateStatus = (user) => {
15
+  //   const status = user.status === 1 ? 0 : 1;
16
+  //   const hide = message.loading("请稍候...", 0);
17
+  //   updateUserStatus(user.id, status)
18
+  //     .then((res) => {
19
+  //       hide();
20
+  //       actionRef.current.reload();
21
+  //     })
22
+  //     .catch(() => {
23
+  //       hide();
24
+  //     });
25
+  // };
26
+  const handleDelete = (id) => {
27
+    if (id) {
28
+      deleteSysPosition(id).then((res) => {
29
+        actionRef.current.reload();
30
+      });
31
+    }
32
+  };
33
+
34
+  const columns = [
35
+    {
36
+      title: "岗位ID",
37
+      dataIndex: "positionId",
38
+    },
39
+    {
40
+      title: "岗位名称",
41
+      dataIndex: "name",
42
+    },
43
+    {
44
+      title: "上级岗位",
45
+      dataIndex: "positionPId",
46
+    },
47
+    {
48
+      title: "所属单位",
49
+      dataIndex: "orgId",
50
+    },
51
+
52
+    {
53
+      title: "排序",
54
+      dataIndex: "sortNum",
55
+    },
56
+    {
57
+      title: "状态",
58
+      dataIndex: "status",
59
+      valueEnum: {
60
+        1: {
61
+          text: "正常",
62
+          status: "Processing",
63
+        },
64
+        0: {
65
+          text: "禁用",
66
+          status: "Error",
67
+        },
68
+      },
69
+    },
70
+    {
71
+      title: "创建人",
72
+      dataIndex: "createUser",
73
+    },
74
+    {
75
+      title: "操作",
76
+      valueType: "option",
77
+      width: 200,
78
+      render: (_, record) => [
79
+        // <Button
80
+        //   key={1}
81
+        //   style={{ padding: 0 }}
82
+        //   type="link"
83
+        //   onClick={() => {
84
+        //     updateStatus(record);
85
+        //   }}
86
+        // >
87
+        //   {record.status === 1 ? "禁用" : "启用"}
88
+        // </Button>,
89
+        <Button
90
+          key={2}
91
+          style={{ padding: 0 }}
92
+          type="link"
93
+          onClick={() => {
94
+            console.log(record, "]]");
95
+            navigate(`/system/position/edit?id=${record.id}`);
96
+          }}
97
+        >
98
+          编辑
99
+        </Button>,
100
+        <Popconfirm
101
+          key={3}
102
+          title="您是否确认删除 ?"
103
+          onConfirm={() => handleDelete(record.id)}
104
+          okText="确定"
105
+          cancelText="取消"
106
+        >
107
+          {/* manualPush */}
108
+          <Button style={{ padding: 0 }} type="link">
109
+            删除
110
+          </Button>
111
+        </Popconfirm>,
112
+      ],
113
+    },
114
+  ];
115
+
116
+  return (
117
+    <ProTable
118
+      actionRef={actionRef}
119
+      rowKey="positionId"
120
+      search={false}
121
+      toolBarRender={() => [
122
+        <Button
123
+          key="1"
124
+          type="primary"
125
+          onClick={() => {
126
+            navigate("/system/position/edit");
127
+          }}
128
+        >
129
+          新增
130
+        </Button>,
131
+      ]}
132
+      request={querySysPositionList}
133
+      columns={columns}
134
+    />
135
+  );
136
+};

+ 43
- 1
src/routes/routes.jsx Wyświetl plik

@@ -15,7 +15,10 @@ import Index from '@/pages/index';
15 15
 import Home from "@/pages/sample/home";
16 16
 import BasicForm from '@/pages/sample/form';
17 17
 import BasicTable from '@/pages/sample/table';
18
-
18
+import OrgList from "@/pages/org/list";
19
+import OrgEdit from "@/pages/org/edit";
20
+import PositionList from "@/pages/position/list";
21
+import PositionEdit from "@/pages/position/edit";
19 22
 /**
20 23
  * meta 用来扩展自定义数据数据
21 24
  * {
@@ -61,6 +64,45 @@ export const authRoutes = [
61 64
           // permission: 'form',
62 65
         },
63 66
       },
67
+      {
68
+        path: "org/list",
69
+        element: <OrgList />,
70
+        meta: {
71
+          title: '机构管理',
72
+          // icon: <AppstoreOutlined />,
73
+          // permission: 'form',
74
+        },
75
+      },
76
+      {
77
+        path: "org/edit",
78
+        element: <OrgEdit />,
79
+        meta: {
80
+          hideInMenu: true,
81
+          title: '机构管理编辑',
82
+          // icon: <AppstoreOutlined />,
83
+          // permission: 'form',
84
+        },
85
+      },
86
+      {
87
+        path: "position/list",
88
+        element: <PositionList />,
89
+        meta: {
90
+          title: '岗位管理',
91
+          // icon: <AppstoreOutlined />,
92
+          // permission: 'form',
93
+        },
94
+      },
95
+      ,
96
+      {
97
+        path: "position/edit",
98
+        element: <PositionEdit />,
99
+        meta: {
100
+          hideInMenu: true,
101
+          title: '岗位管理编辑',
102
+          // icon: <AppstoreOutlined />,
103
+          // permission: 'form',
104
+        },
105
+      },
64 106
     ]
65 107
   },
66 108
 

+ 5
- 1
src/service/sysorg.js Wyświetl plik

@@ -15,8 +15,12 @@ export const postSysOrg = (data) => request('/api/sysOrg', { data, method: 'post
15 15
  */
16 16
 export const getSysOrgById = (id) => request(`/api/sysOrg/${id}`);
17 17
 
18
-/*
18
+/** 
19 19
  * 更新数据
20
+ * 
21
+ * @param {*} id
22
+ * @param {*} data
23
+ * @returns
20 24
  */
21 25
 export const putSysOrg = (id, data) => request(`/api/sysOrg/${id}`, { data, method: 'put' });
22 26
 

+ 4
- 1
src/service/taorgconfig.js Wyświetl plik

@@ -15,8 +15,11 @@ export const postTaOrgConfig = (data) => request('/api/taOrgConfig', { data, met
15 15
  */
16 16
 export const getTaOrgConfigById = (id) => request(`/api/taOrgConfig/${id}`);
17 17
 
18
-/*
18
+/**
19 19
  * 更新数据
20
+ *  @param {*} id
21
+ * @param {*} data
22
+ * @returns
20 23
  */
21 24
 export const putTaOrgConfig = (id, data) => request(`/api/taOrgConfig/${id}`, { data, method: 'put' });
22 25
 

+ 1
- 1
vite.config.js Wyświetl plik

@@ -8,7 +8,7 @@ export default defineConfig({
8 8
     port: 3000,
9 9
     proxy: {
10 10
       '/api': {
11
-        target: 'http://192.168.89.147:9087',
11
+        target: 'http://localhost:9087',
12 12
         changeOrigin: true,
13 13
       },
14 14
     }