{
if (!props.maxNum) {
return false
@@ -57,7 +58,7 @@ export default defineComponent({
})
const isDisabled = (item) => {
const { value } = props
- return disableState.value && !includes(value, item.value)
+ return disableState.value && !includes(value, item.hash)
}
const myOptions = computed(() => {
const { options } = props
@@ -68,6 +69,20 @@ export default defineComponent({
}
})
})
+ // 兼容断点续答情况下选项配额为0的情况
+ watch(() => props.value, (value) => {
+ const disabledHash = myOptions.value.filter(i => i.disabled).map(i => i.hash)
+ if (value && disabledHash.length) {
+ disabledHash.forEach(hash => {
+ const index = value.indexOf(hash)
+ if( index> -1) {
+ const newValue = [...value]
+ newValue.splice(index, 1)
+ onChange(newValue)
+ }
+ })
+ }
+ })
const onChange = (value) => {
const key = props.field
emit('change', {
@@ -96,6 +111,7 @@ export default defineComponent({
return {
onChange,
handleSelectMoreChange,
+ disableState,
myOptions,
selectMoreView
}
@@ -111,6 +127,7 @@ export default defineComponent({
options={myOptions}
onChange={onChange}
value={value}
+ layout={this.layout}
quotaNoDisplay={quotaNoDisplay}
>
{{
diff --git a/web/src/materials/questions/widgets/CheckboxModule/meta.js b/web/src/materials/questions/widgets/CheckboxModule/meta.js
index 2af526de..e5561e53 100644
--- a/web/src/materials/questions/widgets/CheckboxModule/meta.js
+++ b/web/src/materials/questions/widgets/CheckboxModule/meta.js
@@ -1,5 +1,4 @@
import basicConfig from '@materials/questions/common/config/basicConfig'
-
const meta = {
title: '多选',
type: 'checkbox',
@@ -83,6 +82,12 @@ const meta = {
propType: Number,
description: '最多选择数',
defaultValue: 0
+ },
+ {
+ name: 'layout',
+ propType: String,
+ description: '排列方式',
+ defaultValue: 'vertical'
}
],
formConfig: [
@@ -92,21 +97,38 @@ const meta = {
title: '选项配置',
type: 'Customed',
content: [
+ {
+ label: '排列方式',
+ type: 'RadioGroup',
+ key: 'layout',
+ value: 'vertical',
+ options: [
+ {
+ label: '竖排',
+ value: 'vertical'
+ },
+ {
+ label: '横排',
+ value: 'horizontal'
+ },
+ ]
+ },
{
label: '至少选择数',
type: 'InputNumber',
key: 'minNum',
- value: '',
+ value: 0,
min: 0,
- max: 'maxNum',
+ max: moduleConfig => { return moduleConfig?.maxNum || 0 },
contentClass: 'input-number-config'
},
{
label: '最多选择数',
type: 'InputNumber',
key: 'maxNum',
- value: '',
- min: 'minNum',
+ value: 0,
+ min: moduleConfig => { return moduleConfig?.minNum || 0 },
+ max: moduleConfig => { return moduleConfig?.options?.length },
contentClass: 'input-number-config'
},
]
diff --git a/web/src/materials/questions/widgets/EditOptions/Options/OptionEditBar.vue b/web/src/materials/questions/widgets/EditOptions/Options/OptionEditBar.vue
index e9689c47..1e1405be 100644
--- a/web/src/materials/questions/widgets/EditOptions/Options/OptionEditBar.vue
+++ b/web/src/materials/questions/widgets/EditOptions/Options/OptionEditBar.vue
@@ -15,7 +15,7 @@
diff --git a/web/src/materials/setters/widgets/ELSwitch.vue b/web/src/materials/setters/widgets/ELSwitch.vue
deleted file mode 100644
index 719e8135..00000000
--- a/web/src/materials/setters/widgets/ELSwitch.vue
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/web/src/materials/setters/widgets/InputNumber.vue b/web/src/materials/setters/widgets/InputNumber.vue
index b34e02f8..b93bb080 100644
--- a/web/src/materials/setters/widgets/InputNumber.vue
+++ b/web/src/materials/setters/widgets/InputNumber.vue
@@ -13,6 +13,7 @@ import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
+
interface Props {
formConfig: any
moduleConfig: any
@@ -24,12 +25,15 @@ interface Emit {
const emit = defineEmits
()
const props = defineProps()
-const modelValue = ref(Number(props.formConfig.value) || 0)
+const modelValue = ref(Number(props.formConfig.value))
+
+const myModuleConfig = ref(props.moduleConfig)
+
const minModelValue = computed(() => {
const { min } = props.formConfig
- if (min) {
+ if (min !== undefined) {
if (typeof min === 'function') {
- return min(props.moduleConfig)
+ return min(myModuleConfig.value)
} else {
return Number(min)
}
@@ -38,16 +42,13 @@ const minModelValue = computed(() => {
})
const maxModelValue = computed(() => {
- const { max, min } = props.formConfig
-
+ const { max } = props.formConfig
if (max) {
if (typeof max === 'function') {
- return max(props.moduleConfig)
+ return max(myModuleConfig.value)
} else {
return Number(max)
}
- } else if (min !== undefined && Array.isArray(props.moduleConfig?.options)) {
- return props.moduleConfig.options.length
} else {
return Infinity
}
@@ -65,6 +66,9 @@ const handleInputChange = (value: number) => {
emit(FORM_CHANGE_EVENT_KEY, { key, value })
}
+watch(() => props.moduleConfig, (newVal) => {
+ myModuleConfig.value = newVal
+})
watch(
() => props.formConfig.value,
(newVal) => {
diff --git a/web/src/materials/setters/widgets/QuotaConfig.vue b/web/src/materials/setters/widgets/QuotaConfig.vue
index 86a54f54..e88cd39c 100644
--- a/web/src/materials/setters/widgets/QuotaConfig.vue
+++ b/web/src/materials/setters/widgets/QuotaConfig.vue
@@ -12,8 +12,12 @@
style="width: 100%"
@cell-click="handleCellClick"
>
-
-
+
+
+
+
+
+
配额设置
@@ -30,6 +34,7 @@
-
-