fix: 修改bug
This commit is contained in:
parent
f7eef5e61a
commit
9b465d8271
|
@ -6,6 +6,37 @@
|
|||
<div class="left">
|
||||
<div class="left-content">
|
||||
<TitleComponent data="基本信息" />
|
||||
<j-alert
|
||||
v-if="_error && modelRef?.id"
|
||||
style="margin: 10px 0"
|
||||
type="warning"
|
||||
>
|
||||
<template #message>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
<span
|
||||
style="
|
||||
width: calc(100% - 100px);
|
||||
text-align: center;
|
||||
"
|
||||
>{{ _error }}</span
|
||||
>
|
||||
<j-popconfirm
|
||||
title="确认启用"
|
||||
@confirm="onActiveProduct"
|
||||
>
|
||||
<j-button size="small"
|
||||
>立即启用</j-button
|
||||
>
|
||||
</j-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</j-alert>
|
||||
<j-form
|
||||
:layout="'vertical'"
|
||||
ref="formRef"
|
||||
|
@ -244,12 +275,14 @@
|
|||
v-if="modelRef.mappings.length"
|
||||
:activeKey="activeKey"
|
||||
@change="onCollChange"
|
||||
|
||||
>
|
||||
<j-collapse-panel
|
||||
v-for="(
|
||||
item, index
|
||||
) in modelRef.mappings"
|
||||
:key="index"
|
||||
:forceRender="false"
|
||||
:header="
|
||||
item.productKey
|
||||
? aliyunProductList.find(
|
||||
|
@ -317,13 +350,21 @@
|
|||
index,
|
||||
'productId',
|
||||
]"
|
||||
:rules="{
|
||||
required: true,
|
||||
message:
|
||||
'请选择平台产品',
|
||||
}"
|
||||
:rules="[
|
||||
{
|
||||
required: true,
|
||||
message:
|
||||
'请选择平台产品',
|
||||
},
|
||||
{
|
||||
validator:
|
||||
_validator,
|
||||
trigger:
|
||||
'change',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<j-select
|
||||
<!-- <j-select
|
||||
placeholder="请选择平台产品"
|
||||
v-model:value="
|
||||
item.productId
|
||||
|
@ -346,7 +387,18 @@
|
|||
i.name
|
||||
}}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
</j-select> -->
|
||||
<MSelect
|
||||
v-model:value="
|
||||
item.productId
|
||||
"
|
||||
:options="
|
||||
getPlatProduct(
|
||||
item.productId ||
|
||||
'',
|
||||
)
|
||||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
</j-col>
|
||||
</j-row>
|
||||
|
@ -427,11 +479,15 @@ import {
|
|||
} from '@/api/northbound/alicloud';
|
||||
import _ from 'lodash';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
import MSelect from '../../components/MSelect/index.vue';
|
||||
import { _deploy } from '@/api/device/product';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const formRef = ref();
|
||||
const _error = ref<string>('');
|
||||
const _set = new Set()
|
||||
|
||||
const modelRef = reactive({
|
||||
id: undefined,
|
||||
|
@ -531,6 +587,37 @@ 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 = ''
|
||||
}
|
||||
_set.clear()
|
||||
}).catch((error) => {
|
||||
onlyMessage('操作失败', 'error')
|
||||
})
|
||||
};
|
||||
|
||||
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('');
|
||||
});
|
||||
|
||||
const saveBtn = () => {
|
||||
formRef.value
|
||||
.validate()
|
||||
|
@ -574,6 +661,7 @@ watch(
|
|||
getAliyunProduct(_data?.accessConfig);
|
||||
}
|
||||
Object.assign(modelRef, _data);
|
||||
activeKey.value = (_data?.mappings || []).map((_: any, index: number) => index)
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
|
|
|
@ -6,6 +6,37 @@
|
|||
<div class="left">
|
||||
<div class="left-content">
|
||||
<TitleComponent data="基本信息" />
|
||||
<j-alert
|
||||
v-if="_error && modelRef?.id"
|
||||
style="margin: 10px 0"
|
||||
type="warning"
|
||||
>
|
||||
<template #message>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
<span
|
||||
style="
|
||||
width: calc(100% - 100px);
|
||||
text-align: center;
|
||||
"
|
||||
>{{ _error }}</span
|
||||
>
|
||||
<j-popconfirm
|
||||
title="确认启用"
|
||||
@confirm="onActiveProduct"
|
||||
>
|
||||
<j-button size="small"
|
||||
>立即启用</j-button
|
||||
>
|
||||
</j-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</j-alert>
|
||||
<j-form
|
||||
:layout="'vertical'"
|
||||
ref="formRef"
|
||||
|
@ -42,33 +73,22 @@
|
|||
required: true,
|
||||
message: '请选择产品',
|
||||
},
|
||||
// {
|
||||
// validator: _validator,
|
||||
// trigger: 'change',
|
||||
// },
|
||||
{
|
||||
validator: _validator,
|
||||
trigger: 'change',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<j-select
|
||||
<MSelect
|
||||
v-model:value="modelRef.id"
|
||||
:options="productList"
|
||||
:disabled="
|
||||
type !== 'edit' &&
|
||||
modelRef.id &&
|
||||
modelRef.id !== ':id'
|
||||
"
|
||||
placeholder="请选择产品"
|
||||
v-model:value="modelRef.id"
|
||||
show-search
|
||||
@change="productChange"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in productList"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
:label="item.name"
|
||||
>{{
|
||||
item.name
|
||||
}}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
/>
|
||||
</j-form-item>
|
||||
</j-col>
|
||||
<j-col :span="12">
|
||||
|
@ -407,13 +427,15 @@
|
|||
index,
|
||||
'target',
|
||||
]"
|
||||
:rules="{
|
||||
required: true,
|
||||
message:
|
||||
'请选择平台属性',
|
||||
}"
|
||||
:rules="[
|
||||
{
|
||||
required: true,
|
||||
message:
|
||||
'请选择平台属性',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<j-select
|
||||
<!-- <j-select
|
||||
placeholder="请选择平台属性"
|
||||
v-model:value="
|
||||
item.target
|
||||
|
@ -432,7 +454,16 @@
|
|||
i.name
|
||||
}}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
</j-select> -->
|
||||
<MSelect
|
||||
v-model:value="
|
||||
item.target
|
||||
"
|
||||
type="target"
|
||||
:options="
|
||||
getProductProperties(item.target)
|
||||
"
|
||||
/>
|
||||
</j-form-item>
|
||||
</j-col>
|
||||
</j-row>
|
||||
|
@ -514,6 +545,8 @@ import {
|
|||
import _, { cloneDeep } from 'lodash';
|
||||
import { useMenuStore } from '@/store/menu';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
import MSelect from '../../components/MSelect/index.vue';
|
||||
import { _deploy } from '@/api/device/product';
|
||||
|
||||
const menuStory = useMenuStore();
|
||||
const route = useRoute();
|
||||
|
@ -556,6 +589,8 @@ const type = ref<'edit' | 'view'>('edit');
|
|||
const actionActiveKey = ref<string[]>(['0']);
|
||||
const propertyActiveKey = ref<string[]>(['0']);
|
||||
|
||||
const _error = ref<string>('');
|
||||
|
||||
const onPropertyCollChange = (_key: string[]) => {
|
||||
propertyActiveKey.value = _key;
|
||||
};
|
||||
|
@ -652,12 +687,20 @@ const findApplianceType = computed(() => {
|
|||
return typeList.value.find((item) => item.id === modelRef.applianceType);
|
||||
});
|
||||
|
||||
const findProductMetadata = computed(() => {
|
||||
const findProduct = computed(() => {
|
||||
if (!modelRef.id) return;
|
||||
const _product = productList.value?.find(
|
||||
(item: any) => item.id === modelRef.id,
|
||||
);
|
||||
return _product?.metadata && JSON.parse(_product.metadata || '{}');
|
||||
return _product;
|
||||
});
|
||||
|
||||
const findProductMetadata = computed(() => {
|
||||
if (!modelRef.id) return;
|
||||
return (
|
||||
findProduct.value?.metadata &&
|
||||
JSON.parse(findProduct.value?.metadata || '{}')
|
||||
);
|
||||
});
|
||||
|
||||
// 查询产品列表
|
||||
|
@ -717,18 +760,34 @@ const getTypesActions = (val: string) => {
|
|||
return list || [];
|
||||
};
|
||||
|
||||
// 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('该产品已被删除');
|
||||
// }
|
||||
// return resolve('');
|
||||
// });
|
||||
const onActiveProduct = () => {
|
||||
if (modelRef.id) {
|
||||
_deploy(modelRef.id).then((resp) => {
|
||||
if (resp.status === 200) {
|
||||
onlyMessage('操作成功!');
|
||||
getProduct(modelRef.id);
|
||||
_error.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
console.log(modelRef.id)
|
||||
})
|
||||
const _validator = (_rule: any, value: string): Promise<any> =>
|
||||
new Promise((resolve, reject) => {
|
||||
const _item = productList.value.find((item) => item.id === value);
|
||||
if (!_item) {
|
||||
productChange(value);
|
||||
return reject('关联产品已被删除,请重新选择');
|
||||
} else {
|
||||
if (!_item?.state) {
|
||||
_error.value = `当前选择的${_item.name}产品为禁用状态`;
|
||||
// return reject(`当前选择的${_item.name}产品为禁用状态`)
|
||||
} else {
|
||||
_error.value = '';
|
||||
}
|
||||
}
|
||||
return resolve('');
|
||||
});
|
||||
|
||||
const saveBtn = async () => {
|
||||
const tasks: any[] = [];
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<template>
|
||||
<j-select
|
||||
:disabled="disabled"
|
||||
placeholder="请选择"
|
||||
:value="_value"
|
||||
show-search
|
||||
@change="productChange"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in _options"
|
||||
:key="item?.id"
|
||||
:value="item.id"
|
||||
:label="item.name"
|
||||
>{{ item.name }}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PropType } from "vue";
|
||||
import { Form } from 'jetlinks-ui-components';
|
||||
|
||||
const props = defineProps({
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
options: {
|
||||
type: Array as PropType<any[]>,
|
||||
default: () => []
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'product'
|
||||
}
|
||||
})
|
||||
|
||||
const emits = defineEmits(['update:value', 'change']);
|
||||
|
||||
const formItemContext = Form.useInjectFormItemContext()
|
||||
|
||||
const _value = ref<any>(undefined)
|
||||
|
||||
const formTouchOff = () => {
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
|
||||
const _options = computed(() => {
|
||||
if(props.type === 'product') {
|
||||
return props.options.filter(i => i?.state || i.id === props.value)
|
||||
} else {
|
||||
return props.options
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
_value.value = props.value
|
||||
if(props.type !== 'product') {
|
||||
formTouchOff()
|
||||
} else {
|
||||
if(props.value){
|
||||
formTouchOff()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const productChange = (val: any) => {
|
||||
emits('update:value', val)
|
||||
emits('change', val)
|
||||
}
|
||||
</script>
|
|
@ -6,7 +6,17 @@
|
|||
@cancel="emits('update:visible', false)"
|
||||
class="view-dialog-container"
|
||||
>
|
||||
<template v-if="type === 'alarm'">
|
||||
<template v-if="['device-transparent-codec', 'system-event'].includes(data?.topicProvider)">
|
||||
<div>
|
||||
<div class="label">通知流水:</div>
|
||||
<div style="padding: 10px; background-color: #fafafa">
|
||||
<j-scrollbar height="200px">
|
||||
<JsonViewer :value="data" />
|
||||
</j-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<j-descriptions
|
||||
:column="2"
|
||||
:contentStyle="{
|
||||
|
@ -19,28 +29,28 @@
|
|||
>
|
||||
<template v-if="data?.topicProvider === 'alarm-device'">
|
||||
<j-descriptions-item label="告警设备">
|
||||
<j-ellipsis>{{ data?.targetName || ''}}</j-ellipsis>
|
||||
<j-ellipsis>{{ _data?.targetName || ''}}</j-ellipsis>
|
||||
</j-descriptions-item>
|
||||
<j-descriptions-item label="设备ID">
|
||||
<j-ellipsis>
|
||||
{{ data?.targetId || '' }}
|
||||
{{ _data?.targetId || '' }}
|
||||
</j-ellipsis>
|
||||
</j-descriptions-item>
|
||||
</template>
|
||||
<j-descriptions-item label="告警名称">
|
||||
<j-ellipsis>
|
||||
{{ data?.alarmName || data?.alarmConfigName || '' }}
|
||||
{{ _data?.alarmName || _data?.alarmConfigName || '' }}
|
||||
</j-ellipsis>
|
||||
</j-descriptions-item>
|
||||
<j-descriptions-item label="告警时间">{{
|
||||
dayjs(data?.alarmTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
dayjs(_data?.alarmTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
}}</j-descriptions-item>
|
||||
<j-descriptions-item label="告警级别">{{
|
||||
(levelList.length > 0 && getLevelLabel(data.level)) || ''
|
||||
(levelList.length > 0 && getLevelLabel(_data.level)) || ''
|
||||
}}</j-descriptions-item>
|
||||
<j-descriptions-item label="告警说明">
|
||||
<j-ellipsis>
|
||||
{{ data?.description || '' }}
|
||||
{{ _data?.description || '' }}
|
||||
</j-ellipsis>
|
||||
</j-descriptions-item>
|
||||
</j-descriptions>
|
||||
|
@ -50,22 +60,12 @@
|
|||
<j-scrollbar height="200px">
|
||||
<JsonViewer
|
||||
style="background-color: #fafafa"
|
||||
:value="JSON.parse(data?.alarmInfo || '{}')"
|
||||
:value="JSON.parse(_data?.alarmInfo || '{}')"
|
||||
/>
|
||||
</j-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div>
|
||||
<div class="label">通知流水:</div>
|
||||
<div style="padding: 10px; background-color: #fafafa">
|
||||
<j-scrollbar height="200px">
|
||||
<JsonViewer :value="data" />
|
||||
</j-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<j-button type="primary" @click="emits('update:visible', false)">确定</j-button>
|
||||
</template>
|
||||
|
@ -87,7 +87,7 @@ const props = defineProps<{
|
|||
|
||||
const levelList = ref<any[]>([]);
|
||||
|
||||
const data = computed(() => {
|
||||
const _data = computed(() => {
|
||||
if (props.data.detailJson) return JSON.parse(props.data.detailJson);
|
||||
else return props.data?.detail || props.data;
|
||||
});
|
||||
|
|
|
@ -254,6 +254,10 @@ onMounted(() => {
|
|||
view(routerParams.params?.value.row);
|
||||
}
|
||||
});
|
||||
onUnmounted(() => {
|
||||
user.messageInfo = {}
|
||||
viewVisible.value = false
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<Detail
|
||||
@unsubscribe="onUnSubscribe"
|
||||
@save="onSave"
|
||||
v-if="current?.channelProvider !== 'inside-mail'"
|
||||
v-if="current?.channelProvider !== 'inside-mail' && popoverVisible"
|
||||
:current="current"
|
||||
:data="props.data"
|
||||
@close="popoverVisible = false"
|
||||
|
|
|
@ -110,16 +110,20 @@ const handleSearch = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.current,
|
||||
() => {
|
||||
handleSearch();
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
onMounted(() => {
|
||||
handleSearch()
|
||||
})
|
||||
|
||||
// watch(
|
||||
// () => props.current,
|
||||
// () => {
|
||||
// handleSearch();
|
||||
// },
|
||||
// {
|
||||
// immediate: true,
|
||||
// deep: true,
|
||||
// },
|
||||
// );
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
:request="query"
|
||||
:params="_params"
|
||||
:bodyStyle="{ padding: '0 0 0 20px' }"
|
||||
:scroll="{y : 400}"
|
||||
:scroll="{y : 450}"
|
||||
>
|
||||
<template #headerTitle>
|
||||
<j-input-search
|
||||
|
|
|
@ -106,6 +106,7 @@ const functionData = computed(() => {
|
|||
format: datum.valueType?.format || undefined,
|
||||
options: handlePropertiesOptions(datum.valueType),
|
||||
value: undefined,
|
||||
required: datum.expands?.required
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -115,13 +116,16 @@ const functionData = computed(() => {
|
|||
|
||||
const rules = [{
|
||||
validator(_: string, value: any) {
|
||||
if (!value?.length && functionData.value.length) {
|
||||
return Promise.reject('请输入功能值')
|
||||
} else {
|
||||
let hasValue = value.find((item: { name: string, value: any}) => item.value === undefined)
|
||||
if (hasValue) {
|
||||
const functionItem = functionData.value.find((item: any) => item.id === hasValue.name)
|
||||
return Promise.reject(functionItem?.name ? `请输入${functionItem?.name}值` : '请输入功能值')
|
||||
const arr = functionData.value.filter((i: any) => i?.required)
|
||||
if(arr.length){
|
||||
if (!value?.length) {
|
||||
return Promise.reject('请输入功能值')
|
||||
} else {
|
||||
let hasValue = value.find((item: { name: string, value: any}) => item.value === undefined)
|
||||
if (hasValue) {
|
||||
const functionItem = arr.find((item: any) => item.id === hasValue.name)
|
||||
return Promise.reject(functionItem?.name ? `请输入${functionItem?.name}值` : '请输入功能值')
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
|
|
@ -173,25 +173,31 @@ const propertySelect = (val: any, options?: any) => {
|
|||
const functionRules = [
|
||||
{
|
||||
validator(_: string, value: any) {
|
||||
if (!value?.length && functions.value.length) {
|
||||
return Promise.reject('请输入功能值');
|
||||
} else {
|
||||
const hasValue = value?.find(
|
||||
(item: { name: string; value: any }) => item.value === undefined,
|
||||
);
|
||||
if (hasValue) {
|
||||
const functionItem = functions.value?.find(
|
||||
(item: any) => item.id === hasValue.name,
|
||||
);
|
||||
return Promise.reject(
|
||||
functionItem?.name
|
||||
? `请输入${functionItem.name}值`
|
||||
: '请输入功能值',
|
||||
const arr = functions.value.filter((i: any) => {
|
||||
return i?.expands?.required
|
||||
})
|
||||
if(arr.length){
|
||||
if(!value?.length) {
|
||||
return Promise.reject('请输入功能值');
|
||||
} else {
|
||||
const hasValue = value?.find(
|
||||
(item: { name: string; value: any }) => item.value === undefined,
|
||||
);
|
||||
if (hasValue) {
|
||||
const functionItem = arr?.find(
|
||||
(item: any) => item.id === hasValue.name,
|
||||
);
|
||||
return Promise.reject(
|
||||
functionItem?.name
|
||||
? `请输入${functionItem.name}值`
|
||||
: '请输入功能值',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: ['change', 'blur']
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ const onType = (_type: string) => {
|
|||
const onSave = (data: ActionsType, options: any) => {
|
||||
const { key, terms } = _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name]
|
||||
|
||||
const columns = new Set([...(props.options?.termsColumns || []), ...(options.otherColumns.filter((item?: string) => item))])
|
||||
const columns = new Set([...(props.options?.termsColumns || []), ...(options?.otherColumns?.filter?.((item?: string) => item) || [])])
|
||||
|
||||
const actionItem: ActionsType = {
|
||||
...data,
|
||||
|
|
Loading…
Reference in New Issue