From 1c2da6dfb1e23fa38c58ada5d7e98f91ae2d738e Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期三, 11 九月 2024 14:19:21 +0800 Subject: [PATCH] 修改导出文件名称 --- src/views/system/user/index.vue | 114 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 3f988fa..aa2e13b 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -8,7 +8,7 @@ v-model="deptName" placeholder="璇疯緭鍏ラ儴闂ㄥ悕绉�" clearable - prefix-icon="el-icon-search" + prefix-icon="Search" style="margin-bottom: 20px" /> </div> @@ -19,6 +19,8 @@ :expand-on-click-node="false" :filter-node-method="filterNode" ref="deptTreeRef" + node-key="id" + highlight-current default-expand-all @node-click="handleNodeClick" /> @@ -151,41 +153,17 @@ </el-table-column> <el-table-column label="鎿嶄綔" align="center" width="150" class-name="small-padding fixed-width"> <template #default="scope"> - <el-tooltip content="淇敼" placement="top"> - <el-button - v-if="scope.row.userId !== 1" - type="text" - icon="Edit" - @click="handleUpdate(scope.row)" - v-hasPermi="['system:user:edit']" - ></el-button> + <el-tooltip content="淇敼" placement="top" v-if="scope.row.userId !== 1"> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']"></el-button> </el-tooltip> - <el-tooltip content="鍒犻櫎" placement="top"> - <el-button - v-if="scope.row.userId !== 1" - type="text" - icon="Delete" - @click="handleDelete(scope.row)" - v-hasPermi="['system:user:remove']" - ></el-button> + <el-tooltip content="鍒犻櫎" placement="top" v-if="scope.row.userId !== 1"> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']"></el-button> </el-tooltip> - <el-tooltip content="閲嶇疆瀵嗙爜" placement="top"> - <el-button - v-if="scope.row.userId !== 1" - type="text" - icon="Key" - @click="handleResetPwd(scope.row)" - v-hasPermi="['system:user:resetPwd']" - ></el-button> + <el-tooltip content="閲嶇疆瀵嗙爜" placement="top" v-if="scope.row.userId !== 1"> + <el-button link type="primary" icon="Key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button> </el-tooltip> - <el-tooltip content="鍒嗛厤瑙掕壊" placement="top"> - <el-button - v-if="scope.row.userId !== 1" - type="text" - icon="CircleCheck" - @click="handleAuthRole(scope.row)" - v-hasPermi="['system:user:edit']" - ></el-button> + <el-tooltip content="鍒嗛厤瑙掕壊" placement="top" v-if="scope.row.userId !== 1"> + <el-button link type="primary" icon="CircleCheck" @click="handleAuthRole(scope.row)" v-hasPermi="['system:user:edit']"></el-button> </el-tooltip> </template> </el-table-column> @@ -211,11 +189,13 @@ </el-col> <el-col :span="12"> <el-form-item label="褰掑睘閮ㄩ棬" prop="deptId"> - <tree-select - v-model:value="form.deptId" - :options="deptOptions" + <el-tree-select + v-model="form.deptId" + :data="deptOptions" + :props="{ value: 'id', label: 'label', children: 'children' }" + value-key="id" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" - :objMap="{ value: 'id', label: 'label', children: 'children' }" + check-strictly /> </el-form-item> </el-col> @@ -263,7 +243,7 @@ <el-radio v-for="dict in sys_normal_disable" :key="dict.value" - :label="dict.value" + :value="dict.value" >{{ dict.label }}</el-radio> </el-radio-group> </el-form-item> @@ -351,8 +331,7 @@ <script setup name="User"> import { getToken } from "@/utils/auth"; -import { treeselect } from "@/api/system/dept"; -import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser } from "@/api/system/user"; +import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user"; const router = useRouter(); const { proxy } = getCurrentInstance(); @@ -386,7 +365,7 @@ // 璁剧疆涓婁紶鐨勮姹傚ご閮� headers: { Authorization: "Bearer " + getToken() }, // 涓婁紶鐨勫湴鍧� - url: import.meta.env.VITE_APP_BASE_API + "system/user/importData" + url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData" }); // 鍒楁樉闅愪俊鎭� const columns = ref([ @@ -412,7 +391,7 @@ rules: { userName: [{ required: true, message: "鐢ㄦ埛鍚嶇О涓嶈兘涓虹┖", trigger: "blur" }, { min: 2, max: 20, message: "鐢ㄦ埛鍚嶇О闀垮害蹇呴』浠嬩簬 2 鍜� 20 涔嬮棿", trigger: "blur" }], nickName: [{ required: true, message: "鐢ㄦ埛鏄电О涓嶈兘涓虹┖", trigger: "blur" }], - password: [{ required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" }, { min: 5, max: 20, message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿", trigger: "blur" }], + password: [{ required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" }, { min: 5, max: 20, message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > \" ' \\\ |", trigger: "blur" }], email: [{ type: "email", message: "璇疯緭鍏ユ纭殑閭鍦板潃", trigger: ["blur", "change"] }], phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜", trigger: "blur" }] } @@ -425,16 +404,19 @@ if (!value) return true; return data.label.indexOf(value) !== -1; }; + /** 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲 */ watch(deptName, val => { proxy.$refs["deptTreeRef"].filter(val); }); + /** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */ -function getTreeselect() { - treeselect().then(response => { +function getDeptTree() { + deptTreeSelect().then(response => { deptOptions.value = response.data; }); }; + /** 鏌ヨ鐢ㄦ埛鍒楄〃 */ function getList() { loading.value = true; @@ -444,22 +426,28 @@ total.value = res.total; }); }; + /** 鑺傜偣鍗曞嚮浜嬩欢 */ function handleNodeClick(data) { queryParams.value.deptId = data.id; handleQuery(); }; + /** 鎼滅储鎸夐挳鎿嶄綔 */ function handleQuery() { queryParams.value.pageNum = 1; getList(); }; + /** 閲嶇疆鎸夐挳鎿嶄綔 */ function resetQuery() { dateRange.value = []; proxy.resetForm("queryRef"); + queryParams.value.deptId = undefined; + proxy.$refs.deptTreeRef.setCurrentKey(null); handleQuery(); }; + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ function handleDelete(row) { const userIds = row.userId || ids.value; @@ -470,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" ? "鍚敤" : "鍋滅敤"; @@ -487,6 +477,7 @@ row.status = row.status === "0" ? "1" : "0"; }); }; + /** 鏇村鎿嶄綔 */ function handleCommand(command, row) { switch (command) { @@ -500,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 + '"鐨勬柊瀵嗙爜', "鎻愮ず", { @@ -513,53 +506,56 @@ closeOnClickModal: false, inputPattern: /^.{5,20}$/, inputErrorMessage: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿", + inputValidator: (value) => { + if (/<|>|"|'|\||\\/.test(value)) { + return "涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > \" ' \\\ |" + } + }, }).then(({ value }) => { resetUserPwd(row.userId, value).then(response => { proxy.$modal.msgSuccess("淇敼鎴愬姛锛屾柊瀵嗙爜鏄細" + value); }); }).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; upload.isUploading = false; - proxy.$refs["uploadRef"].clearFiles(); + proxy.$refs["uploadRef"].handleRemove(file); 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 initTreeData() { - // 鍒ゆ柇閮ㄩ棬鐨勬暟鎹槸鍚﹀瓨鍦紝瀛樺湪涓嶈幏鍙栵紝涓嶅瓨鍦ㄥ垯鑾峰彇 - if (deptOptions.value === undefined) { - treeselect().then(response => { - deptOptions.value = response.data; - }); - } -}; + /** 閲嶇疆鎿嶄綔琛ㄥ崟 */ function reset() { form.value = { @@ -578,27 +574,28 @@ }; proxy.resetForm("userRef"); }; + /** 鍙栨秷鎸夐挳 */ function cancel() { open.value = false; reset(); }; + /** 鏂板鎸夐挳鎿嶄綔 */ function handleAdd() { reset(); - initTreeData(); getUser().then(response => { postOptions.value = response.posts; roleOptions.value = response.roles; open.value = true; title.value = "娣诲姞鐢ㄦ埛"; - form.password.value = initPassword.value; + form.value.password = initPassword.value; }); }; + /** 淇敼鎸夐挳鎿嶄綔 */ function handleUpdate(row) { reset(); - initTreeData(); const userId = row.userId || ids.value; getUser(userId).then(response => { form.value = response.data; @@ -611,6 +608,7 @@ form.password = ""; }); }; + /** 鎻愪氦鎸夐挳 */ function submitForm() { proxy.$refs["userRef"].validate(valid => { @@ -632,6 +630,6 @@ }); }; -getTreeselect(); +getDeptTree(); getList(); </script> -- Gitblit v1.9.3