fix: 边缘网关绑定子设备
This commit is contained in:
parent
2f073b0413
commit
530ac0421d
|
@ -252,6 +252,17 @@ export const unbindBatchDevice = (deviceId: string, data: Record<string, any>) =
|
||||||
*/
|
*/
|
||||||
export const bindDevice = (deviceId: string, data: Record<string, any>) => server.post(`/device/gateway/${deviceId}/bind`, data)
|
export const bindDevice = (deviceId: string, data: Record<string, any>) => server.post(`/device/gateway/${deviceId}/bind`, data)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询是否存在云端映射设备
|
||||||
|
*/
|
||||||
|
export const queryDeviceMapping = (deviceId: string, data?: any) => server.post(`/edge/operations/${deviceId}/device-mapping-list/invoke`, data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存云端映射设备
|
||||||
|
*/
|
||||||
|
export const saveDeviceMapping = (deviceId: string, data: any) => server.post(`/edge/operations/${deviceId}/device-mapping-save-batch/invoke`, data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取产品列表
|
* 获取产品列表
|
||||||
* @param data
|
* @param data
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="BindChildDevice">
|
<script setup lang="ts" name="BindChildDevice">
|
||||||
import { query, queryByParent, bindDevice } from '@/api/device/instance';
|
import { query, queryByParent, bindDevice, queryDeviceMapping, saveDeviceMapping } from '@/api/device/instance';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { useInstanceStore } from '@/store/instance';
|
import { useInstanceStore } from '@/store/instance';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
@ -187,15 +187,28 @@ const handleOk = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
btnLoading.value = true;
|
btnLoading.value = true;
|
||||||
bindDevice(detail.value.id, _selectedRowKeys.value)
|
queryDeviceMapping(instanceStore.current.id)
|
||||||
.then((resp) => {
|
.then(res => {
|
||||||
emit('change', true);
|
const arr = bindDeviceRef.value?._dataSource.filter(item => {
|
||||||
cancelSelect();
|
return !res.result?.[0]?.find(val => val.deviceId === item.id) && _selectedRowKeys.value.includes(item.id);
|
||||||
onlyMessage('操作成功');
|
}).map(item => {
|
||||||
|
return {
|
||||||
|
deviceId: item.id,
|
||||||
|
deviceName: item.name
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
return saveDeviceMapping(instanceStore.current.id, {info: arr})
|
||||||
btnLoading.value = false;
|
})
|
||||||
});
|
.then(res => {
|
||||||
|
return bindDevice(detail.value.id, _selectedRowKeys.value)
|
||||||
|
}).then(res => {
|
||||||
|
emit('change', true);
|
||||||
|
cancelSelect();
|
||||||
|
onlyMessage('操作成功');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
btnLoading.value = false;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
|
|
|
@ -129,6 +129,7 @@ import {
|
||||||
edgeChannel,
|
edgeChannel,
|
||||||
addDevice,
|
addDevice,
|
||||||
editDevice,
|
editDevice,
|
||||||
|
saveDeviceMapping
|
||||||
} from '@/api/device/instance';
|
} from '@/api/device/instance';
|
||||||
import MSelect from './MSelect.vue';
|
import MSelect from './MSelect.vue';
|
||||||
import PatchMapping from './PatchMapping.vue';
|
import PatchMapping from './PatchMapping.vue';
|
||||||
|
@ -274,6 +275,12 @@ const onSave = async () => {
|
||||||
const array = modelRef.dataSource.filter(
|
const array = modelRef.dataSource.filter(
|
||||||
(item: any) => item.channelId,
|
(item: any) => item.channelId,
|
||||||
);
|
);
|
||||||
|
const params = {
|
||||||
|
info: [
|
||||||
|
{ deviceId: resq.result?.id, deviceName: formData.name }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
const res = await saveDeviceMapping(instanceStore.current.id, params)
|
||||||
const submitData = {
|
const submitData = {
|
||||||
deviceId: instanceStore.current.parentId
|
deviceId: instanceStore.current.parentId
|
||||||
? instanceStore.current.parentId
|
? instanceStore.current.parentId
|
||||||
|
|
Loading…
Reference in New Issue