fix: 修改执行动作
This commit is contained in:
parent
00ca314972
commit
d45ff4431b
|
@ -173,7 +173,7 @@ const objectValue = ref<string>('');
|
|||
const handleItemModalSubmit = () => {
|
||||
myValue.value = objectValue.value.replace(/[\r\n]\s*/g, '');
|
||||
modalVis.value = false;
|
||||
inputChange(myValue.value)
|
||||
emit('change', objectValue.value)
|
||||
};
|
||||
|
||||
// 文件上传
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<j-col :span="12">
|
||||
<j-form-item
|
||||
name="properties"
|
||||
label="读取属性"
|
||||
:rules="[{ required: true, message: '请选择读取属性' }]"
|
||||
label="设置属性"
|
||||
:rules="[{ required: true, message: '请选择设置属性' }]"
|
||||
>
|
||||
<j-select
|
||||
showSearch
|
||||
|
@ -18,7 +18,7 @@
|
|||
@change="onChange"
|
||||
>
|
||||
<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"
|
||||
:key="item?.id"
|
||||
>{{ item?.name }}</j-select-option
|
||||
|
@ -33,7 +33,6 @@
|
|||
:rules="[{ required: true, message: '请选择' }]"
|
||||
>
|
||||
<ParamsDropdown
|
||||
placeholder="请选择"
|
||||
:options="handleOptions"
|
||||
:tabsOptions="tabOptions"
|
||||
:metricOptions="upperOptions"
|
||||
|
@ -42,7 +41,7 @@
|
|||
@select="onValueChange"
|
||||
>
|
||||
<template v-slot="{ label }">
|
||||
<j-input :value="label" />
|
||||
<j-input :value="label" placeholder="请选择" />
|
||||
</template>
|
||||
</ParamsDropdown>
|
||||
</j-form-item>
|
||||
|
@ -73,7 +72,7 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:value']);
|
||||
const emit = defineEmits(['update:value', 'change']);
|
||||
|
||||
const propertyFormRef = ref();
|
||||
|
||||
|
@ -83,6 +82,7 @@ const propertyModelRef = reactive({
|
|||
source: 'fixed',
|
||||
});
|
||||
|
||||
|
||||
const getType = computed(() => {
|
||||
return props.metadata.properties.find(
|
||||
(item: any) => item.id === propertyModelRef.properties,
|
||||
|
@ -154,7 +154,7 @@ const handleOptions = computed(() => {
|
|||
|
||||
const onChange = () => {
|
||||
propertyModelRef.propertiesValue = undefined;
|
||||
propertyModelRef.source = 'fixed'
|
||||
propertyModelRef.source = 'fixed';
|
||||
emit('update:value', {
|
||||
[`${propertyModelRef.properties}`]: {
|
||||
value: propertyModelRef?.propertiesValue,
|
||||
|
@ -169,8 +169,9 @@ const onValueChange = () => {
|
|||
value: propertyModelRef?.propertiesValue,
|
||||
source: propertyModelRef?.source,
|
||||
},
|
||||
}
|
||||
};
|
||||
emit('update:value', obj);
|
||||
emit('change', propertyModelRef?.propertiesValue)
|
||||
};
|
||||
|
||||
watch(
|
||||
|
@ -187,4 +188,19 @@ watch(
|
|||
},
|
||||
{ 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>
|
|
@ -22,7 +22,7 @@
|
|||
showSearch
|
||||
placeholder="请选择功能"
|
||||
v-model:value="modelRef.message.functionId"
|
||||
@select='functionSelect'
|
||||
@select="functionSelect"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in metadata?.functions || []"
|
||||
|
@ -56,7 +56,9 @@
|
|||
v-model:value="modelRef.message.properties[0]"
|
||||
>
|
||||
<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"
|
||||
:key="item?.id"
|
||||
>{{ item?.name }}</j-select-option
|
||||
|
@ -66,9 +68,11 @@
|
|||
</template>
|
||||
<template v-else-if="deviceMessageType === 'WRITE_PROPERTY'">
|
||||
<WriteProperty
|
||||
ref="writeFormRef"
|
||||
v-model:value="modelRef.message.properties"
|
||||
:metadata="metadata"
|
||||
:builtInList="builtInList"
|
||||
@change="onWriteChange"
|
||||
/>
|
||||
</template>
|
||||
</j-form>
|
||||
|
@ -83,7 +87,7 @@ import EditTable from './EditTable.vue';
|
|||
import WriteProperty from './WriteProperty.vue';
|
||||
import { useSceneStore } from '@/store/scene';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getParams } from '../../../util'
|
||||
import { getParams } from '../../../util';
|
||||
|
||||
const sceneStore = useSceneStore();
|
||||
const { data } = storeToRefs(sceneStore);
|
||||
|
@ -137,26 +141,39 @@ const modelRef = reactive({
|
|||
properties: undefined,
|
||||
inputs: [],
|
||||
},
|
||||
propertiesValue: '',
|
||||
});
|
||||
|
||||
const functionSelect = () => {
|
||||
modelRef.message.inputs = []
|
||||
}
|
||||
const writeFormRef = ref();
|
||||
|
||||
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)
|
||||
if (hasValue) {
|
||||
const functionItem = functions.value.find((item: any) => item.id === hasValue.name)
|
||||
return Promise.reject(functionItem?.name ? `请输入${functionItem.name}值` : '请输入功能值')
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}]
|
||||
const functionSelect = () => {
|
||||
modelRef.message.inputs = [];
|
||||
};
|
||||
|
||||
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,
|
||||
);
|
||||
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<{
|
||||
functions: any[];
|
||||
|
@ -205,15 +222,15 @@ const queryBuiltIn = async () => {
|
|||
action: props.name - 1,
|
||||
};
|
||||
const _data = await getParams(_params, unref(data));
|
||||
builtInList.value = _data
|
||||
builtInList.value = _data;
|
||||
};
|
||||
|
||||
const onMessageTypeChange = (val: string) => {
|
||||
const flag = ['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val)
|
||||
const flag = ['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(val);
|
||||
modelRef.message = {
|
||||
messageType: val,
|
||||
functionId: undefined,
|
||||
properties:(flag ? undefined : []) as any,
|
||||
properties: (flag ? undefined : []) as any,
|
||||
inputs: [],
|
||||
};
|
||||
if (flag) {
|
||||
|
@ -251,7 +268,11 @@ watch(
|
|||
(newVal) => {
|
||||
if (newVal?.messageType) {
|
||||
modelRef.message = newVal;
|
||||
if (['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(newVal.messageType)) {
|
||||
if (
|
||||
['WRITE_PROPERTY', 'INVOKE_FUNCTION'].includes(
|
||||
newVal.messageType,
|
||||
)
|
||||
) {
|
||||
queryBuiltIn();
|
||||
}
|
||||
}
|
||||
|
@ -259,11 +280,21 @@ watch(
|
|||
{ immediate: true },
|
||||
);
|
||||
|
||||
const onWriteChange = (val: string) => {
|
||||
modelRef.propertiesValue = val;
|
||||
};
|
||||
|
||||
const onFormSave = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then((_data: any) => {
|
||||
.then(async (_data: any) => {
|
||||
if (writeFormRef.value) {
|
||||
const _val = await writeFormRef.value?.onSave();
|
||||
if (!_val) {
|
||||
reject(false);
|
||||
}
|
||||
}
|
||||
// 处理三种情况的值的格式
|
||||
const obj = {
|
||||
message: {
|
||||
|
@ -273,6 +304,7 @@ const onFormSave = () => {
|
|||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||
? _function.value?.name
|
||||
: _property.value?.name,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
},
|
||||
};
|
||||
resolve(obj);
|
||||
|
|
|
@ -77,12 +77,12 @@ type Emit = {
|
|||
|
||||
const actionRef = ref();
|
||||
const params = ref({
|
||||
terms: []
|
||||
terms: [],
|
||||
});
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: Array as PropType<any>,
|
||||
default: []
|
||||
default: [],
|
||||
},
|
||||
detail: {
|
||||
type: Object,
|
||||
|
@ -90,8 +90,8 @@ const props = defineProps({
|
|||
},
|
||||
productId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits<Emit>();
|
||||
|
@ -143,9 +143,9 @@ const handleSearch = (p: any) => {
|
|||
...p,
|
||||
terms: [
|
||||
...p.terms,
|
||||
{terms: [{ column: 'productId', value: props?.productId }]}
|
||||
]
|
||||
}
|
||||
{ terms: [{ column: 'productId', value: props?.productId }] },
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
const deviceQuery = (p: any) => {
|
||||
|
@ -162,19 +162,26 @@ const deviceQuery = (p: any) => {
|
|||
};
|
||||
|
||||
const handleClick = (detail: any) => {
|
||||
emit('update:value', [{ value: detail.id, name: detail.name }]);
|
||||
emit('change', detail);
|
||||
if (props.value?.[0]?.value === detail.id) {
|
||||
emit('update:value', undefined);
|
||||
emit('change', {});
|
||||
} else {
|
||||
emit('update:value', [{ value: detail.id, name: detail.name }]);
|
||||
emit('change', detail);
|
||||
}
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
params.value = {
|
||||
...params.value,
|
||||
terms: params.value?.terms ? [
|
||||
...(params.value.terms || []),
|
||||
{terms: [{ column: 'productId', value: props?.productId }]}
|
||||
] : [{terms: [{ column: 'productId', value: props?.productId }]}]
|
||||
}
|
||||
})
|
||||
terms: params.value?.terms
|
||||
? [
|
||||
...(params.value.terms || []),
|
||||
{ terms: [{ column: 'productId', value: props?.productId }] },
|
||||
]
|
||||
: [{ terms: [{ column: 'productId', value: props?.productId }] }],
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang='less'>
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
<div class="'way-item-title">
|
||||
<span class="way-item-label">{{ item.label }}</span>
|
||||
<j-popover v-if="item.tip">
|
||||
<AIcon
|
||||
type="QuestionCircleOutlined"
|
||||
class="way-item-icon"
|
||||
/>
|
||||
<j-tooltip :title="item.tip">
|
||||
<AIcon
|
||||
type="QuestionCircleOutlined"
|
||||
class="way-item-icon"
|
||||
/>
|
||||
</j-tooltip>
|
||||
</j-popover>
|
||||
</div>
|
||||
<div class="way-item-image">
|
||||
|
@ -54,7 +56,7 @@ const _value = ref(props?.value || '');
|
|||
watch(
|
||||
() => props.value,
|
||||
(newValue) => {
|
||||
_value.value = newValue || ""
|
||||
_value.value = newValue || '';
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
@ -63,7 +65,7 @@ const onSelect = (_type: string) => {
|
|||
if (!props.disabled) {
|
||||
_value.value = _type;
|
||||
emits('update:value', _type);
|
||||
emits('change', _type)
|
||||
emits('change', _type);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -13,17 +13,18 @@
|
|||
@change="onSelectorChange"
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
<!-- <j-form-item
|
||||
v-if="modelRef.selector === 'fixed'"
|
||||
name="selectorValues"
|
||||
:rules="[{ required: true, message: '请选择设备' }]"
|
||||
>
|
||||
<Device
|
||||
:productId="values.productDetail.id"
|
||||
v-model:value="modelRef.selectorValues"
|
||||
@change="onDeviceChange"
|
||||
/>
|
||||
</j-form-item>
|
||||
> -->
|
||||
<Device
|
||||
v-if="modelRef.selector === 'fixed'"
|
||||
:productId="values.productDetail.id"
|
||||
v-model:value="modelRef.selectorValues"
|
||||
@change="onDeviceChange"
|
||||
/>
|
||||
<!-- </j-form-item> -->
|
||||
<j-form-item
|
||||
v-else-if="modelRef.selector === 'relation'"
|
||||
label="关系"
|
||||
|
@ -78,7 +79,7 @@
|
|||
import { useSceneStore } from '@/store/scene';
|
||||
import TopCard from './TopCard.vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getImage } from '@/utils/comm';
|
||||
import { getImage, onlyMessage } from '@/utils/comm';
|
||||
import NoticeApi from '@/api/notice/config';
|
||||
import Device from './Device.vue';
|
||||
import Tag from './Tag.vue';
|
||||
|
@ -318,7 +319,19 @@ const onFormSave = () => {
|
|||
formRef.value
|
||||
.validate()
|
||||
.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) => {
|
||||
reject(err);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
v-if="current === 0"
|
||||
v-model:rowKey="DeviceModel.productId"
|
||||
v-model:detail="DeviceModel.productDetail"
|
||||
@change="onProductChange"
|
||||
/>
|
||||
<Device
|
||||
v-else-if="current === 1"
|
||||
|
@ -173,9 +174,9 @@ const onSave = (_data: any) => {
|
|||
_options.type = '设置';
|
||||
_options.properties = _data.message.propertiesName;
|
||||
_options.propertiesValue =
|
||||
typeof DeviceModel.propertiesValue === 'object'
|
||||
? JSON.stringify(DeviceModel.propertiesValue)
|
||||
: `${DeviceModel.propertiesValue}`;
|
||||
typeof _data.message.propertiesValue === 'object'
|
||||
? JSON.stringify(_data.message.propertiesValue)
|
||||
: `${_data.message.propertiesValue}`;
|
||||
_options.columns = DeviceModel.columns;
|
||||
_options.otherColumns = DeviceModel.columns;
|
||||
const cur: any = Object.values(_data.message.properties)?.[0];
|
||||
|
@ -184,13 +185,6 @@ const onSave = (_data: any) => {
|
|||
}
|
||||
}
|
||||
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) => ({
|
||||
name: it.column || it.name,
|
||||
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
|
||||
|
@ -203,6 +197,11 @@ const onSave = (_data: any) => {
|
|||
emit('save', item, _options);
|
||||
};
|
||||
|
||||
const onProductChange = () => {
|
||||
DeviceModel.selectorValues = undefined
|
||||
DeviceModel.message = {}
|
||||
}
|
||||
|
||||
const save = async (step?: number) => {
|
||||
let _step = step !== undefined ? step : current.value;
|
||||
if (_step === 0) {
|
||||
|
@ -213,8 +212,10 @@ const save = async (step?: number) => {
|
|||
if (deviceRef.value) {
|
||||
await deviceRef.value?.onFormSave();
|
||||
current.value = 2;
|
||||
} else if (DeviceModel.selectorValues.length) {
|
||||
} else if (DeviceModel.selectorValues?.length) {
|
||||
current.value = 2;
|
||||
} else {
|
||||
onlyMessage('请选择设备', 'error')
|
||||
}
|
||||
} else {
|
||||
if (actionRef.value) {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
:rules="[
|
||||
{
|
||||
validator: (_rule, value) => checkValue(_rule, value, item),
|
||||
trigger: ['change', 'blur']
|
||||
trigger: ['change', 'blur'],
|
||||
},
|
||||
]"
|
||||
>
|
||||
|
@ -22,6 +22,7 @@
|
|||
:notify="notify"
|
||||
v-if="getType(item) === 'user'"
|
||||
v-model:value="modelRef[item.id]"
|
||||
@change="(val) => onChange(val, 'user')"
|
||||
/>
|
||||
<Org
|
||||
:notify="notify"
|
||||
|
@ -78,7 +79,7 @@ const formRef = ref();
|
|||
const modelRef = reactive({});
|
||||
|
||||
watchEffect(() => {
|
||||
Object.assign(modelRef, props.value);
|
||||
Object.assign(modelRef, props?.value);
|
||||
});
|
||||
|
||||
const getType = (item: any) => {
|
||||
|
@ -102,34 +103,41 @@ const checkValue = (_rule: any, value: any, item: any) => {
|
|||
return Promise.reject(new Error('请选择' + item.name));
|
||||
} else {
|
||||
if (value?.source === 'upper') {
|
||||
if (!value.upperKey) {
|
||||
if (!value?.upperKey) {
|
||||
return Promise.reject(new Error('请选择' + item.name));
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
} else {
|
||||
if (!value.value) {
|
||||
if (!value?.value) {
|
||||
return Promise.reject(new Error('请选择' + item.name));
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value?.source === 'fixed' && !value.value) {
|
||||
} else if (value?.source === 'fixed' && !value?.value) {
|
||||
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));
|
||||
} else if (value?.source === 'upper' && !value.upperKey) {
|
||||
return Promise.reject(new Error('请选择' + item.name));
|
||||
} else if (type === 'user') {
|
||||
if (props.notify.notifyType === 'email' && value?.source !== 'relation') {
|
||||
if (Array.isArray(value.value)) {
|
||||
if (!value.value.length) {
|
||||
if (
|
||||
props.notify.notifyType === 'email' &&
|
||||
value?.source !== 'relation'
|
||||
) {
|
||||
if (Array.isArray(value?.value)) {
|
||||
if (!value?.value.length) {
|
||||
return Promise.reject(new Error('请输入收件人'));
|
||||
}
|
||||
const reg =
|
||||
/^[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);
|
||||
});
|
||||
if (!flag) {
|
||||
|
@ -143,10 +151,11 @@ const checkValue = (_rule: any, value: any, item: any) => {
|
|||
}
|
||||
if (
|
||||
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}$/;
|
||||
if (!reg.test(value.value)) {
|
||||
if (!reg.test(value?.value)) {
|
||||
return Promise.reject(new Error('请输入正确的手机号码'));
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
|
@ -161,12 +170,14 @@ const onChange = (val: any, type: any) => {
|
|||
emit('change', { orgName: val.join(',') });
|
||||
} else if (type === 'tag') {
|
||||
emit('change', { tagName: val });
|
||||
} else if (type === 'user') {
|
||||
emit('change', { sendTo: val });
|
||||
}
|
||||
};
|
||||
|
||||
const onSave = () =>
|
||||
new Promise((resolve) => {
|
||||
formRef.value.validate().then(async (_data: any) => {
|
||||
formRef.value?.validate().then(async (_data: any) => {
|
||||
resolve(_data);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,21 +33,59 @@
|
|||
固定号码
|
||||
</j-select-option>
|
||||
</j-select>
|
||||
<j-tree-select
|
||||
v-if="source === 'relation'"
|
||||
style="width: calc(100% - 120px)"
|
||||
placeholder="请选择收信人"
|
||||
@select="(key, node) => onChange(source, key, false, node?.relation, node.name)"
|
||||
:tree-data="treeData"
|
||||
:multiple="['email'].includes(notifyType)"
|
||||
: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 v-if="source === 'relation'">
|
||||
<j-tree-select
|
||||
v-if="['email'].includes(notifyType)"
|
||||
style="width: calc(100% - 120px)"
|
||||
placeholder="请选择收信人"
|
||||
@change="(key, label) => onChange(source, key, false, label)"
|
||||
:tree-data="treeData"
|
||||
:multiple="true"
|
||||
: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>
|
||||
<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>
|
||||
<j-select
|
||||
style="width: calc(100% - 120px)"
|
||||
|
@ -55,7 +93,15 @@
|
|||
placeholder="请选择收信人"
|
||||
:value="value?.value"
|
||||
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"
|
||||
/>
|
||||
<j-select
|
||||
|
@ -64,14 +110,25 @@
|
|||
placeholder="请输入收件人邮箱,多个收件人用换行分隔"
|
||||
:value="value?.value"
|
||||
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
|
||||
style="width: calc(100% - 120px)"
|
||||
v-else-if="['sms', 'voice'].includes(notifyType)"
|
||||
placeholder="请输入固定号码"
|
||||
: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>
|
||||
</template>
|
||||
</j-input-group>
|
||||
|
@ -262,7 +319,7 @@ const onChange = (
|
|||
_name?: string,
|
||||
) => {
|
||||
let _values: any = undefined;
|
||||
const _names: string[] = [_name || ''];
|
||||
const _names: string[] = Array.isArray(_name) ? _name : [_name || ''];
|
||||
if (Array.isArray(_value)) {
|
||||
if (props?.notify?.notifyType === 'email') {
|
||||
if (isRelation) {
|
||||
|
@ -280,7 +337,7 @@ const onChange = (
|
|||
_values = getObj(_source, _value, isRelation);
|
||||
}
|
||||
emit('update:value', _values);
|
||||
emit('change', { sendTo: _names.filter((item) => !!item).join(',') });
|
||||
emit('change', _names.filter((item) => !!item).join(','));
|
||||
};
|
||||
|
||||
watch(
|
||||
|
|
Loading…
Reference in New Issue