fangmingyue 2 年 前
コミット
00cdff5f69

+ 119
- 0
src/pages/locType/edit/index.jsx ファイルの表示

@@ -0,0 +1,119 @@
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 { postTdLocType, putTdLocType, getTdLocTypeById } from "@/service/tdloctype";
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
+
41
+  useEffect(() => {
42
+    if (id) {
43
+      getTdLocTypeById(id).then((res) => {
44
+        form.setFieldsValue(res);
45
+      });
46
+    }
47
+  }, [id]);
48
+
49
+  const onFinish = (values) => {
50
+    startSubmit();
51
+    console.log('locType修改id', id);
52
+    if (id) {
53
+      // 修改
54
+      putTdLocType(id, values).then((res) => {
55
+        navigate(-1);
56
+      }).catch(() => {
57
+        cancelSubmit();
58
+      });
59
+    } else {
60
+      // 新增
61
+      postTdLocType(values).then((res) => {
62
+        navigate(-1);
63
+      }).catch(() => {
64
+        cancelSubmit();
65
+      });
66
+    }
67
+  }
68
+
69
+
70
+  return (
71
+    <Card loading={loading}>
72
+      <Form onFinish={onFinish} form={form} {...formItemLayout} scrollToFirstError style={{ maxWidth: '1000px' }}>
73
+        <Form.Item
74
+          name="name"
75
+          label="分类名称"
76
+        >
77
+          <Input />
78
+        </Form.Item>
79
+        <Form.Item
80
+          name="desc"
81
+          label="分类描述"
82
+        >
83
+          <Input />
84
+        </Form.Item>
85
+
86
+        <Form.Item
87
+          name="sortNo"
88
+          label="排序"
89
+        >
90
+          <Input />
91
+        </Form.Item>
92
+
93
+
94
+        <Form.Item
95
+          name="status"
96
+          label="状态"
97
+        >
98
+          <Select
99
+            style={{ width: '100%' }}
100
+            placeholder="请选择状态"
101
+          >
102
+            <Option key={0}>不正常</Option>
103
+            <Option key={1}>正常</Option>
104
+          </Select>
105
+        </Form.Item>
106
+        <Form.Item {...tailFormItemLayout}>
107
+          <Button loading={submiting} type="primary" htmlType="submit">
108
+            保存
109
+          </Button>
110
+          <Button style={{ marginLeft: '2em' }} onClick={() => navigate(-1)}>
111
+            返回
112
+          </Button>
113
+        </Form.Item>
114
+      </Form>
115
+    </Card>
116
+  )
117
+}
118
+
119
+

+ 127
- 0
src/pages/locType/list/index.jsx ファイルの表示

@@ -0,0 +1,127 @@
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 { getTdLocType, deleteTdLocType } from "@/service/tdloctype";
7
+
8
+const queryTdLocTypeList = queryTable(getTdLocType);
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
+      deleteTdLocType(id).then((res) => {
29
+        actionRef.current.reload();
30
+      });
31
+    }
32
+  };
33
+
34
+  const columns = [
35
+    {
36
+      title: "分类ID",
37
+      dataIndex: "typeId",
38
+    },
39
+    {
40
+      title: "分类名称",
41
+      dataIndex: "name",
42
+    },
43
+    {
44
+      title: "分类描述",
45
+      dataIndex: "desc",
46
+    },
47
+    {
48
+      title: "排序",
49
+      dataIndex: "sortNo",
50
+    },
51
+    {
52
+      title: "状态",
53
+      dataIndex: "status",
54
+      valueEnum: {
55
+        1: {
56
+          text: "正常",
57
+          status: "Processing",
58
+        },
59
+        0: {
60
+          text: "禁用",
61
+          status: "Error",
62
+        },
63
+      },
64
+    },
65
+    {
66
+      title: "操作",
67
+      valueType: "option",
68
+      width: 200,
69
+      render: (_, record) => [
70
+        // <Button
71
+        //   key={1}
72
+        //   style={{ padding: 0 }}
73
+        //   type="link"
74
+        //   onClick={() => {
75
+        //     updateStatus(record);
76
+        //   }}
77
+        // >
78
+        //   {record.status === 1 ? "禁用" : "启用"}
79
+        // </Button>,
80
+        <Button
81
+          key={2}
82
+          style={{ padding: 0 }}
83
+          type="link"
84
+          onClick={() => {
85
+            console.log(record, "]]");
86
+            navigate(`/system/locType/edit?id=${record.typeId}`);
87
+          }}
88
+        >
89
+          编辑
90
+        </Button>,
91
+        <Popconfirm
92
+          key={3}
93
+          title="您是否确认删除 ?"
94
+          onConfirm={() => handleDelete(record.typeId)}
95
+          okText="确定"
96
+          cancelText="取消"
97
+        >
98
+          {/* manualPush */}
99
+          <Button style={{ padding: 0 }} type="link">
100
+            删除
101
+          </Button>
102
+        </Popconfirm>,
103
+      ],
104
+    },
105
+  ];
106
+
107
+  return (
108
+    <ProTable
109
+      actionRef={actionRef}
110
+      rowKey="typeId"
111
+      search={false}
112
+      toolBarRender={() => [
113
+        <Button
114
+          key="1"
115
+          type="primary"
116
+          onClick={() => {
117
+            navigate("/system/locType/edit");
118
+          }}
119
+        >
120
+          新增
121
+        </Button>,
122
+      ]}
123
+      request={queryTdLocTypeList}
124
+      columns={columns}
125
+    />
126
+  );
127
+};

+ 29
- 11
src/pages/org/edit/index.jsx ファイルの表示

@@ -37,28 +37,31 @@ export default (props) => {
37 37
   const navigate = useNavigate();
38 38
   const [searchParams, setSearchParams] = useSearchParams();
39 39
   const id = searchParams.get("id");
40
-  const [data, setDate] = useState();
41 40
 
42 41
   useEffect(() => {
43 42
     if (id) {
44 43
       getSysOrgById(id).then((res) => {
45 44
         form.setFieldsValue(res);
46
-        setDate(res);
45
+        // setDate(res);
47 46
       });
48 47
     }
49 48
   }, [id]);
50 49
 
51 50
   const onFinish = (values) => {
51
+    startSubmit();
52 52
     if (id) {
53
-      startLoading();
54 53
       // 修改
55
-      putTaOrgConfig(id, values).then((res) => {
54
+      putSysOrg(id, values).then((res) => {
56 55
         navigate(-1);
56
+      }).catch(() => {
57
+        cancelSubmit();
57 58
       });
58 59
     } else {
59 60
       // 新增
60
-      postTaOrgConfig(values).then((res) => {
61
+      postSysOrg(values).then((res) => {
61 62
         navigate(-1);
63
+      }).catch(() => {
64
+        cancelSubmit();
62 65
       });
63 66
     }
64 67
   }
@@ -68,23 +71,32 @@ export default (props) => {
68 71
     <Card loading={loading}>
69 72
       <Form onFinish={onFinish} form={form} {...formItemLayout} scrollToFirstError style={{ maxWidth: '1000px' }}>
70 73
         <Form.Item
71
-          name="orgId"
72
-          label="机构ID"
74
+          name="orgCode"
75
+          label="机构编码"
73 76
         >
74 77
           <Input />
75 78
         </Form.Item>
76 79
         <Form.Item
77
-          name="configCode"
78
-          label="配置编码"
80
+          name="name"
81
+          label="机构名称"
79 82
         >
80 83
           <Input />
81 84
         </Form.Item>
82 85
         <Form.Item
83
-          name="configValue"
84
-          label="配置项值"
86
+          name="orgPId"
87
+          label="上级单位"
85 88
         >
86 89
           <Input />
87 90
         </Form.Item>
91
+
92
+        <Form.Item
93
+          name="sortNo"
94
+          label="排序"
95
+        >
96
+          <Input />
97
+        </Form.Item>
98
+
99
+
88 100
         <Form.Item
89 101
           name="status"
90 102
           label="状态"
@@ -97,6 +109,12 @@ export default (props) => {
97 109
             <Option key={1}>正常</Option>
98 110
           </Select>
99 111
         </Form.Item>
112
+        <Form.Item
113
+          name="createUser"
114
+          label="创建人"
115
+        >
116
+          <Input />
117
+        </Form.Item>
100 118
         <Form.Item {...tailFormItemLayout}>
101 119
           <Button loading={submiting} type="primary" htmlType="submit">
102 120
             保存

+ 2
- 2
src/pages/org/list/index.jsx ファイルの表示

@@ -93,7 +93,7 @@ export default (props) => {
93 93
           type="link"
94 94
           onClick={() => {
95 95
             console.log(record, "]]");
96
-            navigate(`/system/org/edit?id=${record.id}`);
96
+            navigate(`/system/org/edit?id=${record.orgId}`);
97 97
           }}
98 98
         >
99 99
           编辑
@@ -101,7 +101,7 @@ export default (props) => {
101 101
         <Popconfirm
102 102
           key={3}
103 103
           title="您是否确认删除 ?"
104
-          onConfirm={() => handleDelete(record.id)}
104
+          onConfirm={() => handleDelete(record.orgId)}
105 105
           okText="确定"
106 106
           cancelText="取消"
107 107
         >

+ 37
- 6
src/pages/position/edit/index.jsx ファイルの表示

@@ -1,7 +1,7 @@
1
-import React from 'react';
1
+import React, { useRef, useEffect, useState } from 'react';
2 2
 import { Button, Card, Form, Input, Select } from 'antd';
3 3
 import useBool from '@/utils/hooks/useBool';
4
-import { postSysPosition, putSysPosition } from "@/service/sysposition";
4
+import { getSysPosition, postSysPosition, putSysPosition, getSysPositionById } from "@/service/sysposition";
5 5
 import { useSearchParams, useNavigate } from 'react-router-dom';
6 6
 
7 7
 const formItemLayout = {
@@ -34,26 +34,51 @@ export default (props) => {
34 34
   const [submiting, startSubmit, cancelSubmit] = useBool();
35 35
   const [form] = Form.useForm();
36 36
   const navigate = useNavigate();
37
+  const actionRef = useRef();
37 38
   const [searchParams, setSearchParams] = useSearchParams();
38 39
   const id = searchParams.get("id");
40
+  const [sysPositionList, setSysPositionList] = useState([]);
39 41
 
42
+  useEffect(() => {
43
+    if (id) {
44
+      getSysPositionById(id).then((res) => {
45
+        form.setFieldsValue(res);
46
+      });
47
+    }
48
+  }, [id]);
40 49
 
41
-  const onFinish = async (values) => {
50
+  useEffect(() => {
51
+    getSysPosition({ pageSize: 999 }).then((res) => {
52
+      console.log('res', res.records);
53
+      setSysPositionList(res.records);
54
+    })
55
+  }, [])
56
+
57
+  const onFinish = (values) => {
58
+    startSubmit();
59
+    console.log('fff', id);
42 60
     if (id) {
61
+
43 62
       // 修改
44 63
       putSysPosition(id, values).then((res) => {
45 64
         navigate(-1);
65
+      }).catch(() => {
66
+        cancelSubmit();
46 67
       });
47 68
     } else {
48 69
       // 新增
49
-      postSysPosition({ ...values }).then((res) => {
70
+      postSysPosition(values).then((res) => {
50 71
         navigate(-1);
72
+      }).catch(() => {
73
+        cancelSubmit();
51 74
       });
52 75
     }
53
-    return false;
54 76
   }
55 77
 
56 78
 
79
+  console.log('tiantian', sysPositionList);
80
+
81
+
57 82
   return (
58 83
     <Card loading={loading}>
59 84
       <Form onFinish={onFinish} form={form} {...formItemLayout} scrollToFirstError style={{ maxWidth: '1000px' }}>
@@ -73,7 +98,13 @@ export default (props) => {
73 98
           name="orgId"
74 99
           label="所属单位"
75 100
         >
76
-          <Input />
101
+          <Select allowClear>
102
+            {sysPositionList.map((item) => (
103
+              <Option value={item.positionId} key={item.positionId}>
104
+                {item.orgId}
105
+              </Option>
106
+            ))}
107
+          </Select>
77 108
         </Form.Item>
78 109
         <Form.Item
79 110
           name="sortNum"

+ 2
- 2
src/pages/position/list/index.jsx ファイルの表示

@@ -92,7 +92,7 @@ export default (props) => {
92 92
           type="link"
93 93
           onClick={() => {
94 94
             console.log(record, "]]");
95
-            navigate(`/system/position/edit?id=${record.id}`);
95
+            navigate(`/system/position/edit?id=${record.positionId}`);
96 96
           }}
97 97
         >
98 98
           编辑
@@ -100,7 +100,7 @@ export default (props) => {
100 100
         <Popconfirm
101 101
           key={3}
102 102
           title="您是否确认删除 ?"
103
-          onConfirm={() => handleDelete(record.id)}
103
+          onConfirm={() => handleDelete(record.positionId)}
104 104
           okText="确定"
105 105
           cancelText="取消"
106 106
         >

+ 24
- 0
src/routes/routes.jsx ファイルの表示

@@ -25,6 +25,9 @@ import OrgList from "@/pages/org/list";
25 25
 import OrgEdit from "@/pages/org/edit";
26 26
 import PositionList from "@/pages/position/list";
27 27
 import PositionEdit from "@/pages/position/edit";
28
+import LocTypeList from "@/pages/locType/list";
29
+import LocTypeEdit from "@/pages/locType/edit";
30
+
28 31
 /**
29 32
  * meta 用来扩展自定义数据数据
30 33
  * {
@@ -119,6 +122,27 @@ export const authRoutes = [
119 122
           // permission: 'form',
120 123
         },
121 124
       },
125
+      ,
126
+      {
127
+        path: "locType/list",
128
+        element: <LocTypeList />,
129
+        meta: {
130
+          title: '点位分类',
131
+          // icon: <AppstoreOutlined />,
132
+          // permission: 'form',
133
+        },
134
+      },
135
+      ,
136
+      {
137
+        path: "locType/edit",
138
+        element: <LocTypeEdit />,
139
+        meta: {
140
+          hideInMenu: true,
141
+          title: '点位分类编辑',
142
+          // icon: <AppstoreOutlined />,
143
+          // permission: 'form',
144
+        },
145
+      },
122 146
     ]
123 147
   },
124 148
 

+ 4
- 1
src/service/tdloctype.js ファイルの表示

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