表格跳转处理

This commit is contained in:
gary.fu
2024-01-04 11:06:38 +08:00
parent f64ad3573c
commit 5355e4fd3e
6 changed files with 90 additions and 22 deletions

View File

@@ -85,6 +85,17 @@ html, body, #app, .index-container {
display: block; display: block;
} }
.container-center {
display: flex;
justify-content: center;
align-items: center;
padding-top: 20px;
}
.form-edit-width {
width:70%
}
/** /**
* slide-fade动画 * slide-fade动画
*/ */

View File

@@ -119,10 +119,10 @@ defineExpose({
{{ $t('common.label.reset') }} {{ $t('common.label.reset') }}
</el-button> </el-button>
<el-button <el-button
v-if="showBack" v-if="showBack||backUrl"
@click="backUrl?$router.push(backUrl):$router.go(-1)" @click="backUrl?$router.push(backUrl):$router.go(-1)"
> >
{{ $t('common.label.reset') }} {{ $t('common.label.back') }}
</el-button> </el-button>
<slot <slot
:form="form" :form="form"

View File

@@ -10,7 +10,6 @@
* @property {string} slot 自定义插槽 * @property {string} slot 自定义插槽
* @property [ButtonProps] buttons 自定义按钮 * @property [ButtonProps] buttons 自定义按钮
* @property {Object} attrs 其他属性 * @property {Object} attrs 其他属性
* @property {string} link 链接地址
* @property {Object} linkAttrs 链接配置 * @property {Object} linkAttrs 链接配置
* @method click 点击事件 * @method click 点击事件
* @method formatter 格式化 * @method formatter 格式化
@@ -47,15 +46,14 @@ const props = defineProps({
:formatter="column.formatter" :formatter="column.formatter"
> >
<template <template
v-if="column.slot||column.link||column.click" v-if="column.slot||column.click"
#default="scope" #default="scope"
> >
<el-link <el-link
v-if="column.link||column.click" v-if="column.click"
:href="column.link"
type="primary" type="primary"
v-bind="column.linkAttrs" v-bind="column.linkAttrs"
@click="column.click&&column.click(scope.row, scope)" @click="column.click(scope.row, scope)"
> >
{{ scope.row[column.property] }} {{ scope.row[column.property] }}
</el-link> </el-link>

View File

@@ -18,7 +18,7 @@ export default [{
name: 'tables-index', name: 'tables-index',
component: () => import('@/views/tools/Tables.vue') component: () => import('@/views/tools/Tables.vue')
}, { }, {
path: 'edit', path: 'edit/:id',
name: 'tables-edit', name: 'tables-edit',
component: () => import('@/views/tools/TableEdit.vue'), component: () => import('@/views/tools/TableEdit.vue'),
meta: { meta: {

View File

@@ -1,19 +1,71 @@
<script setup> <script setup>
import { useRouter } from 'vue-router' import { ref } from 'vue'
const router = useRouter()
const userDto = ref({})
/**
* @type {[CommonFormOption]}
*/
const userFormOptions = [{
label: '中文名',
prop: 'nameCn',
placeholder: '请输入中文名',
required: true
}, {
label: '英文名',
prop: 'nameEn',
placeholder: '请输入英文名',
required: true
}, {
label: '出生日期',
type: 'date-picker',
prop: 'birthday',
value: '',
placeholder: '选择出生日期',
required: true
}, {
label: '性别',
type: 'radio-group',
prop: 'gender',
value: '',
required: true,
children: [
{
label: '男',
value: 'male'
},
{
label: '女',
value: 'female'
}
]
}, {
label: '地址',
prop: 'address',
value: '',
attrs: {
type: 'textarea'
}
}]
const submitForm = form => {
form.validate(valid => {
if (valid) {
console.log('submit', userDto.value)
}
})
}
</script> </script>
<template> <template>
<div> <el-container class="container-center">
<strong>编辑数据</strong> <common-form
<br> class="form-edit-width"
<el-link :model="userDto"
type="primary" :options="userFormOptions"
@click="router.replace('/tables')" label-width="120px"
> back-url="/tables"
{{ $t('common.label.back') }} @submit-form="submitForm"
</el-link> />
</div> </el-container>
</template> </template>
<style scoped> <style scoped>

View File

@@ -2,6 +2,9 @@
import { onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
import { loadUsersResult } from '@/services/user/UserService' import { loadUsersResult } from '@/services/user/UserService'
import { useDefaultPage } from '@/config' import { useDefaultPage } from '@/config'
import { useRouter } from 'vue-router'
const router = useRouter()
const page = ref(useDefaultPage()) const page = ref(useDefaultPage())
@@ -27,11 +30,15 @@ onMounted(() => {
const columns = [{ const columns = [{
label: '中文名', label: '中文名',
property: 'nameCn', property: 'nameCn',
link: '#/tables/edit' click (data) {
router.push(`tables/edit/${data.id}`)
}
}, { }, {
label: '英文名', label: '英文名',
property: 'nameEn', property: 'nameEn',
link: '#/tables/edit' click (data) {
router.push(`tables/edit/${data.id}`)
}
}, { }, {
label: '性别', label: '性别',
property: 'gender', property: 'gender',