This commit is contained in:
haodd 2023-07-13 15:39:26 +08:00
commit 1ce92713c1
14 changed files with 171 additions and 138 deletions

View File

@ -27,30 +27,30 @@ const filterProductMetadata = (data: any[], productMetaData: any[]) => {
): ProductItem | DeviceInstance => {
if (!data) return data;
const metadata = JSON.parse(data.metadata || '{}') as DeviceMetadata;
let productMetaData
// let productMetaData
if ((data as DeviceInstance).productMetadata) {
productMetaData = JSON.parse((data as DeviceInstance).productMetadata)
}
if (productMetaData) {
if (productMetaData.properties && productMetaData.properties.length) {
metadata.properties = filterProductMetadata(item, productMetaData.properties)
}
if (productMetaData.functions && productMetaData.functions.length) {
metadata.functions = filterProductMetadata(item, productMetaData.functions)
}
if (productMetaData.events && productMetaData.events.length) {
metadata.events = filterProductMetadata(item, productMetaData.events)
}
if (productMetaData.tags && productMetaData.tags.length) {
metadata.tags = filterProductMetadata(item, productMetaData.tags)
}
} else {
metadata[type] = item as any
}
console.log(metadata, type)
metadata[type] = metadata[type].sort((a, b) => b?.sortsIndex - a?.sortsIndex) as any[]
// if ((data as DeviceInstance).productMetadata) {
// productMetaData = JSON.parse((data as DeviceInstance).productMetadata)
// }
//
// if (productMetaData) {
// if (productMetaData.properties && productMetaData.properties.length) {
// metadata.properties = filterProductMetadata(item, productMetaData.properties)
// }
// if (productMetaData.functions && productMetaData.functions.length) {
// metadata.functions = filterProductMetadata(item, productMetaData.functions)
// }
// if (productMetaData.events && productMetaData.events.length) {
// metadata.events = filterProductMetadata(item, productMetaData.events)
// }
// if (productMetaData.tags && productMetaData.tags.length) {
// metadata.tags = filterProductMetadata(item, productMetaData.tags)
// }
// } else {
// metadata[type] = item as any
// }
// console.log(metadata, type)
metadata[type] = (item || []).sort((a, b) => b?.sortsIndex - a?.sortsIndex) as any[]
data.metadata = JSON.stringify(metadata);
onEvent?.(data.metadata)
return data;

View File

@ -7,7 +7,7 @@
ref="listRef"
model="table"
:columns="columns"
:request="(e:any) => CascadeApi.queryBindChannel(route?.query.id as string, e)"
:request="(e) => CascadeApi.queryBindChannel(route?.query.id, e)"
:defaultParams="{
sorts: [{ name: 'name', order: 'desc' }],
}"

View File

@ -21,13 +21,13 @@
</div>
<template #overlay>
<j-menu @click="recordStart">
<j-menu-item key='false' v-if='route.query.type !== "fixed-media"'>
<j-menu-item key='true' v-if='route.query.type !== "fixed-media"'>
<span style='padding-right: 12px;'>本地存储</span>
<j-tooltip title='存储在设备本地'>
<a-icon type='QuestionCircleOutlined' />
</j-tooltip>
</j-menu-item>
<j-menu-item key='true'>
<j-menu-item key='false'>
<span style='padding-right: 12px;'>云端存储</span>
<j-tooltip title='存储在服务器中'>
<a-icon type='QuestionCircleOutlined' />
@ -244,4 +244,10 @@ watch(
</script>
<style lang="less" scoped>
@import './index.less';
:deep(.live-player-stretch-btn){
display: none;
}
:deep(.vjs-icon-spinner){
display: none;
}
</style>

View File

@ -98,7 +98,6 @@
height: 19px;
background-color: @primary-color;
border-radius: 2px;
visibility: hidden;
}
.time-line {
@ -112,7 +111,6 @@
background-color: #d9d9d9;
border-radius: 2px;
box-shadow: 0 0 12px rgba(#000, 0.15);
visibility: hidden;
}
}
}

View File

@ -37,7 +37,7 @@
}
"
:on-time-update="
(e: any) => {
(e) => {
playTime = e;
}
"

View File

@ -24,8 +24,8 @@
"
></div>
</div>
<div id="btn" class="time-line-btn"></div>
<div id="time" class="time-line">
<div id="btn" v-show="timePosition" class="time-line-btn" :style="{left: timePosition + 'px' }"></div>
<div id="time" v-show="timePosition" class="time-line" :style="{left: (timePosition - 15) + 'px' }">
{{ dayjs(playTime || 0).format('HH:mm:ss') }}
</div>
</div>
@ -76,7 +76,7 @@ const endT = ref<number>(
).getTime(),
);
const list = ref<any[]>([]);
const playTime = ref<number>(0);
const _playTime = ref<number>(0);
const LineContent = ref<HTMLDivElement>();
const LineContentSize = useElementSize(LineContent);
@ -107,7 +107,7 @@ const onChange = (
deviceId: string,
channelId: string,
) => {
playTime.value = startTime;
_playTime.value = startTime;
props.onChange({
startTime: dayjs(startTime),
endTime: dayjs(endTime),
@ -132,11 +132,11 @@ const playByStartTime = (time: any) => {
playByStartTime(0);
const onNextPlay = () => {
if (playTime.value) {
if (_playTime.value) {
//
const nowIndex = props.data.findIndex((item) => {
const startTime = item.startTime || item.mediaStartTime;
return startTime === playTime.value;
return startTime === _playTime.value;
});
//
if (nowIndex !== props.data.length - 1) {
@ -216,35 +216,44 @@ const getLineItemStyle = (
const start = startTime - startT.value > 0 ? startTime - startT.value : 0;
const _width = LineContentSize.width.value!;
const itemWidth = ((endTime - startTime) / (24 * 3600000)) * _width;
console.log()
return {
left: `${(start / (24 * 3600000)) * _width}px`,
width: `${itemWidth < 1 ? 1 : itemWidth}px`,
};
};
const playTimeChange = () => {
if (
props.playTime &&
props.playTime >= startT.value &&
props.playTime <= endT.value &&
props.data &&
props.data.length
) {
setTimeAndPosition((props.playTime - startT.value) / 3600000 / 24);
}
};
watch(
() => props.playTime,
() => {
playTimeChange();
},
);
watch(
() => startT.value,
() => {
playTimeChange();
},
);
const timePosition = computed(() => {
console.log(props.playTime, startT.value, LineContentSize.width.value)
console.log(((props.playTime - startT.value) / 3600000 / 24) * LineContentSize.width.value)
return ((props.playTime - startT.value) / 3600000 / 24) * LineContentSize.width.value
})
// const playTimeChange = () => {
// if (
// props.playTime &&
// props.playTime >= startT.value &&
// props.playTime <= endT.value &&
// props.data &&
// props.data.length
// ) {
// console.log(props.playTime, props.playTime - startT.value)
// setTimeAndPosition((props.playTime - startT.value) / 3600000 / 24);
// }
// };
// watch(
// () => props.playTime,
// () => {
// playTimeChange();
// },
// );
// watch(
// () => startT.value,
// () => {
// playTimeChange();
// },
// );
const handleProgress = (event: any, item: any) => {
const pos = LineContent.value?.getBoundingClientRect();

View File

@ -187,6 +187,7 @@ const columns = [
options: [
{ label: '在线', value: 'online' },
{ label: '离线', value: 'offline' },
{ label: '禁用', value: 'notActive'}
],
handleValue: (v: any) => {
return v;

View File

@ -8,6 +8,7 @@
:loadData="onLoadData"
:fieldNames="{ title: 'name', key: 'id' }"
@select="onSelect"
v-model:expandedKeys="expandedKeys"
>
<template #title="{id, name}">
<div class="name"><AIcon
@ -28,6 +29,12 @@ type Emits = {
(e: 'onSelect', data: { dId: string; cId: string }): void;
};
/**
* 默认展开第一个
*/
const expandedKeys = ref<any[]>([]); // key
// const selectedKeys = ref<any[]>([]); // key
const emit = defineEmits<Emits>();
interface DataNode {
@ -80,6 +87,16 @@ const getDeviceList = async () => {
...extra,
};
});
getChildren(treeData.value[0].id,{
pageIndex: 0,
pageSize: 100,
terms: [
{
column: 'deviceId',
value: treeData.value[0].id,
},
],
},true)
}
};
getDeviceList();
@ -120,7 +137,7 @@ const updateTreeData = (
* @param key
* @param params
*/
const getChildren = (key: any, params: any): Promise<any> => {
const getChildren = (key: any, params: any, first?:any): Promise<any> => {
return new Promise(async (resolve) => {
const res = await cascadeApi.queryChannelList(params);
if (res.status === 200) {
@ -143,6 +160,11 @@ const getChildren = (key: any, params: any): Promise<any> => {
});
}, 50);
}
if(first){
expandedKeys.value.push(treeData.value[0].id)
// selectedKeys.value.push(treeData.value[0].children[0].id)
// emit('onSelect', { dId: treeData.value[0].children[0].deviceId, cId: treeData.value[0].children[0].channelId });
}
resolve(res.result);
}
});
@ -171,6 +193,7 @@ const onLoadData = ({ key, children }: any): Promise<void> => {
resolve();
});
};
</script>
<style lang="less" scoped>

View File

@ -51,6 +51,8 @@ const props = defineProps({
},
});
const data = ref();
const tableRef = ref();
const columns = [
@ -69,14 +71,15 @@ const columns = [
fixed: 'right',
},
];
const dataSource = reactive({
table:props.headers
});
const handleHeader= (data:any) =>{
return data.map((item:any)=>{
return {...item,_key: randomString()}
})
}
const dataSource = reactive({
table:props.headers.length > 0 ? handleHeader(props.headers) : ''
});
watch(()=>JSON.stringify(props.headers),()=>{
dataSource.table = handleHeader(props.headers)
})
@ -85,7 +88,7 @@ const handleDelete = (id: number) => {
dataSource.table.splice(idx, 1);
};
const valueChange = () =>{
return dataSource.table.map((item:any)=>{
data.value = dataSource.table.map((item:any)=>{
const {_key,...extra}=item;
return extra
})
@ -98,14 +101,17 @@ const handleAdd = () => {
});
};
const validate = () =>{
return new Promise((resolve:any,reject:any)=>{
tableRef.value.validate().then(()=>{
return valueChange()
valueChange()
resolve(data.value)
}).catch((err:any)=>{
return false
reject(false)
})
})
}
defineExpose({
validate
validate,
})
</script>

View File

@ -546,7 +546,34 @@ const resetPublicFiles = () => {
*/
const btnLoading = ref<boolean>(false);
const handleSubmit = () => {
if(editTable.value.validate()){
if(formData.value.type === 'webhook') {
Promise.all([editTable.value.validate(),validate()]).then(async (result:any) => {
formData.value.configuration.headers = result[0]
btnLoading.value = true;
let res;
if (!formData.value.id) {
res = await configApi.save(formData.value);
} else {
res = await configApi.update(formData.value);
}
if (res?.success) {
onlyMessage('保存成功');
if (route.query?.notifyType) {
// @ts-ignore
window?.onTabSaveSuccess(res.result);
setTimeout(() => window.close(), 300);
} else {
router.back();
}
}
})
.catch((err:any) => {
console.log('err: ', err);
})
.finally(() => {
btnLoading.value = false;
});
}else{
validate()
.then(async () => {
btnLoading.value = true;
@ -567,65 +594,13 @@ const handleSubmit = () => {
}
}
})
.catch((err) => {
.catch((err:any) => {
console.log('err: ', err);
})
.finally(() => {
btnLoading.value = false;
});
}
// Promise.all([validate(),editTable.value.validate()]).then(async()=>{
// btnLoading.value = true;
// let res;
// if (!formData.value.id) {
// res = await configApi.save(formData.value);
// } else {
// res = await configApi.update(formData.value);
// }
// if (res?.success) {
// onlyMessage('');
// if (route.query?.notifyType) {
// // @ts-ignore
// window?.onTabSaveSuccess(res.result);
// setTimeout(() => window.close(), 300);
// } else {
// router.back();
// }
// }
// }) .catch((err) => {
// console.log('err: ', err);
// })
// .finally(() => {
// btnLoading.value = false;
// });
// validate()
// .then(async () => {
// const a = editTable.value.validate();
// console.log(a);
// btnLoading.value = true;
// let res;
// if (!formData.value.id) {
// res = await configApi.save(formData.value);
// } else {
// res = await configApi.update(formData.value);
// }
// if (res?.success) {
// onlyMessage('');
// if (route.query?.notifyType) {
// // @ts-ignore
// window?.onTabSaveSuccess(res.result);
// setTimeout(() => window.close(), 300);
// } else {
// router.back();
// }
// }
// })
// .catch((err) => {
// console.log('err: ', err);
// })
// .finally(() => {
// btnLoading.value = false;
// });
}
};
watchEffect(() => {

View File

@ -141,15 +141,18 @@ const confirm = () => {
}));
// ,
departmentStore.setProductId(table.selectedRows.map((item: any) => item.id));
// departmentStore.setProductId(table.selectedRows.map((item: any) => item.id));
loading.value = true;
bindDeviceOrProductList_api(props.assetType, params)
.then(() => {
onlyMessage('操作成功');
emits('confirm');
emits('update:visible', false);
emits('next',table.selectedRows.map((item: any) => item.id))
if(props.assetType === 'device'){
departmentStore.setProductId(undefined)
}
emits('update:visible', false);
})
.finally(() => {
loading.value = false;
@ -172,7 +175,7 @@ const columns = props.queryColumns.filter(
const searchColumns = computed(() => {
return props.queryColumns.map(item => {
if (departmentStore.productId) {
if (departmentStore.productId) {
if (item.dataIndex === 'productName') {
item.search.first = true
item.search.componentProps = {
@ -185,6 +188,11 @@ const searchColumns = computed(() => {
} else if (item.search && 'first' in item.search) {
delete item.search.first
}
}
else{
if (item.dataIndex === 'productName'){
item.search.defaultOnceValue = ''
}
}
return item
})
@ -459,18 +467,18 @@ const selectAll = (selected: Boolean, selectedRows: any,changeRows:any) => {
}
const cancel = () => {
departmentStore.setProductId(undefined)
console.log(departmentStore.productId)
emits('update:visible', false)
}
const search = (query: any) => {
queryParams.value = query
}
onUnmounted(()=>{
if(props.assetType ==='device'){
departmentStore.setProductId(undefined)
}
console.log(departmentStore.productId)
})
// onUnmounted(()=>{
// if(props.assetType ==='device'){
// departmentStore.setProductId(undefined)
// }
// })
</script>
<style lang="less" scoped>

View File

@ -27,7 +27,7 @@ const handleOk = () => {
};
const cancel = () => {
departmentStore.setProductId()
// departmentStore.setProductId()
emits('update:visible',false)
}

View File

@ -219,6 +219,7 @@
:all-permission="tableData.permissionList"
asset-type="product"
@confirm="table.addConfirm"
@next="nextAction"
/>
<EditPermissionDialog
v-if="dialogs.editShow"
@ -230,12 +231,11 @@
asset-type="product"
:defaultPermission="tableData.defaultPermission"
@confirm="table.refresh"
@next="next"
/>
<NextDialog
v-if="dialogs.nextShow"
v-model:visible="dialogs.nextShow"
@confirm="emits('openDeviceBind')"
@confirm="nextConfirm"
/>
</div>
</div>
@ -256,9 +256,10 @@ import {
getBindingsPermission,
} from '@/api/system/department';
import { intersection } from 'lodash-es';
import { useDepartmentStore } from '@/store/department';
const permission = 'system/Department';
const departmentStore = useDepartmentStore();
const emits = defineEmits(['openDeviceBind']);
const props = defineProps<{
parentId: string;
@ -614,8 +615,14 @@ watch(
if (!val) tableData.selectedRows = [];
},
);
const next = (data:any) =>{
let Temporary:any = '';
const nextAction = (data:any) =>{
Temporary = data
}
const nextConfirm = () =>{
departmentStore.setProductId(Temporary);
emits('openDeviceBind')
}
</script>

View File

@ -3837,8 +3837,8 @@ jetlinks-ui-components@^1.0.23:
jetlinks-ui-components@^1.0.24:
version "1.0.24"
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#bc536b4ebe5970804216be00fa2e636caf266b05"
integrity sha512-XsxAnU/0fmvhFm9CrYnLxwvpoXKOYnz9D1eA82e/qCqn2QGhiq6h84uuTAkS/hBWnbZurJkj2P5Pl+rnzXD4AA==
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#969a901be0214d3e631f02e537c56e0abc2e48ab"
integrity sha512-t0XkbxldcKjXW/xPYYbBU8YEfK+RK01LYqS/n+wfMq3pPRksegBOt7gnsvJD6kgEpSNf/uzlnV9MWFOgQJFphg==
dependencies:
"@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0"