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/user/index.vue | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 18f101d..60754e8 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -404,16 +404,19 @@ if (!value) return true; return data.label.indexOf(value) !== -1; }; + /** 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲 */ watch(deptName, val => { proxy.$refs["deptTreeRef"].filter(val); }); + /** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */ function getDeptTree() { deptTreeSelect().then(response => { deptOptions.value = response.data; }); }; + /** 鏌ヨ鐢ㄦ埛鍒楄〃 */ function getList() { loading.value = true; @@ -423,16 +426,19 @@ total.value = res.total; }); }; + /** 鑺傜偣鍗曞嚮浜嬩欢 */ function handleNodeClick(data) { queryParams.value.deptId = data.id; handleQuery(); }; + /** 鎼滅储鎸夐挳鎿嶄綔 */ function handleQuery() { queryParams.value.pageNum = 1; getList(); }; + /** 閲嶇疆鎸夐挳鎿嶄綔 */ function resetQuery() { dateRange.value = []; @@ -441,6 +447,7 @@ proxy.$refs.deptTreeRef.setCurrentKey(null); handleQuery(); }; + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ function handleDelete(row) { const userIds = row.userId || ids.value; @@ -451,12 +458,14 @@ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); }).catch(() => {}); }; + /** 瀵煎嚭鎸夐挳鎿嶄綔 */ function handleExport() { proxy.download("system/user/export", { ...queryParams.value, },`user_${new Date().getTime()}.xlsx`); }; + /** 鐢ㄦ埛鐘舵�佷慨鏀� */ function handleStatusChange(row) { let text = row.status === "0" ? "鍚敤" : "鍋滅敤"; @@ -468,6 +477,7 @@ row.status = row.status === "0" ? "1" : "0"; }); }; + /** 鏇村鎿嶄綔 */ function handleCommand(command, row) { switch (command) { @@ -481,11 +491,13 @@ break; } }; + /** 璺宠浆瑙掕壊鍒嗛厤 */ function handleAuthRole(row) { const userId = row.userId; router.push("/system/user-auth/role/" + userId); }; + /** 閲嶇疆瀵嗙爜鎸夐挳鎿嶄綔 */ function handleResetPwd(row) { proxy.$prompt('璇疯緭鍏�"' + row.userName + '"鐨勬柊瀵嗙爜', "鎻愮ず", { @@ -505,26 +517,31 @@ }); }).catch(() => {}); }; + /** 閫夋嫨鏉℃暟 */ function handleSelectionChange(selection) { ids.value = selection.map(item => item.userId); single.value = selection.length != 1; multiple.value = !selection.length; }; + /** 瀵煎叆鎸夐挳鎿嶄綔 */ function handleImport() { upload.title = "鐢ㄦ埛瀵煎叆"; upload.open = true; }; + /** 涓嬭浇妯℃澘鎿嶄綔 */ function importTemplate() { proxy.download("system/user/importTemplate", { }, `user_template_${new Date().getTime()}.xlsx`); }; + /**鏂囦欢涓婁紶涓鐞� */ const handleFileUploadProgress = (event, file, fileList) => { upload.isUploading = true; }; + /** 鏂囦欢涓婁紶鎴愬姛澶勭悊 */ const handleFileSuccess = (response, file, fileList) => { upload.open = false; @@ -533,10 +550,12 @@ proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true }); getList(); }; + /** 鎻愪氦涓婁紶鏂囦欢 */ function submitFileForm() { proxy.$refs["uploadRef"].submit(); }; + /** 閲嶇疆鎿嶄綔琛ㄥ崟 */ function reset() { form.value = { @@ -555,11 +574,13 @@ }; proxy.resetForm("userRef"); }; + /** 鍙栨秷鎸夐挳 */ function cancel() { open.value = false; reset(); }; + /** 鏂板鎸夐挳鎿嶄綔 */ function handleAdd() { reset(); @@ -571,6 +592,7 @@ form.value.password = initPassword.value; }); }; + /** 淇敼鎸夐挳鎿嶄綔 */ function handleUpdate(row) { reset(); @@ -586,6 +608,7 @@ form.password = ""; }); }; + /** 鎻愪氦鎸夐挳 */ function submitForm() { proxy.$refs["userRef"].validate(valid => { -- Gitblit v1.9.3