Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
f8fb98df44
|
@ -89,6 +89,10 @@ const props: JUploadProps = defineProps({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
accept:{
|
||||
type:Array,
|
||||
default:()=>[],
|
||||
}
|
||||
});
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
|
|
|
@ -206,6 +206,17 @@ const findDetailRoutes = (routes: any[]): any[] => {
|
|||
export const findCodeRoute = (asyncRouterMap: any[]) => {
|
||||
const routeMeta = {}
|
||||
|
||||
function getDetail( code: string, url: string) {
|
||||
const detail = findDetailRouteItem(code, url)
|
||||
if (!detail) return
|
||||
routeMeta[(detail as MenuItem).code] = {
|
||||
path: detail.url,
|
||||
title: detail.name,
|
||||
parentName: code,
|
||||
buttons: detail.buttons?.map((b: any) => b.id) || []
|
||||
}
|
||||
}
|
||||
|
||||
function findChildren (data: any[], code: string = '') {
|
||||
data.forEach(route => {
|
||||
routeMeta[route.code] = {
|
||||
|
@ -214,29 +225,24 @@ export const findCodeRoute = (asyncRouterMap: any[]) => {
|
|||
parentName: code,
|
||||
buttons: route.buttons?.map((b: any) => b.id) || []
|
||||
}
|
||||
const detail = findDetailRouteItem(route.code, route.url)
|
||||
if (detail) {
|
||||
routeMeta[(detail as MenuItem).code] = {
|
||||
path: detail.url,
|
||||
title: detail.name,
|
||||
parentName: route.code,
|
||||
buttons: detail.buttons?.map((b: any) => b.id) || []
|
||||
}
|
||||
}
|
||||
|
||||
const otherRoutes = extraRouteObj[route.code]
|
||||
|
||||
if (otherRoutes) {
|
||||
otherRoutes.children.map((item: any) => {
|
||||
const _code = `${route.code}/${item.code}`
|
||||
const url = `${route.url}/${item.code}`
|
||||
routeMeta[_code] = {
|
||||
path: `${route.url}/${item.code}`,
|
||||
title: item.name,
|
||||
parentName: route.code,
|
||||
buttons: item.buttons?.map((b: any) => b.id) || []
|
||||
}
|
||||
getDetail(_code, url)
|
||||
})
|
||||
}
|
||||
|
||||
getDetail(route.code, route.url)
|
||||
|
||||
if (route.children) {
|
||||
findChildren(route.children, route.code)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<!-- 新增编辑弹窗 -->
|
||||
<template>
|
||||
<j-modal
|
||||
v-if="visible"
|
||||
:title="props.title"
|
||||
:maskClosable="false"
|
||||
destroy-on-close
|
||||
v-model:visible="visible"
|
||||
visible
|
||||
@ok="submitData"
|
||||
@cancel="close"
|
||||
okText="确定"
|
||||
|
@ -117,20 +118,20 @@ const submitData = async () => {
|
|||
if (props.isChild === 1) {
|
||||
addParams.value = {
|
||||
...formModel.value,
|
||||
// sortIndex:
|
||||
// childArr.value[childArr.value.length - 1].sortIndex + 1,
|
||||
sortIndex:
|
||||
childArr.value[childArr.value.length - 1].sortIndex + 1,
|
||||
parentId: addObj.value.id,
|
||||
};
|
||||
} else if (props.isChild === 2) {
|
||||
addParams.value = {
|
||||
parentId: addObj.value.id,
|
||||
...formModel.value,
|
||||
// sortIndex: 1,
|
||||
sortIndex: 1,
|
||||
};
|
||||
} else if (props.isChild === 3) {
|
||||
addParams.value = {
|
||||
...formModel.value,
|
||||
// sortIndex: arr.value[arr.value.length - 1].sortIndex + 1,
|
||||
sortIndex: arr.value[arr.value.length - 1].sortIndex + 1,
|
||||
};
|
||||
}
|
||||
const res = await saveTree(addParams.value);
|
||||
|
@ -163,7 +164,7 @@ const submitData = async () => {
|
|||
/**
|
||||
* 显示弹窗
|
||||
*/
|
||||
const show = (row: any) => {
|
||||
const show = async (row: any) => {
|
||||
//新增
|
||||
if (props.isAdd === 0) {
|
||||
if (props.isChild === 1) {
|
||||
|
@ -179,6 +180,7 @@ const show = (row: any) => {
|
|||
visible.value = true;
|
||||
}
|
||||
} else if (props.isChild === 3) {
|
||||
const res = await getTableData();
|
||||
arr.value = listData.value.sort(compare('sortIndex'));
|
||||
if (arr.value.length > 0) {
|
||||
formModel.value = {
|
||||
|
@ -250,7 +252,6 @@ const close = () => {
|
|||
visible.value = false;
|
||||
resetFields();
|
||||
};
|
||||
getTableData();
|
||||
//监听项目ID
|
||||
watch([() => props.isAdd], () => {}, { immediate: false, deep: true });
|
||||
defineExpose({
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
<JProTable
|
||||
ref="tableRef"
|
||||
:columns="table.columns"
|
||||
:dataSource="dataSource"
|
||||
:request="queryTree"
|
||||
model="TABLE"
|
||||
type="TREE"
|
||||
:scroll="{ y: 550 }"
|
||||
:defaultParams="{
|
||||
paging: false,
|
||||
sorts: [
|
||||
|
@ -21,7 +23,7 @@
|
|||
},
|
||||
],
|
||||
}"
|
||||
:params="query.params"
|
||||
:params="params"
|
||||
:loading="tableLoading"
|
||||
>
|
||||
<template #headerTitle>
|
||||
|
@ -118,38 +120,13 @@ const query = reactive({
|
|||
scopedSlots: true,
|
||||
},
|
||||
],
|
||||
params: {
|
||||
paging: false,
|
||||
sorts: [
|
||||
{ name: 'sortIndex', order: 'asc' },
|
||||
{
|
||||
name: 'createTime',
|
||||
order: 'desc',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
/**
|
||||
* 查询树形列表
|
||||
*/
|
||||
const getTableData = async () => {
|
||||
tableLoading.value = true;
|
||||
const res = await queryTree(query.params);
|
||||
if (res.status === 200) {
|
||||
dataSource.value = res.result;
|
||||
}
|
||||
tableLoading.value = false;
|
||||
};
|
||||
getTableData();
|
||||
let params = ref();
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
const handleSearch = (e: any) => {
|
||||
query.params = {
|
||||
...query.params,
|
||||
...e,
|
||||
};
|
||||
getTableData();
|
||||
params.value = e
|
||||
};
|
||||
/**
|
||||
* 操作栏按钮
|
||||
|
@ -200,6 +177,9 @@ const getActions = (
|
|||
{
|
||||
key: 'delete',
|
||||
text: '删除',
|
||||
tooltip: {
|
||||
title: '删除',
|
||||
},
|
||||
popConfirm: {
|
||||
title: '确认删除?',
|
||||
okText: ' 确定',
|
||||
|
@ -208,7 +188,7 @@ const getActions = (
|
|||
const resp = await deleteTree(data.id);
|
||||
if (resp.status === 200) {
|
||||
message.success('操作成功!');
|
||||
getTableData();
|
||||
tableRef.value.reload();
|
||||
} else {
|
||||
message.error('操作失败!');
|
||||
}
|
||||
|
@ -227,20 +207,20 @@ const table = reactive({
|
|||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
ellipsis: true,
|
||||
width:600
|
||||
width: 600,
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortIndex',
|
||||
key: 'sortIndex',
|
||||
scopedSlots: true,
|
||||
width:200
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
width:700
|
||||
width: 700,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
@ -265,7 +245,7 @@ const table = reactive({
|
|||
* 刷新表格数据
|
||||
*/
|
||||
refresh: () => {
|
||||
getTableData();
|
||||
tableRef.value.reload();
|
||||
},
|
||||
});
|
||||
const { add, columns, refresh } = toRefs(table);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
:pagination="false"
|
||||
>
|
||||
<template #bodyCell="{ column, text, record }">
|
||||
<div style="width: 280px">
|
||||
<div>
|
||||
<template v-if="['valueType', 'name'].includes(column.dataIndex)">
|
||||
<span>{{ text }}</span>
|
||||
</template>
|
||||
|
|
|
@ -214,7 +214,7 @@ defineExpose({ saveBtn });
|
|||
|
||||
<style lang="less" scoped>
|
||||
.function {
|
||||
padding: 15px;
|
||||
padding: 24px 15px 0 15px;
|
||||
background-color: #e7eaec;
|
||||
}
|
||||
</style>
|
|
@ -30,7 +30,7 @@
|
|||
<j-col :span="8">
|
||||
<div class="right-log">
|
||||
<TitleComponent data="日志" />
|
||||
<div :style="{ marginTop: '10px' }">
|
||||
<div class="right-log-box">
|
||||
<template v-if="logList.length">
|
||||
<Log
|
||||
v-for="item in logList"
|
||||
|
@ -38,7 +38,9 @@
|
|||
:key="item.key"
|
||||
/>
|
||||
</template>
|
||||
<j-empty v-else />
|
||||
<div v-else class="right-log-box-empty">
|
||||
<j-empty />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</j-col>
|
||||
|
@ -187,8 +189,21 @@ onUnmounted(() => {
|
|||
padding-left: 20px;
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.09);
|
||||
overflow: hidden;
|
||||
max-height: 600px;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
min-height: 400px;
|
||||
|
||||
.right-log-box {
|
||||
padding-top: 10px;
|
||||
height: calc(100% - 40px);
|
||||
width: 100%;
|
||||
.right-log-box-empty {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -23,73 +23,15 @@
|
|||
<j-row type="flex">
|
||||
<j-col flex="180px">
|
||||
<j-form-item name="photoUrl">
|
||||
<Upload v-model="form.photoUrl" />
|
||||
<j-pro-upload
|
||||
v-model="form.photoUrl"
|
||||
:accept="
|
||||
imageTypes && imageTypes.length
|
||||
? imageTypes.toString()
|
||||
: ''
|
||||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
<!-- <j-form-item>
|
||||
<div class="upload-image-warp-logo">
|
||||
<div class="upload-image-border-logo">
|
||||
<a-upload
|
||||
name="file"
|
||||
:action="FILE_UPLOAD"
|
||||
:headers="headers"
|
||||
:showUploadList="false"
|
||||
:beforeUpload="beforeUpload"
|
||||
@change="handleChange"
|
||||
:accept="
|
||||
imageTypes && imageTypes.length
|
||||
? imageTypes.toString()
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<div class="upload-image-content-logo">
|
||||
<div
|
||||
class="loading-logo"
|
||||
v-if="logoLoading"
|
||||
>
|
||||
<LoadingOutlined
|
||||
style="font-size: 28px"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="upload-image"
|
||||
v-if="photoValue"
|
||||
:style="
|
||||
photoValue
|
||||
? `background-image: url(${photoValue});`
|
||||
: ''
|
||||
"
|
||||
></div>
|
||||
<div
|
||||
v-if="photoValue"
|
||||
class="upload-image-mask"
|
||||
>
|
||||
点击修改
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-if="logoLoading">
|
||||
<LoadingOutlined
|
||||
style="font-size: 28px"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<PlusOutlined
|
||||
style="font-size: 28px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
<div v-if="logoLoading">
|
||||
<div class="upload-loading-mask">
|
||||
<LoadingOutlined
|
||||
v-if="logoLoading"
|
||||
style="font-size: 28px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</j-form-item> -->
|
||||
</j-col>
|
||||
<j-col flex="auto">
|
||||
<j-form-item name="id">
|
||||
|
@ -186,8 +128,11 @@
|
|||
</j-row>
|
||||
</j-radio-group>
|
||||
</j-form-item>
|
||||
<j-form-item label="说明" name="describe">
|
||||
<j-form-item label="说明" name="description">
|
||||
<j-textarea
|
||||
:maxlength="200"
|
||||
showCount
|
||||
:auto-size="{ minRows: 4, maxRows: 5 }"
|
||||
v-model:value="form.describe"
|
||||
placeholder="请输入说明"
|
||||
/>
|
||||
|
@ -319,6 +264,9 @@ const rules = reactive({
|
|||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
description: [
|
||||
{ max: 200, message: '最多可输入200位字符', trigger: 'blur' },
|
||||
],
|
||||
});
|
||||
|
||||
const valueChange = (value: string, label: string) => {
|
||||
|
|
|
@ -123,9 +123,6 @@
|
|||
:status="statusMap.get(slotProps.state)"
|
||||
/>
|
||||
</template>
|
||||
<template #id="slotProps">
|
||||
<a>{{ slotProps.id }}</a>
|
||||
</template>
|
||||
<template #action="slotProps">
|
||||
<j-space :size="16">
|
||||
<template
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
placeholder="请选择"
|
||||
:options="handleOptions"
|
||||
:tabsOptions="tabOptions"
|
||||
:metricOption="upperOptions"
|
||||
:metricOptions="upperOptions"
|
||||
v-model:value="propertyModelRef.propertiesValue"
|
||||
v-model:source="propertyModelRef.source"
|
||||
@change="onValueChange"
|
||||
@select="onValueChange"
|
||||
>
|
||||
<template v-slot="{ label }">
|
||||
<j-input :value="label" />
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<j-select
|
||||
showSearch
|
||||
placeholder="请选择属性"
|
||||
v-model:value="modelRef.message.properties"
|
||||
v-model:value="modelRef.message.properties[0]"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in metadata?.properties || []"
|
||||
|
@ -80,9 +80,9 @@ import TopCard from '../device/TopCard.vue';
|
|||
import { detail } from '@/api/device/instance';
|
||||
import EditTable from './EditTable.vue';
|
||||
import WriteProperty from './WriteProperty.vue';
|
||||
import { queryBuiltInParams } from '@/api/rule-engine/scene';
|
||||
import { useSceneStore } from '@/store/scene';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getParams } from '../../../util'
|
||||
|
||||
const sceneStore = useSceneStore();
|
||||
const { data } = storeToRefs(sceneStore);
|
||||
|
@ -121,7 +121,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
branchGroup: {
|
||||
branchesName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
@ -131,7 +131,7 @@ const formRef = ref();
|
|||
|
||||
const modelRef = reactive({
|
||||
message: {
|
||||
messageType: undefined,
|
||||
messageType: 'INVOKE_FUNCTION',
|
||||
functionId: undefined,
|
||||
properties: undefined,
|
||||
inputs: [],
|
||||
|
@ -166,7 +166,7 @@ const _property = computed(() => {
|
|||
Object.keys(modelRef.message.properties || {})?.[0] === item.id
|
||||
);
|
||||
}
|
||||
return modelRef.message?.properties === item.id;
|
||||
return modelRef.message?.properties?.[0] === item.id;
|
||||
});
|
||||
return _item;
|
||||
});
|
||||
|
@ -178,18 +178,26 @@ const _function = computed(() => {
|
|||
return _item;
|
||||
});
|
||||
|
||||
const queryBuiltIn = async () => {
|
||||
const _params = {
|
||||
branch: props.thenName,
|
||||
branchGroup: props.branchesName,
|
||||
action: props.name - 1,
|
||||
};
|
||||
const _data = await getParams(_params, unref(data));
|
||||
builtInList.value = _data
|
||||
};
|
||||
|
||||
const onMessageTypeChange = (val: string) => {
|
||||
if (['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val)) {
|
||||
const _params = {
|
||||
branch: props.thenName,
|
||||
branchGroup: props.branchGroup,
|
||||
action: props.name - 1,
|
||||
};
|
||||
queryBuiltInParams(unref(data), _params).then((res: any) => {
|
||||
if (res.status === 200) {
|
||||
builtInList.value = res.result;
|
||||
}
|
||||
});
|
||||
const flag = ['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val)
|
||||
modelRef.message = {
|
||||
messageType: val,
|
||||
functionId: undefined,
|
||||
properties:(flag ? undefined : []) as any,
|
||||
inputs: [],
|
||||
};
|
||||
if (flag) {
|
||||
queryBuiltIn();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -223,10 +231,9 @@ watch(
|
|||
(newVal) => {
|
||||
if (newVal?.messageType) {
|
||||
modelRef.message = newVal;
|
||||
if (newVal.messageType === 'READ_PROPERTY') {
|
||||
modelRef.message.properties = newVal.properties?.[0];
|
||||
if (['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(newVal.messageType)) {
|
||||
queryBuiltIn();
|
||||
}
|
||||
onMessageTypeChange(newVal.messageType);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
|
@ -238,18 +245,16 @@ const onFormSave = () => {
|
|||
.validate()
|
||||
.then((_data: any) => {
|
||||
// 处理三种情况的值的格式
|
||||
const _properties = _data.message.properties || modelRef.message.properties
|
||||
const obj = {
|
||||
message: {
|
||||
...modelRef.message,
|
||||
..._data.message,
|
||||
properties: _data.message.messageType === 'READ_PROPERTY' ? [_properties] : _properties,
|
||||
propertiesName:
|
||||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||
? _function.value?.name
|
||||
: _property.value?.name,
|
||||
},
|
||||
}
|
||||
};
|
||||
resolve(obj);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</j-button>
|
||||
<j-button
|
||||
danger
|
||||
v-if="tagData.length > 1"
|
||||
v-if="tagList.length > 1"
|
||||
style="padding: 0 8px"
|
||||
@click="deleteItem(index)"
|
||||
>
|
||||
|
@ -109,6 +109,7 @@ const addItem = () => {
|
|||
|
||||
const deleteItem = (_index: number) => {
|
||||
tagList.value.splice(_index, 1);
|
||||
onValueChange();
|
||||
};
|
||||
|
||||
const onTypeSelect = (key: any, _index: number) => {
|
||||
|
@ -168,26 +169,23 @@ watch(
|
|||
);
|
||||
|
||||
const onValueChange = () => {
|
||||
const newValue = tagList.value
|
||||
.filter((item) => !!item.value)
|
||||
.map((item: any) => {
|
||||
return {
|
||||
column: item.id,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
const arr = newValue
|
||||
.filter((item) => !!item.value)
|
||||
.map((item: any) => {
|
||||
return {
|
||||
column: item.name,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
const _data = tagList.value.filter((item) => !!item.value);
|
||||
const newValue = _data.map((item: any) => {
|
||||
return {
|
||||
column: item.id,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
const arr = _data.map((item: any) => {
|
||||
return {
|
||||
column: item.name,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
emits('update:value', [{ value: newValue, name: '标签' }]);
|
||||
emits('change', [{ value: newValue, name: '标签' }], undefined);
|
||||
emits('change', [{ value: newValue, name: '标签' }], arr);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
name="selectorValues"
|
||||
:rules="[{ required: true, message: '请选择关系' }]"
|
||||
>
|
||||
<RelationSelect @change="onRelationChange" v-model:value="modelRef.selectorValues" />
|
||||
<RelationSelect
|
||||
@change="onRelationChange"
|
||||
v-model:value="modelRef.selectorValues"
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
v-else-if="modelRef.selector === 'tag'"
|
||||
|
@ -75,12 +78,13 @@
|
|||
import { useSceneStore } from '@/store/scene';
|
||||
import TopCard from './TopCard.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { queryBuiltInParams } from '@/api/rule-engine/scene';
|
||||
import { getImage } from '@/utils/comm';
|
||||
import NoticeApi from '@/api/notice/config';
|
||||
import Device from './Device.vue';
|
||||
import Tag from './Tag.vue';
|
||||
import RelationSelect from './RelationSelect.vue'
|
||||
import RelationSelect from './RelationSelect.vue';
|
||||
import { getParams } from '../../../util';
|
||||
import { handleParamsData } from '../../../components/Terms/util';
|
||||
|
||||
const props = defineProps({
|
||||
values: {
|
||||
|
@ -95,7 +99,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
branchGroup: {
|
||||
branchesName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
@ -185,15 +189,18 @@ const filterTree = (nodes: any[]) => {
|
|||
const sourceChangeEvent = async () => {
|
||||
const _params = {
|
||||
branch: props.thenName,
|
||||
branchGroup: props.branchGroup,
|
||||
branchGroup: props.branchesName,
|
||||
action: props.name - 1,
|
||||
};
|
||||
const resp = await queryBuiltInParams(unref(data), _params);
|
||||
if (resp.status === 200) {
|
||||
const array = filterTree(resp.result as any[]);
|
||||
//判断相同产品才有按变量
|
||||
// if (props.formProductId === DeviceModel.productId)// TODO
|
||||
builtInList.value = [] // array;
|
||||
//判断相同产品才有按变量
|
||||
const productId =
|
||||
data.value?.branches?.[props.branchesName].then?.[props.thenName]
|
||||
?.actions?.[props.name > 0 ? props.name - 1 : 0]?.device?.productId;
|
||||
if (productId === props.values?.productDetail?.id) {
|
||||
const _data = await getParams(_params, unref(data));
|
||||
builtInList.value = handleParamsData(filterTree(_data), 'id');
|
||||
} else {
|
||||
builtInList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -277,16 +284,13 @@ const onTagChange = (val: any[], arr: any[]) => {
|
|||
modelRef.deviceId = 'deviceId';
|
||||
modelRef.source = 'fixed';
|
||||
}
|
||||
if (arr) {
|
||||
tagList.value = arr;
|
||||
}
|
||||
emits('save', unref(modelRef), {}, {tagList: tagList.value});
|
||||
emits('save', unref(modelRef), {}, arr ? { tagList: arr } : {});
|
||||
};
|
||||
|
||||
const onVariableChange = (val: any, node: any) => {
|
||||
modelRef.deviceId = val;
|
||||
emits('save', unref(modelRef), node);
|
||||
modelRef.selectorValues = [{ value: val, name: node.description }] as any;
|
||||
emits('save', unref(modelRef), node);
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
v-else-if="current === 1"
|
||||
:name="name"
|
||||
:parallel="parallel"
|
||||
:branchGroup="branchGroup"
|
||||
:branchesName="branchesName"
|
||||
:thenName="thenName"
|
||||
:values="DeviceModel"
|
||||
@save="onDeviceSave"
|
||||
|
@ -38,7 +38,7 @@
|
|||
<Action
|
||||
v-else-if="current === 2"
|
||||
:name="name"
|
||||
:branchGroup="branchGroup"
|
||||
:branchesName="branchesName"
|
||||
:thenName="thenName"
|
||||
:values="DeviceModel"
|
||||
ref="actionRef"
|
||||
|
@ -91,7 +91,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
branchGroup: {
|
||||
branchesName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
@ -132,18 +132,18 @@ const onCancel = () => {
|
|||
|
||||
const onSave = (_data: any) => {
|
||||
const item: any = {
|
||||
selector: DeviceModel.selector,
|
||||
source: DeviceModel.source,
|
||||
selectorValues: DeviceModel.selectorValues,
|
||||
productId: DeviceModel.productId,
|
||||
message: _data.message,
|
||||
selector: DeviceModel.selector,
|
||||
source: DeviceModel.source,
|
||||
selectorValues: DeviceModel.selectorValues,
|
||||
productId: DeviceModel.productId,
|
||||
message: _data.message,
|
||||
};
|
||||
//处理按变量
|
||||
if (DeviceModel.selector === 'variable') {
|
||||
item.selector = 'fixed';
|
||||
item.selector = 'fixed';
|
||||
}
|
||||
if (DeviceModel.selector === 'relation') {
|
||||
item.upperKey = 'scene.deviceId';
|
||||
item.upperKey = 'scene.deviceId';
|
||||
}
|
||||
const _options: any = {
|
||||
name: '-', //设备名称
|
||||
|
@ -158,7 +158,8 @@ const onSave = (_data: any) => {
|
|||
columns: [],
|
||||
otherColumns: [],
|
||||
};
|
||||
_options.name = DeviceModel.deviceDetail?.name || DeviceModel.selectorValues?.[0]?.name;
|
||||
_options.name =
|
||||
DeviceModel.deviceDetail?.name || DeviceModel.selectorValues?.[0]?.name;
|
||||
const _type = _data.message.messageType;
|
||||
if (_type === 'INVOKE_FUNCTION') {
|
||||
_options.type = '执行';
|
||||
|
@ -183,7 +184,14 @@ const onSave = (_data: any) => {
|
|||
}
|
||||
}
|
||||
if (_options.selector === 'tag') {
|
||||
_options.tagList = DeviceModel.tagList.map((it) => ({
|
||||
// const arr = _data.map((item: any) => {
|
||||
// return {
|
||||
// column: item.name,
|
||||
// type: item.type,
|
||||
// value: item.value,
|
||||
// };
|
||||
// });
|
||||
_options.taglist = DeviceModel.tagList.map((it) => ({
|
||||
name: it.column || it.name,
|
||||
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
|
||||
value: it.value,
|
||||
|
@ -205,10 +213,8 @@ const save = async (step?: number) => {
|
|||
if (deviceRef.value) {
|
||||
await deviceRef.value?.onFormSave();
|
||||
current.value = 2;
|
||||
} else {
|
||||
if(DeviceModel.selector === 'fixed' && DeviceModel.selectorValues?.length){
|
||||
current.value = 2;
|
||||
}
|
||||
} else if (DeviceModel.selectorValues.length) {
|
||||
current.value = 2;
|
||||
}
|
||||
} else {
|
||||
if (actionRef.value) {
|
||||
|
@ -233,7 +239,7 @@ const prev = () => {
|
|||
const saveClick = () => save();
|
||||
|
||||
const onDeviceSave = (_data: any, _detail: any, obj?: any) => {
|
||||
Object.assign(DeviceModel, {..._data, ...obj});
|
||||
Object.assign(DeviceModel, { ..._data, ...obj });
|
||||
DeviceModel.deviceDetail = _detail;
|
||||
};
|
||||
|
||||
|
@ -245,6 +251,28 @@ watch(
|
|||
detail(newValue.productId).then((resp) => {
|
||||
if (resp.status === 200) {
|
||||
DeviceModel.productDetail = resp.result;
|
||||
if (
|
||||
DeviceModel.selector === 'tag' &&
|
||||
DeviceModel.selectorValues[0]?.value
|
||||
) {
|
||||
const metadata = JSON.parse(
|
||||
DeviceModel.productDetail?.metadata || '{}',
|
||||
);
|
||||
const tags = metadata.tags || [];
|
||||
const arr = DeviceModel.selectorValues[0]?.value
|
||||
.filter((item: any) => !!item.value)
|
||||
.map((item: any) => {
|
||||
return {
|
||||
column:
|
||||
tags.find(
|
||||
(i: any) => i.id === item.column,
|
||||
)?.name || item.column,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
DeviceModel.tagList = arr;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
</j-popconfirm>
|
||||
<j-form-item
|
||||
v-for='(item, index) in termsOptions'
|
||||
:key='item.key'
|
||||
:name='["branches", branchName, "then", thenName, "actions", actionName, "terms", name, "terms", index]'
|
||||
:rules='rules'
|
||||
>
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
v-if="data?.executor === 'alarm'"
|
||||
>
|
||||
<template v-if="data?.alarm?.mode === 'trigger'">
|
||||
满足条件后将触发<j-button style="padding: 0;"
|
||||
满足条件后将触发<j-button
|
||||
style="padding: 0"
|
||||
type="link"
|
||||
@click.stop="triggerVisible = true"
|
||||
>关联此场景的告警</j-button
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
满足条件后将解除<j-button style="padding: 0;"
|
||||
满足条件后将解除<j-button
|
||||
style="padding: 0"
|
||||
type="link"
|
||||
@click.stop="triggerVisible = true"
|
||||
>关联此场景的告警</j-button
|
||||
|
@ -278,10 +280,16 @@
|
|||
/>
|
||||
{{ data?.options?.type }}
|
||||
<span
|
||||
v-for="i in data?.options?.taglist || []"
|
||||
v-for="(i, _index) in data?.options?.taglist ||
|
||||
[]"
|
||||
:key="i.value"
|
||||
>
|
||||
{{ i.type }}
|
||||
{{
|
||||
_index !== 0 &&
|
||||
_index !==
|
||||
(data?.options?.taglist || []).length &&
|
||||
i.type
|
||||
}}
|
||||
{{ i.name }}为{{ i.value }}
|
||||
</span>
|
||||
的{{ data?.options?.productName }}
|
||||
|
@ -318,27 +326,33 @@
|
|||
</j-popconfirm>
|
||||
</div>
|
||||
<template v-if="!isLast && type === 'serial'">
|
||||
<div :class='["actions-item-filter-warp", termsOptions.length ? "filter-border" : ""]'>
|
||||
<template v-if='termsOptions.length'>
|
||||
<div class='actions-item-filter-warp-tip'>
|
||||
满足此条件后执行后续动作
|
||||
<div
|
||||
:class="[
|
||||
'actions-item-filter-warp',
|
||||
termsOptions.length ? 'filter-border' : '',
|
||||
]"
|
||||
>
|
||||
<template v-if="termsOptions.length">
|
||||
<div class="actions-item-filter-warp-tip">
|
||||
满足此条件后执行后续动作
|
||||
</div>
|
||||
<div class="actions-item-filter-overflow">
|
||||
<FilterGroup
|
||||
v-for="(item, index) in termsOptions"
|
||||
:key="item.key"
|
||||
:branchName="branchesName"
|
||||
:thenName="thenName"
|
||||
:actionName="name"
|
||||
:name="index"
|
||||
:isLast="index === termsOptions.length - 1"
|
||||
:isFirst="index === 0"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="filter-add-button">
|
||||
<AIcon type="PlusOutlined" style="padding-right: 4px" />
|
||||
<span>添加过滤条件</span>
|
||||
</div>
|
||||
<div class='actions-item-filter-overflow'>
|
||||
<FilterGroup
|
||||
v-for='(item, index) in termsOptions'
|
||||
:branchName='branchesName'
|
||||
:thenName='thenName'
|
||||
:actionName='name'
|
||||
:name='index'
|
||||
:isLast='index === termsOptions.length - 1'
|
||||
:isFirst='index === 0'
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class='filter-add-button'>
|
||||
<AIcon type='PlusOutlined' style='padding-right: 4px;' />
|
||||
<span>添加过滤条件</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 编辑 -->
|
||||
|
@ -378,8 +392,8 @@ import ActionTypeComponent from '../Modal/ActionTypeComponent.vue';
|
|||
import TriggerAlarm from '../TriggerAlarm/index.vue';
|
||||
import { useSceneStore } from '@/store/scene';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { iconMap, itemNotifyIconMap, typeIconMap } from './util'
|
||||
import FilterGroup from './FilterGroup.vue'
|
||||
import { iconMap, itemNotifyIconMap, typeIconMap } from './util';
|
||||
import FilterGroup from './FilterGroup.vue';
|
||||
|
||||
const sceneStore = useSceneStore();
|
||||
const { data: _data } = storeToRefs(sceneStore);
|
||||
|
@ -390,8 +404,8 @@ const props = defineProps({
|
|||
default: 0,
|
||||
},
|
||||
thenName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
name: {
|
||||
type: Number,
|
||||
|
@ -421,11 +435,15 @@ const triggerVisible = ref<boolean>(false);
|
|||
const actionType = ref('');
|
||||
|
||||
const termsOptions = computed(() => {
|
||||
if (!props.parallel) { // 串行
|
||||
return _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name].terms || []
|
||||
}
|
||||
return []
|
||||
})
|
||||
if (!props.parallel) {
|
||||
// 串行
|
||||
return (
|
||||
_data.value.branches![props.branchesName].then?.[props.thenName]
|
||||
.actions?.[props.name].terms || []
|
||||
);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
const onDelete = () => {
|
||||
emit('delete');
|
||||
|
@ -463,12 +481,14 @@ const onPropsCancel = () => {
|
|||
actionType.value = '';
|
||||
};
|
||||
|
||||
watch(() => props.data, () => {
|
||||
if (props.data) {
|
||||
|
||||
}
|
||||
}, { immediate: true, deep: true})
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
() => {
|
||||
if (props.data) {
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
@ -589,16 +609,16 @@ watch(() => props.data, () => {
|
|||
}
|
||||
|
||||
.actions-item-filter-warp-tip {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 16px;
|
||||
z-index: 2;
|
||||
color: rgba(0, 0, 0, 0.55);
|
||||
font-weight: 800;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
background-color: #fff;
|
||||
transform: translateY(-50%);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 16px;
|
||||
z-index: 2;
|
||||
color: rgba(0, 0, 0, 0.55);
|
||||
font-weight: 800;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
background-color: #fff;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.actions-item-filter-overflow {
|
||||
|
@ -609,11 +629,11 @@ watch(() => props.data, () => {
|
|||
row-gap: 16px;
|
||||
}
|
||||
|
||||
.filter-add-button{
|
||||
width: 100%;
|
||||
color: rgba(0, 0, 0, 0.3);
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
.filter-add-button {
|
||||
width: 100%;
|
||||
color: rgba(0, 0, 0, 0.3);
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.terms-params {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<template v-if="actionType === 'device'">
|
||||
<Device v-bind="props" :value="data?.device" @cancel="onCancel" @save="onPropsOk" :thenName="branchesName" />
|
||||
<Device v-bind="props" :value="data?.device" @cancel="onCancel" @save="onPropsOk" />
|
||||
</template>
|
||||
<template v-else-if="actionType === 'notify'">
|
||||
<Notify :options="data?.options" :value="data?.notify" @cancel="onCancel" @save="onPropsOk" />
|
||||
|
@ -24,7 +24,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
branchGroup: {
|
||||
thenName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
|
|
@ -47,7 +47,7 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
branchGroup: {
|
||||
thenName: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
|
|
@ -279,7 +279,6 @@ const onChange = (
|
|||
} else {
|
||||
_values = getObj(_source, _value, isRelation);
|
||||
}
|
||||
console.log(_values, '_values')
|
||||
emit('update:value', _values);
|
||||
emit('change', { sendTo: _names.filter((item) => !!item).join(',') });
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue