From 6666ce5526b1ed17f5c3906c94620cad586745a5 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期五, 28 六月 2024 17:01:39 +0800 Subject: [PATCH] 优化代码 --- src/views/system/role/index.vue | 55 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index ee2e11d..22a5fa4 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -1,6 +1,6 @@ <template> <div class="app-container"> - <el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true"> + <el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true" label-width="68px"> <el-form-item label="瑙掕壊鍚嶇О" prop="roleName"> <el-input v-model="queryParams.roleName" @@ -116,36 +116,16 @@ <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> <template #default="scope"> <el-tooltip content="淇敼" placement="top" v-if="scope.row.roleId !== 1"> - <el-button - type="text" - icon="Edit" - @click="handleUpdate(scope.row)" - v-hasPermi="['system:role:edit']" - ></el-button> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']"></el-button> </el-tooltip> <el-tooltip content="鍒犻櫎" placement="top" v-if="scope.row.roleId !== 1"> - <el-button - type="text" - icon="Delete" - @click="handleDelete(scope.row)" - v-hasPermi="['system:role:remove']" - ></el-button> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']"></el-button> </el-tooltip> <el-tooltip content="鏁版嵁鏉冮檺" placement="top" v-if="scope.row.roleId !== 1"> - <el-button - type="text" - icon="CircleCheck" - @click="handleDataScope(scope.row)" - v-hasPermi="['system:role:edit']" - ></el-button> + <el-button link type="primary" icon="CircleCheck" @click="handleDataScope(scope.row)" v-hasPermi="['system:role:edit']"></el-button> </el-tooltip> <el-tooltip content="鍒嗛厤鐢ㄦ埛" placement="top" v-if="scope.row.roleId !== 1"> - <el-button - type="text" - icon="User" - @click="handleAuthUser(scope.row)" - v-hasPermi="['system:role:edit']" - ></el-button> + <el-button link type="primary" icon="User" @click="handleAuthUser(scope.row)" v-hasPermi="['system:role:edit']"></el-button> </el-tooltip> </template> </el-table-column> @@ -325,17 +305,20 @@ loading.value = false; }); } + /** 鎼滅储鎸夐挳鎿嶄綔 */ function handleQuery() { queryParams.value.pageNum = 1; getList(); } + /** 閲嶇疆鎸夐挳鎿嶄綔 */ function resetQuery() { dateRange.value = []; proxy.resetForm("queryRef"); handleQuery(); } + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ function handleDelete(row) { const roleIds = row.roleId || ids.value; @@ -346,18 +329,21 @@ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); }).catch(() => {}); } + /** 瀵煎嚭鎸夐挳鎿嶄綔 */ function handleExport() { proxy.download("system/role/export", { ...queryParams.value, }, `role_${new Date().getTime()}.xlsx`); } + /** 澶氶�夋閫変腑鏁版嵁 */ function handleSelectionChange(selection) { ids.value = selection.map(item => item.roleId); single.value = selection.length != 1; multiple.value = !selection.length; } + /** 瑙掕壊鐘舵�佷慨鏀� */ function handleStatusChange(row) { let text = row.status === "0" ? "鍚敤" : "鍋滅敤"; @@ -369,6 +355,7 @@ row.status = row.status === "0" ? "1" : "0"; }); } + /** 鏇村鎿嶄綔 */ function handleCommand(command, row) { switch (command) { @@ -382,16 +369,19 @@ break; } } + /** 鍒嗛厤鐢ㄦ埛 */ function handleAuthUser(row) { router.push("/system/role-auth/user/" + row.roleId); } + /** 鏌ヨ鑿滃崟鏍戠粨鏋� */ function getMenuTreeselect() { menuTreeselect().then(response => { menuOptions.value = response.data; }); } + /** 鎵�鏈夐儴闂ㄨ妭鐐规暟鎹� */ function getDeptAllCheckedKeys() { // 鐩墠琚�変腑鐨勯儴闂ㄨ妭鐐� @@ -401,6 +391,7 @@ checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); return checkedKeys; } + /** 閲嶇疆鏂板鐨勮〃鍗曚互鍙婂叾浠栨暟鎹� */ function reset() { if (menuRef.value != undefined) { @@ -424,6 +415,7 @@ }; proxy.resetForm("roleRef"); } + /** 娣诲姞瑙掕壊 */ function handleAdd() { reset(); @@ -431,6 +423,7 @@ open.value = true; title.value = "娣诲姞瑙掕壊"; } + /** 淇敼瑙掕壊 */ function handleUpdate(row) { reset(); @@ -453,6 +446,7 @@ title.value = "淇敼瑙掕壊"; }); } + /** 鏍规嵁瑙掕壊ID鏌ヨ鑿滃崟鏍戠粨鏋� */ function getRoleMenuTreeselect(roleId) { return roleMenuTreeselect(roleId).then(response => { @@ -460,6 +454,7 @@ return response; }); } + /** 鏍规嵁瑙掕壊ID鏌ヨ閮ㄩ棬鏍戠粨鏋� */ function getDeptTree(roleId) { return deptTreeSelect(roleId).then(response => { @@ -467,6 +462,7 @@ return response; }); } + /** 鏍戞潈闄愶紙灞曞紑/鎶樺彔锛�*/ function handleCheckedTreeExpand(value, type) { if (type == "menu") { @@ -481,6 +477,7 @@ } } } + /** 鏍戞潈闄愶紙鍏ㄩ��/鍏ㄤ笉閫夛級 */ function handleCheckedTreeNodeAll(value, type) { if (type == "menu") { @@ -489,6 +486,7 @@ deptRef.value.setCheckedNodes(value ? deptOptions.value : []); } } + /** 鏍戞潈闄愶紙鐖跺瓙鑱斿姩锛� */ function handleCheckedTreeConnect(value, type) { if (type == "menu") { @@ -497,6 +495,7 @@ form.value.deptCheckStrictly = value ? true : false; } } + /** 鎵�鏈夎彍鍗曡妭鐐规暟鎹� */ function getMenuAllCheckedKeys() { // 鐩墠琚�変腑鐨勮彍鍗曡妭鐐� @@ -506,6 +505,7 @@ checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); return checkedKeys; } + /** 鎻愪氦鎸夐挳 */ function submitForm() { proxy.$refs["roleRef"].validate(valid => { @@ -528,17 +528,20 @@ } }); } + /** 鍙栨秷鎸夐挳 */ function cancel() { open.value = false; reset(); } + /** 閫夋嫨瑙掕壊鏉冮檺鑼冨洿瑙﹀彂 */ function dataScopeSelectChange(value) { if (value !== "2") { deptRef.value.setCheckedKeys([]); } } + /** 鍒嗛厤鏁版嵁鏉冮檺鎿嶄綔 */ function handleDataScope(row) { reset(); @@ -558,6 +561,7 @@ title.value = "鍒嗛厤鏁版嵁鏉冮檺"; }); } + /** 鎻愪氦鎸夐挳锛堟暟鎹潈闄愶級 */ function submitDataScope() { if (form.value.roleId != undefined) { @@ -569,6 +573,7 @@ }); } } + /** 鍙栨秷鎸夐挳锛堟暟鎹潈闄愶級*/ function cancelDataScope() { openDataScope.value = false; -- Gitblit v1.9.3