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