张延森 2 年之前
父節點
當前提交
4f56b44aa6

+ 197
- 0
src/pages/Machinery/Machinery/Edit/components/BasicInfo.jsx 查看文件

@@ -0,0 +1,197 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { history } from 'umi';
3
+import { Form, Input, DatePicker, Select, Button, message } from 'antd';
4
+import ExtendContent from '@/components/ExtendContent';
5
+import { UploadImage, UploadImageList } from '@/components/Upload';
6
+import Money from '@/components/Money';
7
+import { addMachinery, updateMachinery, getMachineryDetail } from '@/services/machinery';
8
+import { getMachineryTypeList } from '@/services/machineryType';
9
+import { getRegionList } from '@/services/region';
10
+import { getCooperativeList } from '@/services/cooperative';
11
+
12
+const { Option } = Select;
13
+const FormItem = Form.Item;
14
+const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
15
+
16
+const goBack = () => {
17
+  history.goBack();
18
+};
19
+
20
+export default (props) => {
21
+  const { id, onSuccess } = props;
22
+
23
+  const [form] = Form.useForm();
24
+  const [loading, setLoading] = useState(false);
25
+  const [imageList, setImageList] = useState([]);
26
+  //农机类型列表
27
+  const [machineryTypeList, setMachineryTypeList] = useState([]);
28
+  //区域列表
29
+  const [regionList, setRegionList] = useState([]);
30
+  //合作社列表
31
+  const [cooperativeList, setCooperativeList] = useState([]);
32
+
33
+  const onSubmit = (data) => {
34
+    var newData = { ...data };
35
+    if (data.buyDate) {
36
+      newData = { ...data, buyDate: data.buyDate.format('YYYY-MM-DD HH:mm:ss') };
37
+    }
38
+    setLoading(true);
39
+    if (id) {
40
+      updateMachinery(id, newData)
41
+        .then(() => {
42
+          setLoading(false);
43
+          message.success('数据更新成功');
44
+          goBack();
45
+        })
46
+        .catch((err) => {
47
+          setLoading(false);
48
+          message.error(err.message || err);
49
+        });
50
+    } else {
51
+      addMachinery(newData)
52
+        .then((res) => {
53
+          setLoading(false);
54
+          message.success('数据保存成功');
55
+          history.replace(`./Edit?id=${res.machineryId}`);
56
+        })
57
+        .catch((err) => {
58
+          setLoading(false);
59
+          message.error(err.message || err);
60
+        });
61
+    }
62
+  };
63
+
64
+  const imageInput = (image) => {
65
+    return {
66
+      uid: image.imageId,
67
+      url: image.url,
68
+    };
69
+  };
70
+
71
+  const imageOutput = (image) => {
72
+    return {
73
+      imageId: image?.raw?.imageId,
74
+      targetId: id,
75
+      url: image.url,
76
+    };
77
+  };
78
+
79
+  useEffect(() => {
80
+    getMachineryTypeList({ pageSize: 500 })
81
+      .then((res) => {
82
+        setMachineryTypeList(res.records);
83
+      })
84
+      .catch((err) => {
85
+        console.log(err.message);
86
+      });
87
+    getRegionList({ pageSize: 500 })
88
+      .then((res) => {
89
+        setRegionList(res.records);
90
+      })
91
+      .catch((err) => {
92
+        console.log(err.message);
93
+      });
94
+    getCooperativeList({ pageSize: 500 })
95
+      .then((res) => {
96
+        setCooperativeList(res.records);
97
+      })
98
+      .catch((err) => {
99
+        console.log(err.message);
100
+      });
101
+  }, []);
102
+
103
+  useEffect(() => {
104
+    if (id) {
105
+      //编辑时获取基本信息内容
106
+      getMachineryDetail(id)
107
+        .then((res) => {
108
+          form.setFieldsValue({
109
+            ...res,
110
+            buyDate: res.buyDate ? moment(res.buyDate, 'YYYY-MM-DD') : null,
111
+          });
112
+        })
113
+        .catch((err) => {
114
+          console.log(err.message);
115
+        });
116
+    }
117
+  }, [id]);
118
+
119
+  return (
120
+    <Form {...formItemLayout} onFinish={onSubmit} form={form}>
121
+      <FormItem label="农机名" name="name" rules={[{ required: true, message: '请输入农机名' }]}>
122
+        <Input placeholder="请输入农机名" style={{ width: '350px' }} />
123
+      </FormItem>
124
+      <FormItem
125
+        label="农机类型"
126
+        name="typeId"
127
+        rules={[{ required: true, message: '请选择农机类型' }]}
128
+      >
129
+        <Select style={{ width: '350px' }}>
130
+          {machineryTypeList.map((item) => (
131
+            <Option value={item.typeId} key={item.typeId}>
132
+              {item.name}
133
+            </Option>
134
+          ))}
135
+        </Select>
136
+      </FormItem>
137
+      <FormItem label="主图" name="thumb" rules={[{ required: true, message: '请选择主图' }]}>
138
+        <UploadImage />
139
+      </FormItem>
140
+      <FormItem label="农机banner图集" name="images">
141
+        <UploadImageList
142
+          value={imageList}
143
+          onChange={setImageList}
144
+          input={imageInput}
145
+          output={imageOutput}
146
+        />
147
+      </FormItem>
148
+      <FormItem label="区域" name="regionId" rules={[{ required: true, message: '请选择区域' }]}>
149
+        <Select style={{ width: '350px' }}>
150
+          {regionList.map((item) => (
151
+            <Option value={item.regionId} key={item.regionId}>
152
+              {item.name}
153
+            </Option>
154
+          ))}
155
+        </Select>
156
+      </FormItem>
157
+      <FormItem
158
+        label="归属合作社"
159
+        name="orgId"
160
+        rules={[{ required: true, message: '请选择归属合作社' }]}
161
+      >
162
+        <Select style={{ width: '350px' }}>
163
+          {cooperativeList.map((item) => (
164
+            <Option value={item.orgId} key={item.orgId}>
165
+              {item.name}
166
+            </Option>
167
+          ))}
168
+        </Select>
169
+      </FormItem>
170
+      <FormItem label="单价" name="price" rules={[{ required: true, message: '请输入价格' }]}>
171
+        <Money style={{ width: '350px' }} />
172
+      </FormItem>
173
+      <FormItem label="购买时间" name="buyDate">
174
+        <DatePicker format="YYYY-MM-DD" style={{ width: '350px' }} />
175
+      </FormItem>
176
+      <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
177
+        <Select placeholder="请选择农机状态" style={{ width: '350px' }}>
178
+          <Option value={1}>正常</Option>
179
+          <Option value={0}>维修</Option>
180
+        </Select>
181
+      </FormItem>
182
+      {id && (
183
+        <FormItem label="详细信息" colon={false}>
184
+          <ExtendContent targetType="machinery" targetId={id} onCancel={goBack} />
185
+        </FormItem>
186
+      )}
187
+      <FormItem label=" " colon={false}>
188
+        <Button type="default" onClick={goBack}>
189
+          返回
190
+        </Button>
191
+        <Button type="primary" loading={loading} htmlType="submit" style={{ marginLeft: '4em' }}>
192
+          保存
193
+        </Button>
194
+      </FormItem>
195
+    </Form>
196
+  );
197
+};

+ 132
- 0
src/pages/Machinery/Machinery/Edit/components/DeviceInfo.jsx 查看文件

@@ -0,0 +1,132 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { history } from 'umi';
3
+import { Form, Drawer, Select, InputNumber, message, Button } from 'antd';
4
+import { getDeviceDetail, addDevice } from '@/services/device';
5
+import DeviceList from './DeviceList';
6
+import { useMemo } from 'react';
7
+
8
+const { Option } = Select;
9
+const FormItem = Form.Item;
10
+const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
11
+
12
+const goBack = () => {
13
+  history.goBack();
14
+};
15
+
16
+export default (props) => {
17
+  const { machineryId } = props;
18
+
19
+  const [form] = Form.useForm();
20
+  const [loading, setLoading] = useState(false);
21
+  const [visible, setVisible] = useState(false);
22
+  const [deviceDetail, setDeviceDetail] = useState();
23
+  const [hatcId, setHatcId] = useState();
24
+
25
+  const onSubmit = (data) => {
26
+    if (!deviceDetail || !deviceDetail.deviceNo) {
27
+      message.error('请先绑定设备');
28
+      return;
29
+    }
30
+
31
+    const apiConfig = JSON.stringify({
32
+      ...data,
33
+      deviceId: hatcId,
34
+    });
35
+
36
+    // 表单的提交, 实际上是把 form 内容 + 其余字段 融合一起提交
37
+    setLoading(true);
38
+    addDevice({ ...deviceDetail, machineryId, apiConfig })
39
+      .then((res) => {
40
+        message.success('保存成功!');
41
+        setLoading(false);
42
+        goBack();
43
+      })
44
+      .catch((err) => {
45
+        setLoading(false);
46
+        console.log(err.message);
47
+      });
48
+  };
49
+
50
+  const handleCheck = (terminalId, hatcDevice) => {
51
+    setHatcId(hatcDevice.deviceId);
52
+    setDeviceDetail({
53
+      ...(deviceDetail || {}),
54
+      deviceNo: terminalId,
55
+      deviceType: hatcDevice.productKey,
56
+    });
57
+    setVisible(false);
58
+  };
59
+
60
+  useEffect(() => {
61
+    if (machineryId) {
62
+      //获取设备信息内容
63
+      getDeviceDetail(machineryId).then((res) => {
64
+        if (!res) return;
65
+
66
+        setDeviceDetail(res);
67
+        const apiConfig = JSON.parse(res.apiConfig) || {};
68
+
69
+        // 表单内容只是整个数据的一个 JSON 字段
70
+        form.setFieldsValue({
71
+          netType: apiConfig.netType,
72
+          channel: apiConfig.channel,
73
+        });
74
+      });
75
+    }
76
+  }, [machineryId, form]);
77
+
78
+  const deviceName = useMemo(() => {
79
+    if (!deviceDetail) return '未绑定';
80
+
81
+    return `${deviceDetail.deviceType}-${deviceDetail.deviceNo}`;
82
+  }, [deviceDetail]);
83
+
84
+  return (
85
+    <>
86
+      <Form {...formItemLayout} onFinish={onSubmit} form={form}>
87
+        <FormItem label="设备">
88
+          <Button type="link" onClick={() => setVisible(true)}>
89
+            {deviceName}
90
+          </Button>
91
+        </FormItem>
92
+        <FormItem
93
+          label="通道号"
94
+          name="channel"
95
+          rules={[{ required: true, message: '请输入通道号' }]}
96
+        >
97
+          <InputNumber min={1} placeholder="请输入通道号" style={{ width: '350px' }} />
98
+        </FormItem>
99
+        <FormItem
100
+          label="网络类型"
101
+          name="netType"
102
+          rules={[{ required: true, message: '请选择网络类型' }]}
103
+        >
104
+          <Select placeholder="请选择网络类型" style={{ width: '350px' }}>
105
+            <Option value={0}>内网</Option>
106
+            <Option value={1}>电信</Option>
107
+            <Option value={2}>移动</Option>
108
+            <Option value={3}>联通</Option>
109
+          </Select>
110
+        </FormItem>
111
+        <FormItem label=" " colon={false}>
112
+          <Button type="default" onClick={goBack}>
113
+            返回
114
+          </Button>
115
+          <Button type="primary" loading={loading} htmlType="submit" style={{ marginLeft: '4em' }}>
116
+            保存
117
+          </Button>
118
+        </FormItem>
119
+      </Form>
120
+      <Drawer
121
+        title="设备列表"
122
+        width={500}
123
+        closable={false}
124
+        onClose={() => setVisible(false)}
125
+        visible={visible}
126
+        destroyOnClose
127
+      >
128
+        <DeviceList value={deviceDetail && deviceDetail.deviceNo} onChange={handleCheck} />
129
+      </Drawer>
130
+    </>
131
+  );
132
+};

+ 113
- 0
src/pages/Machinery/Machinery/Edit/components/DeviceList.jsx 查看文件

@@ -0,0 +1,113 @@
1
+import { useState, useEffect } from 'react';
2
+import { Button, Card, Descriptions, Input, List } from 'antd';
3
+import { getHatcDeviceList } from '@/services/device';
4
+import selectedImg from '@/assets/selectedImg.png';
5
+
6
+const { Search } = Input;
7
+
8
+// 列表是海康设备
9
+// props 传过来的是映射ID
10
+
11
+export default (props) => {
12
+  const { value, onChange } = props;
13
+
14
+  const [loading, setLoading] = useState(false);
15
+  const [hatcDeviceList, setHatcDeviceList] = useState([]); // 所有数据
16
+  const [list, setList] = useState([]); // 页面展示数据
17
+  const [checked, setChecked] = useState();
18
+
19
+  // 搜索
20
+  const onSearch = (val) => {
21
+    if (val == '' || val === undefined || val === null) {
22
+      setList(hatcDeviceList);
23
+    } else {
24
+      setList(hatcDeviceList.filter((x) => x.terminalId.toLowerCase().includes(val.toLowerCase())));
25
+    }
26
+  };
27
+
28
+  //选中设备
29
+  const handleSelect = (item) => {
30
+    setChecked(item);
31
+  };
32
+
33
+  // 提交
34
+  const handleSubmit = () => {
35
+    onChange(checked.terminalId, checked);
36
+  };
37
+
38
+  // 过滤列表
39
+  useEffect(() => {
40
+    setLoading(true);
41
+    getHatcDeviceList({ pageSize: 500 })
42
+      .then((res) => {
43
+        setHatcDeviceList(res.records);
44
+        setList(res.records);
45
+        setLoading(false);
46
+      })
47
+      .catch(() => {
48
+        setLoading(false);
49
+      });
50
+  }, []);
51
+
52
+  useEffect(() => {
53
+    if (!hatcDeviceList || !hatcDeviceList.length) return;
54
+    if (!value) return;
55
+
56
+    if (!checked || value !== checked.terminalId) {
57
+      const target = hatcDeviceList.filter((x) => x.terminalId === value)[0];
58
+      setChecked(target);
59
+    }
60
+  }, [value, checked, hatcDeviceList]);
61
+
62
+  return (
63
+    <div style={{ display: 'flex', height: '100%', flexDirection: 'column' }}>
64
+      <Search
65
+        placeholder="请输入终端ID"
66
+        allowClear
67
+        enterButton="搜索"
68
+        size="middle"
69
+        onSearch={onSearch}
70
+        style={{ padding: '24px' }}
71
+      />
72
+      <List
73
+        split={false}
74
+        style={{ padding: '12px 0', flex: 1, overflowY: 'auto', background: 'rgb(240,242,245)' }}
75
+      >
76
+        {list.map((item) => (
77
+          <List.Item key={item.deviceId} onClick={() => handleSelect(item)}>
78
+            <Card className="listCard" hoverable>
79
+              <Descriptions
80
+                labelStyle={{ width: '72px', display: 'inline-block', textAlign: 'end' }}
81
+              >
82
+                <Descriptions.Item span={3} label="型号名称">
83
+                  {item.modelName}
84
+                </Descriptions.Item>
85
+                <Descriptions.Item span={3} label="协议">
86
+                  {item.protocol}
87
+                </Descriptions.Item>
88
+                <Descriptions.Item span={3} label="终端ID">
89
+                  {item.terminalId}
90
+                </Descriptions.Item>
91
+                <Descriptions.Item span={3} label="通道列表">
92
+                  {item.deviceChannelList}
93
+                </Descriptions.Item>
94
+              </Descriptions>
95
+              {checked && checked.deviceId === item.deviceId && <img src={selectedImg} />}
96
+            </Card>
97
+          </List.Item>
98
+        ))}
99
+      </List>
100
+      <div style={{ padding: '24px' }}>
101
+        <Button
102
+          type="primary"
103
+          style={{ float: 'right' }}
104
+          loading={loading}
105
+          onClick={handleSubmit}
106
+          disabled={!checked}
107
+        >
108
+          确定
109
+        </Button>
110
+      </div>
111
+    </div>
112
+  );
113
+};

+ 5
- 370
src/pages/Machinery/Machinery/Edit/index.jsx 查看文件

@@ -1,386 +1,21 @@
1
-import { useState, useEffect } from 'react';
2
-import { history } from 'umi';
3
-import { Form, Input, Drawer, DatePicker, Select, InputNumber, message, Button, List, Card, Descriptions } from 'antd';
4 1
 import ProCard from '@ant-design/pro-card';
5 2
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
-import moment from 'moment';
7
-import ExtendContent from '@/components/ExtendContent';
8
-import { UploadImage, UploadImageList } from '@/components/Upload';
9
-import Money from '@/components/Money';
10
-import { addMachinery, updateMachinery, getMachineryDetail } from '@/services/machinery';
11
-import { getMachineryTypeList } from '@/services/machineryType';
12
-import { getRegionList } from '@/services/region';
13
-import { getDeviceList, getdeviceDetail, getTerminalDeviceList, addDevice } from '@/services/device';
14
-import { getCooperativeList } from '@/services/cooperative';
15
-import selectedImg from '@/assets/selectedImg.png'
16
-import './style.less'
3
+import BasicInfo from './components/BasicInfo';
4
+import DeviceInfo from './components/DeviceInfo';
5
+import './style.less';
17 6
 
18
-const { Option } = Select;
19
-const { Search } = Input;
20
-const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
21
-
22
-const goBack = () => {
23
-  history.goBack();
24
-};
25
-const FormItem = Form.Item;
26 7
 export default (props) => {
27 8
   const { location } = props;
28 9
   const { id } = location.query;
29
-  const [form] = Form.useForm();
30
-  const [loading, setLoading] = useState(false);
31
-  const [imageList, setImageList] = useState([]);
32
-  //农机类型列表
33
-  const [machineryTypeList, setMachineryTypeList] = useState([]);
34
-  //区域列表
35
-  const [regionList, setRegionList] = useState([]);
36
-  //合作社列表
37
-  const [cooperativeList, setCooperativeList] = useState([]);
38
-
39
-  const Submit = (data) => {
40
-    var newData = { ...data }
41
-    if (data.buyDate) {
42
-      newData = { ...data, buyDate: data.buyDate.format('YYYY-MM-DD HH:mm:ss') };
43
-    }
44
-    setLoading(true);
45
-    if (id) {
46
-      updateMachinery(id, newData)
47
-        .then(() => {
48
-          setLoading(false);
49
-          message.success('数据更新成功');
50
-          goBack();
51
-        })
52
-        .catch((err) => {
53
-          setLoading(false);
54
-          message.error(err.message || err);
55
-        });
56
-    } else {
57
-      addMachinery(newData)
58
-        .then((res) => {
59
-          setLoading(false);
60
-          message.success('数据保存成功');
61
-          history.replace(`./Edit?id=${res.machineryId}`)
62
-        })
63
-        .catch((err) => {
64
-          setLoading(false);
65
-          message.error(err.message || err);
66
-        });
67
-    }
68
-  };
69
-
70
-  const imageInput = (image) => {
71
-    return {
72
-      uid: image.imageId,
73
-      url: image.url,
74
-    };
75
-  };
76
-
77
-  const imageOutput = (image) => {
78
-    return {
79
-      imageId: image?.raw?.imageId,
80
-      targetId: id,
81
-      url: image.url,
82
-    };
83
-  };
84
-
85
-
86
-  //设备信息
87
-  const [deviceForm] = Form.useForm();
88
-  const [visible, setVisible] = useState(false);
89
-  const [terminalId, setTerminalId] = useState();
90
-  //设备列表
91
-  const [deviceList, setDeviceList] = useState([]);
92
-  const [device, setDevice] = useState();
93
-  const [bind, setBind] = useState(false);
94
-  const [deviceLoading, setDeviceLoading] = useState(false);
95
-  const [deviceDetail, setDeviceDetail] = useState();
96
-
97
-  //弹出设备列表抽屉
98
-  const changeCamera = () => {
99
-    if (device != null) {
100
-      getTerminalDeviceList(device.deviceId).then((res) => {
101
-        setDeviceList([res]);
102
-        setVisible(true);
103
-      })
104
-    } else {
105
-      setVisible(true);
106
-    }
107
-
108
-  }
109
-  const handleClose = () => {
110
-    setVisible(false);
111
-  }
112
-  const onSearch = (val) => {
113
-    if (val == '') {
114
-      getDeviceList({ pageSize: 500 }).then((res) => {
115
-        setDeviceList(res.records);
116
-      })
117
-    } else {
118
-      setTerminalId(val)
119
-    }
120
-  }
121
-  //选中设备
122
-  const handleSelect = (item) => {
123
-    setDevice(item);
124
-  }
125
-  const handleOk = () => {
126
-    if (device != null) {
127
-      setBind(true)
128
-    }
129
-    handleClose();
130
-  }
131
-  const submitDevice = (data) => {
132
-    if (!bind) {
133
-      message.info('请绑定摄像头');
134
-      return;
135
-    }
136
-    let obj = {
137
-      deviceId: device.deviceId,
138
-      channel: data.channel,
139
-      netType: data.netType
140
-    }
141
-    let config = JSON.stringify(obj);
142
-    setDeviceLoading(true);
143
-    addDevice({ ...deviceDetail, machineryId: id, apiConfig: config }).then((res) => {
144
-      message.success('保存成功!');
145
-      setDeviceLoading(false);
146
-      goBack();
147
-    }).catch((err) => {
148
-      setDeviceLoading(false);
149
-      console.log(err.message);
150
-    })
151
-  }
152
-  useEffect(() => {
153
-    getDeviceList({ terminalId: terminalId, pageSize: 500 }).then((res) => {
154
-      setDeviceList(res.records);
155
-    })
156
-  }, [terminalId])
157
-
158
-  useEffect(() => {
159
-    getMachineryTypeList({ pageSize: 500 }).then((res) => {
160
-      setMachineryTypeList(res.records);
161
-    }).catch((err) => {
162
-      console.log(err.message)
163
-    });
164
-    getRegionList({ pageSize: 500 }).then((res) => {
165
-      setRegionList(res.records);
166
-    }).catch((err) => {
167
-      console.log(err.message)
168
-    });
169
-    getCooperativeList({ pageSize: 500 }).then((res) => {
170
-      setCooperativeList(res.records);
171
-    }).catch((err) => {
172
-      console.log(err.message)
173
-    });
174
-  }, [])
175
-
176
-
177
-  useEffect(() => {
178
-    if (id) {
179
-      //编辑时获取基本信息内容
180
-      getMachineryDetail(id).then((res) => {
181
-        form.setFieldsValue({ ...res, buyDate: res.buyDate ? moment(res.buyDate, 'YYYY-MM-DD') : null });
182
-      }).catch((err) => {
183
-        console.log(err.message)
184
-      });
185
-      //获取设备信息内容
186
-      getdeviceDetail(id).then((res) => {
187
-        setDeviceDetail(res);
188
-        if (res) {
189
-          //json字符串转普通对象
190
-          let confit = JSON.parse(res.apiConfig)
191
-          deviceForm.setFieldsValue(confit);
192
-          if (res && res.deviceId != null) {
193
-            //获取绑定设备详情
194
-            getTerminalDeviceList(confit.deviceId).then((res) => {
195
-              setDevice(res);
196
-              setBind(true)
197
-            })
198
-          }
199
-        }
200
-      })
201
-    }
202
-  }, [id]);
203 10
 
204 11
   return (
205 12
     <PageHeaderWrapper>
206 13
       <ProCard tabs={{ type: 'card' }} style={{ minHeight: '700px' }}>
207 14
         <ProCard.TabPane key={1} tab="基本信息">
208
-          <Form {...formItemLayout} onFinish={Submit} form={form}>
209
-            <FormItem
210
-              label="农机名"
211
-              name="name"
212
-              rules={[{ required: true, message: '请输入农机名' }]}
213
-            >
214
-              <Input placeholder="请输入农机名" style={{ width: '350px' }} />
215
-            </FormItem>
216
-            <FormItem
217
-              label="农机类型"
218
-              name="typeId"
219
-              rules={[{ required: true, message: '请选择农机类型' }]}
220
-            >
221
-              <Select style={{ width: '350px' }}>
222
-                {machineryTypeList.map((item) => (
223
-                  <Option value={item.typeId} key={item.typeId}>
224
-                    {item.name}
225
-                  </Option>
226
-                ))}
227
-              </Select>
228
-            </FormItem>
229
-            <FormItem label="主图" name="thumb" rules={[{ required: true, message: '请选择主图' }]}>
230
-              <UploadImage />
231
-            </FormItem>
232
-            <FormItem label="农机banner图集" name="images">
233
-              <UploadImageList
234
-                value={imageList}
235
-                onChange={setImageList}
236
-                input={imageInput}
237
-                output={imageOutput}
238
-              />
239
-            </FormItem>
240
-            <FormItem
241
-              label="区域"
242
-              name="regionId"
243
-              rules={[{ required: true, message: '请选择区域' }]}
244
-            >
245
-              <Select style={{ width: '350px' }}>
246
-                {regionList.map((item) => (
247
-                  <Option value={item.regionId} key={item.regionId}>
248
-                    {item.name}
249
-                  </Option>
250
-                ))}
251
-              </Select>
252
-            </FormItem>
253
-            <FormItem
254
-              label="归属合作社"
255
-              name="orgId"
256
-              rules={[{ required: true, message: '请选择归属合作社' }]}
257
-            >
258
-              <Select style={{ width: '350px' }}>
259
-                {cooperativeList.map((item) => (
260
-                  <Option value={item.orgId} key={item.orgId}>
261
-                    {item.name}
262
-                  </Option>
263
-                ))}
264
-              </Select>
265
-            </FormItem>
266
-            <FormItem label="单价" name="price" rules={[{ required: true, message: '请输入价格' }]}>
267
-              <Money style={{ width: '350px' }} />
268
-            </FormItem>
269
-            <FormItem label="购买时间" name="buyDate">
270
-              <DatePicker format="YYYY-MM-DD" style={{ width: '350px' }} />
271
-            </FormItem>
272
-            <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
273
-              <Select placeholder="请选择农机状态" style={{ width: '350px' }}>
274
-                <Option value={1}>正常</Option>
275
-                <Option value={0}>维修</Option>
276
-              </Select>
277
-            </FormItem>
278
-            {id && (
279
-              <FormItem label="详细信息" colon={false}>
280
-                <ExtendContent targetType="machinery" targetId={id} onCancel={goBack} />
281
-              </FormItem>
282
-            )}
283
-            <FormItem label=" " colon={false}>
284
-              <Button type="default" onClick={goBack}>
285
-                返回
286
-              </Button>
287
-              <Button
288
-                type="primary"
289
-                loading={loading}
290
-                htmlType="submit"
291
-                style={{ marginLeft: '4em' }}
292
-              >
293
-                保存
294
-              </Button>
295
-            </FormItem>
296
-          </Form>
15
+          <BasicInfo id={id} />
297 16
         </ProCard.TabPane>
298 17
         <ProCard.TabPane key={2} disabled={!id} tab="设备信息">
299
-          <Form {...formItemLayout} onFinish={submitDevice} form={deviceForm}>
300
-            <FormItem label='摄像头'  >
301
-              <Button type='link' onClick={changeCamera}>{bind ? '已绑定' : '未绑定'}</Button>
302
-            </FormItem>
303
-            <FormItem
304
-              label="通道号"
305
-              name='channel'
306
-              rules={[{ required: true, message: '请输入通道号' }]}
307
-            >
308
-              <InputNumber min={1} placeholder="请输入通道号" style={{ width: '350px' }} />
309
-            </FormItem>
310
-            <FormItem
311
-              label="网络类型"
312
-              name='netType'
313
-              rules={[{ required: true, message: '请选择网络类型' }]}
314
-            >
315
-              <Select placeholder="请选择网络类型" style={{ width: '350px' }}>
316
-                <Option value={0}>内网</Option>
317
-                <Option value={1}>电信</Option>
318
-                <Option value={2}>移动</Option>
319
-                <Option value={3}>联通</Option>
320
-              </Select>
321
-            </FormItem>
322
-            <FormItem label=" " colon={false}>
323
-              <Button type="default" onClick={goBack}>
324
-                返回
325
-              </Button>
326
-              <Button
327
-                type="primary"
328
-                loading={deviceLoading}
329
-                htmlType="submit"
330
-                style={{ marginLeft: '4em' }}
331
-              >
332
-                保存
333
-              </Button>
334
-            </FormItem>
335
-          </Form>
336
-          <Drawer
337
-            title="摄像头列表"
338
-            width={500}
339
-            closable={false}
340
-            onClose={handleClose}
341
-            visible={visible}
342
-          >
343
-            <div style={{ display: 'flex', height: '100%', flexDirection: 'column' }}>
344
-              <Search
345
-                placeholder="请输入终端ID"
346
-                allowClear
347
-                enterButton="搜索"
348
-                size="middle"
349
-                onSearch={onSearch}
350
-                style={{ padding: '24px' }}
351
-              />
352
-              <List split={false} style={{ padding: '12px 0', flex: 1, overflowY: 'auto', background: 'rgb(240,242,245)' }}>
353
-                {
354
-                  deviceList.map(item =>
355
-                    <List.Item key={item.deviceId} onClick={() => handleSelect(item)}>
356
-                      <Card className='listCard' hoverable>
357
-                        <Descriptions labelStyle={{ width: '72px', display: 'inline-block', textAlign: 'end' }} >
358
-                          <Descriptions.Item span={3} label='型号名称'>{item.modelName}</Descriptions.Item>
359
-                          <Descriptions.Item span={3} label='协议'>{item.protocol}</Descriptions.Item>
360
-                          <Descriptions.Item span={3} label='终端ID'>{item.terminalId}</Descriptions.Item>
361
-                          <Descriptions.Item span={3} label='通道列表'>{item.deviceChannelList}</Descriptions.Item>
362
-                        </Descriptions>
363
-                        {
364
-                          device && item.deviceId == device.deviceId && <img src={selectedImg} />
365
-                        }
366
-                      </Card>
367
-                    </List.Item>
368
-                  )
369
-                }
370
-
371
-              </List>
372
-              <div style={{ padding: '24px' }}>
373
-                <Button
374
-                  type="primary"
375
-                  style={{ float: 'right' }}
376
-                  loading={loading}
377
-                  onClick={handleOk}
378
-                >
379
-                  确定
380
-                </Button>
381
-              </div>
382
-            </div>
383
-          </Drawer>
18
+          <DeviceInfo machineryId={id} />
384 19
         </ProCard.TabPane>
385 20
       </ProCard>
386 21
     </PageHeaderWrapper>

+ 2
- 2
src/services/device.js 查看文件

@@ -5,7 +5,7 @@ import request from '@/utils/request';
5 5
  * @param {*} params
6 6
  * @returns
7 7
  */
8
-export const getDeviceList = (params) => request('/hatc-device', { params });
8
+export const getHatcDeviceList = (params) => request('/hatc-device', { params });
9 9
 
10 10
 /**
11 11
  * 通过设备号查询相关设备列表  选好了点击绑定时根据当前选择的设备id查询
@@ -21,7 +21,7 @@ export const getTerminalDeviceList = (id) => request(`/hatc-device/${id}`);
21 21
  * @param {*} params
22 22
  * @returns
23 23
  */
24
-export const getdeviceDetail = (id) => request(`/machinery/${id}/device`);
24
+export const getDeviceDetail = (id) => request(`/machinery/${id}/device`);
25 25
 
26 26
 //  新增修改设备信息
27 27
 /**