perf: 显示逻辑展示优化 (#249)
This commit is contained in:
parent
b224077d19
commit
01eb1dda73
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="condition-wrapper" data-content-before="且">
|
<div
|
||||||
|
class="condition-wrapper"
|
||||||
|
:class="{ 'is-last': isLastCondition }"
|
||||||
|
:data-content-before="!isLastCondition ? '且' : ''"
|
||||||
|
>
|
||||||
<span class="desc">如果</span>
|
<span class="desc">如果</span>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
:prop="`conditions[${index}].field`"
|
:prop="`conditions[${index}].field`"
|
||||||
@ -11,8 +15,16 @@
|
|||||||
placeholder="请选择题目"
|
placeholder="请选择题目"
|
||||||
@change="(val: any) => handleChange(conditionNode, 'field', val)"
|
@change="(val: any) => handleChange(conditionNode, 'field', val)"
|
||||||
>
|
>
|
||||||
<el-option v-for="{ label, value } in fieldList" :key="value" :label="label" :value="value">
|
<el-option
|
||||||
|
v-for="{ label, value } in fieldList"
|
||||||
|
:key="value"
|
||||||
|
:label="label"
|
||||||
|
:value="value"
|
||||||
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
<template #empty>
|
||||||
|
无数据
|
||||||
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<span class="desc">选择了</span>
|
<span class="desc">选择了</span>
|
||||||
@ -32,8 +44,10 @@
|
|||||||
:key="value"
|
:key="value"
|
||||||
:label="label"
|
:label="label"
|
||||||
:value="value"
|
:value="value"
|
||||||
>
|
></el-option>
|
||||||
</el-option>
|
<template #empty>
|
||||||
|
无数据
|
||||||
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<span class="desc">中的任一选项 </span>
|
<span class="desc">中的任一选项 </span>
|
||||||
@ -112,6 +126,10 @@ const conditionValue = computed(() => {
|
|||||||
return props.conditionNode.value
|
return props.conditionNode.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isLastCondition = computed(() => {
|
||||||
|
return props.index === props.ruleNode.conditions.length - 1
|
||||||
|
})
|
||||||
|
|
||||||
const handleChange = (conditionNode: ConditionNode, key: string, value: any) => {
|
const handleChange = (conditionNode: ConditionNode, key: string, value: any) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'field':
|
case 'field':
|
||||||
@ -127,21 +145,34 @@ const handleChange = (conditionNode: ConditionNode, key: string, value: any) =>
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
props.ruleNode.addCondition(new ConditionNode())
|
props.ruleNode.addCondition(new ConditionNode())
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['delete'])
|
const emit = defineEmits(['delete'])
|
||||||
const handleDelete = (id: any) => {
|
const handleDelete = (id: any) => {
|
||||||
emit('delete', id)
|
emit('delete', id)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.condition-wrapper {
|
.condition-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 24px 0;
|
padding: 24px 0;
|
||||||
&:not(:last-child)::before {
|
&.is-last::before,
|
||||||
|
&.is-last::after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
width: calc(100% - 32px);
|
||||||
|
border-top: 1px dashed #e3e4e8;
|
||||||
|
position: absolute;
|
||||||
|
left: 32px;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
&:not(.is-last)::before {
|
||||||
content: attr(data-content-before);
|
content: attr(data-content-before);
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
@ -156,7 +187,7 @@ const handleDelete = (id: any) => {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -8px;
|
bottom: -8px;
|
||||||
}
|
}
|
||||||
&:not(:last-child)::after {
|
&:not(.is-last)::after {
|
||||||
content: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
width: calc(100% - 32px);
|
width: calc(100% - 32px);
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
:value="value"
|
:value="value"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
<template #empty>
|
||||||
|
无数据
|
||||||
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user