Commit 5a21645599d4e96f556fd142c08fb0b5909f0e89

Authored by sqy
1 parent c5e9fc1a

'fix:添加取消分配客户时的检查'

@@ -156,6 +156,13 @@ export const dispatchCustomer = (data) => { @@ -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 export const cancelDispatchCustomer = (data) => { 167 export const cancelDispatchCustomer = (data) => {
161 const { tbDeviceId } = data; 168 const { tbDeviceId } = data;
@@ -154,6 +154,7 @@ @@ -154,6 +154,7 @@
154 import { 154 import {
155 deleteDevice, 155 deleteDevice,
156 devicePage, 156 devicePage,
  157 + checkDeviceOccupied,
157 cancelDispatchCustomer, 158 cancelDispatchCustomer,
158 getGATEWAY, 159 getGATEWAY,
159 } from '/@/api/device/deviceManager'; 160 } from '/@/api/device/deviceManager';
@@ -197,6 +198,7 @@ @@ -197,6 +198,7 @@
197 const [registerModal, { openModal }] = useModal(); 198 const [registerModal, { openModal }] = useModal();
198 const [registerCustomerModal, { openModal: openCustomerModal }] = useModal(); 199 const [registerCustomerModal, { openModal: openCustomerModal }] = useModal();
199 const [registerDetailDrawer, { openDrawer }] = useDrawer(); 200 const [registerDetailDrawer, { openDrawer }] = useDrawer();
  201 +
200 const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({ 202 const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({
201 title: '设备列表', 203 title: '设备列表',
202 api: devicePage, 204 api: devicePage,
@@ -253,8 +255,16 @@ @@ -253,8 +255,16 @@
253 } 255 }
254 // 取消分配客户 256 // 取消分配客户
255 async function handleCancelDispatchCustomer(record: Recordable) { 257 async function handleCancelDispatchCustomer(record: Recordable) {
256 - await cancelDispatchCustomer(record);  
257 - handleReload(); 258 + try {
  259 + // 该设备是否正在被场景联动使用中?
  260 + const isEnabled = await checkDeviceOccupied(record.id);
  261 + if (!isEnabled) {
  262 + await cancelDispatchCustomer(record);
  263 + handleReload();
  264 + } else {
  265 + createMessage.warn('该设备正在使用中~');
  266 + }
  267 + } catch {}
258 } 268 }
259 269
260 function handleDetail(record: Recordable) { 270 function handleDetail(record: Recordable) {