|
@@ -3,24 +3,13 @@ import WdButton from 'wot-design-uni/components/wd-button/wd-button.vue'
|
|
|
import WdInput from 'wot-design-uni/components/wd-input/wd-input.vue'
|
|
|
import WdPicker from 'wot-design-uni/components/wd-picker/wd-picker.vue'
|
|
|
import { ConfigProviderThemeVars } from 'wot-design-uni'
|
|
|
+import { DataFormProps } from './data-form'
|
|
|
+import { addUnit } from 'wot-design-uni/components/common/util'
|
|
|
|
|
|
const modelValue = defineModel({
|
|
|
type: Object,
|
|
|
default: () => ({}),
|
|
|
})
|
|
|
-// defineProps({
|
|
|
-// schema: {
|
|
|
-// type: Object as PropType<{
|
|
|
-// [key: string | symbol]: { type: 'TextField' | 'Submit' | string; label?: string; props?: any }
|
|
|
-// }>,
|
|
|
-// required: true,
|
|
|
-// default: () => ({}),
|
|
|
-// },
|
|
|
-// direction: {
|
|
|
-// type: String as PropType<'horizontal' | 'vertical'>,
|
|
|
-// default: 'vertical',
|
|
|
-// },
|
|
|
-// })
|
|
|
withDefaults(
|
|
|
defineProps<{
|
|
|
schema: {
|
|
@@ -28,7 +17,7 @@ withDefaults(
|
|
|
type: 'TextField' | 'Select' | 'Radio' | 'Submit' | 'timePick' | 'TimePick' | 'textarea'
|
|
|
label?: string
|
|
|
existing?: boolean
|
|
|
- props?: any
|
|
|
+ props?: DataFormProps
|
|
|
}
|
|
|
}
|
|
|
direction?: 'horizontal' | 'vertical'
|
|
@@ -78,6 +67,9 @@ const horizontalDefaultProps = {
|
|
|
Radio: {
|
|
|
customClass: 'my--4!',
|
|
|
},
|
|
|
+ TimePick: {
|
|
|
+ customClass: 'm-0!',
|
|
|
+ },
|
|
|
}
|
|
|
const themeVars: ConfigProviderThemeVars = {
|
|
|
cellPadding: '0',
|
|
@@ -103,22 +95,24 @@ defineExpose({
|
|
|
<div
|
|
|
v-if="existing ?? true"
|
|
|
class="grid mb-4"
|
|
|
- :class="[direction === 'horizontal' ? 'items-center' : '']"
|
|
|
+ :class="[direction === 'horizontal' ? 'items-start' : '']"
|
|
|
:style="
|
|
|
direction === 'horizontal'
|
|
|
- ? { 'grid-template-columns': `${props?.labelWidth} auto` }
|
|
|
+ ? { 'grid-template-columns': `${addUnit(props?.labelWidth)} auto` }
|
|
|
: {}
|
|
|
"
|
|
|
>
|
|
|
- <label
|
|
|
- v-if="type !== 'Submit'"
|
|
|
- class="text-sm font-normal leading-relaxed"
|
|
|
- :class="[direction === 'horizontal' ? 'text-black/60' : 'mb-1 text-black/40']"
|
|
|
- :for="prop"
|
|
|
- >
|
|
|
- <span v-if="props?.required" style="color: #ff2e2e">*</span>
|
|
|
- {{ label || prop }}
|
|
|
- </label>
|
|
|
+ <div class="flex items-center h-11">
|
|
|
+ <label
|
|
|
+ v-if="type !== 'Submit'"
|
|
|
+ class="text-sm font-normal leading-relaxed"
|
|
|
+ :class="[direction === 'horizontal' ? 'text-black/60' : 'mb-1 text-black/40']"
|
|
|
+ :for="prop"
|
|
|
+ >
|
|
|
+ <span v-if="props?.required" style="color: #ff2e2e">*</span>
|
|
|
+ {{ label || prop }}
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
<wd-input
|
|
|
v-if="type === 'TextField'"
|
|
|
v-bind="{
|