Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev

This commit is contained in:
jackhoo_98 2023-03-29 19:16:08 +08:00
commit 18abd85100
18 changed files with 153 additions and 51 deletions

View File

@ -87,7 +87,7 @@ export default {
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: false, granted: false },
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
@ -149,7 +149,7 @@ export default {
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: false, granted: false },
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
@ -194,7 +194,25 @@ export default {
granted: true,
},
],
assetAccesses: [],
assetAccesses: [{
supportId: 'ignore',
name: '全部数据',
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
enabled: false,
granted: false,
},
{
supportId: 'org-include-children',
name: '所在组织及下级组织',
enabled: false,
granted: false,
},],
options: { switch: true },
createTime: 1659344075524,
granted: true,
@ -541,7 +559,7 @@ export default {
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: false, granted: false },
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
@ -603,7 +621,7 @@ export default {
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: false, granted: false },
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
@ -648,7 +666,25 @@ export default {
granted: true,
},
],
assetAccesses: [],
assetAccesses: [{
supportId: 'ignore',
name: '全部数据',
enabled: false,
granted: false,
},
{ supportId: 'creator', name: '自己创建的', enabled: true, granted: true },
{
supportId: 'org',
name: '所在组织',
enabled: false,
granted: false,
},
{
supportId: 'org-include-children',
name: '所在组织及下级组织',
enabled: false,
granted: false,
}],
options: { switch: true },
createTime: 1659344075524,
granted: true,

View File

@ -73,15 +73,21 @@
style="margin-top: 50px"
>
<template #description>
暂无数据请先
<PermissionButton
type="link"
style="padding: 0"
hasPermission="link/AccessConfig:add"
@click="handleAdd"
<template v-if="!isPermission"
>暂无权限, 请联系管理员</template
>
添加{{ providerType[props.channel] }}接入网关
</PermissionButton>
<template v-else>
暂无数据请先
<j-button
type="link"
style="padding: 0"
@click="handleAdd"
>
添加{{
providerType[props.channel]
}}接入网关
</j-button>
</template>
</template>
</j-empty>
<div
@ -166,9 +172,11 @@ import DeviceApi from '@/api/media/device';
import { getImage } from '@/utils/comm';
import { gatewayType } from '@/views/media/Device/typings';
import { providerType } from '../const';
import { useMenuStore } from '@/store/menu';
import { usePermissionStore } from '@/store/permission';
const menuStory = useMenuStore();
const isPermission = usePermissionStore().hasPermission(
'link/AccessConfig:add',
);
type Emits = {
(e: 'update:visible', data: boolean): void;

View File

@ -1,6 +1,5 @@
<template>
<ParamsDropdown
placeholder="请选择"
:options="handleOptions"
:tabsOptions="tabOptions"
:metricOptions="upperOptions"
@ -10,7 +9,7 @@
valueName="id"
>
<template v-slot="{ label }">
<j-input :value="label" readonly />
<j-input :value="label" readonly placeholder="请选择" />
</template>
</ParamsDropdown>
</template>

View File

@ -58,7 +58,7 @@
@change="propertySelect"
>
<j-select-option
v-for="item in metadata?.properties.filter((i) =>
v-for="item in (metadata?.properties || []).filter((i) =>
i?.expands?.type?.includes('read'),
) || []"
:value="item?.id"

View File

@ -171,15 +171,12 @@ const handleClick = (_detail: any) => {
}
};
watch(() => props.value?.[0]?.value, (newVal) => {
if(newVal){
detail(newVal).then(resp => {
onMounted(() => {
if(props.value?.[0]?.value){
detail(props.value?.[0]?.value).then(resp => {
emit('change', resp.result);
})
}
}, {
deep: true,
immediate: true
})
watchEffect(() => {

View File

@ -113,9 +113,10 @@ const deleteItem = (_index: number) => {
};
const onTypeSelect = (key: any, _index: number) => {
const indexItem = tagList[_index];
const indexItem = tagList.value[_index];
indexItem.type = key;
tagList.value[_index] = indexItem;
onValueChange()
};
const onTagSelect = (_data: any, _index: number) => {
@ -127,6 +128,7 @@ const onTagSelect = (_data: any, _index: number) => {
handleItem({ ..._data, value: undefined, type: indexType }),
);
tagList.value = newList;
onValueChange()
};
watch(
@ -173,13 +175,29 @@ const onValueChange = () => {
const newValue = _data.map((item: any) => {
return {
column: item.id,
type: item?.valueType,
type: item?.type,
value: item?.value,
};
});
emits('update:value', [{ value: newValue, name: '标签' }]);
emits('change', [{ value: newValue, name: '标签' }], _data);
};
onMounted(() => {
if(props.value?.[0]?.value){
const arr: any[] = []
props.value?.[0]?.value.map((item: any) => {
const _item = props.tagData.find(i => i.id === item.column)
if(_item){
arr.push({
..._item,
...item,
})
}
})
emits('change', props.value, arr);
}
})
</script>
<style lang="less" scoped>

View File

@ -31,7 +31,7 @@
/>
</j-form-item>
<j-form-item
v-else-if="modelRef.selector === 'tag'"
v-else-if="modelRef.selector === 'tag' && isTags"
name="selectorValues"
:rules="[{ required: true, message: '请选择标签' }]"
>
@ -80,6 +80,7 @@ import Tag from './Tag.vue';
import RelationSelect from './RelationSelect.vue';
import { getParams } from '../../../util';
import { handleParamsData } from '../../../components/Terms/util';
import _ from 'lodash';
const props = defineProps({
values: {
@ -107,6 +108,11 @@ const props = defineProps({
},
});
// option
const isTags = computed(() => {
return _.map(list.value, 'value').includes('tag');
});
// savedeviceDetail
const emits = defineEmits(['save', 'cancel']);
@ -281,16 +287,10 @@ const onTagChange = (val: any[], arr: any[]) => {
modelRef.source = 'fixed';
}
const tagName = arr.map((i, _index) => {
return `${_index !== 0 && _index !== (arr || []).length && i.type}${
i.name
}为${i.value}`;
const _type = (_index !== 0 && _index !== (arr || []).length && i.type) ? (i.type === 'and' ? '并且' : '或者') : '';
return `${_type}${i.name}${i.value}`;
});
emits(
'save',
unref(modelRef),
{},
arr ? { tagName: tagName.join('') } : {},
);
emits('save', unref(modelRef), { tagName: tagName.join('') });
};
const onVariableChange = (val: any, node: any) => {
@ -314,7 +314,7 @@ watch(
() => props.productDetail,
async (newVal) => {
await sourceChangeEvent();
if (newVal) {
if (newVal?.id) {
filterType(newVal);
}
},

View File

@ -69,10 +69,10 @@ import Product from './Product.vue';
import Device from './device/index.vue';
import Action from './actions/index.vue';
import { onlyMessage } from '@/utils/comm';
import { detail } from '@/api/device/product';
import { useSceneStore } from '@/store/scene';
import { storeToRefs } from 'pinia';
import { isActionChange } from '../../util';
const sceneStore = useSceneStore();
const { data } = storeToRefs(sceneStore);
@ -174,11 +174,17 @@ const onSave = (_data: any) => {
const onProductChange = (_val: any, bol: boolean) => {
if (!bol) {
DeviceModel.selectorValues = undefined;
DeviceModel.message = {
messageType: 'INVOKE_FUNCTION',
};
const flag = isActionChange(
JSON.parse(_val.metadata || '{}'),
DeviceModel?.message,
);
if (!flag) {
DeviceModel.message = {
messageType: 'INVOKE_FUNCTION',
};
}
}
productDetail.value = _val
productDetail.value = _val;
DeviceOptions.value.productName = _val?.name;
};

View File

@ -12,7 +12,8 @@ type DeviceModelType = {
message: {
properties?: any;
messageType: string;
inputs?: any[]
inputs?: any[];
functionId?: string;
}
}

View File

@ -16,6 +16,7 @@
}"
:params="params"
:gridColumn="2"
:noPagination="true"
:rowSelection="{
selectedRowKeys: _selectedRowKeys,
onChange: onSelectChange,

View File

@ -52,6 +52,7 @@
/>
</j-form-item>
</j-form>
<j-empty v-else style="margin: 20px 0" description="暂无模板变量" />
</template>
<script lang="ts" setup>

View File

@ -203,11 +203,11 @@ const onCancel = () => {
emit('cancel');
};
const onOk = async () => {
let _data = undefined
let _data = null
if(variable.value.length){
_data = await variableRef.value.onSave()
}
formModel.variables = _data || [];
formModel.variables = _data;
const { options, ...extra } = formModel;
emit('save', { ...extra }, { ...options });
};

View File

@ -66,7 +66,9 @@ const save = async () => {
if (formData) {
loading.value = true
const branches = data.value.branches?.filter(item => item)
const resp = await modify(data.value.id!, { ...data.value, branches }).then(res => res)
const resp: any = await modify(data.value.id!, { ...data.value, branches }).then(res => res).catch(() => {
loading.value = false
})
loading.value = false
if (resp.success) {
menuStore.jumpPage('rule-engine/Scene')

View File

@ -121,3 +121,33 @@ export const EventEmitter = {
return this
}
}
export const isActionChange = (_metadata: any, _message: any) => {
const _properties = _metadata?.properties || [];
const _functions = _metadata?.functions || [];
if (
_message?.messageType === 'READ_PROPERTY' &&
_message?.properties?.[0]
) {
const _item = _properties.find(
(i: any) => i.id === _message?.properties?.[0],
);
return _item?.id;
} else if (
_message?.messageType === 'INVOKE_FUNCTION' &&
_message?.functionId
) {
const _item = _functions.find(
(i: any) => i.id === _message?.functionId,
);
return _item?.id;
} else if (_message?.messageType === 'WRITE_PROPERTY') {
const _data = Object.keys(_message?.properties)?.[0]
if (_data) {
const _item = _functions.find((i: any) => i.id === _data);
return _item?.id;
}
return false;
}
return false;
};

View File

@ -27,6 +27,7 @@
</div>
<pro-search
type="simple"
:columns="props.queryColumns"
target="category"
@search="(params:any)=>queryParams = {...params}"

View File

@ -240,6 +240,7 @@ const columns = [
ellipsis: true,
search: {
type: 'string',
first: true,
},
},
{

View File

@ -188,6 +188,7 @@
v-model:value="form.data.assetType"
style="width: 500px"
placeholder="请选择资产类型"
show-search
>
<j-select-option
v-for="item in form.assetsType"
@ -235,7 +236,9 @@
<PermissionButton
type="primary"
:hasPermission="`${permission}:update`"
:hasPermission="`${permission}:${
route.params.id === ':id' ? 'add' : 'update'
}`"
@click="form.clickSave"
>
保存
@ -405,8 +408,6 @@ type assetType = {
label: string;
value: string;
};
</script>
<style lang="less" scoped>

View File

@ -88,7 +88,7 @@ const form = reactive({
console.log(form.menus);
Promise.all([updateRole, updateTree]).then((resp) => {
message.success('操作成功');
jumpPage(`system/Role`);
// jumpPage(`system/Role`);
});
});
},