Commit 9cf4500ed56034911f2ef83cb45a202a9399619d

Authored by xingyu4j
1 parent d3526e6f

refactor: button

yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue
... ... @@ -6,9 +6,13 @@
6 6 <ContentWrap>
7 7 <!-- 操作工具栏 -->
8 8 <div class="mb-10px">
9   - <el-button type="primary" v-hasPermi="['system:sms-channel:create']" @click="handleCreate">
10   - <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
11   - </el-button>
  9 + <XButton
  10 + type="primary"
  11 + preIcon="ep:zoom-in"
  12 + :title="t('action.add')"
  13 + v-hasPermi="['system:sms-channel:create']"
  14 + @click="handleCreate()"
  15 + />
12 16 </div>
13 17 <!-- 列表 -->
14 18 <Table
... ...
yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue
... ... @@ -6,9 +6,12 @@
6 6 <ContentWrap>
7 7 <!-- 操作工具栏 -->
8 8 <div class="mb-10px">
9   - <el-button type="primary" @click="handleCreate">
10   - <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
11   - </el-button>
  9 + <XButton
  10 + type="primary"
  11 + preIcon="ep:zoom-in"
  12 + :title="t('action.add')"
  13 + @click="handleCreate()"
  14 + />
12 15 </div>
13 16 <!-- 列表 -->
14 17 <Table
... ... @@ -30,12 +33,8 @@
30 33 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
31 34 </template>
32 35 <template #action="{ row }">
33   - <el-button link type="primary" @click="handleUpdate(row)">
34   - <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
35   - </el-button>
36   - <el-button link type="primary" @click="delList(row.id, false)">
37   - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
38   - </el-button>
  36 + <XTextButton preIcon="ep:edit" :title="t('action.edit')" @click="handleUpdate(row)" />
  37 + <XTextButton preIcon="ep:delete" :title="t('action.del')" @click="delList(row.id, false)" />
39 38 </template>
40 39 </Table>
41 40 </ContentWrap>
... ...
yudao-ui-admin-vue3/src/views/system/user/index.vue
... ... @@ -4,9 +4,7 @@
4 4 <template #header>
5 5 <div class="card-header">
6 6 <span>部门列表</span>
7   - <el-button link class="button" type="primary" @click="handleDeptEdit">
8   - 修改部门
9   - </el-button>
  7 + <XTextButton title="修改部门" @click="handleDeptEdit()" />
10 8 </div>
11 9 </template>
12 10 <el-input v-model="filterText" placeholder="搜索部门" />
... ... @@ -37,23 +35,27 @@
37 35 />
38 36 <!-- 操作工具栏 -->
39 37 <div class="mb-10px">
40   - <el-button type="primary" v-hasPermi="['system:user:create']" @click="handleAdd">
41   - <Icon icon="ep:zoom-in" class="mr-5px" /> {{ t('action.add') }}
42   - </el-button>
43   - <el-button
44   - type="info"
  38 + <XButton
  39 + type="primary"
  40 + preIcon="ep:zoom-in"
  41 + :title="t('action.add')"
  42 + v-hasPermi="['system:user:create']"
  43 + @click="handleCreate()"
  44 + />
  45 + <XButton
  46 + type="warning"
  47 + preIcon="ep:upload"
  48 + :title="t('action.import')"
45 49 v-hasPermi="['system:user:import']"
46 50 @click="importDialogVisible = true"
47   - >
48   - <Icon icon="ep:upload" class="mr-5px" /> {{ t('action.import') }}
49   - </el-button>
50   - <el-button
  51 + />
  52 + <XButton
51 53 type="warning"
  54 + preIcon="ep:download"
  55 + :title="t('action.export')"
52 56 v-hasPermi="['system:user:export']"
53 57 @click="exportList('用户数据.xls')"
54   - >
55   - <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
56   - </el-button>
  58 + />
57 59 </div>
58 60 <!-- 列表 -->
59 61 <Table
... ... @@ -80,46 +82,38 @@
80 82 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
81 83 </template>
82 84 <template #action="{ row }">
83   - <el-button
84   - link
85   - type="primary"
  85 + <XTextButton
  86 + preIcon="ep:edit"
  87 + :title="t('action.edit')"
86 88 v-hasPermi="['system:user:update']"
87   - @click="handleUpdate(row)"
88   - >
89   - <Icon icon="ep:edit" class="mr-1px" /> {{ t('action.edit') }}
90   - </el-button>
91   - <el-button
92   - link
93   - type="primary"
  89 + @click="handleUpdate(row.id)"
  90 + />
  91 + <!-- 操作:详情 -->
  92 + <XTextButton
  93 + preIcon="ep:view"
  94 + :title="t('action.detail')"
94 95 v-hasPermi="['system:user:update']"
95 96 @click="handleDetail(row)"
96   - >
97   - <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
98   - </el-button>
99   - <el-button
100   - link
101   - type="primary"
  97 + />
  98 + <XTextButton
  99 + preIcon="ep:key"
  100 + title="重置密码"
102 101 v-hasPermi="['system:user:update-password']"
103 102 @click="handleResetPwd(row)"
104   - >
105   - <Icon icon="ep:key" class="mr-1px" /> 重置密码
106   - </el-button>
107   - <el-button
108   - link
109   - type="primary"
  103 + />
  104 + <XTextButton
  105 + preIcon="ep:key"
  106 + title="分配角色"
110 107 v-hasPermi="['system:permission:assign-user-role']"
111 108 @click="handleRole(row)"
112   - >
113   - <Icon icon="ep:key" class="mr-1px" /> 分配角色
114   - </el-button>
115   - <el-button
116   - link
117   - type="primary"
  109 + />
  110 + <!-- 操作:删除 -->
  111 + <XTextButton
  112 + preIcon="ep:delete"
  113 + :title="t('action.del')"
118 114 v-hasPermi="['system:user:delete']"
119 115 @click="delList(row.id, false)"
120   - >
121   - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
122   - </el-button>
  116 + />
123 117 </template>
124 118 </Table>
125 119 </el-card>
... ... @@ -296,6 +290,7 @@ import { useRouter } from &#39;vue-router&#39;
296 290 import { CommonStatusEnum } from '@/utils/constants'
297 291 import { getAccessToken, getTenantId } from '@/utils/auth'
298 292 import { useMessage } from '@/hooks/web/useMessage'
  293 +import { nextTick } from 'process'
299 294  
300 295 const message = useMessage()
301 296  
... ... @@ -365,23 +360,24 @@ const setDialogTile = async (type: string) =&gt; {
365 360 }
366 361  
367 362 // 新增操作
368   -const handleAdd = async () => {
  363 +const handleCreate = async () => {
369 364 // 重置表单
370 365 deptId.value = null
371 366 postIds.value = []
372 367 dialogVisible.value = true
373 368 dialogTitle.value = t('action.create')
374 369 actionType.value = 'create'
375   - await unref(formRef)?.getElFormRef().resetFields()
  370 + await nextTick()
  371 + unref(formRef)?.getElFormRef().resetFields()
376 372 }
377 373  
378 374 // 修改操作
379   -const handleUpdate = async (row: UserVO) => {
  375 +const handleUpdate = async (rowId: number) => {
380 376 await setDialogTile('update')
381 377 unref(formRef)?.delSchema('username')
382 378 unref(formRef)?.delSchema('password')
383 379 // 设置数据
384   - const res = await UserApi.getUserApi(row.id)
  380 + const res = await UserApi.getUserApi(rowId)
385 381 deptId.value = res.deptId
386 382 postIds.value = res.postIds
387 383 unref(formRef)?.setValues(res)
... ...