| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <script lang="ts" setup>
- import type { BasicForm } from '@/types/form'
- import useValidator from '@/hooks/useValidator'
- const validator = useValidator()
- const proFormRef = ref<any>()
- const handleSave = () => {
- proFormRef.value.submit()
- }
- const formData = reactive<any>({})
- const formConfig = reactive<BasicForm>({
- formItems: [
- {
- label: '',
- value: '',
- name: 'formSteps',
- type: 'form-steps',
- span: 24,
- props: {
- steps: [
- {
- title: 'step 1'
- },
- {
- title: 'step 2'
- },
- {
- title: 'step 3'
- }
- ],
- active: 0,
- simple: true
- },
- events: {
- submit: handleSave
- },
- children: [
- {
- label: '',
- value: '',
- name: '',
- type: 'form-group',
- span: 24,
- children: [
- {
- label: '付款账户',
- value: '',
- name: 'pay',
- type: 'input'
- },
- {
- label: '收款账户',
- value: '',
- name: 'account',
- type: 'input'
- },
- {
- label: '收款人姓名',
- value: '',
- name: 'name',
- type: 'input'
- },
- {
- label: '收款金额',
- value: '',
- name: 'sum',
- type: 'input'
- },
- {
- label: '',
- value: '',
- name: '',
- type: 'button',
- span: 24,
- props: {
- type: 'primary',
- buttonName: '下一步',
- class: 'mt-4',
- style: {
- marginLeft: '50%',
- transform: 'translateX(-50%)'
- }
- },
- events: {
- click: () => {
- formConfig.formItems[0].props.active = 1
- }
- }
- }
- ]
- },
- {
- label: '',
- value: '',
- name: '',
- type: 'form-group',
- children: [
- {
- label: '区域1',
- value: '',
- name: 'area1',
- type: 'area'
- },
- {
- label: '手机号',
- value: '',
- name: 'phone1',
- type: 'input',
- rules: [
- {
- validator: validator.mobile
- }
- ]
- },
- {
- label: '',
- value: '',
- name: '',
- type: 'button',
- span: 24,
- props: {
- type: 'primary',
- buttonName: '下一步',
- class: 'mt-4',
- style: {
- marginLeft: '50%',
- transform: 'translateX(-50%)'
- }
- },
- events: {
- click: () => {
- formConfig.formItems[0].props.active = 2
- }
- }
- }
- ]
- },
- {
- label: '',
- value: '',
- name: '',
- type: 'form-group',
- children: [
- {
- label: '',
- value: '',
- name: '',
- notFormItem: true,
- type: 'result',
- span: 24,
- props: {
- icon: 'success',
- title: '操作成功',
- class: 'w-full text-center'
- }
- }
- ]
- }
- ]
- }
- ]
- })
- const create = (data: any) => {
- console.log(data)
- }
- const update = (data: any) => {
- console.log(data)
- }
- </script>
- <template>
- <div class="h-full bg-white p-16px pt-50px flex justify-center overflow-auto">
- <div class="w-800px">
- <pro-form :formConfig="formConfig" :formData="formData" :create="create" :update="update" ref="proFormRef">
- <template #prepend1> test1 </template>
- <template #append1> test1 </template>
- </pro-form>
- </div>
- </div>
- </template>
- <style lang="scss" scoped></style>
|