李志伟 3 vuotta sitten
vanhempi
commit
a08cc57373
1 muutettua tiedostoa jossa 17 lisäystä ja 8 poistoa
  1. 17
    8
      src/pages/Machinery/Machinery/Edit/index.jsx

+ 17
- 8
src/pages/Machinery/Machinery/Edit/index.jsx Näytä tiedosto

99
     if (device != null) {
99
     if (device != null) {
100
       getTerminalDeviceList(device.deviceId).then((res) => {
100
       getTerminalDeviceList(device.deviceId).then((res) => {
101
         setDeviceList([res]);
101
         setDeviceList([res]);
102
+        setVisible(true);
102
       })
103
       })
104
+    } else {
105
+      setVisible(true);
103
     }
106
     }
104
-    setVisible(true);
107
+
105
   }
108
   }
106
   const handleClose = () => {
109
   const handleClose = () => {
107
     setVisible(false);
110
     setVisible(false);
130
       message.info('请绑定摄像头');
133
       message.info('请绑定摄像头');
131
       return;
134
       return;
132
     }
135
     }
133
-    let config = `{'deviceId':${device.deviceId},'channel':${data.channel},'netType':${data.netType}}`;
136
+    let obj = {
137
+      deviceId: device.deviceId,
138
+      channel: data.channel,
139
+      netType: data.netType
140
+    }
141
+    let config = JSON.stringify(obj);
134
     setDeviceLoading(true);
142
     setDeviceLoading(true);
135
     addDevice({ ...deviceDetail, machineryId: id, apiConfig: config }).then((res) => {
143
     addDevice({ ...deviceDetail, machineryId: id, apiConfig: config }).then((res) => {
136
       message.success('保存成功!');
144
       message.success('保存成功!');
148
   }, [terminalId])
156
   }, [terminalId])
149
 
157
 
150
   useEffect(() => {
158
   useEffect(() => {
151
-    getMachineryTypeList({ pageSize: 999 }).then((res) => {
159
+    getMachineryTypeList({ pageSize: 500 }).then((res) => {
152
       setMachineryTypeList(res.records);
160
       setMachineryTypeList(res.records);
153
     }).catch((err) => {
161
     }).catch((err) => {
154
       console.log(err.message)
162
       console.log(err.message)
155
     });
163
     });
156
-    getRegionList({ pageSize: 999 }).then((res) => {
164
+    getRegionList({ pageSize: 500 }).then((res) => {
157
       setRegionList(res.records);
165
       setRegionList(res.records);
158
     }).catch((err) => {
166
     }).catch((err) => {
159
       console.log(err.message)
167
       console.log(err.message)
160
     });
168
     });
161
-    getCooperativeList({ pageSize: 999 }).then((res) => {
169
+    getCooperativeList({ pageSize: 500 }).then((res) => {
162
       setCooperativeList(res.records);
170
       setCooperativeList(res.records);
163
     }).catch((err) => {
171
     }).catch((err) => {
164
       console.log(err.message)
172
       console.log(err.message)
178
       getdeviceDetail(id).then((res) => {
186
       getdeviceDetail(id).then((res) => {
179
         setDeviceDetail(res);
187
         setDeviceDetail(res);
180
         if (res) {
188
         if (res) {
181
-          //eval('(' + res.apiConfig + ')') json字符串转普通对象
182
-          deviceForm.setFieldsValue(eval('(' + res.apiConfig + ')'));
189
+          //json字符串转普通对象
190
+          let confit = JSON.parse(res.apiConfig)
191
+          deviceForm.setFieldsValue(confit);
183
           if (res && res.deviceId != null) {
192
           if (res && res.deviceId != null) {
184
             //获取绑定设备详情
193
             //获取绑定设备详情
185
-            getTerminalDeviceList(eval('(' + res.apiConfig + ')').deviceId).then((res) => {
194
+            getTerminalDeviceList(confit.deviceId).then((res) => {
186
               setDevice(res);
195
               setDevice(res);
187
               setBind(true)
196
               setBind(true)
188
             })
197
             })