Commit fadf49a83fde0bdfc6cfdecdadf7eb2a25cfcd64

Authored by xp.Huang
2 parents 4ccbc176 731bb4e0

Merge branch 'sqy_dev' into 'main'

fix:调整设备取消分配客户的接口与设备列表客户展示

See merge request huang/yun-teng-iot-front!208
@@ -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;
@@ -36,6 +36,10 @@ export const columns: BasicColumn[] = [ @@ -36,6 +36,10 @@ export const columns: BasicColumn[] = [
36 dataIndex: 'organizationDTO.name', 36 dataIndex: 'organizationDTO.name',
37 }, 37 },
38 { 38 {
  39 + title: '客户',
  40 + dataIndex: 'customerName',
  41 + },
  42 + {
39 title: '标签', 43 title: '标签',
40 dataIndex: 'label', 44 dataIndex: 'label',
41 width: 180, 45 width: 180,
@@ -163,6 +163,7 @@ @@ -163,6 +163,7 @@
163 import { 163 import {
164 deleteDevice, 164 deleteDevice,
165 devicePage, 165 devicePage,
  166 + checkDeviceOccupied,
166 cancelDispatchCustomer, 167 cancelDispatchCustomer,
167 getGATEWAY, 168 getGATEWAY,
168 } from '/@/api/device/deviceManager'; 169 } from '/@/api/device/deviceManager';
@@ -209,6 +210,7 @@ @@ -209,6 +210,7 @@
209 const [registerModal, { openModal }] = useModal(); 210 const [registerModal, { openModal }] = useModal();
210 const [registerCustomerModal, { openModal: openCustomerModal }] = useModal(); 211 const [registerCustomerModal, { openModal: openCustomerModal }] = useModal();
211 const [registerDetailDrawer, { openDrawer }] = useDrawer(); 212 const [registerDetailDrawer, { openDrawer }] = useDrawer();
  213 +
212 const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({ 214 const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({
213 title: '设备列表', 215 title: '设备列表',
214 api: devicePage, 216 api: devicePage,
@@ -265,8 +267,16 @@ @@ -265,8 +267,16 @@
265 } 267 }
266 // 取消分配客户 268 // 取消分配客户
267 async function handleCancelDispatchCustomer(record: Recordable) { 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 function handleDetail(record: Recordable) { 282 function handleDetail(record: Recordable) {