|
|
|
@ -104,11 +104,13 @@
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-dropdown placement='bottom' trigger="click" @command="dropdownDeviceCommand($event,i,k)">
|
|
|
|
|
<el-button size="mini" round>...</el-button>
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
|
<el-dropdown-item command="del">删除</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="update">修改</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="mapping">设置结果映射</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
<el-dropdown-menu >
|
|
|
|
|
<el-dropdown-item command="del">删除</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="update">修改</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="mapping">设置结果映射</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -137,7 +139,7 @@
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="添加请求"
|
|
|
|
|
append-to-body
|
|
|
|
|
:visible.sync="addRequestDialogVisible"
|
|
|
|
|
v-model="addRequestDialogVisible"
|
|
|
|
|
width="30%">
|
|
|
|
|
<el-row :gutter="12">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
@ -188,7 +190,7 @@
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="网络请求"
|
|
|
|
|
append-to-body
|
|
|
|
|
:visible.sync="addRequestFormDialogVisible"
|
|
|
|
|
v-model="addRequestFormDialogVisible"
|
|
|
|
|
width="30%">
|
|
|
|
|
<el-form :model="addRequestForm">
|
|
|
|
|
<InterfaceRequest :form="addRequestForm" />
|
|
|
|
@ -202,7 +204,7 @@
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="添加设备"
|
|
|
|
|
append-to-body
|
|
|
|
|
:visible.sync="addEquipmentFormDialogVisible"
|
|
|
|
|
v-model="addEquipmentFormDialogVisible"
|
|
|
|
|
width="30%">
|
|
|
|
|
<el-form :model="addEquipmentForm" label-width="120px">
|
|
|
|
|
<EquipmentRequest :form="addEquipmentForm" />
|
|
|
|
@ -213,7 +215,7 @@
|
|
|
|
|
</span>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<el-dialog title="设置结果映射" :visible.sync="mappingDialogVisible"
|
|
|
|
|
<el-dialog title="设置结果映射" v-model="mappingDialogVisible"
|
|
|
|
|
append-to-body width="30%">
|
|
|
|
|
<el-form :model="mappingForm">
|
|
|
|
|
<el-form-item label="pid" v-if="false">
|
|
|
|
@ -245,7 +247,8 @@
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import addIcon from '@/assets/add.png';
|
|
|
|
|
import subtractIcon from '@/assets/subtract.png';
|
|
|
|
|
import networkImg from '@/assets/request/network.png';
|
|
|
|
@ -255,313 +258,300 @@ import InterfaceRequest from './InterfaceRequest';
|
|
|
|
|
import EquipmentRequest from './EquipmentRequest';
|
|
|
|
|
import { customRequest, interfaceRequest } from '@/components/Configure/networkRequest/requestSend';
|
|
|
|
|
import { getHistoryData } from '@/api/configure/configuration/equipment';
|
|
|
|
|
import { queryGlobalCfg } from '@/api/configure/configuration/globalCfg.js';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
requests: Object
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
InterfaceRequest,
|
|
|
|
|
EquipmentRequest
|
|
|
|
|
},
|
|
|
|
|
props: ['requests'],
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
value: false,
|
|
|
|
|
addIcon,
|
|
|
|
|
subtractIcon,
|
|
|
|
|
networkImg,
|
|
|
|
|
customizationRequestImg,
|
|
|
|
|
addRequestDialogVisible: false,
|
|
|
|
|
addRequestFormDialogVisible: false,
|
|
|
|
|
addEquipmentFormDialogVisible: false,
|
|
|
|
|
mappingDialogVisible: false,
|
|
|
|
|
addRequestForm: {},
|
|
|
|
|
addEquipmentForm: {},
|
|
|
|
|
mappingForm: {},
|
|
|
|
|
option: [],
|
|
|
|
|
enumOption: [],
|
|
|
|
|
updateFlag: false,
|
|
|
|
|
updateIndex: 0,
|
|
|
|
|
updateDeviceFlag: false,
|
|
|
|
|
updateDeviceIndex: 0
|
|
|
|
|
const { requests } = toRefs(props);
|
|
|
|
|
const value = ref(false);
|
|
|
|
|
const addRequestDialogVisible = ref(false);
|
|
|
|
|
const addRequestFormDialogVisible = ref(false);
|
|
|
|
|
const addEquipmentFormDialogVisible = ref(false);
|
|
|
|
|
const mappingDialogVisible = ref(false);
|
|
|
|
|
const addRequestForm = ref({});
|
|
|
|
|
const addEquipmentForm = ref({});
|
|
|
|
|
const mappingForm = ref({});
|
|
|
|
|
const option = ref([]);
|
|
|
|
|
const enumOption = ref([]);
|
|
|
|
|
const updateFlag = ref(false);
|
|
|
|
|
const updateIndex = ref(0);
|
|
|
|
|
const updateDeviceFlag = ref(false);
|
|
|
|
|
const updateDeviceIndex = ref(0);
|
|
|
|
|
const options = ref({});
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
if (!requests.value || !Array.isArray(requests.value)) {
|
|
|
|
|
requests.value = [];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const addRequest = () => {
|
|
|
|
|
addRequestDialogVisible.value = true;
|
|
|
|
|
};
|
|
|
|
|
const addNetworkRequest = () => {
|
|
|
|
|
addRequestFormDialogVisible.value = true;
|
|
|
|
|
};
|
|
|
|
|
const addEquipment = () => {
|
|
|
|
|
addEquipmentFormDialogVisible.value = true;
|
|
|
|
|
};
|
|
|
|
|
const addRequestConfirm = () => {
|
|
|
|
|
if (updateFlag.value) {
|
|
|
|
|
requests.value[updateIndex.value] = ({
|
|
|
|
|
...addRequestForm.value,
|
|
|
|
|
type: 1,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
requests.value.push(({
|
|
|
|
|
...addRequestForm.value,
|
|
|
|
|
type: 1,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
updateFlag.value = false;
|
|
|
|
|
addRequestFormDialogVisible.value = false;
|
|
|
|
|
addRequestDialogVisible.value = false;
|
|
|
|
|
addRequestForm.value = {};
|
|
|
|
|
};
|
|
|
|
|
const addEquipmentConfirm = () => {
|
|
|
|
|
if (updateDeviceFlag.value) {
|
|
|
|
|
requests.value[updateDeviceIndex.value] = {
|
|
|
|
|
...addEquipmentForm.value,
|
|
|
|
|
type: 2,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
if (!this.requests || !Array.isArray(this.requests)) {
|
|
|
|
|
this.requests = [];
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
addRequest() {
|
|
|
|
|
this.addRequestDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
subtractRequest(key) {
|
|
|
|
|
if (this.requests?.length > 1) {
|
|
|
|
|
this.$delete(this.requests, key);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
addNetworkRequest() {
|
|
|
|
|
this.addRequestFormDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
addEquipment() {
|
|
|
|
|
this.addEquipmentFormDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
addRequestConfirm() {
|
|
|
|
|
if (this.updateFlag) {
|
|
|
|
|
this.$set(this.requests, this.updateIndex, ({
|
|
|
|
|
...this.addRequestForm,
|
|
|
|
|
type: 1,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
this.requests.push(({
|
|
|
|
|
...this.addRequestForm,
|
|
|
|
|
type: 1,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
this.updateFlag = false;
|
|
|
|
|
this.addRequestFormDialogVisible = false;
|
|
|
|
|
this.addRequestDialogVisible = false;
|
|
|
|
|
this.addRequestForm = {};
|
|
|
|
|
},
|
|
|
|
|
addEquipmentConfirm() {
|
|
|
|
|
if (this.updateDeviceFlag) {
|
|
|
|
|
this.$set(this.requests, this.updateDeviceIndex, ({
|
|
|
|
|
...this.addEquipmentForm,
|
|
|
|
|
type: 2,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
this.requests.push(({
|
|
|
|
|
...this.addEquipmentForm,
|
|
|
|
|
type: 2,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
this.updateDeviceFlag = false;
|
|
|
|
|
this.addEquipmentFormDialogVisible = false;
|
|
|
|
|
this.addRequestDialogVisible = false;
|
|
|
|
|
this.addEquipmentForm = {};
|
|
|
|
|
},
|
|
|
|
|
testConnection(i, k) {
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', 0);
|
|
|
|
|
interfaceRequest(i).then(e => {
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2);
|
|
|
|
|
this.$set(this.requests[k], 'request', e.data);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
testDeviceConnection(i, k) {
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', 0);
|
|
|
|
|
getHistoryData({
|
|
|
|
|
deviceModeId: i.deviceModeId,
|
|
|
|
|
functionIdentifier: i.functionIdentifier + '1',
|
|
|
|
|
interval: i.interval,
|
|
|
|
|
'sceneId': 144,
|
|
|
|
|
'deviceId': i.deviceId,
|
|
|
|
|
startTime: i.startTime,
|
|
|
|
|
endTime: i.endTime,
|
|
|
|
|
intervalType: 1 || i.intervalType
|
|
|
|
|
}).then(e => {
|
|
|
|
|
// this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2)
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', e.code === 200 ? 1 : 2);
|
|
|
|
|
this.$set(this.requests[k], 'request', e.data);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
dropdownCommand(command, i, k) {
|
|
|
|
|
switch (command) {
|
|
|
|
|
case 'del':
|
|
|
|
|
this.delRequest(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'update':
|
|
|
|
|
this.updateRequestForm(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'mapping':
|
|
|
|
|
this.setMapping(i, k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
dropdownDeviceCommand(command, i, k) {
|
|
|
|
|
switch (command) {
|
|
|
|
|
case 'del':
|
|
|
|
|
this.delRequest(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'update':
|
|
|
|
|
this.updateDeviceRequestForm(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'mapping':
|
|
|
|
|
this.setDeviceMapping(i, k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
delRequest(i, k) {
|
|
|
|
|
this.$confirm('此操作将删除该网络请求, 是否继续?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.$delete(this.requests, k);
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '删除成功!'
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消删除'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
updateRequestForm(i, k) {
|
|
|
|
|
this.updateFlag = true;
|
|
|
|
|
this.updateIndex = k;
|
|
|
|
|
this.addRequestForm = JSON.parse(JSON.stringify(i));
|
|
|
|
|
this.addRequestFormDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
updateDeviceRequestForm(i, k) {
|
|
|
|
|
this.updateDeviceFlag = true;
|
|
|
|
|
this.updateDeviceIndex = k;
|
|
|
|
|
this.addEquipmentForm = JSON.parse(JSON.stringify(i));
|
|
|
|
|
this.addEquipmentFormDialogVisible = true;
|
|
|
|
|
},
|
|
|
|
|
async setMapping(i, k) {
|
|
|
|
|
if (!this.requests?.[k]?.request) {
|
|
|
|
|
await interfaceRequest(i).then(e => {
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2);
|
|
|
|
|
this.$set(this.requests[k], 'request', e.data);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.mappingDialogVisible = true;
|
|
|
|
|
// this.mappingForm = {mappingArr:[...(i.mappingForm || {})], pid: k}
|
|
|
|
|
let obj;
|
|
|
|
|
if (!i.mappingForm?.mappingArr || !Array.isArray(i.mappingForm?.mappingArr)) {
|
|
|
|
|
obj = { mappingArr: [i.mappingForm || {}], pid: k };
|
|
|
|
|
} else {
|
|
|
|
|
requests.value.push({
|
|
|
|
|
...addEquipmentForm.value,
|
|
|
|
|
type: 2,
|
|
|
|
|
connectionStatus: -1,
|
|
|
|
|
isOpen: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
updateDeviceFlag.value = false;
|
|
|
|
|
addEquipmentFormDialogVisible.value = false;
|
|
|
|
|
addRequestDialogVisible.value = false;
|
|
|
|
|
addEquipmentForm.value = {};
|
|
|
|
|
};
|
|
|
|
|
const testConnection = (i, k) => {
|
|
|
|
|
requests.value[k]['connectionStatus'] = 0;
|
|
|
|
|
interfaceRequest(i).then(e => {
|
|
|
|
|
requests.value[k]['connectionStatus'] = e.status ? 1 : 2;
|
|
|
|
|
requests.value[k]['request'] = e.data;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const testDeviceConnection = (i, k) => {
|
|
|
|
|
requests.value[k]['connectionStatus'] = 0;
|
|
|
|
|
getHistoryData({
|
|
|
|
|
deviceModeId: i.deviceModeId,
|
|
|
|
|
functionIdentifier: i.functionIdentifier + '1',
|
|
|
|
|
interval: i.interval,
|
|
|
|
|
'sceneId': 144,
|
|
|
|
|
'deviceId': i.deviceId,
|
|
|
|
|
startTime: i.startTime,
|
|
|
|
|
endTime: i.endTime,
|
|
|
|
|
intervalType: 1 || i.intervalType
|
|
|
|
|
}).then(e => {
|
|
|
|
|
// this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2)
|
|
|
|
|
requests.value[k]['connectionStatus'] = e.code === 200 ? 1 : 2;
|
|
|
|
|
requests.value[k]['request'] = e.data;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const dropdownCommand = (command, i, k) => {
|
|
|
|
|
switch (command) {
|
|
|
|
|
case 'del':
|
|
|
|
|
delRequest(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'update':
|
|
|
|
|
updateRequestForm(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'mapping':
|
|
|
|
|
setMapping(i, k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const dropdownDeviceCommand = (command, i, k) => {
|
|
|
|
|
switch (command) {
|
|
|
|
|
case 'del':
|
|
|
|
|
delRequest(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'update':
|
|
|
|
|
updateDeviceRequestForm(i, k);
|
|
|
|
|
break;
|
|
|
|
|
case 'mapping':
|
|
|
|
|
setDeviceMapping(i, k);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const delRequest = (i, k) => {
|
|
|
|
|
ElMessageBox.confirm('此操作将删除该网络请求, 是否继续?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
requests.value.splice(k, 1);
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '删除成功!'
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消删除'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const updateRequestForm = (i, k) => {
|
|
|
|
|
updateFlag.value = true;
|
|
|
|
|
updateIndex.value = k;
|
|
|
|
|
addRequestForm.value = JSON.parse(JSON.stringify(i));
|
|
|
|
|
addRequestFormDialogVisible.value = true;
|
|
|
|
|
};
|
|
|
|
|
const updateDeviceRequestForm = (i, k) => {
|
|
|
|
|
updateDeviceFlag.value = true;
|
|
|
|
|
updateDeviceIndex.value = k;
|
|
|
|
|
addEquipmentForm.value = JSON.parse(JSON.stringify(i));
|
|
|
|
|
addEquipmentFormDialogVisible.value = true;
|
|
|
|
|
};
|
|
|
|
|
const setMapping = async (i, k) => {
|
|
|
|
|
if (!requests.value?.[k]?.request) {
|
|
|
|
|
await interfaceRequest(i).then(e => {
|
|
|
|
|
requests.value[k]['connectionStatus'] = e.status ? 1 : 2;
|
|
|
|
|
requests.value[k]['request'] = e.data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
mappingDialogVisible.value = true;
|
|
|
|
|
// this.mappingForm = {mappingArr:[...(i.mappingForm || {})], pid: k}
|
|
|
|
|
let obj;
|
|
|
|
|
if (!i.mappingForm?.mappingArr || !Array.isArray(i.mappingForm?.mappingArr)) {
|
|
|
|
|
obj = { mappingArr: [i.mappingForm || {}], pid: k };
|
|
|
|
|
} else {
|
|
|
|
|
obj = { mappingArr: i.mappingForm.mappingArr || [], pid: k };
|
|
|
|
|
}
|
|
|
|
|
mappingForm.value = (obj);
|
|
|
|
|
let data = requests.value?.[k]?.request;
|
|
|
|
|
let fun = (v) => {
|
|
|
|
|
return Object.keys(v).map(e => {
|
|
|
|
|
if (v[e].constructor === Object) {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: 'Object',
|
|
|
|
|
children: fun(v[e])
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
obj = { mappingArr: i.mappingForm.mappingArr || [], pid: k };
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: Array.isArray(v[e]) ? 'Array' : 'String',
|
|
|
|
|
enum: Array.isArray(v[e]) ? Object.keys(v[e]?.[0] || {}) : []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
this.mappingForm = (obj);
|
|
|
|
|
let data = this.requests?.[k]?.request;
|
|
|
|
|
let fun = (v) => {
|
|
|
|
|
return Object.keys(v).map(e => {
|
|
|
|
|
if (v[e].constructor === Object) {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: 'Object',
|
|
|
|
|
children: fun(v[e])
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: Array.isArray(v[e]) ? 'Array' : 'String',
|
|
|
|
|
enum: Array.isArray(v[e]) ? Object.keys(v[e]?.[0] || {}) : []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let option = fun(data);
|
|
|
|
|
this.options = option;
|
|
|
|
|
if (this.mappingForm.isArray) {
|
|
|
|
|
this.mappingChange();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async setDeviceMapping(i, k) {
|
|
|
|
|
if (!this.requests?.[k]?.request) {
|
|
|
|
|
await getHistoryData({
|
|
|
|
|
deviceModeId: i.deviceModeId,
|
|
|
|
|
functionIdentifier: i.functionIdentifier + '1',
|
|
|
|
|
interval: i.interval,
|
|
|
|
|
'sceneId': 144,
|
|
|
|
|
'deviceId': i.deviceId,
|
|
|
|
|
startTime: i.startTime,
|
|
|
|
|
endTime: i.endTime,
|
|
|
|
|
intervalType: 1 || i.intervalType
|
|
|
|
|
}).then(e => {
|
|
|
|
|
// this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2)
|
|
|
|
|
this.$set(this.requests[k], 'connectionStatus', e.code === 200 ? 1 : 2);
|
|
|
|
|
this.$set(this.requests[k], 'request', e.data);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.mappingDialogVisible = true;
|
|
|
|
|
this.mappingForm = { mappingArr: [(i.mappingForm || {})], pid: k };
|
|
|
|
|
let obj;
|
|
|
|
|
if (!i.mappingForm?.mappingArr || !Array.isArray(i.mappingForm?.mappingArr)) {
|
|
|
|
|
obj = { mappingArr: [(i.mappingForm || {})], pid: k };
|
|
|
|
|
let option1 = fun(data);
|
|
|
|
|
options.value = option1;
|
|
|
|
|
if (mappingForm.value.isArray) {
|
|
|
|
|
mappingChange();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const setDeviceMapping = async (i, k) => {
|
|
|
|
|
if (!requests.value?.[k]?.request) {
|
|
|
|
|
await getHistoryData({
|
|
|
|
|
deviceModeId: i.deviceModeId,
|
|
|
|
|
functionIdentifier: i.functionIdentifier + '1',
|
|
|
|
|
interval: i.interval,
|
|
|
|
|
'sceneId': 144,
|
|
|
|
|
'deviceId': i.deviceId,
|
|
|
|
|
startTime: i.startTime,
|
|
|
|
|
endTime: i.endTime,
|
|
|
|
|
intervalType: 1 || i.intervalType
|
|
|
|
|
}).then(e => {
|
|
|
|
|
// this.$set(this.requests[k], 'connectionStatus', e.status ? 1 : 2)
|
|
|
|
|
requests.value[k]['connectionStatus'] = e.code === 200 ? 1 : 2;
|
|
|
|
|
requests.value[k]['request'] = e.data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
mappingDialogVisible.value = true;
|
|
|
|
|
mappingForm.value = { mappingArr: [(i.mappingForm || {})], pid: k };
|
|
|
|
|
let obj;
|
|
|
|
|
if (!i.mappingForm?.mappingArr || !Array.isArray(i.mappingForm?.mappingArr)) {
|
|
|
|
|
obj = { mappingArr: [(i.mappingForm || {})], pid: k };
|
|
|
|
|
} else {
|
|
|
|
|
obj = { mappingArr: i.mappingForm.mappingArr || [], pid: k };
|
|
|
|
|
}
|
|
|
|
|
mappingForm.value = (obj);
|
|
|
|
|
let data = requests.value?.[k]?.request;
|
|
|
|
|
let fun = (v) => {
|
|
|
|
|
return Object.keys(v).map(e => {
|
|
|
|
|
if (v[e].constructor === Object) {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: 'Object',
|
|
|
|
|
children: fun(v[e])
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
obj = { mappingArr: i.mappingForm.mappingArr || [], pid: k };
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: Array.isArray(v[e]) ? 'Array' : 'String',
|
|
|
|
|
enum: Array.isArray(v[e]) ? Object.keys(v[e]?.[0] || {}) : []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
this.mappingForm = (obj);
|
|
|
|
|
let data = this.requests?.[k]?.request;
|
|
|
|
|
let fun = (v) => {
|
|
|
|
|
return Object.keys(v).map(e => {
|
|
|
|
|
if (v[e].constructor === Object) {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: 'Object',
|
|
|
|
|
children: fun(v[e])
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e,
|
|
|
|
|
type: Array.isArray(v[e]) ? 'Array' : 'String',
|
|
|
|
|
enum: Array.isArray(v[e]) ? Object.keys(v[e]?.[0] || {}) : []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let option = fun(data);
|
|
|
|
|
this.options = option;
|
|
|
|
|
if (this.mappingForm.isArray) {
|
|
|
|
|
this.mappingChange();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mappingChange(e, k) {
|
|
|
|
|
let data = this.options;
|
|
|
|
|
this.mappingForm.mappingArr[k]?.region.forEach(e => {
|
|
|
|
|
if (Array.isArray(data?.children)) {
|
|
|
|
|
data = data.children?.find(v => v.value === e) || data;
|
|
|
|
|
} else {
|
|
|
|
|
data = data?.find(v => v.value === e) || data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.$set(this.mappingForm.mappingArr[k], 'isArray', data.type === 'Array');
|
|
|
|
|
if (this.mappingForm.mappingArr[k].isArray) {
|
|
|
|
|
this.enumOption = data.enum.map(e => {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.enumOption = [];
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mappingDialogOk() {
|
|
|
|
|
this.$set(this.requests[this.mappingForm.pid], 'mappingForm', this.mappingForm);
|
|
|
|
|
this.mappingDialogVisible = false;
|
|
|
|
|
},
|
|
|
|
|
addMappingArr() {
|
|
|
|
|
this.mappingForm.mappingArr.push(
|
|
|
|
|
{
|
|
|
|
|
name: '',
|
|
|
|
|
region: '',
|
|
|
|
|
isArray: false,
|
|
|
|
|
mapData: ''
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
let option1 = fun(data);
|
|
|
|
|
options.value = option1;
|
|
|
|
|
if (mappingForm.value.isArray) {
|
|
|
|
|
mappingChange();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const mappingChange = (e, k) => {
|
|
|
|
|
let data = options.value;
|
|
|
|
|
mappingForm.value.mappingArr[k]?.region.forEach(e => {
|
|
|
|
|
if (Array.isArray(data?.children)) {
|
|
|
|
|
data = data.children?.find(v => v.value === e) || data;
|
|
|
|
|
} else {
|
|
|
|
|
data = data?.find(v => v.value === e) || data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mappingForm.value.mappingArr[k]['isArray'] = data.type === 'Array';
|
|
|
|
|
if (mappingForm.value.mappingArr[k].isArray) {
|
|
|
|
|
enumOption.value = data.enum.map(e => {
|
|
|
|
|
return {
|
|
|
|
|
value: e,
|
|
|
|
|
label: e
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
enumOption.value = [];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const mappingDialogOk = () => {
|
|
|
|
|
requests.value[mappingForm.value.pid]['mappingForm'] = mappingForm.value;
|
|
|
|
|
mappingDialogVisible.value = false;
|
|
|
|
|
};
|
|
|
|
|
const addMappingArr = () => {
|
|
|
|
|
mappingForm.value.mappingArr.push(
|
|
|
|
|
{
|
|
|
|
|
name: '',
|
|
|
|
|
region: '',
|
|
|
|
|
isArray: false,
|
|
|
|
|
mapData: ''
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
.add {
|
|
|
|
|