Commit e2dba57d8f11c8387d8c9e233546b58f5aa13e6f

Authored by YunaiV
1 parent b249b117

vue3:测试 client、token、errorCode 模块,导出需要优化

yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts
@@ -4,12 +4,14 @@ import { useI18n } from '@/hooks/web/useI18n' @@ -4,12 +4,14 @@ import { useI18n } from '@/hooks/web/useI18n'
4 import { DICT_TYPE } from '@/utils/dict' 4 import { DICT_TYPE } from '@/utils/dict'
5 import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' 5 import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
6 const { t } = useI18n() // 国际化 6 const { t } = useI18n() // 国际化
  7 +
7 // 表单校验 8 // 表单校验
8 export const rules = reactive({ 9 export const rules = reactive({
9 applicationName: [required], 10 applicationName: [required],
10 code: [required], 11 code: [required],
11 message: [required] 12 message: [required]
12 }) 13 })
  14 +
13 // 新增 + 修改 15 // 新增 + 修改
14 const crudSchemas = reactive<VxeCrudSchema>({ 16 const crudSchemas = reactive<VxeCrudSchema>({
15 primaryKey: 'id', 17 primaryKey: 'id',
yudao-ui-admin-vue3/src/views/system/errorCode/index.vue
1 <template> 1 <template>
2 <ContentWrap> 2 <ContentWrap>
  3 + <!-- 列表 -->
3 <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> 4 <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5 + <!-- 操作:新增 -->
4 <template #toolbar_buttons> 6 <template #toolbar_buttons>
5 <XButton 7 <XButton
6 type="primary" 8 type="primary"
@@ -11,18 +13,21 @@ @@ -11,18 +13,21 @@
11 /> 13 />
12 </template> 14 </template>
13 <template #actionbtns_default="{ row }"> 15 <template #actionbtns_default="{ row }">
  16 + <!-- 操作:修改 -->
14 <XTextButton 17 <XTextButton
15 preIcon="ep:edit" 18 preIcon="ep:edit"
16 :title="t('action.edit')" 19 :title="t('action.edit')"
17 v-hasPermi="['system:error-code:update']" 20 v-hasPermi="['system:error-code:update']"
18 @click="handleUpdate(row.id)" 21 @click="handleUpdate(row.id)"
19 /> 22 />
  23 + <!-- 操作:详情 -->
20 <XTextButton 24 <XTextButton
21 preIcon="ep:view" 25 preIcon="ep:view"
22 :title="t('action.detail')" 26 :title="t('action.detail')"
23 v-hasPermi="['system:error-code:update']" 27 v-hasPermi="['system:error-code:update']"
24 @click="handleDetail(row.id)" 28 @click="handleDetail(row.id)"
25 /> 29 />
  30 + <!-- 操作:删除 -->
26 <XTextButton 31 <XTextButton
27 preIcon="ep:delete" 32 preIcon="ep:delete"
28 :title="t('action.del')" 33 :title="t('action.del')"
@@ -32,6 +37,7 @@ @@ -32,6 +37,7 @@
32 </template> 37 </template>
33 </vxe-grid> 38 </vxe-grid>
34 </ContentWrap> 39 </ContentWrap>
  40 + <!-- 弹窗 -->
35 <XModal id="errorCodeModel" v-model="dialogVisible" :title="dialogTitle"> 41 <XModal id="errorCodeModel" v-model="dialogVisible" :title="dialogTitle">
36 <template #default> 42 <template #default>
37 <!-- 对话框(添加 / 修改) --> 43 <!-- 对话框(添加 / 修改) -->
@@ -48,8 +54,8 @@ @@ -48,8 +54,8 @@
48 :data="detailRef" 54 :data="detailRef"
49 /> 55 />
50 </template> 56 </template>
51 - <!-- 操作按钮 -->  
52 <template #footer> 57 <template #footer>
  58 + <!-- 按钮:保存 -->
53 <XButton 59 <XButton
54 v-if="['create', 'update'].includes(actionType)" 60 v-if="['create', 'update'].includes(actionType)"
55 type="primary" 61 type="primary"
@@ -57,35 +63,40 @@ @@ -57,35 +63,40 @@
57 :loading="actionLoading" 63 :loading="actionLoading"
58 @click="submitForm" 64 @click="submitForm"
59 /> 65 />
  66 + <!-- 按钮:关闭 -->
60 <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" /> 67 <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
61 </template> 68 </template>
62 </XModal> 69 </XModal>
63 </template> 70 </template>
64 71
65 <script setup lang="ts"> 72 <script setup lang="ts">
  73 +// 全局相关的 import
66 import { ref, unref } from 'vue' 74 import { ref, unref } from 'vue'
67 -import { rules, allSchemas } from './errorCode.data'  
68 -import * as ErrorCodeApi from '@/api/system/errorCode'  
69 import { useI18n } from '@/hooks/web/useI18n' 75 import { useI18n } from '@/hooks/web/useI18n'
70 import { useMessage } from '@/hooks/web/useMessage' 76 import { useMessage } from '@/hooks/web/useMessage'
71 import { useVxeGrid } from '@/hooks/web/useVxeGrid' 77 import { useVxeGrid } from '@/hooks/web/useVxeGrid'
72 import { VxeGridInstance } from 'vxe-table' 78 import { VxeGridInstance } from 'vxe-table'
73 import { FormExpose } from '@/components/Form' 79 import { FormExpose } from '@/components/Form'
  80 +// 业务相关的 import
  81 +import { rules, allSchemas } from './errorCode.data'
  82 +import * as ErrorCodeApi from '@/api/system/errorCode'
74 83
75 const { t } = useI18n() // 国际化 84 const { t } = useI18n() // 国际化
76 const message = useMessage() // 消息弹窗 85 const message = useMessage() // 消息弹窗
  86 +// 列表相关的变量
  87 +const xGrid = ref<VxeGridInstance>() // grid Ref
  88 +const { gridOptions } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
  89 + allSchemas: allSchemas,
  90 + getListApi: ErrorCodeApi.getErrorCodePageApi
  91 +})
  92 +// 弹窗相关的变量
77 const dialogVisible = ref(false) // 是否显示弹出层 93 const dialogVisible = ref(false) // 是否显示弹出层
78 const dialogTitle = ref('edit') // 弹出层标题 94 const dialogTitle = ref('edit') // 弹出层标题
79 const actionType = ref('') // 操作按钮的类型 95 const actionType = ref('') // 操作按钮的类型
80 -const actionLoading = ref(false) // 按钮Loading  
81 -const xGrid = ref<VxeGridInstance>() // grid Ref 96 +const actionLoading = ref(false) // 按钮 Loading
82 const formRef = ref<FormExpose>() // 表单 Ref 97 const formRef = ref<FormExpose>() // 表单 Ref
83 const detailRef = ref() // 详情 Ref 98 const detailRef = ref() // 详情 Ref
84 99
85 -const { gridOptions } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({  
86 - allSchemas: allSchemas,  
87 - getListApi: ErrorCodeApi.getErrorCodePageApi  
88 -})  
89 // 设置标题 100 // 设置标题
90 const setDialogTile = (type: string) => { 101 const setDialogTile = (type: string) => {
91 dialogTitle.value = t('action.' + type) 102 dialogTitle.value = t('action.' + type)
@@ -125,11 +136,12 @@ const handleDelete = async (rowId: number) =&gt; { @@ -125,11 +136,12 @@ const handleDelete = async (rowId: number) =&gt; {
125 message.success(t('common.delSuccess')) 136 message.success(t('common.delSuccess'))
126 }) 137 })
127 .finally(() => { 138 .finally(() => {
  139 + // 刷新列表
128 xGrid.value?.commitProxy('query') 140 xGrid.value?.commitProxy('query')
129 }) 141 })
130 } 142 }
131 143
132 -// 提交按钮 144 +// 提交新增/修改的表单
133 const submitForm = async () => { 145 const submitForm = async () => {
134 const elForm = unref(formRef)?.getElFormRef() 146 const elForm = unref(formRef)?.getElFormRef()
135 if (!elForm) return 147 if (!elForm) return
@@ -149,6 +161,7 @@ const submitForm = async () =&gt; { @@ -149,6 +161,7 @@ const submitForm = async () =&gt; {
149 dialogVisible.value = false 161 dialogVisible.value = false
150 } finally { 162 } finally {
151 actionLoading.value = false 163 actionLoading.value = false
  164 + // 刷新列表
152 xGrid.value?.commitProxy('query') 165 xGrid.value?.commitProxy('query')
153 } 166 }
154 } 167 }
yudao-ui-admin-vue3/src/views/system/oauth2/client/client.data.ts
@@ -40,38 +40,38 @@ const crudSchemas = reactive&lt;VxeCrudSchema&gt;({ @@ -40,38 +40,38 @@ const crudSchemas = reactive&lt;VxeCrudSchema&gt;({
40 { 40 {
41 title: t('common.status'), 41 title: t('common.status'),
42 field: 'status', 42 field: 'status',
43 - dictType: DICT_TYPE.COMMON_STATUS, 43 + dictType: DICT_TYPE.COMMON_STATUS, // TODO @星语:编辑时,status 展示为 0 或者 1 了
44 isSearch: true 44 isSearch: true
45 }, 45 },
46 { 46 {
47 title: '访问令牌的有效期', 47 title: '访问令牌的有效期',
48 - field: 'accessTokenValiditySeconds' 48 + field: 'accessTokenValiditySeconds' // TODO @星语:数字输入框
49 }, 49 },
50 { 50 {
51 title: '刷新令牌的有效期', 51 title: '刷新令牌的有效期',
52 - field: 'refreshTokenValiditySeconds' 52 + field: 'refreshTokenValiditySeconds' // TODO @星语:数字输入框
53 }, 53 },
54 { 54 {
55 title: '授权类型', 55 title: '授权类型',
56 field: 'authorizedGrantTypes', 56 field: 'authorizedGrantTypes',
57 dictType: DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE, 57 dictType: DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE,
58 form: { 58 form: {
59 - component: 'Select' 59 + component: 'Select' // TODO @星语:多选
60 } 60 }
61 }, 61 },
62 { 62 {
63 title: '授权范围', 63 title: '授权范围',
64 - field: 'scopes', 64 + field: 'scopes', // TODO @星语:带输入的 SELECT
65 isTable: false 65 isTable: false
66 }, 66 },
67 { 67 {
68 title: '自动授权范围', 68 title: '自动授权范围',
69 - field: 'autoApproveScopes', 69 + field: 'autoApproveScopes', // TODO @星语:带输入的 SELECT
70 isTable: false 70 isTable: false
71 }, 71 },
72 { 72 {
73 title: '可重定向的 URI 地址', 73 title: '可重定向的 URI 地址',
74 - field: 'redirectUris', 74 + field: 'redirectUris', // TODO @星语:带输入的 SELECT
75 isTable: false 75 isTable: false
76 }, 76 },
77 { 77 {
@@ -102,7 +102,7 @@ const crudSchemas = reactive&lt;VxeCrudSchema&gt;({ @@ -102,7 +102,7 @@ const crudSchemas = reactive&lt;VxeCrudSchema&gt;({
102 { 102 {
103 title: t('common.createTime'), 103 title: t('common.createTime'),
104 field: 'createTime', 104 field: 'createTime',
105 - formatter: 'formatDate', 105 + formatter: 'formatDate', // TODO @星语:宽度,保证时间可以展示出来
106 isForm: false 106 isForm: false
107 } 107 }
108 ] 108 ]
yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue
@@ -58,6 +58,7 @@ @@ -58,6 +58,7 @@
58 :rules="rules" 58 :rules="rules"
59 /> 59 />
60 <!-- 表单:详情 --> 60 <!-- 表单:详情 -->
  61 + <!-- TODO @星语:展示详情时,有点小丑,可额能得看看 -->
61 <Descriptions 62 <Descriptions
62 v-if="actionType === 'detail'" 63 v-if="actionType === 'detail'"
63 :schema="allSchemas.detailSchema" 64 :schema="allSchemas.detailSchema"
yudao-ui-admin-vue3/src/views/system/oauth2/token/index.vue
@@ -61,7 +61,7 @@ const handleForceLogout = (rowId: number) =&gt; { @@ -61,7 +61,7 @@ const handleForceLogout = (rowId: number) =&gt; {
61 .delConfirm() 61 .delConfirm()
62 .then(async () => { 62 .then(async () => {
63 await TokenApi.deleteAccessTokenApi(rowId) 63 await TokenApi.deleteAccessTokenApi(rowId)
64 - message.success(t('common.delSuccess')) 64 + message.success(t('common.delSuccess')) // TODO 星语:提示内容不对
65 }) 65 })
66 .finally(() => { 66 .finally(() => {
67 // 刷新列表 67 // 刷新列表