ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script lang="ts" setup>
import { ref } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
import { BasicTitle, ScrollContainer } from '@jnpf/ui';
import { BasicForm, useForm } from '@jnpf/ui/form';
 
import { Space as ASpace } from 'ant-design-vue';
 
import { getDictionaryType } from '#/api/systemData/dictionary';
import { $t } from '#/locales';
 
import { getFormSchema } from './schemaData';
 
defineOptions({ name: 'ExtendFormDemoFieldForm1' });
 
const { createMessage } = useMessage();
const loading = ref(false);
const btnLoading = ref(false);
const [registerForm, { resetFields, validate, updateSchema }] = useForm({
  labelWidth: 100,
  labelAlign: 'right',
  schemas: getFormSchema(),
});
 
function initData() {
  getDictionaryType().then((res) => {
    const treeData = res.data.list;
    updateSchema({ field: 'fieldTreeSelect', componentProps: { options: treeData } });
    updateSchema({ field: 'fieldCascader', componentProps: { options: treeData } });
  });
}
async function handleSubmit() {
  const values = await validate();
  if (!values) return;
  btnLoading.value = true;
  setTimeout(() => {
    btnLoading.value = false;
  }, 1000);
  createMessage.success('请在控制台查看!');
}
 
initData();
</script>
<template>
  <div class="jnpf-content-wrapper jnpf-content-wrapper-form">
    <div class="jnpf-common-page-header">
      <BasicTitle>表单示例</BasicTitle>
      <ASpace>
        <a-button :loading="btnLoading" type="primary" @click="handleSubmit">{{ $t('common.okText') }}</a-button>
        <a-button @click="resetFields">{{ $t('common.resetText') }}</a-button>
      </ASpace>
    </div>
    <div class="jnpf-content-wrapper-form-body">
      <ScrollContainer v-loading="loading">
        <div class="p-[10px]">
          <BasicForm @register="registerForm" />
        </div>
      </ScrollContainer>
    </div>
  </div>
</template>