Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 去除设置器中不存在的题目字段 #465

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions web/src/materials/setters/widgets/CheckBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
<el-checkbox
v-model="modelValue"
@change="handleCheckboxChange"
:disabled="checkBoxDis"
:class="{ inline: !!formConfig?.inline }"
>
</el-checkbox>
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'

Check warning on line 10 in web/src/materials/setters/widgets/CheckBox.vue

View workflow job for this annotation

GitHub Actions / Lint

'computed' is defined but never used
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'

interface Props {
Expand All @@ -24,46 +23,14 @@
const props = defineProps<Props>()

const modelValue = ref(props.formConfig.value)
const checkBoxDis = computed(
() =>
props.formConfig.key === 'randomSort' &&
props.moduleConfig?.optionOrigin?.length > 0 &&
props.moduleConfig?.extraOptions &&
props.moduleConfig?.extraOptions?.length === 0
)


const handleCheckboxChange = (value: boolean) => {
const key = props.formConfig.key

emit(FORM_CHANGE_EVENT_KEY, { key, value })
}

watch(
() => props.moduleConfig.optionOrigin,
(newVal) => {
const key = props.formConfig.key
const extraLen = props.moduleConfig?.extraOptions?.length

if (key === 'randomSort' && newVal && extraLen === 0) {
emit(FORM_CHANGE_EVENT_KEY, { key: 'randomSort', value: false })
modelValue.value = false
}
}
)

watch(
() => props.moduleConfig?.extraOptions?.length || [],
(newVal) => {
const key = props.formConfig.key
const origin = props.moduleConfig?.optionOrigin

if (key === 'randomSort' && origin && newVal === 0) {
emit(FORM_CHANGE_EVENT_KEY, { key: 'randomSort', value: false })
modelValue.value = false
}
}
)

watch(
() => props.formConfig.value,
(newVal: boolean) => {
Expand Down
4 changes: 0 additions & 4 deletions web/src/materials/setters/widgets/SelectSetter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ const emit = defineEmits<Emit>()
const placeholder = computed(() => {
const defaultValue = '请选择'

if (!['matrixOptionsRely', 'optionOrigin'].includes(props.formConfig.key)) {
return props.formConfig.label
}

return defaultValue
})

Expand Down
Loading