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,9 +6,13 @@
6 <ContentWrap> 6 <ContentWrap>
7 <!-- 操作工具栏 --> 7 <!-- 操作工具栏 -->
8 <div class="mb-10px"> 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 </div> 16 </div>
13 <!-- 列表 --> 17 <!-- 列表 -->
14 <Table 18 <Table
yudao-ui-admin-vue3/src/views/system/tenantPackage/index.vue
@@ -6,9 +6,12 @@ @@ -6,9 +6,12 @@
6 <ContentWrap> 6 <ContentWrap>
7 <!-- 操作工具栏 --> 7 <!-- 操作工具栏 -->
8 <div class="mb-10px"> 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 </div> 15 </div>
13 <!-- 列表 --> 16 <!-- 列表 -->
14 <Table 17 <Table
@@ -30,12 +33,8 @@ @@ -30,12 +33,8 @@
30 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> 33 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
31 </template> 34 </template>
32 <template #action="{ row }"> 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 </template> 38 </template>
40 </Table> 39 </Table>
41 </ContentWrap> 40 </ContentWrap>
yudao-ui-admin-vue3/src/views/system/user/index.vue
@@ -4,9 +4,7 @@ @@ -4,9 +4,7 @@
4 <template #header> 4 <template #header>
5 <div class="card-header"> 5 <div class="card-header">
6 <span>部门列表</span> 6 <span>部门列表</span>
7 - <el-button link class="button" type="primary" @click="handleDeptEdit">  
8 - 修改部门  
9 - </el-button> 7 + <XTextButton title="修改部门" @click="handleDeptEdit()" />
10 </div> 8 </div>
11 </template> 9 </template>
12 <el-input v-model="filterText" placeholder="搜索部门" /> 10 <el-input v-model="filterText" placeholder="搜索部门" />
@@ -37,23 +35,27 @@ @@ -37,23 +35,27 @@
37 /> 35 />
38 <!-- 操作工具栏 --> 36 <!-- 操作工具栏 -->
39 <div class="mb-10px"> 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 v-hasPermi="['system:user:import']" 49 v-hasPermi="['system:user:import']"
46 @click="importDialogVisible = true" 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 type="warning" 53 type="warning"
  54 + preIcon="ep:download"
  55 + :title="t('action.export')"
52 v-hasPermi="['system:user:export']" 56 v-hasPermi="['system:user:export']"
53 @click="exportList('用户数据.xls')" 57 @click="exportList('用户数据.xls')"
54 - >  
55 - <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}  
56 - </el-button> 58 + />
57 </div> 59 </div>
58 <!-- 列表 --> 60 <!-- 列表 -->
59 <Table 61 <Table
@@ -80,46 +82,38 @@ @@ -80,46 +82,38 @@
80 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> 82 <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
81 </template> 83 </template>
82 <template #action="{ row }"> 84 <template #action="{ row }">
83 - <el-button  
84 - link  
85 - type="primary" 85 + <XTextButton
  86 + preIcon="ep:edit"
  87 + :title="t('action.edit')"
86 v-hasPermi="['system:user:update']" 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 v-hasPermi="['system:user:update']" 95 v-hasPermi="['system:user:update']"
95 @click="handleDetail(row)" 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 v-hasPermi="['system:user:update-password']" 101 v-hasPermi="['system:user:update-password']"
103 @click="handleResetPwd(row)" 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 v-hasPermi="['system:permission:assign-user-role']" 107 v-hasPermi="['system:permission:assign-user-role']"
111 @click="handleRole(row)" 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 v-hasPermi="['system:user:delete']" 114 v-hasPermi="['system:user:delete']"
119 @click="delList(row.id, false)" 115 @click="delList(row.id, false)"
120 - >  
121 - <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}  
122 - </el-button> 116 + />
123 </template> 117 </template>
124 </Table> 118 </Table>
125 </el-card> 119 </el-card>
@@ -296,6 +290,7 @@ import { useRouter } from &#39;vue-router&#39; @@ -296,6 +290,7 @@ import { useRouter } from &#39;vue-router&#39;
296 import { CommonStatusEnum } from '@/utils/constants' 290 import { CommonStatusEnum } from '@/utils/constants'
297 import { getAccessToken, getTenantId } from '@/utils/auth' 291 import { getAccessToken, getTenantId } from '@/utils/auth'
298 import { useMessage } from '@/hooks/web/useMessage' 292 import { useMessage } from '@/hooks/web/useMessage'
  293 +import { nextTick } from 'process'
299 294
300 const message = useMessage() 295 const message = useMessage()
301 296
@@ -365,23 +360,24 @@ const setDialogTile = async (type: string) =&gt; { @@ -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 deptId.value = null 365 deptId.value = null
371 postIds.value = [] 366 postIds.value = []
372 dialogVisible.value = true 367 dialogVisible.value = true
373 dialogTitle.value = t('action.create') 368 dialogTitle.value = t('action.create')
374 actionType.value = 'create' 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 await setDialogTile('update') 376 await setDialogTile('update')
381 unref(formRef)?.delSchema('username') 377 unref(formRef)?.delSchema('username')
382 unref(formRef)?.delSchema('password') 378 unref(formRef)?.delSchema('password')
383 // 设置数据 379 // 设置数据
384 - const res = await UserApi.getUserApi(row.id) 380 + const res = await UserApi.getUserApi(rowId)
385 deptId.value = res.deptId 381 deptId.value = res.deptId
386 postIds.value = res.postIds 382 postIds.value = res.postIds
387 unref(formRef)?.setValues(res) 383 unref(formRef)?.setValues(res)