diff --git a/apps/example/src/router/modules/feature.example.ts b/apps/example/src/router/modules/feature.example.ts index fb9fdf10..222edf87 100755 --- a/apps/example/src/router/modules/feature.example.ts +++ b/apps/example/src/router/modules/feature.example.ts @@ -31,15 +31,6 @@ const routes: RouteRecordRaw = { icon: 'i-mdi:regex', }, }, - { - path: 'tableautoheight', - name: 'featureExampleTableautoheight', - component: () => import('@/views/feature_example/table.autoheight.vue'), - meta: { - title: '表格高度自适应', - icon: 'i-tabler:arrow-autofit-height', - }, - }, { path: 'reload', name: 'featureExampleReload', diff --git a/apps/example/src/views/feature_example/rules.vue b/apps/example/src/views/feature_example/rules.vue index 796b9b73..c48a7d84 100755 --- a/apps/example/src/views/feature_example/rules.vue +++ b/apps/example/src/views/feature_example/rules.vue @@ -458,23 +458,14 @@ const dialog = ref({ form: { test: '', }, - formRules: { - test: [ - { - validator: (_rule: any, value: any, callback: any) => { - if (rules.value[dialog.value.index].rule.test(value)) { - callback() - } - else { - callback(new Error('不通过')) - } - }, - trigger: 'change', - }, - ], - }, }) +const validationSchema = { + test(value: string) { + return rules.value[dialog.value.index].rule.test(value) ? true : '不通过' + }, +} + watch(copied, (val) => { val && useFaToast().success(`复制成功:${text.value}`) }) @@ -498,7 +489,7 @@ function open(url: string) { -
+
{{ item.rule }}
@@ -510,18 +501,12 @@ function open(url: string) {
- - - - - - - + + + + + + +
- - diff --git a/apps/example/src/views/feature_example/table.autoheight.vue b/apps/example/src/views/feature_example/table.autoheight.vue deleted file mode 100755 index f0dc39eb..00000000 --- a/apps/example/src/views/feature_example/table.autoheight.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - - - diff --git a/apps/example/src/views/plugin_example/currency.input.vue b/apps/example/src/views/plugin_example/currency.input.vue index f9fa6dd8..ccfd9b46 100755 --- a/apps/example/src/views/plugin_example/currency.input.vue +++ b/apps/example/src/views/plugin_example/currency.input.vue @@ -17,9 +17,11 @@ const Option = createReusableTemplate<{ const localeEnabled = ref(false) const locale = ref('zh-ZH') const locales = ref(['de-DE', 'de-CH', 'en-US', 'en-IN', 'nl-NL', 'sv-SE', 'fr-FR', 'es-ES', 'pt-PT', 'pt-BR', 'zh-ZH', 'ja-JP', 'ar-SA', 'fa-IR', 'bg-BG']) +const localeOptions = computed(() => locales.value.map(item => ({ label: item, value: item }))) const currency = ref('CNY') const currencies = ref(['EUR', 'USD', 'GBP', 'BRL', 'INR', 'CNY', 'JPY', 'SAR', 'IRR', 'BGN']) +const currencyOptions = computed(() => currencies.value.map(item => ({ label: item, value: item }))) const currencyDisplay = ref('symbol') const currencyDisplays = ref([ @@ -40,8 +42,24 @@ const hideNegligibleDecimalDigitsOnFocus = ref(true) const hideNegligibleDecimalDigitsOnFocusEnabled = ref(true) const valueRangeEnabled = ref(false) -const minValue = ref(undefined) -const maxValue = ref(undefined) +const minValue = ref() +const maxValue = ref() +const minNumberValue = computed({ + get() { + return minValue.value ?? 0 + }, + set(value: number) { + minValue.value = value + }, +}) +const maxNumberValue = computed({ + get() { + return maxValue.value ?? 0 + }, + set(value: number) { + maxValue.value = value + }, +}) const precisionEnabled = ref(false) const precisionRangeEnabled = ref(false) @@ -51,6 +69,7 @@ function range(from: number, to: number) { } const precision = ref(2) const precisionOptions = computed(() => range(1, 16)) +const precisionSelectOptions = computed(() => precisionOptions.value.map(item => ({ label: String(item), value: item }))) const valueScalingEnabled = ref(false) const valueScaling = ref('precision') @@ -74,8 +93,8 @@ const options = computed(() => { currencyDisplay: currencyDisplay.value, valueRange: valueRangeEnabled.value ? { - min: minValue.value === '' ? undefined : minValue.value, - max: maxValue.value === '' ? undefined : maxValue.value, + min: minValue.value, + max: maxValue.value, } : undefined, precision: precisionEnabled.value @@ -93,8 +112,22 @@ const options = computed(() => { } }) -// @ts-expect-error inputRef -const { inputRef, setValue, setOptions, numberValue, formattedValue } = useCurrencyInput(options.value as CurrencyInputOptions) +const currencyInputRef = useTemplateRef<{ ref?: HTMLInputElement }>('currencyInputRef') +const { inputRef: currencyNativeInputRef, setValue, setOptions, numberValue, formattedValue } = useCurrencyInput(options.value as CurrencyInputOptions) +const formattedInputValue = computed({ + get() { + return formattedValue.value ?? '' + }, + set(value: string) { + formattedValue.value = value + }, +}) + +watch(currencyInputRef, (value) => { + currencyNativeInputRef.value = value?.ref ?? null +}, { + flush: 'post', +}) watch(options, (value) => { setOptions(value as CurrencyInputOptions) @@ -106,7 +139,8 @@ watch(numberValue, (val) => { immediate: true, }) -onMounted(() => { +onMounted(async () => { + await nextTick() numberValue.value = 1234.5 }) @@ -154,7 +188,7 @@ function open(url: string) {
- +
数值:{{ numberValue != null ? numberValue : 'null' }}
@@ -164,87 +198,85 @@ function open(url: string) {
- - - + - - - + - - - +
- + + 隐藏货币符号 +
- + + 隐藏分组分隔符 +
- + + 隐藏可忽略的小数位数 +
- + to - +
-
- - - - - +
+ + 使用范围 + + +
- - - +
diff --git a/apps/example/src/views/standard_module_example/components/DetailForm/index.vue b/apps/example/src/views/standard_module_example/components/DetailForm/index.vue index 77b789a1..71d07cf2 100755 --- a/apps/example/src/views/standard_module_example/components/DetailForm/index.vue +++ b/apps/example/src/views/standard_module_example/components/DetailForm/index.vue @@ -1,5 +1,5 @@ diff --git a/apps/example/src/views/standard_module_example/detail.vue b/apps/example/src/views/standard_module_example/detail.vue index 083e391f..c4bb6d38 100755 --- a/apps/example/src/views/standard_module_example/detail.vue +++ b/apps/example/src/views/standard_module_example/detail.vue @@ -12,7 +12,11 @@ const router = useRouter() const formRef = useTemplateRef('formRef') function onSubmit() { - formRef.value?.submit().then(() => { + formRef.value?.submit().then((success) => { + if (!success) { + return + } + eventBus.emit('get-data-list') onCancel() }) @@ -34,11 +38,9 @@ function onCancel() { - - - - - +
+ +
diff --git a/apps/example/src/views/standard_module_example/list.vue b/apps/example/src/views/standard_module_example/list.vue index b1a8c06d..899c2ac8 100755 --- a/apps/example/src/views/standard_module_example/list.vue +++ b/apps/example/src/views/standard_module_example/list.vue @@ -122,7 +122,11 @@ const { open: openModal, update: updateModal } = useFaModal().create({ beforeClose: (action, done) => { if (action === 'confirm') { // 调用 DetailForm 组件内部 submit 方法 - formRef.value?.submit().then(() => { + formRef.value?.submit().then((success) => { + if (!success) { + return + } + getDataList() done() }) @@ -144,7 +148,11 @@ const { open: openDrawer, update: updateDrawer } = useFaDrawer().create({ beforeClose: (action, done) => { if (action === 'confirm') { // 调用 DetailForm 组件内部 submit 方法 - formRef.value?.submit().then(() => { + formRef.value?.submit().then((success) => { + if (!success) { + return + } + getDataList() done() })