Просмотр исходного кода

Merge branch 'master' of http://git.ycjcjy.com/civilized_city/pc-admin

Your Name 2 лет назад
Родитель
Сommit
28c6016141

+ 111
- 0
src/pages/issueType/edit/index.jsx Просмотреть файл

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

+ 123
- 0
src/pages/issueType/list/index.jsx Просмотреть файл

@@ -0,0 +1,123 @@
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 { getTdIssueType, deleteTdIssueType } from "@/service/tdissuetype";
7
+
8
+const queryTdIssueList = queryTable(getTdIssueType);
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
+      deleteTdIssueType(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: "sortNo",
46
+    },
47
+    {
48
+      title: "状态",
49
+      dataIndex: "status",
50
+      valueEnum: {
51
+        1: {
52
+          text: "正常",
53
+          status: "Processing",
54
+        },
55
+        0: {
56
+          text: "禁用",
57
+          status: "Error",
58
+        },
59
+      },
60
+    },
61
+    {
62
+      title: "操作",
63
+      valueType: "option",
64
+      width: 200,
65
+      render: (_, record) => [
66
+        // <Button
67
+        //   key={1}
68
+        //   style={{ padding: 0 }}
69
+        //   type="link"
70
+        //   onClick={() => {
71
+        //     updateStatus(record);
72
+        //   }}
73
+        // >
74
+        //   {record.status === 1 ? "禁用" : "启用"}
75
+        // </Button>,
76
+        <Button
77
+          key={2}
78
+          style={{ padding: 0 }}
79
+          type="link"
80
+          onClick={() => {
81
+            console.log(record, "]]");
82
+            navigate(`/system/issueType/edit?id=${record.typeId}`);
83
+          }}
84
+        >
85
+          编辑
86
+        </Button>,
87
+        <Popconfirm
88
+          key={3}
89
+          title="您是否确认删除 ?"
90
+          onConfirm={() => handleDelete(record.typeId)}
91
+          okText="确定"
92
+          cancelText="取消"
93
+        >
94
+          {/* manualPush */}
95
+          <Button style={{ padding: 0 }} type="link">
96
+            删除
97
+          </Button>
98
+        </Popconfirm>,
99
+      ],
100
+    },
101
+  ];
102
+
103
+  return (
104
+    <ProTable
105
+      actionRef={actionRef}
106
+      rowKey="typeId"
107
+      search={false}
108
+      toolBarRender={() => [
109
+        <Button
110
+          key="1"
111
+          type="primary"
112
+          onClick={() => {
113
+            navigate("/system/issueType/edit");
114
+          }}
115
+        >
116
+          新增
117
+        </Button>,
118
+      ]}
119
+      request={queryTdIssueList}
120
+      columns={columns}
121
+    />
122
+  );
123
+};

+ 3
- 1
src/pages/locType/edit/index.jsx Просмотреть файл

@@ -35,7 +35,7 @@ export default (props) => {
35 35
   const [submiting, startSubmit, cancelSubmit] = useBool();
36 36
   const [form] = Form.useForm();
37 37
   const navigate = useNavigate();
38
-  const [searchParams, setSearchParams] = useSearchParams();
38
+  const [searchParams] = useSearchParams();
39 39
   const id = searchParams.get("id");
40 40
 
41 41
   useEffect(() => {
@@ -46,6 +46,8 @@ export default (props) => {
46 46
     }
47 47
   }, [id]);
48 48
 
49
+  console.log('id', id);
50
+
49 51
   const onFinish = (values) => {
50 52
     startSubmit();
51 53
     console.log('locType修改id', id);

+ 22
- 3
src/routes/routes.jsx Просмотреть файл

@@ -28,6 +28,8 @@ import PositionList from "@/pages/position/list";
28 28
 import PositionEdit from "@/pages/position/edit";
29 29
 import LocTypeList from "@/pages/locType/list";
30 30
 import LocTypeEdit from "@/pages/locType/edit";
31
+import IssueTypeList from "@/pages/issueType/list";
32
+import IssueTypeEdit from "@/pages/issueType/edit";
31 33
 
32 34
 /**
33 35
  * meta 用来扩展自定义数据数据
@@ -112,7 +114,6 @@ export const authRoutes = [
112 114
           // permission: 'form',
113 115
         },
114 116
       },
115
-      ,
116 117
       {
117 118
         path: "position/edit",
118 119
         element: <PositionEdit />,
@@ -123,7 +124,6 @@ export const authRoutes = [
123 124
           // permission: 'form',
124 125
         },
125 126
       },
126
-      ,
127 127
       {
128 128
         path: "locType/list",
129 129
         element: <LocTypeList />,
@@ -133,7 +133,6 @@ export const authRoutes = [
133 133
           // permission: 'form',
134 134
         },
135 135
       },
136
-      ,
137 136
       {
138 137
         path: "locType/edit",
139 138
         element: <LocTypeEdit />,
@@ -144,6 +143,26 @@ export const authRoutes = [
144 143
           // permission: 'form',
145 144
         },
146 145
       },
146
+
147
+      {
148
+        path: "issueType/list",
149
+        element: <IssueTypeList />,
150
+        meta: {
151
+          title: '问题分类',
152
+          // icon: <AppstoreOutlined />,
153
+          // permission: 'form',
154
+        },
155
+      },
156
+      {
157
+        path: "issueType/edit",
158
+        element: <IssueTypeEdit />,
159
+        meta: {
160
+          hideInMenu: true,
161
+          title: '问题分类编辑',
162
+          // icon: <AppstoreOutlined />,
163
+          // permission: 'form',
164
+        },
165
+      },
147 166
     ]
148 167
   },
149 168
   {

+ 1
- 1
vite.config.js Просмотреть файл

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