diff --git a/src/components/GuipRadio.vue b/src/components/GuipRadio.vue
index e5b286c..018e88b 100644
--- a/src/components/GuipRadio.vue
+++ b/src/components/GuipRadio.vue
@@ -1,13 +1,10 @@
-
+
-
- {{ getLabel(option) }}
+
+ {{ getLabel(optionValue) }}
@@ -18,17 +15,19 @@ export default {
name: 'MyRadioGroup',
props: {
// 是否是纵向排列
- column:{
- type:String,
- default:''
+ column: {
+ type: String,
+ default: ''
},
- required:{
- type:Boolean,
- default:false
+ required: {
+ type: Boolean,
+ default: false
},
- // 选项列表,格式为 [{ label: '显示文本', value: '值', disabled: false }]
+ // 选项列表,支持多种格式:
+ // 1. 数组格式: [{ label: '显示文本', value: '值', disabled: false }]
+ // 2. 对象格式: { key1: 'value1', key2: 'value2' }
options: {
- type: Array,
+ type: [Array, Object],
required: true,
},
// 当前选中的值,使用 v-model 绑定
@@ -64,19 +63,27 @@ export default {
formatter: {
type: Function,
default: null
+ },
+ // 禁用选项的key数组
+ disabledKeys: {
+ type: Array,
+ default: () => []
}
},
computed: {
- processedOptions() {
- return this.options.map(option => {
- if (this.formatter) {
- return {
- ...option,
- formattedLabel: this.formatter(option)
- }
- }
- return option
- })
+ // 统一处理数组和对象格式
+ normalizedOptions() {
+ // 数组
+ if (Array.isArray(this.options)) {
+ return this.options;
+ } else if (typeof this.options === 'object' && this.options !== null) {
+ // 将对象格式统一转换为数组
+ return Object.keys(this.options).map(key => ({
+ key,
+ value: this.options[key]
+ }));
+ }
+ return [];
}
},
data() {
@@ -97,12 +104,27 @@ export default {
this.$emit('change', value); // 触发 change 事件
},
getLabel(option) {
- if (this.formatter) return option.formattedLabel || this.formatter(option)
- return option[this.labelKey]
+ if (this.formatter) return this.formatter(option);
+
+ // 处理对象格式的选项
+ if (typeof option === 'object' && 'key' in option && 'value' in option) {
+ return option.value;
+ }
+
+ return option[this.labelKey] || option;
},
getValue(option) {
- return option[this.valueKey]
+ // 处理对象格式的选项
+ if (typeof option === 'object' && 'key' in option && 'value' in option) {
+ return option.key;
+ }
+
+ return option[this.valueKey] || option;
},
+ // 判断选项是否禁用
+ isDisabled(key) {
+ return this.disabledKeys.includes(key);
+ }
},
};
diff --git a/src/components/PreviewTab.vue b/src/components/PreviewTab.vue
new file mode 100644
index 0000000..1c317d3
--- /dev/null
+++ b/src/components/PreviewTab.vue
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/elementGroups.vue b/src/views/elementGroups.vue
index 1294688..b1f92bf 100644
--- a/src/views/elementGroups.vue
+++ b/src/views/elementGroups.vue
@@ -26,18 +26,33 @@
+
+
+
+
+
+
+ 电脑端内容-内容自定义
+
+
+ 内容自定义
+ 手机端端内容-- 手机端端内容
+
+
+
+
-
+
-
- 单选框2(数组格式 + 自定义取值):
+
@@ -537,6 +552,7 @@ import HoverButton from '@/components/HoverButton.vue'
import GuipFormItem from '@/components/GuipFormItem.vue'
import SvgIcon from '@/components/SvgIcon.vue';
import PromptText from "@/components/PromptText.vue";
+import DevicePreview from "@/components/PreviewTab.vue";
export default {
@@ -555,6 +571,7 @@ export default {
HoverButton,
SvgIcon,
GuipFormItem,
+ DevicePreview,
CustomDropdown
},
data() {
@@ -635,12 +652,16 @@ export default {
input2: '',
input3: '',
},
- languageOptions: [
+ languageOptions1: [
{ label: 'JavaScript', value: 'js', selectedLabel: 'JavaScripthhhhhhhhhh',id:'1',name:'麻辣烫' },
{ label: 'Python', value: 'py', selectedLabel: 'JavaScripthhhhhhhhhh',id:'10',name:'易烊千玺' },
{ label: 'Java', value: 'java', disabled: true, selectedLabel: 'JavaScripthhhhhhhhhh',id:'11',name:'王鹤di' }, // 禁用选项
{ label: 'Go', value: 'go', selectedLabel: 'JavaScripthhhhhhhhhh',id:'12',name:'王俊凯' },
],
+ languageOptions:{
+ '20':'查重站',
+ '31':'AI站'
+ },
rules: {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' }