Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
58e01fe28e
|
@ -45,6 +45,7 @@ initAMapApiLoader({
|
||||||
|
|
||||||
interface EmitProps {
|
interface EmitProps {
|
||||||
(e: 'update:point', data: string): void;
|
(e: 'update:point', data: string): void;
|
||||||
|
(e: 'change', data: string): void;
|
||||||
}
|
}
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
point: { type: [Number, String], default: '' },
|
point: { type: [Number, String], default: '' },
|
||||||
|
@ -59,6 +60,7 @@ const inputPoint = computed({
|
||||||
set: (val: any) => {
|
set: (val: any) => {
|
||||||
mapPoint.value = val;
|
mapPoint.value = val;
|
||||||
emit('update:point', val);
|
emit('update:point', val);
|
||||||
|
emit('change', val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
<GeoComponent
|
<GeoComponent
|
||||||
v-else-if="typeMap.get(itemType) === 'geoPoint'"
|
v-else-if="typeMap.get(itemType) === 'geoPoint'"
|
||||||
v-model:point="myValue"
|
v-model:point="myValue"
|
||||||
|
@change='inputChange'
|
||||||
/>
|
/>
|
||||||
<j-input
|
<j-input
|
||||||
v-else-if="typeMap.get(itemType) === 'file'"
|
v-else-if="typeMap.get(itemType) === 'file'"
|
||||||
|
@ -172,7 +173,7 @@ const objectValue = ref<string>('');
|
||||||
const handleItemModalSubmit = () => {
|
const handleItemModalSubmit = () => {
|
||||||
myValue.value = objectValue.value.replace(/[\r\n]\s*/g, '');
|
myValue.value = objectValue.value.replace(/[\r\n]\s*/g, '');
|
||||||
modalVis.value = false;
|
modalVis.value = false;
|
||||||
emit('change', myValue.value);
|
emit('change', objectValue.value)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 文件上传
|
// 文件上传
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<j-col :span="12">
|
<j-col :span="12">
|
||||||
<j-form-item
|
<j-form-item
|
||||||
name="properties"
|
name="properties"
|
||||||
label="读取属性"
|
label="设置属性"
|
||||||
:rules="[{ required: true, message: '请选择读取属性' }]"
|
:rules="[{ required: true, message: '请选择设置属性' }]"
|
||||||
>
|
>
|
||||||
<j-select
|
<j-select
|
||||||
showSearch
|
showSearch
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
>
|
>
|
||||||
<j-select-option
|
<j-select-option
|
||||||
v-for="item in metadata?.properties || []"
|
v-for="item in (metadata?.properties || [])?.filter(i => i?.expands?.type?.includes('write')) || []"
|
||||||
:value="item?.id"
|
:value="item?.id"
|
||||||
:key="item?.id"
|
:key="item?.id"
|
||||||
>{{ item?.name }}</j-select-option
|
>{{ item?.name }}</j-select-option
|
||||||
|
@ -33,7 +33,6 @@
|
||||||
:rules="[{ required: true, message: '请选择' }]"
|
:rules="[{ required: true, message: '请选择' }]"
|
||||||
>
|
>
|
||||||
<ParamsDropdown
|
<ParamsDropdown
|
||||||
placeholder="请选择"
|
|
||||||
:options="handleOptions"
|
:options="handleOptions"
|
||||||
:tabsOptions="tabOptions"
|
:tabsOptions="tabOptions"
|
||||||
:metricOptions="upperOptions"
|
:metricOptions="upperOptions"
|
||||||
|
@ -42,7 +41,7 @@
|
||||||
@select="onValueChange"
|
@select="onValueChange"
|
||||||
>
|
>
|
||||||
<template v-slot="{ label }">
|
<template v-slot="{ label }">
|
||||||
<j-input :value="label" />
|
<j-input :value="label" placeholder="请选择" />
|
||||||
</template>
|
</template>
|
||||||
</ParamsDropdown>
|
</ParamsDropdown>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
|
@ -73,7 +72,7 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:value']);
|
const emit = defineEmits(['update:value', 'change']);
|
||||||
|
|
||||||
const propertyFormRef = ref();
|
const propertyFormRef = ref();
|
||||||
|
|
||||||
|
@ -83,6 +82,7 @@ const propertyModelRef = reactive({
|
||||||
source: 'fixed',
|
source: 'fixed',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const getType = computed(() => {
|
const getType = computed(() => {
|
||||||
return props.metadata.properties.find(
|
return props.metadata.properties.find(
|
||||||
(item: any) => item.id === propertyModelRef.properties,
|
(item: any) => item.id === propertyModelRef.properties,
|
||||||
|
@ -154,7 +154,7 @@ const handleOptions = computed(() => {
|
||||||
|
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
propertyModelRef.propertiesValue = undefined;
|
propertyModelRef.propertiesValue = undefined;
|
||||||
propertyModelRef.source = 'fixed'
|
propertyModelRef.source = 'fixed';
|
||||||
emit('update:value', {
|
emit('update:value', {
|
||||||
[`${propertyModelRef.properties}`]: {
|
[`${propertyModelRef.properties}`]: {
|
||||||
value: propertyModelRef?.propertiesValue,
|
value: propertyModelRef?.propertiesValue,
|
||||||
|
@ -169,8 +169,9 @@ const onValueChange = () => {
|
||||||
value: propertyModelRef?.propertiesValue,
|
value: propertyModelRef?.propertiesValue,
|
||||||
source: propertyModelRef?.source,
|
source: propertyModelRef?.source,
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
emit('update:value', obj);
|
emit('update:value', obj);
|
||||||
|
emit('change', propertyModelRef?.propertiesValue)
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -187,4 +188,19 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true, immediate: true },
|
{ deep: true, immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onSave = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
propertyFormRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch((err: any) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({ onSave });
|
||||||
</script>
|
</script>
|
|
@ -22,7 +22,7 @@
|
||||||
showSearch
|
showSearch
|
||||||
placeholder="请选择功能"
|
placeholder="请选择功能"
|
||||||
v-model:value="modelRef.message.functionId"
|
v-model:value="modelRef.message.functionId"
|
||||||
@select='functionSelect'
|
@select="functionSelect"
|
||||||
>
|
>
|
||||||
<j-select-option
|
<j-select-option
|
||||||
v-for="item in metadata?.functions || []"
|
v-for="item in metadata?.functions || []"
|
||||||
|
@ -56,7 +56,9 @@
|
||||||
v-model:value="modelRef.message.properties[0]"
|
v-model:value="modelRef.message.properties[0]"
|
||||||
>
|
>
|
||||||
<j-select-option
|
<j-select-option
|
||||||
v-for="item in metadata?.properties || []"
|
v-for="item in metadata?.properties.filter((i) =>
|
||||||
|
i?.expands?.type?.includes('read'),
|
||||||
|
) || []"
|
||||||
:value="item?.id"
|
:value="item?.id"
|
||||||
:key="item?.id"
|
:key="item?.id"
|
||||||
>{{ item?.name }}</j-select-option
|
>{{ item?.name }}</j-select-option
|
||||||
|
@ -66,9 +68,11 @@
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="deviceMessageType === 'WRITE_PROPERTY'">
|
<template v-else-if="deviceMessageType === 'WRITE_PROPERTY'">
|
||||||
<WriteProperty
|
<WriteProperty
|
||||||
|
ref="writeFormRef"
|
||||||
v-model:value="modelRef.message.properties"
|
v-model:value="modelRef.message.properties"
|
||||||
:metadata="metadata"
|
:metadata="metadata"
|
||||||
:builtInList="builtInList"
|
:builtInList="builtInList"
|
||||||
|
@change="onWriteChange"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</j-form>
|
</j-form>
|
||||||
|
@ -83,7 +87,7 @@ import EditTable from './EditTable.vue';
|
||||||
import WriteProperty from './WriteProperty.vue';
|
import WriteProperty from './WriteProperty.vue';
|
||||||
import { useSceneStore } from '@/store/scene';
|
import { useSceneStore } from '@/store/scene';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { getParams } from '../../../util'
|
import { getParams } from '../../../util';
|
||||||
|
|
||||||
const sceneStore = useSceneStore();
|
const sceneStore = useSceneStore();
|
||||||
const { data } = storeToRefs(sceneStore);
|
const { data } = storeToRefs(sceneStore);
|
||||||
|
@ -137,26 +141,39 @@ const modelRef = reactive({
|
||||||
properties: undefined,
|
properties: undefined,
|
||||||
inputs: [],
|
inputs: [],
|
||||||
},
|
},
|
||||||
|
propertiesValue: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const functionSelect = () => {
|
const writeFormRef = ref();
|
||||||
modelRef.message.inputs = []
|
|
||||||
}
|
|
||||||
|
|
||||||
const functionRules = [{
|
const functionSelect = () => {
|
||||||
validator(_: string, value: any) {
|
modelRef.message.inputs = [];
|
||||||
if (!value?.length && functions.value.length) {
|
};
|
||||||
return Promise.reject('请输入功能值')
|
|
||||||
} else {
|
const functionRules = [
|
||||||
const hasValue = value.find((item: { name: string, value: any}) => !item.value)
|
{
|
||||||
if (hasValue) {
|
validator(_: string, value: any) {
|
||||||
const functionItem = functions.value.find((item: any) => item.id === hasValue.name)
|
if (!value?.length && functions.value.length) {
|
||||||
return Promise.reject(functionItem?.name ? `请输入${functionItem.name}值` : '请输入功能值')
|
return Promise.reject('请输入功能值');
|
||||||
}
|
} else {
|
||||||
}
|
const hasValue = value.find(
|
||||||
return Promise.resolve();
|
(item: { name: string; value: any }) => !item.value,
|
||||||
}
|
);
|
||||||
}]
|
if (hasValue) {
|
||||||
|
const functionItem = functions.value.find(
|
||||||
|
(item: any) => item.id === hasValue.name,
|
||||||
|
);
|
||||||
|
return Promise.reject(
|
||||||
|
functionItem?.name
|
||||||
|
? `请输入${functionItem.name}值`
|
||||||
|
: '请输入功能值',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const metadata = ref<{
|
const metadata = ref<{
|
||||||
functions: any[];
|
functions: any[];
|
||||||
|
@ -205,15 +222,15 @@ const queryBuiltIn = async () => {
|
||||||
action: props.name - 1,
|
action: props.name - 1,
|
||||||
};
|
};
|
||||||
const _data = await getParams(_params, unref(data));
|
const _data = await getParams(_params, unref(data));
|
||||||
builtInList.value = _data
|
builtInList.value = _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMessageTypeChange = (val: string) => {
|
const onMessageTypeChange = (val: string) => {
|
||||||
const flag = ['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val)
|
const flag = ['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val);
|
||||||
modelRef.message = {
|
modelRef.message = {
|
||||||
messageType: val,
|
messageType: val,
|
||||||
functionId: undefined,
|
functionId: undefined,
|
||||||
properties:(flag ? undefined : []) as any,
|
properties: (flag ? undefined : []) as any,
|
||||||
inputs: [],
|
inputs: [],
|
||||||
};
|
};
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
@ -251,7 +268,11 @@ watch(
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal?.messageType) {
|
if (newVal?.messageType) {
|
||||||
modelRef.message = newVal;
|
modelRef.message = newVal;
|
||||||
if (['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(newVal.messageType)) {
|
if (
|
||||||
|
['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(
|
||||||
|
newVal.messageType,
|
||||||
|
)
|
||||||
|
) {
|
||||||
queryBuiltIn();
|
queryBuiltIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,11 +280,21 @@ watch(
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onWriteChange = (val: string) => {
|
||||||
|
modelRef.propertiesValue = val;
|
||||||
|
};
|
||||||
|
|
||||||
const onFormSave = () => {
|
const onFormSave = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
formRef.value
|
formRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then((_data: any) => {
|
.then(async (_data: any) => {
|
||||||
|
if (writeFormRef.value) {
|
||||||
|
const _val = await writeFormRef.value?.onSave();
|
||||||
|
if (!_val) {
|
||||||
|
reject(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 处理三种情况的值的格式
|
// 处理三种情况的值的格式
|
||||||
const obj = {
|
const obj = {
|
||||||
message: {
|
message: {
|
||||||
|
@ -273,6 +304,7 @@ const onFormSave = () => {
|
||||||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||||
? _function.value?.name
|
? _function.value?.name
|
||||||
: _property.value?.name,
|
: _property.value?.name,
|
||||||
|
propertiesValue: modelRef.propertiesValue,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
resolve(obj);
|
resolve(obj);
|
||||||
|
|
|
@ -77,12 +77,12 @@ type Emit = {
|
||||||
|
|
||||||
const actionRef = ref();
|
const actionRef = ref();
|
||||||
const params = ref({
|
const params = ref({
|
||||||
terms: []
|
terms: [],
|
||||||
});
|
});
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
type: Array as PropType<any>,
|
type: Array as PropType<any>,
|
||||||
default: []
|
default: [],
|
||||||
},
|
},
|
||||||
detail: {
|
detail: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -90,8 +90,8 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
productId: {
|
productId: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits<Emit>();
|
const emit = defineEmits<Emit>();
|
||||||
|
@ -143,9 +143,9 @@ const handleSearch = (p: any) => {
|
||||||
...p,
|
...p,
|
||||||
terms: [
|
terms: [
|
||||||
...p.terms,
|
...p.terms,
|
||||||
{terms: [{ column: 'productId', value: props?.productId }]}
|
{ terms: [{ column: 'productId', value: props?.productId }] },
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const deviceQuery = (p: any) => {
|
const deviceQuery = (p: any) => {
|
||||||
|
@ -162,19 +162,26 @@ const deviceQuery = (p: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = (detail: any) => {
|
const handleClick = (detail: any) => {
|
||||||
emit('update:value', [{ value: detail.id, name: detail.name }]);
|
if (props.value?.[0]?.value === detail.id) {
|
||||||
emit('change', detail);
|
emit('update:value', undefined);
|
||||||
|
emit('change', {});
|
||||||
|
} else {
|
||||||
|
emit('update:value', [{ value: detail.id, name: detail.name }]);
|
||||||
|
emit('change', detail);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
params.value = {
|
params.value = {
|
||||||
...params.value,
|
...params.value,
|
||||||
terms: params.value?.terms ? [
|
terms: params.value?.terms
|
||||||
...(params.value.terms || []),
|
? [
|
||||||
{terms: [{ column: 'productId', value: props?.productId }]}
|
...(params.value.terms || []),
|
||||||
] : [{terms: [{ column: 'productId', value: props?.productId }]}]
|
{ terms: [{ column: 'productId', value: props?.productId }] },
|
||||||
}
|
]
|
||||||
})
|
: [{ terms: [{ column: 'productId', value: props?.productId }] }],
|
||||||
|
};
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang='less'>
|
<style scoped lang='less'>
|
||||||
|
|
|
@ -13,10 +13,12 @@
|
||||||
<div class="'way-item-title">
|
<div class="'way-item-title">
|
||||||
<span class="way-item-label">{{ item.label }}</span>
|
<span class="way-item-label">{{ item.label }}</span>
|
||||||
<j-popover v-if="item.tip">
|
<j-popover v-if="item.tip">
|
||||||
<AIcon
|
<j-tooltip :title="item.tip">
|
||||||
type="QuestionCircleOutlined"
|
<AIcon
|
||||||
class="way-item-icon"
|
type="QuestionCircleOutlined"
|
||||||
/>
|
class="way-item-icon"
|
||||||
|
/>
|
||||||
|
</j-tooltip>
|
||||||
</j-popover>
|
</j-popover>
|
||||||
</div>
|
</div>
|
||||||
<div class="way-item-image">
|
<div class="way-item-image">
|
||||||
|
@ -54,7 +56,7 @@ const _value = ref(props?.value || '');
|
||||||
watch(
|
watch(
|
||||||
() => props.value,
|
() => props.value,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
_value.value = newValue || ""
|
_value.value = newValue || '';
|
||||||
},
|
},
|
||||||
{ immediate: true, deep: true },
|
{ immediate: true, deep: true },
|
||||||
);
|
);
|
||||||
|
@ -63,7 +65,7 @@ const onSelect = (_type: string) => {
|
||||||
if (!props.disabled) {
|
if (!props.disabled) {
|
||||||
_value.value = _type;
|
_value.value = _type;
|
||||||
emits('update:value', _type);
|
emits('update:value', _type);
|
||||||
emits('change', _type)
|
emits('change', _type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -13,17 +13,18 @@
|
||||||
@change="onSelectorChange"
|
@change="onSelectorChange"
|
||||||
/>
|
/>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
<j-form-item
|
<!-- <j-form-item
|
||||||
v-if="modelRef.selector === 'fixed'"
|
v-if="modelRef.selector === 'fixed'"
|
||||||
name="selectorValues"
|
name="selectorValues"
|
||||||
:rules="[{ required: true, message: '请选择设备' }]"
|
:rules="[{ required: true, message: '请选择设备' }]"
|
||||||
>
|
> -->
|
||||||
<Device
|
<Device
|
||||||
:productId="values.productDetail.id"
|
v-if="modelRef.selector === 'fixed'"
|
||||||
v-model:value="modelRef.selectorValues"
|
:productId="values.productDetail.id"
|
||||||
@change="onDeviceChange"
|
v-model:value="modelRef.selectorValues"
|
||||||
/>
|
@change="onDeviceChange"
|
||||||
</j-form-item>
|
/>
|
||||||
|
<!-- </j-form-item> -->
|
||||||
<j-form-item
|
<j-form-item
|
||||||
v-else-if="modelRef.selector === 'relation'"
|
v-else-if="modelRef.selector === 'relation'"
|
||||||
label="关系"
|
label="关系"
|
||||||
|
@ -78,7 +79,7 @@
|
||||||
import { useSceneStore } from '@/store/scene';
|
import { useSceneStore } from '@/store/scene';
|
||||||
import TopCard from './TopCard.vue';
|
import TopCard from './TopCard.vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { getImage } from '@/utils/comm';
|
import { getImage, onlyMessage } from '@/utils/comm';
|
||||||
import NoticeApi from '@/api/notice/config';
|
import NoticeApi from '@/api/notice/config';
|
||||||
import Device from './Device.vue';
|
import Device from './Device.vue';
|
||||||
import Tag from './Tag.vue';
|
import Tag from './Tag.vue';
|
||||||
|
@ -318,7 +319,19 @@ const onFormSave = () => {
|
||||||
formRef.value
|
formRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async (_data: any) => {
|
.then(async (_data: any) => {
|
||||||
resolve(_data);
|
if(modelRef.selector === 'fixed'){
|
||||||
|
if(!modelRef?.selectorValues?.[0]?.value){
|
||||||
|
onlyMessage('请选择设备', 'error')
|
||||||
|
reject(false);
|
||||||
|
} else {
|
||||||
|
resolve({
|
||||||
|
..._data,
|
||||||
|
selectorValues: modelRef.selectorValues
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve(_data);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
v-if="current === 0"
|
v-if="current === 0"
|
||||||
v-model:rowKey="DeviceModel.productId"
|
v-model:rowKey="DeviceModel.productId"
|
||||||
v-model:detail="DeviceModel.productDetail"
|
v-model:detail="DeviceModel.productDetail"
|
||||||
|
@change="onProductChange"
|
||||||
/>
|
/>
|
||||||
<Device
|
<Device
|
||||||
v-else-if="current === 1"
|
v-else-if="current === 1"
|
||||||
|
@ -173,9 +174,9 @@ const onSave = (_data: any) => {
|
||||||
_options.type = '设置';
|
_options.type = '设置';
|
||||||
_options.properties = _data.message.propertiesName;
|
_options.properties = _data.message.propertiesName;
|
||||||
_options.propertiesValue =
|
_options.propertiesValue =
|
||||||
typeof DeviceModel.propertiesValue === 'object'
|
typeof _data.message.propertiesValue === 'object'
|
||||||
? JSON.stringify(DeviceModel.propertiesValue)
|
? JSON.stringify(_data.message.propertiesValue)
|
||||||
: `${DeviceModel.propertiesValue}`;
|
: `${_data.message.propertiesValue}`;
|
||||||
_options.columns = DeviceModel.columns;
|
_options.columns = DeviceModel.columns;
|
||||||
_options.otherColumns = DeviceModel.columns;
|
_options.otherColumns = DeviceModel.columns;
|
||||||
const cur: any = Object.values(_data.message.properties)?.[0];
|
const cur: any = Object.values(_data.message.properties)?.[0];
|
||||||
|
@ -184,13 +185,6 @@ const onSave = (_data: any) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_options.selector === 'tag') {
|
if (_options.selector === 'tag') {
|
||||||
// const arr = _data.map((item: any) => {
|
|
||||||
// return {
|
|
||||||
// column: item.name,
|
|
||||||
// type: item.type,
|
|
||||||
// value: item.value,
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
_options.taglist = DeviceModel.tagList.map((it) => ({
|
_options.taglist = DeviceModel.tagList.map((it) => ({
|
||||||
name: it.column || it.name,
|
name: it.column || it.name,
|
||||||
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
|
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
|
||||||
|
@ -203,6 +197,11 @@ const onSave = (_data: any) => {
|
||||||
emit('save', item, _options);
|
emit('save', item, _options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onProductChange = () => {
|
||||||
|
DeviceModel.selectorValues = undefined
|
||||||
|
DeviceModel.message = {}
|
||||||
|
}
|
||||||
|
|
||||||
const save = async (step?: number) => {
|
const save = async (step?: number) => {
|
||||||
let _step = step !== undefined ? step : current.value;
|
let _step = step !== undefined ? step : current.value;
|
||||||
if (_step === 0) {
|
if (_step === 0) {
|
||||||
|
@ -213,8 +212,10 @@ const save = async (step?: number) => {
|
||||||
if (deviceRef.value) {
|
if (deviceRef.value) {
|
||||||
await deviceRef.value?.onFormSave();
|
await deviceRef.value?.onFormSave();
|
||||||
current.value = 2;
|
current.value = 2;
|
||||||
} else if (DeviceModel.selectorValues.length) {
|
} else if (DeviceModel.selectorValues?.length) {
|
||||||
current.value = 2;
|
current.value = 2;
|
||||||
|
} else {
|
||||||
|
onlyMessage('请选择设备', 'error')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (actionRef.value) {
|
if (actionRef.value) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
:rules="[
|
:rules="[
|
||||||
{
|
{
|
||||||
validator: (_rule, value) => checkValue(_rule, value, item),
|
validator: (_rule, value) => checkValue(_rule, value, item),
|
||||||
trigger: ['change', 'blur']
|
trigger: ['change', 'blur'],
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
:notify="notify"
|
:notify="notify"
|
||||||
v-if="getType(item) === 'user'"
|
v-if="getType(item) === 'user'"
|
||||||
v-model:value="modelRef[item.id]"
|
v-model:value="modelRef[item.id]"
|
||||||
|
@change="(val) => onChange(val, 'user')"
|
||||||
/>
|
/>
|
||||||
<Org
|
<Org
|
||||||
:notify="notify"
|
:notify="notify"
|
||||||
|
@ -78,7 +79,7 @@ const formRef = ref();
|
||||||
const modelRef = reactive({});
|
const modelRef = reactive({});
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
Object.assign(modelRef, props.value);
|
Object.assign(modelRef, props?.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getType = (item: any) => {
|
const getType = (item: any) => {
|
||||||
|
@ -102,34 +103,41 @@ const checkValue = (_rule: any, value: any, item: any) => {
|
||||||
return Promise.reject(new Error('请选择' + item.name));
|
return Promise.reject(new Error('请选择' + item.name));
|
||||||
} else {
|
} else {
|
||||||
if (value?.source === 'upper') {
|
if (value?.source === 'upper') {
|
||||||
if (!value.upperKey) {
|
if (!value?.upperKey) {
|
||||||
return Promise.reject(new Error('请选择' + item.name));
|
return Promise.reject(new Error('请选择' + item.name));
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!value.value) {
|
if (!value?.value) {
|
||||||
return Promise.reject(new Error('请选择' + item.name));
|
return Promise.reject(new Error('请选择' + item.name));
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (value?.source === 'fixed' && !value.value) {
|
} else if (value?.source === 'fixed' && !value?.value) {
|
||||||
return Promise.reject(new Error('请输入' + item.name));
|
return Promise.reject(new Error('请输入' + item.name));
|
||||||
} else if (value?.source === 'relation' && !value.value && !value.relation) {
|
} else if (
|
||||||
|
value?.source === 'relation' &&
|
||||||
|
!value?.value &&
|
||||||
|
!value?.relation
|
||||||
|
) {
|
||||||
return Promise.reject(new Error('请选择' + item.name));
|
return Promise.reject(new Error('请选择' + item.name));
|
||||||
} else if (value?.source === 'upper' && !value.upperKey) {
|
} else if (value?.source === 'upper' && !value.upperKey) {
|
||||||
return Promise.reject(new Error('请选择' + item.name));
|
return Promise.reject(new Error('请选择' + item.name));
|
||||||
} else if (type === 'user') {
|
} else if (type === 'user') {
|
||||||
if (props.notify.notifyType === 'email' && value?.source !== 'relation') {
|
if (
|
||||||
if (Array.isArray(value.value)) {
|
props.notify.notifyType === 'email' &&
|
||||||
if (!value.value.length) {
|
value?.source !== 'relation'
|
||||||
|
) {
|
||||||
|
if (Array.isArray(value?.value)) {
|
||||||
|
if (!value?.value.length) {
|
||||||
return Promise.reject(new Error('请输入收件人'));
|
return Promise.reject(new Error('请输入收件人'));
|
||||||
}
|
}
|
||||||
const reg =
|
const reg =
|
||||||
/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
|
/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
|
||||||
const flag = value.value.every((it: string) => {
|
const flag = value?.value.every((it: string) => {
|
||||||
return reg.test(it);
|
return reg.test(it);
|
||||||
});
|
});
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
|
@ -143,10 +151,11 @@ const checkValue = (_rule: any, value: any, item: any) => {
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
props.notify.notifyType &&
|
props.notify.notifyType &&
|
||||||
['sms', 'voice'].includes(props?.notify?.notifyType) && value?.source !== 'relation'
|
['sms', 'voice'].includes(props?.notify?.notifyType) &&
|
||||||
|
value?.source !== 'relation'
|
||||||
) {
|
) {
|
||||||
const reg = /^[1][3-9]\d{9}$/;
|
const reg = /^[1][3-9]\d{9}$/;
|
||||||
if (!reg.test(value.value)) {
|
if (!reg.test(value?.value)) {
|
||||||
return Promise.reject(new Error('请输入正确的手机号码'));
|
return Promise.reject(new Error('请输入正确的手机号码'));
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -161,12 +170,14 @@ const onChange = (val: any, type: any) => {
|
||||||
emit('change', { orgName: val.join(',') });
|
emit('change', { orgName: val.join(',') });
|
||||||
} else if (type === 'tag') {
|
} else if (type === 'tag') {
|
||||||
emit('change', { tagName: val });
|
emit('change', { tagName: val });
|
||||||
|
} else if (type === 'user') {
|
||||||
|
emit('change', { sendTo: val });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSave = () =>
|
const onSave = () =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
formRef.value.validate().then(async (_data: any) => {
|
formRef.value?.validate().then(async (_data: any) => {
|
||||||
resolve(_data);
|
resolve(_data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,21 +33,59 @@
|
||||||
固定号码
|
固定号码
|
||||||
</j-select-option>
|
</j-select-option>
|
||||||
</j-select>
|
</j-select>
|
||||||
<j-tree-select
|
<template v-if="source === 'relation'">
|
||||||
v-if="source === 'relation'"
|
<j-tree-select
|
||||||
style="width: calc(100% - 120px)"
|
v-if="['email'].includes(notifyType)"
|
||||||
placeholder="请选择收信人"
|
style="width: calc(100% - 120px)"
|
||||||
@select="(key, node) => onChange(source, key, false, node?.relation, node.name)"
|
placeholder="请选择收信人"
|
||||||
:tree-data="treeData"
|
@change="(key, label) => onChange(source, key, false, label)"
|
||||||
:multiple="['email'].includes(notifyType)"
|
:tree-data="treeData"
|
||||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
:multiple="true"
|
||||||
:value="relationData"
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||||
>
|
:value="relationData"
|
||||||
<template #title="{ key, username, title }">
|
>
|
||||||
<div style="display: flex; justify-content: space-between; margin-right: 10px;" v-if="key !== 'p1' && key !== 'p2'">{{ title }} <span style="color: #cfcfcf;">{{ username }}</span></div>
|
<template #title="{ key, username, title }">
|
||||||
<span v-else>{{ title }}</span>
|
<div
|
||||||
</template>
|
style="
|
||||||
</j-tree-select>
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-right: 10px;
|
||||||
|
"
|
||||||
|
v-if="key !== 'p1' && key !== 'p2'"
|
||||||
|
>
|
||||||
|
{{ title }}
|
||||||
|
<span style="color: #cfcfcf">{{ username }}</span>
|
||||||
|
</div>
|
||||||
|
<span v-else>{{ title }}</span>
|
||||||
|
</template>
|
||||||
|
</j-tree-select>
|
||||||
|
<j-tree-select
|
||||||
|
v-else
|
||||||
|
style="width: calc(100% - 120px)"
|
||||||
|
placeholder="请选择收信人"
|
||||||
|
@select="
|
||||||
|
(key, node) => onChange(source, key, node?.isRelation, node?.name)
|
||||||
|
"
|
||||||
|
:tree-data="treeData"
|
||||||
|
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
|
||||||
|
:value="relationData"
|
||||||
|
>
|
||||||
|
<template #title="{ key, username, title }">
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-right: 10px;
|
||||||
|
"
|
||||||
|
v-if="key !== 'p1' && key !== 'p2'"
|
||||||
|
>
|
||||||
|
{{ title }}
|
||||||
|
<span style="color: #cfcfcf">{{ username }}</span>
|
||||||
|
</div>
|
||||||
|
<span v-else>{{ title }}</span>
|
||||||
|
</template>
|
||||||
|
</j-tree-select>
|
||||||
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<j-select
|
<j-select
|
||||||
style="width: calc(100% - 120px)"
|
style="width: calc(100% - 120px)"
|
||||||
|
@ -55,7 +93,15 @@
|
||||||
placeholder="请选择收信人"
|
placeholder="请选择收信人"
|
||||||
:value="value?.value"
|
:value="value?.value"
|
||||||
showSearch
|
showSearch
|
||||||
@change="(val, option) => onChange(source, val, false, option?.label || option?.name)"
|
@change="
|
||||||
|
(val, option) =>
|
||||||
|
onChange(
|
||||||
|
source,
|
||||||
|
val,
|
||||||
|
false,
|
||||||
|
option?.label || option?.name,
|
||||||
|
)
|
||||||
|
"
|
||||||
:options="relationList"
|
:options="relationList"
|
||||||
/>
|
/>
|
||||||
<j-select
|
<j-select
|
||||||
|
@ -64,14 +110,25 @@
|
||||||
placeholder="请输入收件人邮箱,多个收件人用换行分隔"
|
placeholder="请输入收件人邮箱,多个收件人用换行分隔"
|
||||||
:value="value?.value"
|
:value="value?.value"
|
||||||
mode="tags"
|
mode="tags"
|
||||||
@change="(val) => onChange(source, val, false, Array.isArray(val) ? val.join(',') : val)"
|
@change="
|
||||||
|
(val) =>
|
||||||
|
onChange(
|
||||||
|
source,
|
||||||
|
val,
|
||||||
|
false,
|
||||||
|
Array.isArray(val) ? val.join(',') : val,
|
||||||
|
)
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<j-input
|
<j-input
|
||||||
style="width: calc(100% - 120px)"
|
style="width: calc(100% - 120px)"
|
||||||
v-else-if="['sms', 'voice'].includes(notifyType)"
|
v-else-if="['sms', 'voice'].includes(notifyType)"
|
||||||
placeholder="请输入固定号码"
|
placeholder="请输入固定号码"
|
||||||
:value="value?.value"
|
:value="value?.value"
|
||||||
@change="(e) => onChange(source, e.target.value, false, e.target.value)"
|
@change="
|
||||||
|
(e) =>
|
||||||
|
onChange(source, e.target.value, false, e.target.value)
|
||||||
|
"
|
||||||
></j-input>
|
></j-input>
|
||||||
</template>
|
</template>
|
||||||
</j-input-group>
|
</j-input-group>
|
||||||
|
@ -262,7 +319,7 @@ const onChange = (
|
||||||
_name?: string,
|
_name?: string,
|
||||||
) => {
|
) => {
|
||||||
let _values: any = undefined;
|
let _values: any = undefined;
|
||||||
const _names: string[] = [_name || ''];
|
const _names: string[] = Array.isArray(_name) ? _name : [_name || ''];
|
||||||
if (Array.isArray(_value)) {
|
if (Array.isArray(_value)) {
|
||||||
if (props?.notify?.notifyType === 'email') {
|
if (props?.notify?.notifyType === 'email') {
|
||||||
if (isRelation) {
|
if (isRelation) {
|
||||||
|
@ -280,7 +337,7 @@ const onChange = (
|
||||||
_values = getObj(_source, _value, isRelation);
|
_values = getObj(_source, _value, isRelation);
|
||||||
}
|
}
|
||||||
emit('update:value', _values);
|
emit('update:value', _values);
|
||||||
emit('change', { sendTo: _names.filter((item) => !!item).join(',') });
|
emit('change', _names.filter((item) => !!item).join(','));
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -367,23 +367,22 @@ const clickDel = (row: any) => {
|
||||||
|
|
||||||
const clickSave = () => {
|
const clickSave = () => {
|
||||||
formRef.value.validate().then((_data: any) => {
|
formRef.value.validate().then((_data: any) => {
|
||||||
console.log(_data)
|
const columns = cloneDeep(table.data);
|
||||||
// const columns = cloneDeep(table.data);
|
columns.forEach((item) => delete item.index);
|
||||||
// columns.forEach((item) => delete item.index);
|
if (!columns.length) {
|
||||||
// if (!columns.length) {
|
onlyMessage('请配置数据源字段', 'error');
|
||||||
// onlyMessage('请配置数据源字段', 'error');
|
return;
|
||||||
// return;
|
}
|
||||||
// }
|
const params = {
|
||||||
// const params = {
|
name: leftData.selectedKeys[0],
|
||||||
// name: leftData.selectedKeys[0],
|
columns,
|
||||||
// columns,
|
};
|
||||||
// };
|
saveTable_api(id, params).then((resp) => {
|
||||||
// saveTable_api(id, params).then((resp) => {
|
if (resp.status === 200) {
|
||||||
// if (resp.status === 200) {
|
message.success('操作成功');
|
||||||
// message.success('操作成功');
|
queryTables(params.name);
|
||||||
// queryTables(params.name);
|
}
|
||||||
// }
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ const dialogTitle = computed(() =>
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const checkUrl = (_rule: Rule, value: string): Promise<any> => {
|
const checkUrl = (_rule: Rule, value: string): Promise<any> => {
|
||||||
if (!value) return Promise.reject('请输入URL');
|
if (!value) return Promise.resolve();
|
||||||
const arr = value.split(':');
|
const arr = value.split(':');
|
||||||
if (arr?.[0] === 'jdbc' || arr?.[0] === 'r2dbc') {
|
if (arr?.[0] === 'jdbc' || arr?.[0] === 'r2dbc') {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
Loading…
Reference in New Issue