Pārlūkot izejas kodu

Merge branch 'master' of http://git.ycjcjy.com/nanyang/machinery-admin

张延森 3 gadus atpakaļ
vecāks
revīzija
a07efaae0b

+ 1
- 0
src/components/ScreenBox/TitleBox/style.less Parādīt failu

@@ -4,6 +4,7 @@
4 4
   align-items: center;
5 5
   padding: 11px 11px 9px 11px;
6 6
   border-radius: 4px;
7
+
7 8
   box-shadow: 0px 0px 10px 0px #3d81f0 inset;
8 9
 
9 10
   .TitleBox-ListBox {

+ 0
- 45
src/pages/MonitoringScreen/DateCommponets.jsx Parādīt failu

@@ -1,45 +0,0 @@
1
-
2
-
3
-
4
-import SquareBox from '@/components/ScreenBox/SquareBox'
5
-import TitleBox from '@/components/ScreenBox/TitleBox'
6
-import { Bar } from '@ant-design/plots';
7
-// import ba from './a.png'
8
-
9
-export default (props) => {
10
-
11
-  const data = [
12
-    {
13
-      year: '收割机',
14
-      value: 200,
15
-    },
16
-    {
17
-      year: '播种机',
18
-      value: 150,
19
-    },
20
-    {
21
-      year: '农药机',
22
-      value: 50,
23
-    },
24
-  ];
25
-  const config = {
26
-    data,
27
-    xField: 'value',
28
-    yField: 'year',
29
-    seriesField: 'year',
30
-
31
-    legend: {
32
-      position: 'top-left',
33
-    },
34
-    color: [' #FB9900', '#23E8AE', '#E63404'],
35
-  };
36
-
37
-  return (
38
-    <div  >
39
-      <TitleBox value='农机类型统计' />
40
-      <SquareBox>
41
-        <Bar  {...config} />
42
-      </SquareBox>
43
-    </div>
44
-  )
45
-}

+ 121
- 0
src/pages/MonitoringScreen/DateCommponetsBottomLeft.jsx Parādīt failu

@@ -0,0 +1,121 @@
1
+
2
+
3
+
4
+import SquareBox from '@/components/ScreenBox/SquareBox'
5
+import TitleBox from '@/components/ScreenBox/TitleBox'
6
+import { Column } from '@ant-design/plots';
7
+// import ba from './a.png'
8
+
9
+export default (props) => {
10
+
11
+
12
+  const style = {
13
+    bgd: {
14
+      width: '25vw',
15
+      display: 'inline-block',
16
+    }
17
+  }
18
+  const data = [
19
+    {
20
+      name: '预约',
21
+      NongType: '预约.',
22
+      sum: 18,
23
+    },
24
+    {
25
+      name: '作业',
26
+      NongType: '作业.',
27
+      sum: 28,
28
+    },
29
+    {
30
+      name: '闲置',
31
+      NongType: '闲置.',
32
+      sum: 100,
33
+    },
34
+    {
35
+      name: '离线',
36
+      NongType: '离线',
37
+      sum: 181,
38
+    },
39
+    {
40
+      name: '维修',
41
+      NongType: '维修',
42
+      sum: 147,
43
+    },
44
+
45
+  ];
46
+  const config = {
47
+    data,
48
+    isGroup: true,
49
+    xField: 'NongType',
50
+    yField: 'sum',
51
+    seriesField: 'name',
52
+    color: ['#F5CC5C', '#44F68B', '#51D4FF', '#B8B2A9', '#F55226'],
53
+    minColumnWidth: 26,
54
+    columnStyle: {
55
+      // fill: 'l(270) 0:rgba(225,225,225,0.0) 1:#FB9900',
56
+    },
57
+    color: ({ name }) => {
58
+      if (name == '预约') {
59
+
60
+        return `l(270) 0:rgba(225,225,225,0.0) 1:#F5CC5C`;
61
+
62
+
63
+      }
64
+      if (name == '作业') {
65
+
66
+        return `l(270) 0:rgba(225,225,225,0.0) 1:#44F68B`;
67
+
68
+
69
+      }
70
+      if (name == '闲置') {
71
+
72
+        return `l(270) 0:rgba(225,225,225,0.0) 1:#51D4FF`;
73
+
74
+
75
+      }
76
+      if (name == '离线') {
77
+
78
+        return `l(270) 0:rgba(225,225,225,0.0) 1:#B8B2A9`;
79
+
80
+
81
+      }
82
+      if (name == '维修') {
83
+
84
+        return `l(270) 0:rgba(225,225,225,0.0) 1:#F55226`;
85
+
86
+
87
+      }
88
+    },
89
+    /** 设置间距 */
90
+    // marginRatio: 0.1,
91
+    label: {
92
+      // 'top', 'middle', 'bottom'
93
+      // 可配置附加的布局方法
94
+      layout: [
95
+        // 柱形图数据标签位置自动调整
96
+        {
97
+          // type: 'interval-adjust-position',
98
+        }, // 数据标签防遮挡
99
+        {
100
+          // type: 'interval-hide-overlap',
101
+        }, // 数据标签文颜色自动调整
102
+        {
103
+          // type: 'adjust-color',
104
+        },
105
+      ],
106
+    },
107
+  };
108
+
109
+  return (
110
+    <div style={{ width: '100vw' }}>
111
+      <div style={style.bgd} >
112
+        <TitleBox value='农机状态统计' />
113
+        <SquareBox>
114
+          <Column  {...config} />
115
+        </SquareBox>
116
+      </div>
117
+
118
+    </div>
119
+
120
+  )
121
+}

+ 85
- 0
src/pages/MonitoringScreen/DateCommponetsBottomRight.jsx Parādīt failu

@@ -0,0 +1,85 @@
1
+
2
+
3
+
4
+import SquareBox from '@/components/ScreenBox/SquareBox'
5
+import TitleBox from '@/components/ScreenBox/TitleBox'
6
+import { Pie, G2 } from '@ant-design/plots';
7
+// import ba from './a.png'
8
+
9
+export default (props) => {
10
+
11
+  const G = G2.getEngine('canvas');
12
+  const style = {
13
+    bgd: {
14
+      width: '30vw',
15
+      display: 'inline-block',
16
+    }
17
+  }
18
+  const data = [
19
+    {
20
+      type: '收割机',
21
+      value: 27,
22
+    },
23
+    {
24
+      type: '播种机',
25
+      value: 25,
26
+    },
27
+    {
28
+      type: '农药机',
29
+      value: 18,
30
+    },
31
+    {
32
+      type: '其他',
33
+      value: 70,
34
+    }
35
+  ];
36
+  const config = {
37
+    color: ['#FB9900', '#355C9C', '#23E8AE', '#E63404'],
38
+    pieStyle: {
39
+      strokeOpacity: 0,
40
+      lineWidth: 0,
41
+    },
42
+    statistic: {
43
+      title: false,
44
+      content: {
45
+        style: {
46
+          whiteSpace: 'pre-wrap',
47
+          overflow: 'hidden',
48
+          textOverflow: 'ellipsis',
49
+        },
50
+        content: ' ',
51
+      },
52
+    },
53
+    appendPadding: 10,
54
+    data,
55
+    angleField: 'value',
56
+    colorField: 'type',
57
+    innerRadius: 0.8,
58
+    radius: 0.75,
59
+    label: {
60
+      type: 'spider',
61
+      labelHeight: 28,
62
+      content: '{name}\n{percentage}',
63
+    },
64
+    interactions: [
65
+      {
66
+        type: 'element-selected',
67
+      },
68
+      {
69
+        type: 'element-active',
70
+      },
71
+    ],
72
+  };
73
+  return (
74
+    <div style={{ width: '100vw' }}>
75
+      <div style={style.bgd} >
76
+        <TitleBox value='农机类型统计' />
77
+        <SquareBox>
78
+          <Pie  {...config} />
79
+        </SquareBox>
80
+      </div>
81
+
82
+    </div>
83
+
84
+  )
85
+}

+ 92
- 0
src/pages/MonitoringScreen/DateCommponetsLeft.jsx Parādīt failu

@@ -0,0 +1,92 @@
1
+
2
+
3
+
4
+import SquareBox from '@/components/ScreenBox/SquareBox'
5
+import TitleBox from '@/components/ScreenBox/TitleBox'
6
+import { Bar } from '@ant-design/plots';
7
+
8
+export default (props) => {
9
+
10
+
11
+  const style = {
12
+    bgd: {
13
+      width: '25vw',
14
+      display: 'inline-block',
15
+    }
16
+  }
17
+  const data = [
18
+    {
19
+      year: '收割机',
20
+      value: 200,
21
+    },
22
+    {
23
+      year: '播种机',
24
+      value: 150,
25
+    },
26
+    {
27
+      year: '农药机',
28
+      value: 50,
29
+    },
30
+  ];
31
+
32
+  const config = {
33
+    maxBarWidth: 20,
34
+    data,
35
+    xField: 'value',
36
+    yField: 'year',
37
+    seriesField: 'year',
38
+
39
+    // color: [' #FB9900', '#23E8AE', '#E63404'],
40
+    color: ({ type, year }) => {
41
+      if (year == '收割机') {
42
+
43
+        return `l(0) 0:rgba(225,225,225,0.0) 1:#FB9900`;
44
+
45
+
46
+      }
47
+      if (year == '播种机') {
48
+
49
+        return `l(0) 0:rgba(225,225,225,0.0) 1:#23E8AE`;
50
+
51
+
52
+      }
53
+      if (year == '农药机') {
54
+
55
+        return `l(0) 0:rgba(225,225,225,0.0) 1:#E63404`;
56
+
57
+
58
+      }
59
+    },
60
+    barStyle: {
61
+      // fill: `l(0) 0:rgba(225,225,225,0.0) 1:#FB9900`,
62
+    },
63
+    legend: {
64
+      position: 'top-left',
65
+
66
+    },
67
+    statistic: {
68
+      style: {
69
+        // fill: '#FB9900',
70
+        // fill: '#23E8AE',
71
+        // fill: '#E63404',
72
+        fontSize: 10,
73
+        fontWeight: 60,
74
+        textAlign: 'center',
75
+        textBaseline: 'middle',
76
+      }
77
+    }
78
+  };
79
+
80
+  return (
81
+    <div style={{ width: '100vw' }}>
82
+      <div style={style.bgd} >
83
+        <TitleBox value='农机类型统计' />
84
+        <SquareBox>
85
+          <Bar  {...config} />
86
+        </SquareBox>
87
+      </div>
88
+
89
+    </div>
90
+
91
+  )
92
+}

+ 3
- 1
src/pages/MonitoringScreen/index.jsx Parādīt failu

@@ -6,7 +6,9 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
6 6
 import { FullscreenOutlined } from '@ant-design/icons';
7 7
 import { Button } from 'antd';
8 8
 import { useFullScreen } from './hook';
9
-import DateCommponets from './DateCommponets';
9
+import DateCommponetsLeft from './DateCommponetsLeft';
10
+import DateCommponetsBottomRight from './DateCommponetsBottomRight';
11
+import DateCommponetsBottomLeft from './DateCommponetsBottomLeft';
10 12
 import Styles from './style.less';
11 13
 import SquareBox from '@/components/ScreenBox/SquareBox';
12 14
 import ScreenHeader from '@/components/ScreenBox/ScreenHeader';

+ 83
- 25
src/pages/SystemManagement/Administrator/index.jsx Parādīt failu

@@ -1,8 +1,6 @@
1 1
 import React, { useState, useEffect, useRef } from 'react';
2
-import { history, Link } from 'umi';
3
-import { Button, Popconfirm, Modal, Form, Input, message, Radio, Select, Tooltip } from 'antd';
2
+import { Button, Popconfirm, Modal, Form, Input, message, Radio, Select } from 'antd';
4 3
 import { PlusOutlined } from '@ant-design/icons';
5
-import { getRegionList, addRegion, deleteRegion, updateRegion } from '@/services/region';
6 4
 import { getCooperativeList } from '@/services/cooperative';
7 5
 import {
8 6
   getUserList,
@@ -20,26 +18,24 @@ const FormItem = Form.Item;
20 18
 const { Option } = Select;
21 19
 
22 20
 export default (props) => {
23
-  const actions = () => [
24
-    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => setEditModal(true)}>
25
-      新增
26
-    </Button>,
27
-  ];
21
+  //编辑弹窗
28 22
   const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
29 23
   const [form] = Form.useForm();
30 24
   const [editModal, setEditModal] = useState(false);
31 25
   const [loading, setLoading] = useState(false);
32 26
   const [userId, setuserId] = useState();
33 27
   const [password, setPassWord] = useState('');
34
-  const actionRef = useRef();
35 28
   const [cooperativeList, setCooperativeList] = useState([]);
36 29
 
30
+  //列表数据
31
+  const actionRef = useRef();
32
+
33
+  // 编辑弹窗的表单提交
37 34
   const Submit = (values) => {
38 35
     const newData = { ...values };
39 36
     if (!newData.sex && newData.sex !== 0) {
40 37
       newData.sex = 1;
41 38
     }
42
-    console.log(newData);
43 39
     setLoading(true);
44 40
     if (!/^1[0-9]{10}$/.test(newData.phone)) {
45 41
       message.warning('请输入正确的十一位手机号');
@@ -67,19 +63,23 @@ export default (props) => {
67 63
         });
68 64
     }
69 65
   };
70
-  const handelEdit = (val) => {
71
-    setuserId(val.userId);
72
-    form.setFieldsValue(val);
73
-    setEditModal(true);
74
-  };
66
+  //表单点击取消按钮
75 67
   const onCancel = () => {
76 68
     setuserId();
77 69
     form.resetFields();
78 70
     setEditModal(false);
79 71
   };
72
+  // 弹窗表单中机构搜索框改变事件目前没用
80 73
   const handelChange = () => {};
74
+
75
+  // 列表点击编辑按钮
76
+  const handelEdit = (val) => {
77
+    setuserId(val.userId);
78
+    setEditModal(true);
79
+  };
80
+  //列表点击删除按钮
81 81
   const handleDelete = (id) => {
82
-    deleteRegion(id)
82
+    deleteUser(id)
83 83
       .then(() => {
84 84
         message.success('删除成功');
85 85
         actionRef.current.reload();
@@ -88,34 +88,75 @@ export default (props) => {
88 88
         message.error(err);
89 89
       });
90 90
   };
91
+  //列表切换人员状态方法
92
+  const handleOK = (record, data) => {
93
+    const title = record.status
94
+      ? '您确定要将该人员状态变更为禁用吗? 禁用后该人员将不能登录'
95
+      : '您确定要将该人员状态变更为启用吗? 启用后该人员可以登录!';
96
+    Modal.confirm({
97
+      title: title,
98
+      okText: '确认',
99
+      cancelText: '取消',
100
+      onOk() {
101
+        updateUser(record.userId, { ...record, status: record.status === 1 ? 0 : 1 })
102
+          .then((res) => {
103
+            message.success('操作成功');
104
+            actionRef.current.reload();
105
+          })
106
+          .catch((err) => {
107
+            message.error(err);
108
+          });
109
+      },
110
+    });
111
+  };
91 112
   useEffect(() => {
113
+    //获取账号默认密码
92 114
     getDefaultPassword().then((res) => {
93 115
       setPassWord(res);
94 116
     });
117
+    //获取机构列表数据
95 118
     getCooperativeList().then((res) => {
96 119
       setCooperativeList(res.records);
97 120
     });
98 121
     if (userId) {
122
+      getUserDetail(userId).then((res) => {
123
+        if (res.orgId === '-1') {
124
+          form.setFieldsValue({ ...res, orgId: cooperativeList[0].orgId });
125
+        } else {
126
+          form.setFieldsValue(res);
127
+        }
128
+      });
99 129
     } else {
100 130
       form.resetFields();
101 131
     }
102 132
   }, [userId]);
133
+
134
+  const actions = () => [
135
+    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => setEditModal(true)}>
136
+      新增
137
+    </Button>,
138
+  ];
103 139
   const columns = [
104
-    {
105
-      title: '登录账号',
106
-      dataIndex: 'loginName',
107
-      key: 'loginName',
108
-    },
109 140
     {
110 141
       title: '用户名',
111 142
       dataIndex: 'userName',
112 143
       key: 'userName',
113 144
     },
114
-
145
+    {
146
+      title: '性别',
147
+      dataIndex: 'sex',
148
+      key: 'sex',
149
+      width: 80,
150
+      render: (_, record) => {
151
+        return record.sex === 1 ? '男' : record.sex === 0 ? '女' : '未知';
152
+      },
153
+      search: false,
154
+    },
115 155
     {
116 156
       title: '手机号',
117 157
       dataIndex: 'phone',
118 158
       key: 'phone',
159
+      width: 120,
119 160
     },
120 161
     {
121 162
       title: '邮箱',
@@ -126,6 +167,14 @@ export default (props) => {
126 167
       title: '状态',
127 168
       dataIndex: 'status',
128 169
       key: 'status',
170
+      renderFormItem: () => {
171
+        return (
172
+          <Select placeholder="请选择">
173
+            <Option value={1}>启用</Option>
174
+            <Option value={0}>禁用</Option>
175
+          </Select>
176
+        );
177
+      },
129 178
       render: (_, record) => {
130 179
         return record.status === 1 ? '启用' : '未启用';
131 180
       },
@@ -134,11 +183,14 @@ export default (props) => {
134 183
       title: '操作',
135 184
       valueType: 'option',
136 185
       render: (_, record) => [
137
-        <a key={1} onClick={() => handelEdit(record)}>
186
+        <Button type="link" key={1} onClick={() => handleOK(record)}>
187
+          {record.status === 0 ? '启用' : '禁用'}
188
+        </Button>,
189
+        <a key={2} onClick={() => handelEdit(record)}>
138 190
           编辑
139 191
         </a>,
140 192
         <Popconfirm
141
-          key={2}
193
+          key={3}
142 194
           title="您是否确认删除 ?"
143 195
           onConfirm={() => handleDelete(record.userId)}
144 196
           okText="确定"
@@ -199,7 +251,7 @@ export default (props) => {
199 251
           <FormItem label="邮箱" name="email" rules={[{ required: true, message: '请输入' }]}>
200 252
             <Input placeholder="请输入" />
201 253
           </FormItem>
202
-          <FormItem label="所属机构" name="orgId">
254
+          <FormItem label="所属机构" name="orgId" rules={[{ required: true, message: '请输入' }]}>
203 255
             <Search placeholder="请选择机构" onChange={handelChange} />
204 256
             {/* <Select
205 257
               placeholder="请选择机构"
@@ -214,6 +266,12 @@ export default (props) => {
214 266
               ))}
215 267
             </Select> */}
216 268
           </FormItem>
269
+          <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
270
+            <Select placeholder="请选择是否启用">
271
+              <Option value={1}>启用</Option>
272
+              <Option value={0}>禁用</Option>
273
+            </Select>
274
+          </FormItem>
217 275
           <FormItem label=" " colon={false}>
218 276
             <Button type="default" onClick={onCancel}>
219 277
               取消