新增示例页面

This commit is contained in:
Ah jung
2021-07-15 13:52:54 +08:00
parent 9fa584eb23
commit 304e7053d7
15 changed files with 769 additions and 29 deletions

View File

@@ -1,3 +1,11 @@
# 1.1 (2021-07-15)
- ### ✨ Features
- 新增 `基础表单` 示例页面
- 新增 `分步表单` 示例页面
- 新增 `表单详情` 示例页面
- 持续更新更多实用示例,同时也演示`Naive UI`使用方法
# 1.0 (2021-07-12) # 1.0 (2021-07-12)
### 🐛 Bug Fixes ### 🐛 Bug Fixes
- 修复页面切换面包屑未及时更新 - 修复页面切换面包屑未及时更新

View File

@@ -1,6 +1,6 @@
{ {
"name": "naive-ui-admin", "name": "naive-ui-admin",
"version": "1.0", "version": "1.1",
"author": { "author": {
"name": "Ahjung", "name": "Ahjung",
"email": "735878602@qq.com", "email": "735878602@qq.com",

View File

@@ -32,8 +32,8 @@
<n-tooltip trigger="hover" placement="bottom"> <n-tooltip trigger="hover" placement="bottom">
<template #trigger> <template #trigger>
<n-icon size="18" :color="element.fixed === 'left' ? '#2080f0':undefined" <n-icon size="18" :color="element.fixed === 'left' ? '#2080f0':undefined"
class="transform -rotate-90 cursor-pointer" @click="fixedColumn(element,'left')"> class="cursor-pointer" @click="fixedColumn(element,'left')">
<VerticalAlignTopOutlined/> <VerticalRightOutlined />
</n-icon> </n-icon>
</template> </template>
<span>固定到左侧</span> <span>固定到左侧</span>
@@ -42,8 +42,8 @@
<n-tooltip trigger="hover" placement="bottom"> <n-tooltip trigger="hover" placement="bottom">
<template #trigger> <template #trigger>
<n-icon size="18" :color="element.fixed === 'right' ? '#2080f0':undefined" <n-icon size="18" :color="element.fixed === 'right' ? '#2080f0':undefined"
class="transform rotate-90 cursor-pointer" @click="fixedColumn(element,'right')"> class="cursor-pointer" @click="fixedColumn(element,'right')">
<VerticalAlignTopOutlined/> <VerticalLeftOutlined />
</n-icon> </n-icon>
</template> </template>
<span>固定到右侧</span> <span>固定到右侧</span>
@@ -64,7 +64,7 @@
<script lang="ts"> <script lang="ts">
import { ref, defineComponent, reactive, unref, toRaw, computed, toRefs, watchEffect } from "vue" import { ref, defineComponent, reactive, unref, toRaw, computed, toRefs, watchEffect } from "vue"
import { useTableContext } from '../../hooks/useTableContext'; import { useTableContext } from '../../hooks/useTableContext';
import { ReloadOutlined, ColumnHeightOutlined, SettingOutlined, DragOutlined, VerticalAlignTopOutlined } from '@vicons/antd' import { ReloadOutlined, ColumnHeightOutlined, SettingOutlined, DragOutlined, VerticalRightOutlined, VerticalLeftOutlined } from '@vicons/antd'
import Draggable from 'vuedraggable/src/vuedraggable' import Draggable from 'vuedraggable/src/vuedraggable'
import { useDesignSetting } from "@/hooks/setting/useDesignSetting"; import { useDesignSetting } from "@/hooks/setting/useDesignSetting";
@@ -78,7 +78,7 @@ export default defineComponent({
name: 'ColumnSetting', name: 'ColumnSetting',
components: { components: {
ReloadOutlined, ColumnHeightOutlined, SettingOutlined, DragOutlined, Draggable, ReloadOutlined, ColumnHeightOutlined, SettingOutlined, DragOutlined, Draggable,
VerticalAlignTopOutlined VerticalRightOutlined, VerticalLeftOutlined
}, },
setup(props, { emit }) { setup(props, { emit }) {
const { getDarkTheme } = useDesignSetting() const { getDarkTheme } = useDesignSetting()

View File

@@ -12,7 +12,7 @@
</a> </a>
</div> </div>
<div class="copyright"> <div class="copyright">
naive-ui-admin 1.0 · Made by Ah jung naive-ui-admin 1.1 · Made by Ah jung
</div> </div>
</div> </div>

View File

@@ -7,7 +7,7 @@
<!--左侧菜单--> <!--左侧菜单-->
<div class="layout-header-left" v-else> <div class="layout-header-left" v-else>
<!-- 菜单收起 --> <!-- 菜单收起 -->
<span class="ml-1 layout-header-trigger layout-header-trigger-min" <div class="ml-1 layout-header-trigger layout-header-trigger-min"
@click="() => $emit('update:collapsed', !collapsed)"> @click="() => $emit('update:collapsed', !collapsed)">
<n-icon size="18" v-if="collapsed"> <n-icon size="18" v-if="collapsed">
<MenuUnfoldOutlined/> <MenuUnfoldOutlined/>
@@ -15,14 +15,14 @@
<n-icon size="18" v-else> <n-icon size="18" v-else>
<MenuFoldOutlined/> <MenuFoldOutlined/>
</n-icon> </n-icon>
</span> </div>
<!-- 刷新 --> <!-- 刷新 -->
<span class="mr-1 layout-header-trigger layout-header-trigger-min" v-if="headerSetting.isReload" <div class="mr-1 layout-header-trigger layout-header-trigger-min" v-if="headerSetting.isReload"
@click="reloadPage"> @click="reloadPage">
<n-icon size="18"> <n-icon size="18">
<ReloadOutlined/> <ReloadOutlined/>
</n-icon> </n-icon>
</span> </div>
<!-- 面包屑 --> <!-- 面包屑 -->
<n-breadcrumb v-if="crumbsSetting.show"> <n-breadcrumb v-if="crumbsSetting.show">
<template v-for="routeItem in breadcrumbList" :key="routeItem.name"> <template v-for="routeItem in breadcrumbList" :key="routeItem.name">
@@ -46,7 +46,7 @@
</n-breadcrumb> </n-breadcrumb>
</div> </div>
<div class="layout-header-right"> <div class="layout-header-right">
<span class="layout-header-trigger layout-header-trigger-min" v-for="item in iconList" :key="item.icon.name"> <div class="layout-header-trigger layout-header-trigger-min" v-for="item in iconList" :key="item.icon.name">
<n-tooltip placement="bottom"> <n-tooltip placement="bottom">
<template #trigger> <template #trigger>
<n-icon size="18"> <n-icon size="18">
@@ -55,15 +55,20 @@
</template> </template>
<span>{{ item.tips }}</span> <span>{{ item.tips }}</span>
</n-tooltip> </n-tooltip>
</span> </div>
<!--切换全屏--> <!--切换全屏-->
<span class="layout-header-trigger layout-header-trigger-min"> <div class="layout-header-trigger layout-header-trigger-min">
<n-tooltip placement="bottom">
<template #trigger>
<n-icon size="18"> <n-icon size="18">
<component :is="fullscreenIcon" @click="toggleFullScreen"/> <component :is="fullscreenIcon" @click="toggleFullScreen"/>
</n-icon> </n-icon>
</span> </template>
<span>全屏</span>
</n-tooltip>
</div>
<!-- 个人中心 --> <!-- 个人中心 -->
<span class="layout-header-trigger layout-header-trigger-min"> <div class="layout-header-trigger layout-header-trigger-min">
<n-dropdown trigger="hover" @select="avatarSelect" :options="avatarOptions"> <n-dropdown trigger="hover" @select="avatarSelect" :options="avatarOptions">
<div class="avatar"> <div class="avatar">
<n-avatar> <n-avatar>
@@ -72,9 +77,9 @@
</n-avatar> </n-avatar>
</div> </div>
</n-dropdown> </n-dropdown>
</span> </div>
<!--设置--> <!--设置-->
<span class="layout-header-trigger layout-header-trigger-min" @click="openSetting"> <div class="layout-header-trigger layout-header-trigger-min" @click="openSetting">
<n-tooltip placement="bottom-end"> <n-tooltip placement="bottom-end">
<template #trigger> <template #trigger>
<n-icon size="18" style="font-weight: bold"> <n-icon size="18" style="font-weight: bold">
@@ -83,7 +88,7 @@
</template> </template>
<span>项目配置</span> <span>项目配置</span>
</n-tooltip> </n-tooltip>
</span> </div>
</div> </div>
</div> </div>
<!--项目配置--> <!--项目配置-->
@@ -91,7 +96,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, reactive, toRefs, createVNode, ref, computed, unref } from 'vue' import { defineComponent, reactive, toRefs, ref, computed, unref } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import components from './components' import components from './components'
import { NDialogProvider, useDialog, useMessage, useNotification } from 'naive-ui' import { NDialogProvider, useDialog, useMessage, useNotification } from 'naive-ui'

View File

@@ -28,7 +28,6 @@ export default {
img { img {
height: 32px; height: 32px;
margin-right: 8px;
} }
.title { .title {

View File

@@ -46,7 +46,17 @@ import {
NThing, NThing,
NDataTable, NDataTable,
NPopover, NPopover,
NPagination NPagination,
NSelect,
NRadioGroup,
NRadio,
NSteps,
NStep,
NInputGroup,
NResult,
NDescriptions,
NDescriptionsItem,
NTable
} from 'naive-ui' } from 'naive-ui'
const naive = create({ const naive = create({
@@ -96,7 +106,17 @@ const naive = create({
NThing, NThing,
NDataTable, NDataTable,
NPopover, NPopover,
NPagination NPagination,
NSelect,
NRadioGroup,
NRadio,
NSteps,
NStep,
NInputGroup,
NResult,
NDescriptions,
NDescriptionsItem,
NTable
] ]
}) })

View File

@@ -1,6 +1,6 @@
import { RouteRecordRaw } from 'vue-router' import { RouteRecordRaw } from 'vue-router'
import { Layout } from '@/router/constant'; import { Layout } from '@/router/constant';
import { ProfileOutlined } from '@vicons/antd' import { WalletOutlined } from '@vicons/antd'
import { renderIcon } from '@/utils/index' import { renderIcon } from '@/utils/index'
@@ -25,7 +25,7 @@ const routes: Array<RouteRecordRaw> = [
component: Layout, component: Layout,
meta: { meta: {
title: '组件', title: '组件',
icon: renderIcon(ProfileOutlined), icon: renderIcon(WalletOutlined ),
sort: 1 sort: 1
}, },
children: [ children: [

View File

@@ -0,0 +1,58 @@
import { RouteRecordRaw } from 'vue-router'
import { Layout } from '@/router/constant';
import { ProfileOutlined } from '@vicons/antd'
import { renderIcon } from '@/utils/index'
/**
* @param name 路由名称, 必须设置,且不能重名
* @param meta 路由元信息(路由附带扩展信息)
* @param redirect 重定向地址, 访问这个路由时,自定进行重定向
* @param meta.disabled 禁用整个菜单
* @param meta.title 菜单名称
* @param meta.icon 菜单图标
* @param meta.keepAlive 缓存该路由
* @param meta.sort 排序越小越排前
*
* */
const routes: Array<RouteRecordRaw> = [
{
path: '/form',
name: 'Form',
redirect: '/form/basic-form',
component: Layout,
meta: {
title: '表单页面',
icon: renderIcon(ProfileOutlined),
sort: 1
},
children: [
{
path: 'basic-form',
name: 'form-basic-form',
meta: {
title: '基础表单',
},
component: () => import('@/views/form/basicForm/index.vue')
},
{
path: 'step-form',
name: 'form-step-form',
meta: {
title: '分步表单',
},
component: () => import('@/views/form/stepForm/stepForm.vue')
},
{
path: 'detail',
name: 'form-detail',
meta: {
title: '表单详情',
},
component: () => import('@/views/form/detail/index.vue')
},
],
}
]
export default routes

View File

@@ -0,0 +1,167 @@
<template>
<div>
<div class="n-layout-page-header">
<n-card :bordered="false" title="基础表单">
表单页用于向用户收集或验证信息基础表单常见于数据项较少的表单场景表单域标签也可支持响应式
</n-card>
</div>
<n-card :bordered="false" class="proCard mt-4">
<n-grid cols="2 s:1 m:3 l:3 xl:3 2xl:3" responsive="screen">
<n-grid-item offset="0 s:0 m:1 l:1 xl:1 2xl:1">
<n-form
:label-width="80"
:model="formValue"
:rules="rules"
label-placement="left"
ref="formRef"
class="py-8"
>
<n-form-item label="预约姓名" path="name">
<n-input v-model:value="formValue.name" placeholder="输入姓名"/>
</n-form-item>
<n-form-item label="预约号码" path="mobile">
<n-input placeholder="电话号码" v-model:value="formValue.mobile"/>
</n-form-item>
<n-form-item label="预约时间" path="datetime">
<n-date-picker type="datetime" v-model:value="formValue.datetime"/>
</n-form-item>
<n-form-item label="预约医生" path="doctor">
<n-select
placeholder="请选择预约医生"
:options="doctorList"
v-model:value="formValue.doctor"
/>
</n-form-item>
<n-form-item label="预约事项" path="matter">
<n-select
placeholder="请选择预约事项"
:options="matterList"
v-model:value="formValue.matter"
multiple
/>
</n-form-item>
<n-form-item label="性别" path="sex">
<n-radio-group v-model:value="formValue.sex" name="sex">
<n-space>
<n-radio :value="1"></n-radio>
<n-radio :value="2"></n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<n-form-item label="预约备注" path="remark">
<n-input
v-model:value="formValue.remark"
type="textarea"
placeholder="请输入预约备注"
/>
</n-form-item>
<div style="margin-left:80px">
<n-space>
<n-button type="primary" @click="formSubmit">提交预约</n-button>
<n-button @click="resetForm">重置</n-button>
</n-space>
</div>
</n-form>
</n-grid-item>
</n-grid>
</n-card>
</div>
</template>
<script>
import { defineComponent, ref } from 'vue'
import { useMessage } from 'naive-ui'
const matterList = [
{
label: '种牙',
value: 1
},
{
label: '补牙',
value: 2
},
{
label: '根管',
value: 3
}
]
const doctorList = [
{
label: '李医生',
value: 1
},
{
label: '黄医生',
value: 2
},
{
label: '张医生',
value: 3
}
]
export default defineComponent({
setup() {
const formRef = ref(null)
const message = useMessage()
return {
formRef,
formValue: ref({
name: '',
mobile: '',
remark: '',
sex: 1,
matter: null,
doctor: null,
datetime: [],
}),
rules: {
name: {
required: true,
message: '请输入预约姓名',
trigger: 'blur'
},
remark: {
required: true,
message: '请输入预约备注',
trigger: 'blur'
},
mobile: {
required: true,
message: '请输入预约电话号码',
trigger: ['input']
},
datetime: {
required: true,
type: 'number',
message: '请选择预约时间',
trigger: ['blur', 'change'],
},
doctor: {
required: true,
type: 'number',
message: '请选择预约医生',
trigger: 'change'
},
},
doctorList,
matterList,
formSubmit(e) {
formRef.value.validate((errors) => {
if (!errors) {
message.success('验证成功')
} else {
message.error('验证失败,请填写完整信息')
}
})
},
resetForm() {
formRef.value.restoreValidation()
}
}
}
})
</script>

View File

@@ -0,0 +1,106 @@
<template>
<div>
<div class="n-layout-page-header">
<n-card :bordered="false" title="表单详情">
表单除了提交数据有时也用于显示只读信息
</n-card>
</div>
<n-card :bordered="false" title="基本信息" class="proCard mt-4" size="small" :segmented="{content: 'hard'}">
<n-descriptions label-placement="left" class="py-2">
<n-descriptions-item><template #label>收款人姓名</template>啊俊</n-descriptions-item>
<n-descriptions-item label="收款账户">NaiveUiAdmin@qq.com</n-descriptions-item>
<n-descriptions-item label="付款类型">支付宝</n-descriptions-item>
<n-descriptions-item label="付款账户">NaiveUiAdmin@163.com</n-descriptions-item>
<n-descriptions-item label="转账金额">1980.00</n-descriptions-item>
<n-descriptions-item label="状态"><n-tag type="success"> 已到账 </n-tag></n-descriptions-item>
</n-descriptions>
</n-card>
<n-card :bordered="false" title="其它信息" class="proCard mt-4" size="small" :segmented="{content: 'hard'}">
<n-descriptions label-placement="left" class="py-2">
<n-descriptions-item><template #label>城市</template>深圳</n-descriptions-item>
<n-descriptions-item label="性别"></n-descriptions-item>
<n-descriptions-item label="邮箱">NaiveUiAdmin@qq.com</n-descriptions-item>
<n-descriptions-item label="地址">广东省深圳市南山区</n-descriptions-item>
<n-descriptions-item label="生日">1991-06-04</n-descriptions-item>
<n-descriptions-item label="认证"><n-tag type="success"> 已认证 </n-tag></n-descriptions-item>
</n-descriptions>
</n-card>
<n-card :bordered="false" title="表格信息" class="proCard mt-4" size="small" :segmented="{content: 'hard'}">
<n-table :bordered="false" :single-line="false">
<thead>
<tr>
<th>姓名</th>
<th>性别</th>
<th>城市</th>
<th>生日</th>
<th width="150">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ah jung</td>
<td></td>
<td>深圳</td>
<td>1993-11-09</td>
<td>
<n-space>
<n-button size="small" type="error">删除</n-button>
<n-button size="small" type="info">查看</n-button>
</n-space>
</td>
</tr>
<tr>
<td>西门飞雪</td>
<td></td>
<td>广州</td>
<td>1991-09-11</td>
<td>
<n-space>
<n-button size="small" type="error">删除</n-button>
<n-button size="small" type="info">查看</n-button>
</n-space>
</td>
</tr>
<tr>
<td>泰坦巨人</td>
<td></td>
<td>北京</td>
<td>1990-11-03</td>
<td>
<n-space>
<n-button size="small" type="error">删除</n-button>
<n-button size="small" type="info">查看</n-button>
</n-space>
</td>
</tr>
<tr>
<td>猎魔人</td>
<td></td>
<td>上海</td>
<td>1992-03-11</td>
<td>
<n-space>
<n-button size="small" type="error">删除</n-button>
<n-button size="small" type="info">查看</n-button>
</n-space>
</td>
</tr>
</tbody>
</n-table>
</n-card>
</div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
setup() {
return {}
}
})
</script>
<style lang="less" scoped>
</style>

View File

@@ -0,0 +1,131 @@
<template>
<n-form
:label-width="90"
:model="formValue"
:rules="rules"
label-placement="left"
ref="form1Ref"
style="max-width: 500px; margin: 40px auto 0;"
>
<n-form-item label="付款账户" path="myAccount">
<n-select
placeholder="请选择付款账户"
:options="myAccountList"
v-model:value="formValue.myAccount"
/>
</n-form-item>
<n-form-item label="收款账户" path="account">
<n-input-group>
<n-select
placeholder="请选择"
:options="accountTypeList"
:style="{ width: '20%' }"
v-model:value="formValue.accountType"
/>
<n-input placeholder="请输入收款账户" :style="{ width: '80%' }" v-model:value="formValue.account"/>
</n-input-group>
</n-form-item>
<n-form-item label="收款人姓名" path="name">
<n-input placeholder="请输入收款人姓名" v-model:value="formValue.name"/>
</n-form-item>
<n-form-item label="转账金额" path="money">
<n-input placeholder="请输入转账金额" v-model:value="formValue.money">
<template #prefix>
<span class="text-gray-400"></span>
</template>
</n-input>
</n-form-item>
<div style="margin-left:80px">
<n-space>
<n-button type="primary" @click="formSubmit">下一步</n-button>
</n-space>
</div>
</n-form>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { useMessage } from 'naive-ui'
const myAccountList = [
{
label: 'NaiveUiAdmin@163.com',
value: 1
},
{
label: 'NaiveUiAdmin@qq.com',
value: 2
},
]
const accountTypeList = [
{
label: '微信',
value: 1
},
{
label: '支付宝',
value: 2
},
]
export default defineComponent({
emits: ['nextStep'],
setup(_, { emit }) {
const form1Ref: any = ref(null)
const message = useMessage()
const current = ref(1)
return {
form1Ref,
current,
formValue: ref({
accountType: 1,
myAccount: null,
account: 'xioama@qq.com',
money: "1980",
name: 'Ah jung',
}),
rules: {
name: {
required: true,
message: '请输入收款人姓名',
trigger: 'blur'
},
account: {
required: true,
message: '请输入收款账户',
trigger: 'blur'
},
money: {
required: true,
message: '请输入转账金额',
trigger: 'blur'
},
myAccount: {
required: true,
type: 'number',
message: '请选择付款账户',
trigger: 'change'
},
},
myAccountList,
accountTypeList,
formSubmit() {
form1Ref.value.validate((errors) => {
if (!errors) {
emit('nextStep')
} else {
message.error('验证失败,请填写完整信息')
}
})
},
resetForm() {
form1Ref.value.restoreValidation()
}
}
}
})
</script>

View File

@@ -0,0 +1,81 @@
<template>
<n-form
:label-width="90"
:model="formValue"
:rules="rules"
label-placement="left"
ref="form2Ref"
style="max-width: 500px; margin: 40px auto 0;"
>
<n-form-item label="付款账户" path="myAccount">
<span>NaiveUiAdmin@163.com</span>
</n-form-item>
<n-form-item label="收款账户" path="account">
<span>NaiveUiAdmin@qq.com</span>
</n-form-item>
<n-form-item label="收款人姓名" path="name">
<span>Ah jung</span>
</n-form-item>
<n-form-item label="转账金额" path="money">
<span>1980</span>
</n-form-item>
<n-divider/>
<n-form-item label="支付密码" path="password">
<n-input type="password" v-model:value="formValue.password"/>
</n-form-item>
<div style="margin-left:80px">
<n-space>
<n-button type="primary" :loading="loading" @click="formSubmit">提交</n-button>
<n-button @click="prevStep">上一步</n-button>
</n-space>
</div>
</n-form>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { useMessage } from 'naive-ui'
export default defineComponent({
emits: ['prevStep', 'nextStep'],
setup(_, { emit }) {
const form2Ref: any = ref(null)
const message = useMessage()
const loading = ref(false)
function prevStep() {
emit('prevStep')
}
function formSubmit() {
loading.value = true
form2Ref.value.validate((errors) => {
if (!errors) {
setTimeout(() => {
emit('nextStep')
}, 1500)
} else {
message.error('验证失败,请填写完整信息')
}
})
}
return {
form2Ref,
loading,
formValue: ref({
password: '086611'
}),
rules: {
password: {
required: true,
message: '请输入支付密码',
trigger: 'blur'
},
},
prevStep,
formSubmit,
}
}
})
</script>

View File

@@ -0,0 +1,89 @@
<template>
<div>
<n-result status="success" title="操作成功" description="预计两小时内到账" class="step-result">
<template #default>
<div class="information">
<n-grid cols="2 s:2 m:3 l:3 xl:3 2xl:3" responsive="screen" class="my-1">
<n-gi>付款账户</n-gi>
<n-gi>NaiveUiAdmin@163.com</n-gi>
</n-grid>
<n-grid cols="2 s:2 m:3 l:3 xl:3 2xl:3" responsive="screen" class="my-1">
<n-gi>收款账户</n-gi>
<n-gi>xiaoma@qq.com</n-gi>
</n-grid>
<n-grid cols="2 s:2 m:3 l:3 xl:3 2xl:3" responsive="screen" class="my-1">
<n-gi>收款人姓名</n-gi>
<n-gi>啊俊</n-gi>
</n-grid>
<n-grid cols="2 s:2 m:3 l:3 xl:3 2xl:3" responsive="screen" class="my-1">
<n-gi>转账金额</n-gi>
<n-gi><span class="money">1980</span> </n-gi>
</n-grid>
</div>
</template>
<template #footer>
<div class="flex justify-center">
<n-button type="primary" @click="finish" class="mr-4">再转一笔</n-button>
<n-button @click="prevStep">查看账单</n-button>
</div>
</template>
</n-result>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
export default defineComponent({
emits: ['finish', 'prevStep'],
setup(_, { emit }) {
const router = useRouter()
function prevStep() {
emit('prevStep')
}
function finish() {
emit('finish')
}
function toOrderList() {
router.push('/form/step-form')
}
return {
prevStep,
finish,
toOrderList
}
}
})
</script>
<style lang="less" scoped>
.step-result {
max-width: 560px;
margin: 40px auto 0;
::v-deep(.n-result-content) {
background-color: #fafafa;
padding: 24px 40px;
}
.information {
line-height: 22px;
.ant-row:not(:last-child) {
margin-bottom: 24px;
}
}
.money {
font-family: "Helvetica Neue", sans-serif;
font-weight: 500;
font-size: 20px;
line-height: 14px;
}
}
</style>

View File

@@ -0,0 +1,76 @@
<template>
<div>
<div class="n-layout-page-header">
<n-card :bordered="false" title="分步表单">
将一个冗长或用户不熟悉的表单任务分成多个步骤指导用户完成
</n-card>
</div>
<n-card :bordered="false" class="proCard mt-4">
<n-space vertical class="steps">
<n-steps :current="currentTab" :status="currentStatus">
<n-step
title="填写转账信息"
description="确保填写正确"
/>
<n-step
title="确认转账信息"
description="确认转账信息"
/>
<n-step
title="完成"
description="恭喜您,转账成功"
/>
</n-steps>
<step1 v-if="currentTab === 1" @nextStep="nextStep"/>
<step2 v-if="currentTab === 2" @nextStep="nextStep" @prevStep="prevStep"/>
<step3 v-if="currentTab === 3" @prevStep="prevStep" @finish="finish"/>
</n-space>
</n-card>
</div>
</template>
<script>
import { defineComponent, ref } from 'vue'
import step1 from './Step1.vue'
import step2 from './Step2.vue'
import step3 from './Step3.vue'
export default defineComponent({
components: { step1, step2, step3 },
setup() {
const currentTab = ref(1)
const currentStatus = ref('process')
function nextStep() {
if (currentTab.value < 3) {
currentTab.value += 1
}
}
function prevStep() {
if (currentTab.value > 1) {
currentTab.value -= 1
}
}
function finish() {
currentTab.value = 1
}
return {
currentTab,
currentStatus,
nextStep,
prevStep,
finish
}
}
})
</script>
<style lang="less" scoped>
.steps {
max-width: 750px;
margin: 16px auto;
}
</style>