李志伟 3 年前
父节点
当前提交
d3ed3edf40

+ 110
- 72
src/pages/ContentManagementSystem/InformationClassification/index.jsx 查看文件

1
-import { history, Link } from 'umi';
2
-import { useRef } from 'react';
3
-import { Button, Modal, message, Popconfirm, Tooltip } from 'antd';
4
-import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Button, Popconfirm, Modal, Form, Input, message } from 'antd';
3
+import { PlusOutlined } from '@ant-design/icons';
5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
-import ProTable, { TableDropdown } from '@ant-design/pro-table';
5
+import moment from 'moment';
6
+import PageTable from '@/components/PageTable';
7
+import { getNewsTypeList, addNewsType, deleteNewsType, updateNewsType } from '@/services/newsType';
7
 
8
 
8
-export default (props) => {
9
-  const dataSource = [
10
-    {
11
-      id: 9,
12
-      key: '1',
13
-      name: '胡彦斌',
14
-      age: 32,
15
-      zz: '西湖区湖底公园1号',
16
-    },
17
-  ];
18
-
19
-  // 测试内容👆-------------------------
9
+const formatterTime = (val) => {
10
+  return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
11
+};
12
+const FormItem = Form.Item;
20
 
13
 
14
+export default (props) => {
15
+  const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
16
+  const [form] = Form.useForm();
17
+  const [editModal, setEditModal] = useState(false);
18
+  const [loading, setLoading] = useState(false);
19
+  const [typeId, setTypeId] = useState();
21
   const actionRef = useRef();
20
   const actionRef = useRef();
22
-  const gotoDetail = (id) => {
23
-    history.push(`InformationClassification/InformationClassificationEdit`);
24
-  };
25
-
26
-  const handleDelete = (e) => {
27
-    deleteNote(e.noteId).then((res) => {
28
-      message.success('删除成功');
29
-      actionRef.current.reload();
30
-    });
31
-  };
32
 
21
 
33
-  const handleOK = (record, data) => {
34
-    const titleCourse = record.status
35
-      ? '您确定要禁用该用户吗? 禁用后该用户不能在后台登陆!'
36
-      : '您确定要启用该用户吗? 启用后该用户将允许在后台登陆!';
37
-    Modal.confirm({
38
-      title: titleCourse,
39
-      okText: '确认',
40
-      cancelText: '取消',
41
-      onOk() {
42
-        publishNote(record.noteId, record.status ? 'off' : 'on').then((res) => {
43
-          message.success('操作成功');
22
+  const Submit = (values) => {
23
+    setLoading(true);
24
+    if (typeId) {
25
+      updateNewsType(typeId, values).then(() => {
26
+        setLoading(false);
27
+        message.success(`修改成功`);
28
+        onCancel();
29
+        actionRef.current.reload();
30
+      });
31
+    } else {
32
+      addNewsType(values)
33
+        .then(() => {
34
+          setLoading(false);
35
+          message.success(`保存成功`);
36
+          onCancel();
44
           actionRef.current.reload();
37
           actionRef.current.reload();
38
+        })
39
+        .catch((err) => {
40
+          setLoading(false);
41
+          message.error(err.message || err);
45
         });
42
         });
46
-      },
47
-    });
43
+    }
44
+  };
45
+  const handelEdit = (val) => {
46
+    setTypeId(val.typeId);
47
+    form.setFieldsValue(val);
48
+    setEditModal(true);
49
+  };
50
+  const onCancel = () => {
51
+    setTypeId();
52
+    form.resetFields();
53
+    setEditModal(false);
48
   };
54
   };
55
+  const handleDelete = (id) => {
56
+    deleteNewsType(id)
57
+      .then(() => {
58
+        message.success('删除成功');
59
+        actionRef.current.reload();
60
+      })
61
+      .catch((err) => {
62
+        message.error(err);
63
+      });
64
+  };
65
+  useEffect(() => {
66
+    if (typeId) {
67
+    } else {
68
+      form.resetFields();
69
+    }
70
+  }, [typeId]);
49
   const actions = () => [
71
   const actions = () => [
50
-    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>
72
+    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => setEditModal(true)}>
51
       新增
73
       新增
52
     </Button>,
74
     </Button>,
53
   ];
75
   ];
56
       title: '分类名',
78
       title: '分类名',
57
       dataIndex: 'name',
79
       dataIndex: 'name',
58
       key: 'name',
80
       key: 'name',
59
-      search: false,
60
     },
81
     },
61
-
62
     {
82
     {
63
-      title: (
64
-        <>
65
-          创建时间
66
-          <Tooltip placement="top">
67
-            <QuestionCircleOutlined style={{ marginLeft: 4 }} />
68
-          </Tooltip>
69
-        </>
70
-      ),
71
-      // hideInTable: true,
83
+      title: '创建时间',
84
+      dataIndex: 'createDate',
85
+      key: 'createDate',
86
+      render: formatterTime,
72
       search: false,
87
       search: false,
73
-
74
-      key: 'createdAt',
75
-      dataIndex: 'createdAt',
76
-      valueType: 'date',
77
-      // render: (t) => formatterTime(t),
78
-      sorter: (a, b) => a.createdAt - b.createdAt, //时间排序
88
+      width: 240,
79
     },
89
     },
80
     {
90
     {
81
       title: '操作',
91
       title: '操作',
82
       valueType: 'option',
92
       valueType: 'option',
83
-      key: 'option',
84
-      ellipsis: true,
85
-      width: 200,
93
+      width: 160,
86
       render: (_, record) => [
94
       render: (_, record) => [
87
-        <Link key={2} to={`InformationClassification/InformationClassificationEdit`}>
95
+        <Button type="link" style={{ padding: 0 }} key={1} onClick={() => handelEdit(record)}>
88
           编辑
96
           编辑
89
-        </Link>,
97
+        </Button>,
90
         <Popconfirm
98
         <Popconfirm
91
-          key={3}
99
+          key={2}
92
           title="您是否确认删除 ?"
100
           title="您是否确认删除 ?"
93
-          onConfirm={() => handleDelete(record)}
101
+          onConfirm={() => handleDelete(record.typeId)}
94
           okText="确定"
102
           okText="确定"
95
           cancelText="取消"
103
           cancelText="取消"
96
         >
104
         >
97
-          <a href="#">删除</a>
105
+          <Button style={{ padding: 0 }} type="link">
106
+            删除
107
+          </Button>
98
         </Popconfirm>,
108
         </Popconfirm>,
99
       ],
109
       ],
100
     },
110
     },
102
 
112
 
103
   return (
113
   return (
104
     <PageHeaderWrapper>
114
     <PageHeaderWrapper>
105
-      <ProTable
106
-        dataSource={dataSource}
115
+      <PageTable
116
+        request={getNewsTypeList}
107
         columns={columns}
117
         columns={columns}
108
-        // request={getNoteList} 请求
109
-        // rowKey="noteId"
110
-        search={false}
118
+        actionRef={actionRef}
119
+        rowKey="typeId"
111
         options={false}
120
         options={false}
112
         toolBarRender={actions}
121
         toolBarRender={actions}
113
-        actionRef={actionRef}
122
+        scroll={{ x: 1000 }}
114
       />
123
       />
124
+      <Modal
125
+        forceRender
126
+        title={typeId ? '分类编辑' : '分类新增'}
127
+        visible={editModal}
128
+        onCancel={onCancel}
129
+        keyboard={false}
130
+        maskClosable={false}
131
+        destroyOnClose={true}
132
+        footer={null}
133
+      >
134
+        <Form {...formItemLayout} onFinish={Submit} form={form}>
135
+          <FormItem label="分类名" name="name" rules={[{ required: true, message: '请输入' }]}>
136
+            <Input placeholder="请输入" />
137
+          </FormItem>
138
+          <FormItem label=" " colon={false}>
139
+            <Button type="default" onClick={onCancel}>
140
+              取消
141
+            </Button>
142
+            <Button
143
+              type="primary"
144
+              loading={loading}
145
+              htmlType="Submit"
146
+              style={{ marginLeft: '4em' }}
147
+            >
148
+              确认
149
+            </Button>
150
+          </FormItem>
151
+        </Form>
152
+      </Modal>
115
     </PageHeaderWrapper>
153
     </PageHeaderWrapper>
116
   );
154
   );
117
 };
155
 };

+ 30
- 18
src/pages/Machinery/Machinery/index.jsx 查看文件

1
-import React, { useRef } from 'react';
1
+import React, { useRef, useEffect, useState } from 'react';
2
 import { history } from 'umi';
2
 import { history } from 'umi';
3
 import { Button, Popconfirm, message, Select, Modal } from 'antd';
3
 import { Button, Popconfirm, message, Select, Modal } from 'antd';
4
 import { PlusOutlined } from '@ant-design/icons';
4
 import { PlusOutlined } from '@ant-design/icons';
5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
 import PageTable from '@/components/PageTable';
6
 import PageTable from '@/components/PageTable';
7
 import { getMachineryList, deleteMachinery, updateMachinery } from '@/services/machinery';
7
 import { getMachineryList, deleteMachinery, updateMachinery } from '@/services/machinery';
8
+import { getMachineryTypeList } from '@/services/machineryType';
8
 
9
 
9
 const { Option } = Select;
10
 const { Option } = Select;
10
 
11
 
11
 export default (props) => {
12
 export default (props) => {
12
   const actionRef = useRef();
13
   const actionRef = useRef();
14
+  const [machineryTypeList, setMachineryTypeList] = useState([]);
13
 
15
 
14
   const gotoEdit = (id) => {
16
   const gotoEdit = (id) => {
15
     const queryStr = id ? `?id=${id}` : '';
17
     const queryStr = id ? `?id=${id}` : '';
42
       },
44
       },
43
     });
45
     });
44
   };
46
   };
47
+  useEffect(() => {
48
+    getMachineryTypeList().then((res) => {
49
+      setMachineryTypeList(res.records);
50
+    });
51
+  }, []);
45
   const actions = () => [
52
   const actions = () => [
46
     <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoEdit()}>
53
     <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoEdit()}>
47
       新增农机
54
       新增农机
53
       dataIndex: 'name',
60
       dataIndex: 'name',
54
       key: 'name',
61
       key: 'name',
55
     },
62
     },
63
+    {
64
+      title: '农机类型',
65
+      dataIndex: 'typeId',
66
+      key: 'typeId',
67
+      renderFormItem: (item, field, form) => {
68
+        return (
69
+          <Select style={{ width: '350px' }}>
70
+            {machineryTypeList.map((item) => (
71
+              <Option value={item.typeId} key={item.typeId}>
72
+                {item.name}
73
+              </Option>
74
+            ))}
75
+          </Select>
76
+        );
77
+      },
78
+      hideInTable: true,
79
+    },
56
     {
80
     {
57
       title: '农机类型',
81
       title: '农机类型',
58
       dataIndex: 'typeName',
82
       dataIndex: 'typeName',
59
       key: 'typeName',
83
       key: 'typeName',
84
+      search: false,
60
     },
85
     },
61
     {
86
     {
62
-      title: '农机归属',
87
+      title: '区域',
63
       dataIndex: 'regionName',
88
       dataIndex: 'regionName',
64
       key: 'regionName',
89
       key: 'regionName',
90
+      search: false,
65
     },
91
     },
66
     {
92
     {
67
       title: '农机价格',
93
       title: '农机价格',
93
       title: '工作状态',
119
       title: '工作状态',
94
       dataIndex: 'jobStatus',
120
       dataIndex: 'jobStatus',
95
       key: 'jobStatus',
121
       key: 'jobStatus',
96
-      renderFormItem: (item, field, form) => {
97
-        return (
98
-          <Select>
99
-            <Option value="1">忙碌</Option>
100
-            <Option value="0">空闲</Option>
101
-          </Select>
102
-        );
103
-      },
122
+      search: false,
104
       render: (_, record) => {
123
       render: (_, record) => {
105
         return record.jobStatus === 1 ? '忙碌' : '空闲';
124
         return record.jobStatus === 1 ? '忙碌' : '空闲';
106
       },
125
       },
109
       title: '发布状态',
128
       title: '发布状态',
110
       dataIndex: 'status',
129
       dataIndex: 'status',
111
       key: 'status',
130
       key: 'status',
112
-      renderFormItem: (item, field, form) => {
113
-        return (
114
-          <Select>
115
-            <Option value="1">发布</Option>
116
-            <Option value="0">未发布</Option>
117
-          </Select>
118
-        );
119
-      },
131
+      search: false,
120
       render: (_, record) => {
132
       render: (_, record) => {
121
         return record.status === 1 ? '发布' : '未发布';
133
         return record.status === 1 ? '发布' : '未发布';
122
       },
134
       },

+ 2
- 2
src/pages/SystemManagement/Cooperative/index.jsx 查看文件

223
                   ))}
223
                   ))}
224
                 </Select>
224
                 </Select>
225
               </FormItem>
225
               </FormItem>
226
-              <FormItem
226
+              {/* <FormItem
227
                 label="身份"
227
                 label="身份"
228
                 name="role"
228
                 name="role"
229
                 rules={[{ required: true, message: '请选择身份' }]}
229
                 rules={[{ required: true, message: '请选择身份' }]}
232
                   <Option value="合作社" key="合作社" />
232
                   <Option value="合作社" key="合作社" />
233
                   <Option value="个体户" key="个体户" />
233
                   <Option value="个体户" key="个体户" />
234
                 </Select>
234
                 </Select>
235
-              </FormItem>
235
+              </FormItem> */}
236
               <FormItem label="员工数">{listForm?.workerNum || 0}</FormItem>
236
               <FormItem label="员工数">{listForm?.workerNum || 0}</FormItem>
237
               <FormItem label="农机数">{listForm?.machineryNum || 0}</FormItem>
237
               <FormItem label="农机数">{listForm?.machineryNum || 0}</FormItem>
238
               <FormItem label="订单完成数">{listForm?.orderNum || 0}</FormItem>
238
               <FormItem label="订单完成数">{listForm?.orderNum || 0}</FormItem>

+ 36
- 0
src/services/newsType.js 查看文件

1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 保存资讯分类
5
+ * @param {*} data
6
+ * @returns
7
+ */
8
+export const addNewsType = (data) => request('/news-type', { method: 'post', data });
9
+
10
+/**
11
+ * 修改资讯分类
12
+ * @param {*} data
13
+ * @returns
14
+ */
15
+export const updateNewsType = (id, data) => request(`/news-type/${id}`, { method: 'put', data });
16
+
17
+/**
18
+ * 查询资讯分类列表
19
+ * @param {*} params
20
+ * @returns
21
+ */
22
+export const getNewsTypeList = (params) => request('/news-type', { params });
23
+
24
+/**
25
+ * 删除资讯分类
26
+ * @param {*} data
27
+ * @returns
28
+ */
29
+export const deleteNewsType = (id) => request(`/news-type/${id}`, { method: 'delete' });
30
+
31
+/**
32
+ * 查询资讯分类详情
33
+ * @param {*} params
34
+ * @returns
35
+ */
36
+export const getNewsTypeDetail = (id) => request(`/news-type/${id}`);