Browse Source

Merge remote-tracking branch 'origin/master'

master
zhanglei 2 weeks ago
parent
commit
d7ce837a1f
  1. 2
      templates/vue/data.ts.j2
  2. 2
      templates/vue/form.ts.j2
  3. 78
      templates/vue/index.vue.j2
  4. 6
      templates/vue/router.ts.j2
  5. 39
      vue-vben-admin/apps/web-antd/src/api/user/user.ts

2
templates/vue/data.ts.j2

@ -15,7 +15,7 @@ export const columns: VxeGridProps['columns'] = [
field: '{{f.name}}', field: '{{f.name}}',
// 宽度 // 宽度
width: 150, width: 150
}, },
{% endfor %} {% endfor %}

2
templates/vue/form.ts.j2

@ -16,7 +16,7 @@ export const formSchema: VbenFormSchema[] = [
label: '{{f.comment}}', label: '{{f.comment}}',
// 自动组件 // 自动组件
component: '{{f.component}}', component: '{{f.component}}'
}, },
{% endfor %} {% endfor %}

78
templates/vue/index.vue.j2

@ -9,56 +9,56 @@ import { columns } from './data';
import { {{entity}}Api } from '#/api/{{entity}}'; import { {{entity}}Api } from '#/api/{{entity}}';
console.log('=== columns 配置 ===', columns)
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
columns, columns,
proxyConfig: { gridOptions: {
proxyConfig: {
ajax: { ajax: {
query: async ({ page }) => {
query: async ({ page }) => { try {
console.log('=== 请求参数 ===', page)
const res = await {{entity}}Api.page({
pageNum: page.currentPage, const res = await userApi.page({
pageSize: page.pageSize, pageNum: page?.currentPage || 1,
}) pageSize: page?.pageSize || 10,
const data = res.data })
const result = { console.log('=== API 返回的数据 ===', res)
items: data.records, const data = res.error?.result || res.result || res
total: data.total const result = {
items: data.records,
total: data.total
}
console.log('=== 转换后的数据 ===', result)
return result
} catch (error) {
console.error('查询用户列表失败:', error)
throw error
}
} }
console.log('=== 返回给 VxeTable 的数据 ===', result)
return result
} }
},
} pagerConfig: {
enabled: true,
},
}, },
pagerConfig: {
enabled: true,
},
}
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
}) })
</script>
<template>
<div>
<Grid table-title="用户列表"> </script>
<template #toolbar-tools>
<button @click="() => gridApi.reload()">刷新</button>
</template>
</Grid>
</div> <template>
<div>
<Grid table-title="用户列表">
<template #toolbar-tools>
<button @click="() => gridApi.reload()">刷新</button>
</template>
</Grid>
</div>
</template> </template>

6
templates/vue/router.ts.j2

@ -8,7 +8,7 @@ const routes: RouteRecordRaw[] = [
{ {
path: '/{{entity}}', path: '/{{entity}}',
name: '{{entityComment}}', name: '{{comment}}模块',
meta: { meta: {
icon: 'ic:baseline-view-in-ar', icon: 'ic:baseline-view-in-ar',
order: 1000, order: 1000,
@ -18,9 +18,9 @@ const routes: RouteRecordRaw[] = [
children: [ children: [
{ {
meta: { meta: {
title: "{{entityComment}}列表", title: "{{comment}}列表",
}, },
name: '{{entity}}_List', name: '{{entity}}List',
path: '/{{entity}}', path: '/{{entity}}',
component: () => import('#/views/{{entity}}/index.vue'), component: () => import('#/views/{{entity}}/index.vue'),
}, },

39
vue-vben-admin/apps/web-antd/src/api/user/user.ts

@ -1,40 +1,43 @@
/**
* API
*
*/
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
import { useAppConfig } from '@vben/hooks';
export namespace UserApi { export namespace userApi {
/** const applicationConfig = useAppConfig(import.meta.env, import.meta.env.PROD);
*
*/
export function page(params:any){
return requestClient.get('/api/user/page',{params});
}
console.log('=== 接口域名 ===', applicationConfig.javaURL + '/health-user/page')
/** /**
* *
*/ */
export function detail(id:number){ export function page(params: any) {
return requestClient.get('/api/user/'+id); return requestClient.post(applicationConfig.javaURL + '/health-user/page', params ,
{ headers: {'Content-Type': 'application/json', Token: 'ded93460-0cf5-45db-81ae-7608dbd3f51e', version: '1.0.1'} });
} }
/** /**
* *
*/ */
export function add(data:any){ export function get(id: number) {
return requestClient.post('/api/user',data); return requestClient.get(applicationConfig.javaURL + '/health_user/' + id);
} }
/** /**
* * /
*/ */
export function update(id:number,data:any){ export function save(data: any) {
return requestClient.put('/api/user/'+id,data); return requestClient.post(applicationConfig.javaURL + '/health_user', data);
} }
/** /**
* *
*/ */
export function remove(id:number){ export function remove(id: number) {
return requestClient.delete('/api/user/'+id); return requestClient.delete(applicationConfig.javaURL + '/health_user/' + id);
} }
} }

Loading…
Cancel
Save