fix: 优化场景联动布尔值
This commit is contained in:
parent
683751af53
commit
84e5a57c67
|
@ -211,7 +211,9 @@ const dateChange = (e: any) => {
|
|||
emit('change', e)
|
||||
}
|
||||
|
||||
myValue.value = props.modelValue
|
||||
watch(() => props.modelValue, () => {
|
||||
myValue.value = props.modelValue
|
||||
}, { immediate: true })
|
||||
|
||||
if (props.itemType === 'object') {
|
||||
objectValue.value = props.modelValue as string
|
||||
|
|
|
@ -75,16 +75,18 @@ const formModel = reactive({
|
|||
functionData: props.functionParameters
|
||||
})
|
||||
|
||||
const handlePropertiesOptions = (propertiesItem: any) => {
|
||||
const _type = propertiesItem?.valueType.type
|
||||
const handlePropertiesOptions = (propertiesValueType: any) => {
|
||||
const _type = propertiesValueType?.type
|
||||
if (_type === 'boolean') {
|
||||
return [
|
||||
{ label: propertiesItem.valueType.falseText || '是', value: propertiesItem.valueType.falseValue || false },
|
||||
{ label: propertiesItem.valueType.trueText || '否', value: propertiesItem.valueType.trueValue || true },
|
||||
{ label: propertiesValueType?.falseText || '是', value: propertiesValueType?.falseValue || false },
|
||||
{ label: propertiesValueType?.trueText || '否', value: propertiesValueType?.trueValue || true },
|
||||
]
|
||||
} else if (_type === 'enum') {
|
||||
return propertiesValueType?.elements?.map((a: any) => ({ ...a, label: a.text }))
|
||||
}
|
||||
|
||||
return propertiesItem.valueType?.elements
|
||||
return propertiesValueType?.elements
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,14 +97,14 @@ const functionData = computed(() => {
|
|||
const arrCache = []
|
||||
|
||||
if (functionItem) {
|
||||
const properties = functionItem.valueType ? functionItem.valueType.properties : functionItem.inputs;
|
||||
const properties = functionItem.input?.properties || functionItem.inputs;
|
||||
for (const datum of properties) {
|
||||
arrCache.push({
|
||||
id: datum.id,
|
||||
name: datum.name,
|
||||
type: datum.valueType ? datum.valueType.type : '-',
|
||||
format: datum.valueType ? datum.valueType.format : undefined,
|
||||
options: handlePropertiesOptions(datum),
|
||||
type: datum.valueType?.type || '-',
|
||||
format: datum.valueType?.format || undefined,
|
||||
options: handlePropertiesOptions(datum.valueType),
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
|
@ -113,12 +115,10 @@ const functionData = computed(() => {
|
|||
|
||||
const rules = [{
|
||||
validator(_: string, value: any) {
|
||||
console.log(value)
|
||||
if (!value?.length && functionData.value.length) {
|
||||
return Promise.reject('请输入功能值')
|
||||
} else {
|
||||
let hasValue = value.find((item: { name: string, value: any}) => item.value === undefined)
|
||||
console.log('hasValue', hasValue)
|
||||
if (hasValue) {
|
||||
const functionItem = functionData.value.find((item: any) => item.id === hasValue.name)
|
||||
return Promise.reject(functionItem?.name ? `请输入${functionItem?.name}值` : '请输入功能值')
|
||||
|
|
|
@ -75,18 +75,32 @@ const callData = ref<Array<{ id: string, value: string | undefined }>>()
|
|||
const writeForm = ref()
|
||||
const _value = ref([])
|
||||
|
||||
const handleOptions = (item: any, type: string) => {
|
||||
if (type === 'enum') {
|
||||
return item.valueType.elements?.map((a: any) => ({ ...a, label: a.text }))
|
||||
} else if (type === 'boolean') {
|
||||
return [
|
||||
{ label: item.valueType.trueText, value: item.valueType.trueValue },
|
||||
{ label: item.valueType.falseText, value: item.valueType.falseValue },
|
||||
]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
const callDataOptions = computed(() => {
|
||||
const _valueKeys = Object.keys(props.value)
|
||||
if (_valueKeys.length) {
|
||||
return _valueKeys.map(key => {
|
||||
const item: any = props.properties.find((p: any) => p.id === key)
|
||||
console.log(item, props.value, key)
|
||||
if (item) {
|
||||
const _options = handleOptions(item, item.valueType?.type)
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: item.valueType ? item.valueType.type : '-',
|
||||
format: item.valueType ? item.valueType.format : undefined,
|
||||
options: item.valueType ? item.valueType.element : undefined,
|
||||
options: _options,
|
||||
value: props.value[key]
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +110,7 @@ const callDataOptions = computed(() => {
|
|||
type: '',
|
||||
format: undefined,
|
||||
options: undefined,
|
||||
value: props.value[key]
|
||||
value: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<ValueItem
|
||||
v-model:modelValue='record.value'
|
||||
:itemType="record.type"
|
||||
:options="handleOptions(record)"
|
||||
:options="record.options"
|
||||
@change='valueChange'
|
||||
/>
|
||||
</div>
|
||||
|
@ -87,17 +87,6 @@ const columns = [
|
|||
},
|
||||
]
|
||||
|
||||
const handleOptions = (record: any) => {
|
||||
switch(record.type) {
|
||||
case 'enum':
|
||||
return (record?.options?.elements || []).map((item: any) => ({ label: item.text, value: item.value }))
|
||||
case 'boolean':
|
||||
return record?.options
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
const valueChange = () => {
|
||||
const _value = dataSource.value.map(item => {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue