fix: 修改bug
This commit is contained in:
parent
5998fe7409
commit
135f1626f7
|
@ -20,6 +20,7 @@
|
|||
<template v-for="i in list" :key="i.id">
|
||||
<NoticeItem
|
||||
:data="i"
|
||||
:type="item.key"
|
||||
@action="emits('action')"
|
||||
@refresh="onRefresh(item.key)"
|
||||
/>
|
||||
|
|
|
@ -55,6 +55,10 @@ const props = defineProps({
|
|||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: "alarm"
|
||||
}
|
||||
});
|
||||
|
||||
const num = ref<-100 | 0>(0);
|
||||
|
@ -74,10 +78,14 @@ const detail = () => {
|
|||
if (route.path === '/account/center') {
|
||||
userInfo.tabKey = 'StationMessage';
|
||||
userInfo.messageInfo = props.data;
|
||||
userInfo.other.tabKey = props.type;
|
||||
} else {
|
||||
menuStory.routerPush('account/center', {
|
||||
row: props.data,
|
||||
tabKey: 'StationMessage',
|
||||
other: {
|
||||
tabKey: props.type
|
||||
}
|
||||
});
|
||||
}
|
||||
emits('action');
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="left-content">
|
||||
<TitleComponent data="基本信息" />
|
||||
<j-alert
|
||||
v-if="_error && modelRef?.id"
|
||||
v-if="!!_error && modelRef?.id && productPermission()"
|
||||
style="margin: 10px 0"
|
||||
type="warning"
|
||||
>
|
||||
|
@ -26,14 +26,16 @@
|
|||
"
|
||||
>{{ _error }}</span
|
||||
>
|
||||
<j-popconfirm
|
||||
title="确认启用"
|
||||
@confirm="onActiveProduct"
|
||||
<PermissionButton
|
||||
:popConfirm="{
|
||||
title: '确认启用',
|
||||
onConfirm: onActiveProduct,
|
||||
}"
|
||||
size="small"
|
||||
:hasPermission="'device/Product:action'"
|
||||
>
|
||||
<j-button size="small"
|
||||
>立即启用</j-button
|
||||
>
|
||||
</j-popconfirm>
|
||||
立即启用
|
||||
</PermissionButton>
|
||||
</div>
|
||||
</template>
|
||||
</j-alert>
|
||||
|
@ -275,7 +277,6 @@
|
|||
v-if="modelRef.mappings.length"
|
||||
:activeKey="activeKey"
|
||||
@change="onCollChange"
|
||||
|
||||
>
|
||||
<j-collapse-panel
|
||||
v-for="(
|
||||
|
@ -398,6 +399,9 @@
|
|||
'',
|
||||
)
|
||||
"
|
||||
@error="
|
||||
onPlatError
|
||||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
</j-col>
|
||||
|
@ -481,13 +485,16 @@ import _ from 'lodash';
|
|||
import { onlyMessage } from '@/utils/comm';
|
||||
import MSelect from '../../components/MSelect/index.vue';
|
||||
import { _deploy } from '@/api/device/product';
|
||||
import { usePermissionStore } from '@/store/permission';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const _error = ref<string>('');
|
||||
const _set = new Set()
|
||||
const _errorSet = ref<Set<string>>(new Set());
|
||||
|
||||
const hasPermission = usePermissionStore().hasPermission;
|
||||
const productPermission = () => hasPermission(`device/Product:action`);
|
||||
|
||||
const modelRef = reactive({
|
||||
id: undefined,
|
||||
|
@ -587,33 +594,34 @@ const onCollChange = (_key: string[]) => {
|
|||
activeKey.value = _key;
|
||||
};
|
||||
|
||||
const onActiveProduct = () => {
|
||||
const arr = [..._set].map(async (i: any) => {
|
||||
return await _deploy(i)
|
||||
})
|
||||
Promise.all(arr).then((res) => {
|
||||
if(res.map(i => i?.status === 200).length === _set.size) {
|
||||
onlyMessage('操作成功!')
|
||||
_error.value = ''
|
||||
const _error = computed(() => {
|
||||
return _errorSet.value.size ? `当前选择的部分产品为禁用状态` : ''
|
||||
})
|
||||
|
||||
const onActiveProduct = async () => {
|
||||
[..._errorSet.value.values()].forEach(async (i: any) => {
|
||||
const resp = await _deploy(i).catch((error) => {
|
||||
onlyMessage('操作失败', 'error');
|
||||
});
|
||||
if(resp?.status === 200) {
|
||||
_errorSet.value.delete(i)
|
||||
onlyMessage('操作成功!');
|
||||
}
|
||||
_set.clear()
|
||||
}).catch((error) => {
|
||||
onlyMessage('操作失败', 'error')
|
||||
})
|
||||
});
|
||||
await getProduct();
|
||||
};
|
||||
|
||||
const onPlatError = (val: any) => {
|
||||
const _item = productList.value.find((item) => item.id === val);
|
||||
if (val && _item && !_item?.state) {
|
||||
_errorSet.value.add(val)
|
||||
}
|
||||
};
|
||||
const _validator = (_rule: any, value: string): Promise<any> =>
|
||||
new Promise((resolve, reject) => {
|
||||
const _item = productList.value.find((item) => item.id === value);
|
||||
if (!_item) {
|
||||
return reject('关联产品已被删除,请重新选择');
|
||||
} else {
|
||||
if (!_item?.state) {
|
||||
_set.add(value)
|
||||
_error.value = `当前选择的部分产品为禁用状态`;
|
||||
} else {
|
||||
_error.value = '';
|
||||
}
|
||||
}
|
||||
return resolve('');
|
||||
});
|
||||
|
@ -661,7 +669,9 @@ watch(
|
|||
getAliyunProduct(_data?.accessConfig);
|
||||
}
|
||||
Object.assign(modelRef, _data);
|
||||
activeKey.value = (_data?.mappings || []).map((_: any, index: number) => index)
|
||||
activeKey.value = (_data?.mappings || []).map(
|
||||
(_: any, index: number) => index,
|
||||
);
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="left-content">
|
||||
<TitleComponent data="基本信息" />
|
||||
<j-alert
|
||||
v-if="_error && modelRef?.id"
|
||||
v-if="_error && modelRef?.id && productPermission()"
|
||||
style="margin: 10px 0"
|
||||
type="warning"
|
||||
>
|
||||
|
@ -26,14 +26,16 @@
|
|||
"
|
||||
>{{ _error }}</span
|
||||
>
|
||||
<j-popconfirm
|
||||
title="确认启用"
|
||||
@confirm="onActiveProduct"
|
||||
<PermissionButton
|
||||
:popConfirm="{
|
||||
title: '确认启用',
|
||||
onConfirm: onActiveProduct,
|
||||
}"
|
||||
size="small"
|
||||
:hasPermission="'device/Product:action'"
|
||||
>
|
||||
<j-button size="small"
|
||||
>立即启用</j-button
|
||||
>
|
||||
</j-popconfirm>
|
||||
立即启用
|
||||
</PermissionButton>
|
||||
</div>
|
||||
</template>
|
||||
</j-alert>
|
||||
|
@ -461,7 +463,9 @@
|
|||
"
|
||||
type="target"
|
||||
:options="
|
||||
getProductProperties(item.target)
|
||||
getProductProperties(
|
||||
item.target,
|
||||
)
|
||||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
|
@ -547,12 +551,16 @@ import { useMenuStore } from '@/store/menu';
|
|||
import { onlyMessage } from '@/utils/comm';
|
||||
import MSelect from '../../components/MSelect/index.vue';
|
||||
import { _deploy } from '@/api/device/product';
|
||||
import { usePermissionStore } from '@/store/permission';
|
||||
|
||||
const menuStory = useMenuStore();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
|
||||
const hasPermission = usePermissionStore().hasPermission;
|
||||
const productPermission = () => hasPermission(`device/Product:action`);
|
||||
|
||||
const modelRef = reactive({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
|
|
|
@ -39,7 +39,7 @@ const props = defineProps({
|
|||
}
|
||||
})
|
||||
|
||||
const emits = defineEmits(['update:value', 'change']);
|
||||
const emits = defineEmits(['update:value', 'change', 'error']);
|
||||
|
||||
const formItemContext = Form.useInjectFormItemContext()
|
||||
|
||||
|
@ -65,6 +65,7 @@ watchEffect(() => {
|
|||
if(props.value){
|
||||
formTouchOff()
|
||||
}
|
||||
emits('error', props.value)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -86,7 +86,9 @@
|
|||
"
|
||||
:class="valueClass"
|
||||
>
|
||||
{{ JSON.stringify(value?.formatValue) }}
|
||||
<div style='width: 100%; white-space: normal;'>
|
||||
<j-ellipsis>{{ JSON.stringify(value?.formatValue) }}</j-ellipsis>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else :class="valueClass">
|
||||
<div style='width: 100%;white-space: normal;'>
|
||||
|
|
|
@ -8,32 +8,37 @@
|
|||
:disabled="disabled"
|
||||
>
|
||||
</j-select>
|
||||
<j-popconfirm-modal
|
||||
v-if="myValue != 'manual'"
|
||||
@confirm="confirm"
|
||||
:bodyStyle="{width: '450px', height: myValue === 'rule' ? '300px' : '80px'}"
|
||||
>
|
||||
<template #content>
|
||||
<j-scrollbar v-if="myValue">
|
||||
<VirtualRule
|
||||
:value="value"
|
||||
:source="myValue"
|
||||
:dataSource="dataSource"
|
||||
ref="virtualRuleRef"
|
||||
/>
|
||||
</j-scrollbar>
|
||||
</template>
|
||||
<j-button :disabled="!myValue" type="link" style="padding: 4px 8px">
|
||||
<AIcon type="EditOutlined" />
|
||||
</j-button>
|
||||
</j-popconfirm-modal>
|
||||
<j-popconfirm-modal
|
||||
v-if="myValue != 'manual'"
|
||||
@confirm="confirm"
|
||||
:bodyStyle="{
|
||||
width: '450px',
|
||||
height: myValue === 'rule' ? '300px' : '80px',
|
||||
}"
|
||||
>
|
||||
<template #content>
|
||||
<j-scrollbar v-if="myValue">
|
||||
<div style="padding: 0 10px">
|
||||
<VirtualRule
|
||||
:value="value"
|
||||
:source="myValue"
|
||||
:dataSource="dataSource"
|
||||
ref="virtualRuleRef"
|
||||
/>
|
||||
</div>
|
||||
</j-scrollbar>
|
||||
</template>
|
||||
<j-button :disabled="!myValue" type="link" style="padding: 4px 8px">
|
||||
<AIcon type="EditOutlined" />
|
||||
</j-button>
|
||||
</j-popconfirm-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="MetadataSource">
|
||||
import { isNoCommunity } from '@/utils/utils';
|
||||
import VirtualRule from './VirtualRule/index.vue';
|
||||
import { Form } from 'jetlinks-ui-components'
|
||||
import { Form } from 'jetlinks-ui-components';
|
||||
|
||||
const PropertySource: { label: string; value: string }[] = isNoCommunity
|
||||
? [
|
||||
|
@ -82,8 +87,8 @@ const props = defineProps({
|
|||
},
|
||||
target: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
default: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits<Emit>();
|
||||
|
@ -94,34 +99,30 @@ const type = ref<string>('');
|
|||
const virtualRuleRef = ref<any>(null);
|
||||
|
||||
const disabled = computed(() => {
|
||||
|
||||
if (props.target === 'device') {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
return props.noEdit?.length ? props.noEdit.includes(props.value._sortIndex) : false
|
||||
})
|
||||
return props.noEdit?.length
|
||||
? props.noEdit.includes(props.value._sortIndex)
|
||||
: false;
|
||||
});
|
||||
|
||||
const updateValue = (data: any) => {
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
expands: {
|
||||
...(props.value?.expands || {}),
|
||||
...data
|
||||
}
|
||||
})
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
expands: {
|
||||
...(props.value?.expands || {}),
|
||||
...data,
|
||||
},
|
||||
});
|
||||
formItemContext.onFieldChange();
|
||||
};
|
||||
|
||||
const onChange = (keys: SourceType) => {
|
||||
myValue.value = keys;
|
||||
updateValue({
|
||||
source: keys,
|
||||
type:
|
||||
keys === 'manual'
|
||||
? ['write']
|
||||
: keys === 'rule'
|
||||
? ['report']
|
||||
: [],
|
||||
updateValue({
|
||||
source: keys,
|
||||
type: keys === 'manual' ? ['write'] : keys === 'rule' ? ['report'] : [],
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -131,13 +132,13 @@ const confirm = async () => {
|
|||
reject();
|
||||
});
|
||||
if (data) {
|
||||
updateValue({
|
||||
source: myValue.value,
|
||||
...data
|
||||
});
|
||||
updateValue({
|
||||
source: myValue.value,
|
||||
...data,
|
||||
});
|
||||
resolve(true);
|
||||
} else {
|
||||
reject()
|
||||
reject();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -98,7 +98,7 @@ watchEffect(() => {
|
|||
});
|
||||
|
||||
watchEffect(() => {
|
||||
if(props?.template?.template?.sendTo) {
|
||||
if(props?.template?.template?.sendTo && Array.isArray(props?.template?.template?.sendTo) && props?.template?.template?.sendTo?.length) {
|
||||
emit('change', { sendTo: props?.template?.template?.sendTo?.join(' ') });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -154,6 +154,7 @@ const onValChange = (val: any, type: string) => {
|
|||
} else if (type === 'templateId') {
|
||||
formModel.variables = [];
|
||||
}
|
||||
console.log(val)
|
||||
formModel.options = {
|
||||
...unref(formModel.options),
|
||||
...val,
|
||||
|
|
Loading…
Reference in New Issue