mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-12-31 03:17:49 +00:00
表格跳转处理
This commit is contained in:
@@ -55,7 +55,7 @@ const props = defineProps({
|
|||||||
v-bind="column.linkAttrs"
|
v-bind="column.linkAttrs"
|
||||||
@click="column.click(scope.row, scope)"
|
@click="column.click(scope.row, scope)"
|
||||||
>
|
>
|
||||||
{{ scope.row[column.property] }}
|
{{ column.formatter?column.formatter(scope.row, scope):scope.row[column.property] }}
|
||||||
</el-link>
|
</el-link>
|
||||||
<slot
|
<slot
|
||||||
v-bind="scope"
|
v-bind="scope"
|
||||||
|
|||||||
@@ -7,14 +7,23 @@
|
|||||||
* @property {string} gender
|
* @property {string} gender
|
||||||
* @property {Date} birthday
|
* @property {Date} birthday
|
||||||
*/
|
*/
|
||||||
import { $httpPost } from '@/vendors/axios'
|
import { $httpGet, $httpPost } from '@/vendors/axios'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载用户数据
|
* 加载用户数据
|
||||||
* @return {{success:boolean, message:string,userList: [UserDto]}}
|
* @return {{success:boolean, message:string, resultData: {userList:[UserDto]}}}
|
||||||
*/
|
*/
|
||||||
export const loadUsersResult = async (data, config) => {
|
export const loadUsersResult = async (data, config) => {
|
||||||
const usersResult = await $httpPost('/api/users', data, config)
|
const usersResult = await $httpPost('/api/users', data, config)
|
||||||
console.info('==================', usersResult)
|
console.info('==================', usersResult)
|
||||||
return usersResult
|
return usersResult
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 加载用户
|
||||||
|
* @return {{success:boolean, message:string, resultData: {user:UserDto}}}
|
||||||
|
*/
|
||||||
|
export const loadUserResult = async (id, config) => {
|
||||||
|
const usersResult = await $httpGet(`/api/users/${id}`, config)
|
||||||
|
console.info('==================', usersResult)
|
||||||
|
return usersResult
|
||||||
|
}
|
||||||
|
|||||||
12
src/vendors/axios.js
vendored
12
src/vendors/axios.js
vendored
@@ -51,3 +51,15 @@ export const $httpPost = (url, data, config) => {
|
|||||||
}, reject)
|
}, reject)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const $httpGet = (url, data, config) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
$http.get(url, config).then(response => {
|
||||||
|
if (response.data) {
|
||||||
|
resolve(response.data) // 只要有数据就认为成功,内容再解析
|
||||||
|
} else {
|
||||||
|
reject(new Error('No response data'))
|
||||||
|
}
|
||||||
|
}, reject)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { loadUserResult } from '@/services/user/UserService'
|
||||||
|
|
||||||
const userDto = ref({})
|
const route = useRoute()
|
||||||
|
|
||||||
|
const userDto = ref({
|
||||||
|
id: route.params.id
|
||||||
|
})
|
||||||
/**
|
/**
|
||||||
* @type {[CommonFormOption]}
|
* @type {[CommonFormOption]}
|
||||||
*/
|
*/
|
||||||
@@ -46,6 +52,23 @@ const userFormOptions = [{
|
|||||||
type: 'textarea'
|
type: 'textarea'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
const loadUser = async () => {
|
||||||
|
console.info('============', route)
|
||||||
|
const id = route.params.id
|
||||||
|
if (id) {
|
||||||
|
const userResult = await loadUserResult(id)
|
||||||
|
if (userResult.success && userResult.resultData) {
|
||||||
|
const resultData = userResult.resultData
|
||||||
|
userDto.value = resultData.user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadUser()
|
||||||
|
})
|
||||||
|
|
||||||
const submitForm = form => {
|
const submitForm = form => {
|
||||||
form.validate(valid => {
|
form.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user