Commit fadf49a83fde0bdfc6cfdecdadf7eb2a25cfcd64
Merge branch 'sqy_dev' into 'main'
fix:调整设备取消分配客户的接口与设备列表客户展示 See merge request huang/yun-teng-iot-front!208
Showing
3 changed files
with
23 additions
and
2 deletions
... | ... | @@ -156,6 +156,13 @@ export const dispatchCustomer = (data) => { |
156 | 156 | } |
157 | 157 | ); |
158 | 158 | }; |
159 | +// 检查设备是否被占用 | |
160 | +export const checkDeviceOccupied = (id) => { | |
161 | + return defHttp.get({ | |
162 | + url: `/device/used/${id}`, | |
163 | + }); | |
164 | +}; | |
165 | + | |
159 | 166 | // 取消分配客户 |
160 | 167 | export const cancelDispatchCustomer = (data) => { |
161 | 168 | const { tbDeviceId } = data; | ... | ... |
... | ... | @@ -163,6 +163,7 @@ |
163 | 163 | import { |
164 | 164 | deleteDevice, |
165 | 165 | devicePage, |
166 | + checkDeviceOccupied, | |
166 | 167 | cancelDispatchCustomer, |
167 | 168 | getGATEWAY, |
168 | 169 | } from '/@/api/device/deviceManager'; |
... | ... | @@ -209,6 +210,7 @@ |
209 | 210 | const [registerModal, { openModal }] = useModal(); |
210 | 211 | const [registerCustomerModal, { openModal: openCustomerModal }] = useModal(); |
211 | 212 | const [registerDetailDrawer, { openDrawer }] = useDrawer(); |
213 | + | |
212 | 214 | const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({ |
213 | 215 | title: '设备列表', |
214 | 216 | api: devicePage, |
... | ... | @@ -265,8 +267,16 @@ |
265 | 267 | } |
266 | 268 | // 取消分配客户 |
267 | 269 | async function handleCancelDispatchCustomer(record: Recordable) { |
268 | - await cancelDispatchCustomer(record); | |
269 | - handleReload(); | |
270 | + try { | |
271 | + // 该设备是否正在被场景联动使用中? | |
272 | + const isEnabled = await checkDeviceOccupied(record.id); | |
273 | + if (!isEnabled) { | |
274 | + await cancelDispatchCustomer(record); | |
275 | + handleReload(); | |
276 | + } else { | |
277 | + createMessage.warn('该设备正在使用中~'); | |
278 | + } | |
279 | + } catch {} | |
270 | 280 | } |
271 | 281 | |
272 | 282 | function handleDetail(record: Recordable) { | ... | ... |