fangmingyue 2 jaren geleden
bovenliggende
commit
2451603e12
4 gewijzigde bestanden met toevoegingen van 109 en 59 verwijderingen
  1. 1
    1
      config/proxy.js
  2. 57
    21
      src/pages/SystemManagement/Sensing/index.jsx
  3. 37
    37
      src/services/machineryType.js
  4. 14
    0
      src/services/usermachinery.js

+ 1
- 1
config/proxy.js Bestand weergeven

11
     // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
11
     // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
12
     '/api/': {
12
     '/api/': {
13
       // 要代理的地址
13
       // 要代理的地址
14
-      target: 'http://127.0.0.1:7080',
14
+      target: 'http://192.168.89.147:7080',
15
       // target: 'http://192.168.89.76:7080',
15
       // target: 'http://192.168.89.76:7080',
16
       // target: 'http://machine.njyunzhi.com',
16
       // target: 'http://machine.njyunzhi.com',
17
       // 配置了这个可以从 http 代理到 https
17
       // 配置了这个可以从 http 代理到 https

+ 57
- 21
src/pages/SystemManagement/Sensing/index.jsx Bestand weergeven

4
 import moment from 'moment';
4
 import moment from 'moment';
5
 import PageTable from '@/components/PageTable';
5
 import PageTable from '@/components/PageTable';
6
 import { getDeviceList, deleteDevice, addDevice } from '@/services/device';
6
 import { getDeviceList, deleteDevice, addDevice } from '@/services/device';
7
+import { addMachinery, getMachineryList } from '@/services/machinery';
8
+import { getMachineryTypeList } from '@/services/machineryType';
7
 import { queryTable } from '@/utils/request';
9
 import { queryTable } from '@/utils/request';
8
 
10
 
9
 const { Option } = Select;
11
 const { Option } = Select;
19
   const [editModal, setEditModal] = useState(false);
21
   const [editModal, setEditModal] = useState(false);
20
   const [loading, setLoading] = useState(false);
22
   const [loading, setLoading] = useState(false);
21
   const [deviceId, setdeviceId] = useState();
23
   const [deviceId, setdeviceId] = useState();
22
-  const [machineryId, setmachineryId] = useState();
24
+  const [machineryId, setMachineryId] = useState();
25
+  const [machineryTypeList, setMachineryTypeList] = useState([]);
23
   const actionRef = useRef();
26
   const actionRef = useRef();
24
-  const [newsTypeList, setNewsTypeList] = useState([]);
27
+  const [machineryList, setMachineryList] = useState([]);
28
+  const [typeId, setTypeId] = useState();
29
+  const e = 0;
25
   // useEffect(() => {
30
   // useEffect(() => {
26
   //   if (regionId) {
31
   //   if (regionId) {
27
   //   } else {
32
   //   } else {
31
 
36
 
32
   //列表编辑
37
   //列表编辑
33
   const handelEdit = (val) => {
38
   const handelEdit = (val) => {
34
-    setmachineryId(val.machineryId);
39
+    setMachineryId(val.machineryId);
35
     form.setFieldsValue(val);
40
     form.setFieldsValue(val);
36
     setEditModal(true);
41
     setEditModal(true);
37
   };
42
   };
38
 
43
 
39
   //绑定弹窗关闭
44
   //绑定弹窗关闭
40
   const onCancel = () => {
45
   const onCancel = () => {
41
-    setmachineryId();
46
+    setMachineryId();
42
     form.resetFields();
47
     form.resetFields();
43
     setEditModal(false);
48
     setEditModal(false);
44
   };
49
   };
46
   // 绑定提交
51
   // 绑定提交
47
   const Submit = (values) => {
52
   const Submit = (values) => {
48
     setLoading(true);
53
     setLoading(true);
49
-    addDevice(...values, machineryId).then(() => {
54
+    addDevice(values).then(() => {
50
       setLoading(false);
55
       setLoading(false);
51
       message.success(`绑定成功`);
56
       message.success(`绑定成功`);
52
       onCancel();
57
       onCancel();
65
     //       message.error(err.message || err);
70
     //       message.error(err.message || err);
66
     //     });
71
     //     });
67
     // }
72
     // }
73
+    console.log(values, 'fangfang')
68
   };
74
   };
69
 
75
 
70
   useEffect(() => {
76
   useEffect(() => {
71
-    getDeviceList().then((res) => {
72
-      setNewsTypeList(res.records);
77
+    getMachineryTypeList({ pageSize: 999 }).then((res) => {
78
+      setMachineryTypeList(res.records);
73
     }).catch((err) => {
79
     }).catch((err) => {
74
       console.log(err.message)
80
       console.log(err.message)
75
     });
81
     });
76
   }, []);
82
   }, []);
77
 
83
 
84
+  useEffect(() => {
85
+    if (typeId) {
86
+      getMachineryTypeList({ typeId }).then((e) => {
87
+        setMachineryTypeList(e.records);
88
+      }).catch((err) => {
89
+        console.log(err.message)
90
+      });
91
+    }
92
+  }, [typeId])
93
+
94
+  useEffect(() => {
95
+    if (machineryId) {
96
+      getMachineryList({ machineryId }).then((e) => {
97
+        setMachineryList(e.records);
98
+      }).catch((err) => {
99
+        console.log(err.message)
100
+      });
101
+    }
102
+  }, [machineryId])
103
+
78
   const columns = [
104
   const columns = [
79
     {
105
     {
80
       title: '行号',
106
       title: '行号',
140
         request={getDeviceList}
166
         request={getDeviceList}
141
         columns={columns}
167
         columns={columns}
142
         actionRef={actionRef}
168
         actionRef={actionRef}
143
-        // rowKey="deviceId"
169
+        rowKey="deviceId"
144
         options={false}
170
         options={false}
145
-        // toolBarRender={actions}
171
+        toolBarRender={() => [
172
+          <Button
173
+            key="1"
174
+            type="primary"
175
+          >
176
+            +同步设备信息
177
+          </Button>,
178
+        ]}
146
         scroll={{ x: 1000 }}
179
         scroll={{ x: 1000 }}
147
       />
180
       />
148
       <Modal
181
       <Modal
154
         maskClosable={false}
187
         maskClosable={false}
155
         destroyOnClose={true}
188
         destroyOnClose={true}
156
         footer={null}
189
         footer={null}
190
+        machineryId={machineryId}
157
       >
191
       >
158
-        <Form {...formItemLayout} onFinish={Submit} form={form}>
159
-          <FormItem label="农机分类" name="deviceType" rules={[{ required: true, message: '请选择农机分类' }]}
160
-          >
161
-            <Select allowClear style={{ width: '320px' }}>
162
-              {newsTypeList.map((item) => (
163
-                <Option value={item.deviceType} key={item.deviceType}>
164
-                  {item.deviceType}
192
+        <Form  {...formItemLayout} onFinish={Submit} form={form}>
193
+          <FormItem label="农机分类" rules={[{ required: true, message: '请选择农机分类' }]}>
194
+            <Select value={typeId} onChange={setTypeId} allowClear style={{ width: '320px' }}>
195
+              {machineryTypeList.map((item) => (
196
+                <Option value={item.typeId} key={item.typeId}>
197
+                  {item.name}
165
                 </Option>
198
                 </Option>
166
               ))}
199
               ))}
167
             </Select>
200
             </Select>
168
           </FormItem>
201
           </FormItem>
169
-          <FormItem label="选择农机" name="deviceNo" rules={[{ required: true, message: '请选择农机名' }]}>
170
-            <Select allowClear style={{ width: '320px' }}>
171
-              {newsTypeList.map((item) => (
172
-                <Option value={item.deviceNo} key={item.deviceNo}>
173
-                  {item.deviceNo}
202
+          <FormItem label="选择农机" rules={[{ required: true, message: '请选择农机名' }]}>
203
+            <Select onChange={setMachineryId} allowClear style={{ width: '320px' }}>
204
+              {machineryList.map((item) => (
205
+                <Option value={item.machineryId} key={item.machineryId}>
206
+                  {item.name}
174
                 </Option>
207
                 </Option>
175
               ))}
208
               ))}
176
             </Select>
209
             </Select>
177
           </FormItem>
210
           </FormItem>
211
+          {/* <FormItem label="选择农机" request={getMachineryList}>
212
+            <Input placeholder='请输入农机名称' name="name" rules={[{ required: true }]} />
213
+          </FormItem> */}
178
           <FormItem label=" " colon={false}>
214
           <FormItem label=" " colon={false}>
179
             <Button type="default" onClick={onCancel} style={{ marginTop: '2em', marginLeft: '4em' }}>
215
             <Button type="default" onClick={onCancel} style={{ marginTop: '2em', marginLeft: '4em' }}>
180
               取消
216
               取消

+ 37
- 37
src/services/machineryType.js Bestand weergeven

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

+ 14
- 0
src/services/usermachinery.js Bestand weergeven

1
+import request from '@/utils/request';
2
+/**
3
+ * 农机绑定列表
4
+ * @param {*} params
5
+ * @returns
6
+ */
7
+export const getUserMachineryList = (params) => request('/user-machinery', { params });
8
+
9
+/**
10
+ * 农机绑定保存
11
+ * @param {*} data
12
+ * @returns
13
+ */
14
+export const addUserMachinery = (id, data) => request(`/user/${id}/machinery`, { method: 'post', data });