Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
54e5688309
|
@ -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 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
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
</template>
|
||||
|
||||
<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 { useInstanceStore } from '@/store/instance';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
@ -187,15 +187,28 @@ const handleOk = () => {
|
|||
return;
|
||||
}
|
||||
btnLoading.value = true;
|
||||
bindDevice(detail.value.id, _selectedRowKeys.value)
|
||||
.then((resp) => {
|
||||
emit('change', true);
|
||||
cancelSelect();
|
||||
onlyMessage('操作成功');
|
||||
queryDeviceMapping(instanceStore.current.id)
|
||||
.then(res => {
|
||||
const arr = bindDeviceRef.value?._dataSource.filter(item => {
|
||||
return !res.result?.[0]?.find(val => val.deviceId === item.id) && _selectedRowKeys.value.includes(item.id);
|
||||
}).map(item => {
|
||||
return {
|
||||
deviceId: item.id,
|
||||
deviceName: item.name
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
btnLoading.value = false;
|
||||
});
|
||||
return saveDeviceMapping(instanceStore.current.id, {info: arr})
|
||||
})
|
||||
.then(res => {
|
||||
return bindDevice(detail.value.id, _selectedRowKeys.value)
|
||||
}).then(res => {
|
||||
emit('change', true);
|
||||
cancelSelect();
|
||||
onlyMessage('操作成功');
|
||||
})
|
||||
.finally(() => {
|
||||
btnLoading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
|
|
|
@ -129,6 +129,7 @@ import {
|
|||
edgeChannel,
|
||||
addDevice,
|
||||
editDevice,
|
||||
saveDeviceMapping
|
||||
} from '@/api/device/instance';
|
||||
import MSelect from './MSelect.vue';
|
||||
import PatchMapping from './PatchMapping.vue';
|
||||
|
@ -274,6 +275,12 @@ const onSave = async () => {
|
|||
const array = modelRef.dataSource.filter(
|
||||
(item: any) => item.channelId,
|
||||
);
|
||||
const params = {
|
||||
info: [
|
||||
{ deviceId: resq.result?.id, deviceName: formData.name }
|
||||
]
|
||||
}
|
||||
const res = await saveDeviceMapping(instanceStore.current.id, params)
|
||||
const submitData = {
|
||||
deviceId: instanceStore.current.parentId
|
||||
? instanceStore.current.parentId
|
||||
|
|
Loading…
Reference in New Issue