Commit ef356d703ea820dbd84189527095e742488c1c3f

Authored by dev001
1 parent caebda75

feat: 设备列表:批量操作新增批量公开、批量私有、批量修改组织

@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 34
35 const record = ref([]); 35 const record = ref([]);
36 36
37 - const [registerModal, { closeModal }] = useModalInner((data) => { 37 + const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => {
38 record.value = data; 38 record.value = data;
39 }); 39 });
40 40
@@ -46,13 +46,18 @@ @@ -46,13 +46,18 @@
46 46
47 // 分配组织 47 // 分配组织
48 const dispatchCustomer = async () => { 48 const dispatchCustomer = async () => {
49 - const value = await validate();  
50 - if (!value) return;  
51 - await doBatchUpdateDevice(value.organizationId, record.value);  
52 - closeModal();  
53 - resetFields();  
54 - emit('reload');  
55 - createMessage.success('操作成功'); 49 + setModalProps({ loading: true });
  50 + try {
  51 + const value = await validate();
  52 + if (!value) return;
  53 + await doBatchUpdateDevice(value.organizationId, record.value);
  54 + closeModal();
  55 + resetFields();
  56 + emit('reload');
  57 + } finally {
  58 + setModalProps({ loading: false });
  59 + createMessage.success('操作成功');
  60 + }
56 }; 61 };
57 62
58 return { 63 return {
@@ -543,20 +543,30 @@ @@ -543,20 +543,30 @@
543 543
544 // 批量公开设备 544 // 批量公开设备
545 const handleBatchPublic = async () => { 545 const handleBatchPublic = async () => {
546 - const options = getSelectRows();  
547 - const tbDeviceIdJoinStr = options.map((item) => item.tbDeviceId).join(',');  
548 - const res = await doBatchPublicDevice(tbDeviceIdJoinStr);  
549 - createMessage.success(res);  
550 - handleReload(); 546 + setLoading(true);
  547 + try {
  548 + const options = getSelectRows();
  549 + const tbDeviceIdJoinStr = options.map((item) => item.tbDeviceId).join(',');
  550 + const res = await doBatchPublicDevice(tbDeviceIdJoinStr);
  551 + createMessage.success(res);
  552 + } finally {
  553 + handleReload();
  554 + setLoading(false);
  555 + }
551 }; 556 };
552 557
553 // 批量私有设备 558 // 批量私有设备
554 const handleBatchPrivate = async () => { 559 const handleBatchPrivate = async () => {
555 - const options = getSelectRows();  
556 - const tbDeviceIdJoinStr = options.map((item) => item.tbDeviceId).join(',');  
557 - const res = await doBatchPrivateDevice(tbDeviceIdJoinStr);  
558 - createMessage.success(res);  
559 - handleReload(); 560 + setLoading(true);
  561 + try {
  562 + const options = getSelectRows();
  563 + const tbDeviceIdJoinStr = options.map((item) => item.tbDeviceId).join(',');
  564 + const res = await doBatchPrivateDevice(tbDeviceIdJoinStr);
  565 + createMessage.success(res);
  566 + } finally {
  567 + handleReload();
  568 + setLoading(false);
  569 + }
560 }; 570 };
561 571
562 const handleDelete = async (record?: DeviceRecord) => { 572 const handleDelete = async (record?: DeviceRecord) => {