李志伟 před 3 roky
rodič
revize
a08cc57373
1 změnil soubory, kde provedl 17 přidání a 8 odebrání
  1. 17
    8
      src/pages/Machinery/Machinery/Edit/index.jsx

+ 17
- 8
src/pages/Machinery/Machinery/Edit/index.jsx Zobrazit soubor

@@ -99,9 +99,12 @@ export default (props) => {
99 99
     if (device != null) {
100 100
       getTerminalDeviceList(device.deviceId).then((res) => {
101 101
         setDeviceList([res]);
102
+        setVisible(true);
102 103
       })
104
+    } else {
105
+      setVisible(true);
103 106
     }
104
-    setVisible(true);
107
+
105 108
   }
106 109
   const handleClose = () => {
107 110
     setVisible(false);
@@ -130,7 +133,12 @@ export default (props) => {
130 133
       message.info('请绑定摄像头');
131 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 142
     setDeviceLoading(true);
135 143
     addDevice({ ...deviceDetail, machineryId: id, apiConfig: config }).then((res) => {
136 144
       message.success('保存成功!');
@@ -148,17 +156,17 @@ export default (props) => {
148 156
   }, [terminalId])
149 157
 
150 158
   useEffect(() => {
151
-    getMachineryTypeList({ pageSize: 999 }).then((res) => {
159
+    getMachineryTypeList({ pageSize: 500 }).then((res) => {
152 160
       setMachineryTypeList(res.records);
153 161
     }).catch((err) => {
154 162
       console.log(err.message)
155 163
     });
156
-    getRegionList({ pageSize: 999 }).then((res) => {
164
+    getRegionList({ pageSize: 500 }).then((res) => {
157 165
       setRegionList(res.records);
158 166
     }).catch((err) => {
159 167
       console.log(err.message)
160 168
     });
161
-    getCooperativeList({ pageSize: 999 }).then((res) => {
169
+    getCooperativeList({ pageSize: 500 }).then((res) => {
162 170
       setCooperativeList(res.records);
163 171
     }).catch((err) => {
164 172
       console.log(err.message)
@@ -178,11 +186,12 @@ export default (props) => {
178 186
       getdeviceDetail(id).then((res) => {
179 187
         setDeviceDetail(res);
180 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 192
           if (res && res.deviceId != null) {
184 193
             //获取绑定设备详情
185
-            getTerminalDeviceList(eval('(' + res.apiConfig + ')').deviceId).then((res) => {
194
+            getTerminalDeviceList(confit.deviceId).then((res) => {
186 195
               setDevice(res);
187 196
               setBind(true)
188 197
             })