Selaa lähdekoodia

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

Yansen 2 vuotta sitten
vanhempi
commit
e9f8f7b977

+ 1
- 1
config/proxy.js Näytä tiedosto

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

+ 57
- 21
src/pages/SystemManagement/Sensing/index.jsx Näytä tiedosto

@@ -4,6 +4,8 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
4 4
 import moment from 'moment';
5 5
 import PageTable from '@/components/PageTable';
6 6
 import { getDeviceList, deleteDevice, addDevice } from '@/services/device';
7
+import { addMachinery, getMachineryList } from '@/services/machinery';
8
+import { getMachineryTypeList } from '@/services/machineryType';
7 9
 import { queryTable } from '@/utils/request';
8 10
 
9 11
 const { Option } = Select;
@@ -19,9 +21,12 @@ export default (props) => {
19 21
   const [editModal, setEditModal] = useState(false);
20 22
   const [loading, setLoading] = useState(false);
21 23
   const [deviceId, setdeviceId] = useState();
22
-  const [machineryId, setmachineryId] = useState();
24
+  const [machineryId, setMachineryId] = useState();
25
+  const [machineryTypeList, setMachineryTypeList] = useState([]);
23 26
   const actionRef = useRef();
24
-  const [newsTypeList, setNewsTypeList] = useState([]);
27
+  const [machineryList, setMachineryList] = useState([]);
28
+  const [typeId, setTypeId] = useState();
29
+  const e = 0;
25 30
   // useEffect(() => {
26 31
   //   if (regionId) {
27 32
   //   } else {
@@ -31,14 +36,14 @@ export default (props) => {
31 36
 
32 37
   //列表编辑
33 38
   const handelEdit = (val) => {
34
-    setmachineryId(val.machineryId);
39
+    setMachineryId(val.machineryId);
35 40
     form.setFieldsValue(val);
36 41
     setEditModal(true);
37 42
   };
38 43
 
39 44
   //绑定弹窗关闭
40 45
   const onCancel = () => {
41
-    setmachineryId();
46
+    setMachineryId();
42 47
     form.resetFields();
43 48
     setEditModal(false);
44 49
   };
@@ -46,7 +51,7 @@ export default (props) => {
46 51
   // 绑定提交
47 52
   const Submit = (values) => {
48 53
     setLoading(true);
49
-    addDevice(...values, machineryId).then(() => {
54
+    addDevice(values).then(() => {
50 55
       setLoading(false);
51 56
       message.success(`绑定成功`);
52 57
       onCancel();
@@ -65,16 +70,37 @@ export default (props) => {
65 70
     //       message.error(err.message || err);
66 71
     //     });
67 72
     // }
73
+    console.log(values, 'fangfang')
68 74
   };
69 75
 
70 76
   useEffect(() => {
71
-    getDeviceList().then((res) => {
72
-      setNewsTypeList(res.records);
77
+    getMachineryTypeList({ pageSize: 999 }).then((res) => {
78
+      setMachineryTypeList(res.records);
73 79
     }).catch((err) => {
74 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 104
   const columns = [
79 105
     {
80 106
       title: '行号',
@@ -140,9 +166,16 @@ export default (props) => {
140 166
         request={getDeviceList}
141 167
         columns={columns}
142 168
         actionRef={actionRef}
143
-        // rowKey="deviceId"
169
+        rowKey="deviceId"
144 170
         options={false}
145
-        // toolBarRender={actions}
171
+        toolBarRender={() => [
172
+          <Button
173
+            key="1"
174
+            type="primary"
175
+          >
176
+            +同步设备信息
177
+          </Button>,
178
+        ]}
146 179
         scroll={{ x: 1000 }}
147 180
       />
148 181
       <Modal
@@ -154,27 +187,30 @@ export default (props) => {
154 187
         maskClosable={false}
155 188
         destroyOnClose={true}
156 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 198
                 </Option>
166 199
               ))}
167 200
             </Select>
168 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 207
                 </Option>
175 208
               ))}
176 209
             </Select>
177 210
           </FormItem>
211
+          {/* <FormItem label="选择农机" request={getMachineryList}>
212
+            <Input placeholder='请输入农机名称' name="name" rules={[{ required: true }]} />
213
+          </FormItem> */}
178 214
           <FormItem label=" " colon={false}>
179 215
             <Button type="default" onClick={onCancel} style={{ marginTop: '2em', marginLeft: '4em' }}>
180 216
               取消

+ 37
- 37
src/services/machineryType.js Näytä tiedosto

@@ -1,37 +1,37 @@
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 Näytä tiedosto

@@ -0,0 +1,14 @@
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 });