|
@@ -1,31 +1,28 @@
|
|
|
<template>
|
|
|
- <t-radio-group
|
|
|
- v-model="valueData"
|
|
|
- allow-uncheck
|
|
|
- :options="options"
|
|
|
- style="min-height: 32px; width: 100%"
|
|
|
- :disabled="!config.writable"
|
|
|
- @change="emitChange"
|
|
|
- >
|
|
|
- <t-radio
|
|
|
- v-for="item in config.options"
|
|
|
- :value="item.value"
|
|
|
- :key="item.value"
|
|
|
- >{{ item.label }}</t-radio
|
|
|
+ <div style="width: 100%">
|
|
|
+ <t-radio-group
|
|
|
+ v-model="valueData"
|
|
|
+ allow-uncheck
|
|
|
+ :options="options"
|
|
|
+ style="min-height: 32px; width: 100%"
|
|
|
+ :disabled="!config.writable"
|
|
|
+ @change="emitChange"
|
|
|
>
|
|
|
+ </t-radio-group>
|
|
|
<t-input
|
|
|
v-model="inputData"
|
|
|
:disabled="!config.writable"
|
|
|
placeholder="请填写具体内容"
|
|
|
+ @change="emitChange"
|
|
|
></t-input>
|
|
|
- </t-radio-group>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="RADIOWITHINPUT">
|
|
|
import { ref, computed, watch } from 'vue';
|
|
|
const props = defineProps({
|
|
|
config: { type: Object },
|
|
|
- modelValue: { type: String },
|
|
|
+ modelValue: { type: Object },
|
|
|
});
|
|
|
const emit = defineEmits(['update:modelValue', 'change']);
|
|
|
const valueData = ref('');
|
|
@@ -41,15 +38,21 @@ const options = computed(() => {
|
|
|
});
|
|
|
|
|
|
const emitChange = () => {
|
|
|
- emit('update:modelValue', valueData.value);
|
|
|
- emit('change', valueData.value);
|
|
|
+ const data = {
|
|
|
+ value: valueData.value,
|
|
|
+ input: inputData.value,
|
|
|
+ };
|
|
|
+
|
|
|
+ emit('update:modelValue', data);
|
|
|
+ emit('change', data);
|
|
|
};
|
|
|
|
|
|
watch(
|
|
|
() => props.modelValue,
|
|
|
(val, oldval) => {
|
|
|
if (val === oldval) return;
|
|
|
- valueData.value = val || null;
|
|
|
+ valueData.value = val?.value || '';
|
|
|
+ inputData.value = val?.input || '';
|
|
|
},
|
|
|
{
|
|
|
immediate: true,
|