From 2591e298a3fd1332ad0ca33059f6ba0b7d426f51 Mon Sep 17 00:00:00 2001 From: pengwei <2071057782@qq.com> Date: 星期四, 20 三月 2025 10:08:00 +0800 Subject: [PATCH] 最新代码提交 --- 项目代码/client/src/views/tts/UserManagement/Usermanagement.vue | 488 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 353 insertions(+), 135 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/tts/UserManagement/Usermanagement.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/tts/UserManagement/Usermanagement.vue" index 2892d82..fcff922 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/tts/UserManagement/Usermanagement.vue" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/tts/UserManagement/Usermanagement.vue" @@ -39,7 +39,7 @@ size="small" /> </div> - <!-- <div class="serch_box"> + <div class="serch_box"> <div class="serchb"> <el-select v-model="queryForm.selectType" @@ -56,11 +56,11 @@ </el-select> </div> <input - v-model="queryForm.selectName" + v-model="queryForm.selectInput" placeholder="璇疯緭鍏ュ叧閿瘝鎼滅储" style="border-left: 0.06rem solid #e2e2e2" /> - </div> --> + </div> <el-button @click="handleQuery" type="primary" @@ -87,7 +87,7 @@ display: flex; align-items: center; " - ><el-icon style="margin-right: 0.2rem"><Plus /></el-icon + ><el-icon style="margin-right: 0.2rem"> <Plus /> </el-icon >鏂板缓</el-button > <!-- 鐢ㄦ埛瑙掕壊鏂板缓 --> @@ -103,7 +103,7 @@ display: flex; align-items: center; " - ><el-icon style="margin-right: 0.2rem"><Plus /></el-icon + ><el-icon style="margin-right: 0.2rem"> <Plus /> </el-icon >鏂板缓</el-button > <el-button @@ -181,7 +181,7 @@ <template #default="scope"> <el-image style="width: 70px; height: 70px" - :src="scope.row.headImageUrl" + :src="'http://115.159.85.185:9098' + scope.row.headImageUrl" show-progress :initial-index="4" fit="cover" @@ -206,12 +206,21 @@ /> <el-table-column label="鎿嶄綔" align="center" min-width="3%"> <template #default="scope"> - <el-button size="small" type="text" @click="Edit(scope.row)" + <el-button + size="small" + type="text" + @click="Edit(scope.row)" + :disabled=" + scope.row.userName == 'admin' || scope.row.user_Id == '1' + " >缂栬緫</el-button > <el-button size="small" type="text" + :disabled=" + scope.row.userName == 'admin' || scope.row.user_Id == '1' + " @click="Editpassword(scope.row)" >淇敼瀵嗙爜</el-button > @@ -244,12 +253,8 @@ <el-table-column prop="name" label="瑙掕壊鏉冮檺" align="center"> <template #default="scope"> <span - @click=" - router.replace({ - path: `/permission`, - state: { info: JSON.stringify(scope.row) }, - }) - " + v-if="scope.row.roleId != '20'" + @click="toDetail(scope.row)" style="color: #4386ff; cursor: pointer" >绠$悊</span > @@ -270,6 +275,7 @@ <el-table-column label="鎿嶄綔" align="center"> <template #default="scope"> <span + v-if="scope.row.roleId != '20'" style="color: blue; font-size: 0.88rem; cursor: pointer" @click="EditRole(scope.row)" >缂栬緫</span @@ -298,17 +304,6 @@ @size-change="handleSizeChange" @current-change="handleCurrentChange" /> - <el-pagination - v-if="isactive == 2" - size="small" - background - layout="prev, pager, next" - :current-page="pageQuery.page" - :page-size="pageQuery.rows" - :total="pageTotal" - @size-change="RoleSizeChange" - @current-change="RoleCurrentChange" - /> </div> </div> @@ -320,6 +315,7 @@ :before-close="handleClose" :show-close="false" :align-center="true" + @close="resetForm(formUserRef)" > <template #title> <div @@ -339,7 +335,9 @@ :model="formUser" label-width="auto" label-position="top" - ref="formRef" + :rules="rules" + ref="formUserRef" + :hide-required-asterisk="true" > <el-row :gutter="20"> <el-col :span="8"> @@ -399,14 +397,14 @@ </el-row> <el-row :gutter="20"> <el-col :span="8"> - <el-form-item> + <el-form-item prop="role_Id"> <template #label> <div style="display: flex; align-items: flex-end"> <span style="color: red; margin-right: 0.2rem">*</span> <span style="font-size: 0.88rem; color: black; font-weight: bold" - >鐢ㄦ埛瑙掕壊</span - > + >鐢ㄦ埛瑙掕壊 + </span> </div> </template> <el-select @@ -415,6 +413,7 @@ size="small" > <el-option + :disabled="item.value == 20" v-for="item in groupOptions" :key="item.value" :label="item.label" @@ -424,7 +423,32 @@ </el-form-item> </el-col> <el-col :span="8"> - <el-form-item> + <el-form-item prop="roleName"> + <template #label> + <div style="display: flex; align-items: flex-end"> + <span style="color: red; margin-right: 0.2rem">*</span> + <span + style="font-size: 0.88rem; color: black; font-weight: bold" + >鐢ㄦ埛绫诲瀷 + </span> + </div> + </template> + <el-select + v-model="formUser.roleName" + placeholder="璇烽�夋嫨" + size="small" + > + <el-option + v-for="item in roleNameList" + :key="item.value" + :label="item.label" + :value="item.value" + /> + </el-select> + </el-form-item> + </el-col> + <el-col :span="8"> + <el-form-item prop="enable"> <template #label> <div style="display: flex; align-items: flex-end"> <span style="color: red; margin-right: 0.2rem">*</span> @@ -458,25 +482,32 @@ <span style="font-size: 0.88rem; color: black; font-weight: bold" >浜鸿劯鍥剧墖</span - ><span + > + <!-- <span style=" color: rgba(255, 0, 0, 1); font-size: 0.75rem; margin-left: 0.5rem; " >娉細鏈�澶氬彲涓婁紶涓夊紶锛屽浘鐗囬渶瑕佹瑙勭殑浜哄儚璇佷欢鐓�</span - > + > --> </div> </template> <el-upload + ref="uploadRef" + name="files" class="avatar-uploader" - action="#" + action="http://115.159.85.185:9098/api/User/SaveFiles" list-type="picture-card" - :auto-upload="false" + limit="1" + :auto-upload="true" @before-upload="beforeAvatarUpload" - :on-change="handleAvatarSuccess" + :on-success="handleAvatarSuccess" + :file-list="fileList != [] ? fileList : []" > - <el-icon><Plus /></el-icon> + <el-icon> + <Plus /> + </el-icon> <template #file="{ file }"> <div> <img @@ -496,14 +527,18 @@ class="el-upload-list__item-delete" @click="handleDownload(file)" > - <el-icon size="15"><Download /></el-icon> + <el-icon size="15"> + <Download /> + </el-icon> </span> <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)" > - <el-icon size="15"><Delete /></el-icon> + <el-icon size="15"> + <Delete /> + </el-icon> </span> </span> </div> @@ -525,7 +560,7 @@ <el-button size="small" type="primary" - @click="saveObj" + @click="saveObj(formUserRef)" style="height: 2rem; font-size: 0.88rem" > 淇濆瓨 @@ -558,7 +593,7 @@ </div> </template> <el-form - :model="formpassword" + :model="formUser" label-width="auto" label-position="top" ref="formpasswordRef" @@ -585,11 +620,11 @@ </div> </el-col> </el-row> - <el-form-item prop="password"> + <el-form-item prop="newPwd"> <el-input style="margin-top: 1rem" size="large" - v-model="formpassword.password" + v-model="formUser.newPwd" placeholder="璇疯緭鍏�" /> </el-form-item> @@ -623,6 +658,7 @@ :before-close="handleClose" :show-close="false" :align-center="true" + @close="resetForm1(formRoleRef)" > <template #title> <div @@ -717,7 +753,7 @@ </div> </template> <script setup> -import { ref, reactive, onMounted } from "vue"; +import { ref, reactive, onMounted, toRef } from "vue"; import { ElMessage, ElMessageBox } from "element-plus"; import { GetUserList, @@ -726,6 +762,10 @@ DelApi, ExportApi, ExportApi1, + UpdatePassword, + UpdatePwd, + AddUserApi, + EditUserApi, } from "@/api/user"; import { useRouter } from "vue-router"; import { formatTime } from "@/utils/index.js"; @@ -736,17 +776,19 @@ UpdateRoleApi, DeleteRoleApi, } from "@/api/role"; -const queryForm = reactive({ +let obj = { selectName: "", selectTime: [], // 鏃堕棿鑼冨洿 selectType: "", selectInput: "", -}); +}; +const queryForm = toRef({ ...obj }); const router = useRouter(); const tableData = ref([]); -const grideData = ref([{ id: 1 }]); -const formRef = ref(); +const grideData = ref([]); +//鏂板缓鐢ㄦ埛ref +const formUserRef = ref(); const options = ref([]); const props = { multiple: true }; const isoptins = ref([ @@ -758,17 +800,16 @@ ]); //鍒嗙粍 const groupOptions = ref([ - { value: 1, label: "瓒呯骇绠$悊鍛�" }, - { value: 2, label: "璐ㄦ缁�" }, - { value: 3, label: "鐢垫皵缁�" }, - { value: 4, label: "鏈烘缁�" }, - { value: 5, label: "鍦版矡缁�" }, + { value: 20, label: "瓒呯骇绠$悊鍛�" }, + { value: 21, label: "璐ㄦ缁�" }, + { value: 22, label: "鐢垫皵缁�" }, + { value: 23, label: "鏈烘缁�" }, + { value: 24, label: "鍦版矡缁�" }, ]); -const table = ref(false); const formUser = ref({ user_Id: undefined, userName: "", - role_Id: 2, + role_Id: 21, roleName: "", phoneNo: "", remark: "", @@ -777,14 +818,47 @@ dept_Id: 0, enable: 1, headImageUrl: "", + createDate: formatTime(new Date()), //鍒涘缓鏃堕棿 + creater: JSON.parse(localStorage.getItem("user")).userName, //鍒涘缓浜� + newPwd: "", }); -const userform = reactive({ - userName: "", - description: "", +const rules = reactive({ + userName: { + required: true, + message: "璇疯緭鍏ョ敤鎴峰悕", + trigger: "blur", + }, + role_Id: { + required: true, + message: "璇烽�夋嫨瑙掕壊", + trigger: "change", + }, + newPwd: [ + { + required: true, + message: "璇疯緭鍏ュ瘑鐮�", + trigger: "blur", + }, + ], + realName: { + required: true, + message: "璇疯緭鍏ュ鍚�", + trigger: "blur", + }, + phoneNo: { + required: true, + message: "璇疯緭鍏ユ墜鏈哄彿", + trigger: "blur", + }, + userTrueName: { + required: true, + message: "璇疯緭鍏ョ湡瀹炲鍚�", + trigger: "blur", + }, }); + const formpasswordRef = ref(); const isactive = ref(1); -const claimdialogVisible = ref(false); const dialogVisible = ref(false); const imgdialogVisible = ref(false); const dialogImageUrl = ref(""); @@ -792,27 +866,7 @@ const dialogVisible1 = ref(false); //鐢ㄦ埛瑙掕壊鏂板缓 const dialogVisible2 = ref(false); -const TorquedialogVisible = ref(false); -//鍒嗛〉璇锋眰鍙傛暟 -const pageQuery = ref({ - page: 1, //褰撳墠椤甸潰 - rows: 10, //姣忛〉鏄剧ず鏉℃暟 - order: "desc", //鎺掑簭鏂瑰紡 - sort: "createDate", //鎺掑簭瀛楁 - wheres: "", //鏉′欢鏌ヨ -}); - -const changeactive = (index) => { - isactive.value = index; - if (isactive.value == 1) { - selectoptions.value = userOptions; - initData(); - } else { - selectoptions.value = roleOptions; - getRole(); - } -}; - +//绛涢�夋潯浠� const userOptions = [ { value: "userName", @@ -827,7 +881,18 @@ label: "鑱旂郴鏂瑰紡", }, ]; - +const fileList = ref([]); +const roleNameList = ref([ + { value: "鐢垫皵璐ㄦ", label: "鐢垫皵璐ㄦ" }, + { value: "鏈烘璐ㄦ", label: "鏈烘璐ㄦ" }, + { value: "鍦版矡璐ㄦ", label: "鍦版矡璐ㄦ" }, + { value: "鐢垫皵鍔涚煩", label: "鐢垫皵鍔涚煩" }, + { value: "鐢垫皵杈呭姪", label: "鐢垫皵杈呭姪" }, + { value: "鏈烘鍔涚煩", label: "鏈烘鍔涚煩" }, + { value: "鏈烘杈呭姪", label: "鏈烘杈呭姪" }, + { value: "鍦版矡鍔涚煩", label: "鍦版矡鍔涚煩" }, + { value: "鍦版矡杈呭姪", label: "鍦版矡杈呭姪" }, +]); const roleOptions = [ { value: "roleName", @@ -836,27 +901,70 @@ ]; const selectoptions = ref([]); selectoptions.value = userOptions; +//鐢ㄦ埛淇敼瀵嗙爜 const formpassword = ref({ - password: "", + oldPwd: "", + newPwd: "", }); const passwordrules = reactive({ - password: { - required: true, - message: "璇疯緭鍏ュ瘑鐮�", - trigger: "blur", - }, + newPwd: [ + { + required: true, + message: "璇疯緭鍏ュ瘑鐮�", + trigger: "blur", + }, + { + min: 6, + max: 12, + message: "瀵嗙爜闀垮害鍦� 6 鍒� 12 涓瓧绗�", + trigger: "blur", + }, + ], }); + +const uploadRef = ref(); +// //鐢ㄦ埛淇敼瀵嗙爜 +// const handleUpdatePassword = (row) => { +// dialogVisible1.value = true; +// formUser.value = Object.assign({}, row); +// }; +// const UpdatePassword = () => { +// formpasswordRef.value.validate((valid) => { +// if (valid) { +// UpdatePassword({ +// user_Id: formUser.value.user_Id, +// oldPwd: formpassword.value.oldPwd, +// newPwd: formpassword.value.newPwd, +// }).then((res) => { +// if (res.code == 200) { +// ElMessage({ +// message: "淇敼鎴愬姛", +// type: "success", +// }); +// dialogVisible1.value = false; +// initData(); +// } else { +// ElMessage({ +// message: res.msg, +// type: "error", +// }); +// } +// }); +// } +// }); +// }; + const pageTotal = ref(0); //鐧诲綍璁板綍 const initData = () => { // 鏌ヨ鏉′欢 - const startTime = formatTime(queryForm.selectTime[0]); - const endTime = formatTime(queryForm.selectTime[1]); + const startTime = formatTime(queryForm.value.selectTime[0]); + const endTime = formatTime(queryForm.value.selectTime[1]); const filter = [ { - name: "", - value: queryForm.selectType, - displayType: "int", + name: queryForm.value.selectType, + value: queryForm.value.selectInput, + displayType: "like", }, { name: "createDate", value: startTime, displayType: "ThanOrEqual" }, { name: "createDate", value: endTime, displayType: "LessOrEqual" }, @@ -869,56 +977,111 @@ pageTotal.value = res.total; }); }; +//鍒嗛〉璇锋眰鍙傛暟 +const pageQuery = ref({ + page: 1, //褰撳墠椤甸潰 + rows: 10, //姣忛〉鏄剧ず鏉℃暟 + order: "desc", //鎺掑簭鏂瑰紡 + sort: "", //鎺掑簭瀛楁 + wheres: "", //鏉′欢鏌ヨ +}); //鏁版嵁妫�绱簨浠� const handleQuery = () => { pageQuery.value.page = 1; - initData(); + if (isactive.value == 1) { + initData(); + } else { + getRole(); + } }; - +//閲嶇疆鏌ヨ鏉′欢 const resetQuery = () => { - queryForm.selectName = ""; - queryForm.selectInput = ""; - queryForm.selectTime = []; - queryForm.selectType = ""; + queryForm.value = Object.assign({}, obj); pageQuery.value.page = 1; - initData(); + if (isactive.value == 1) { + initData(); + } else { + getRole(); + } }; //鍒嗛〉椤甸潰澶у皬鏀瑰彉 const handleSizeChange = (val) => { pageQuery.value.rows = val; - initData(); + if (isactive.value == 1) { + initData(); + } else { + getRole(); + } }; //鍒嗛〉椤甸潰鏀瑰彉 const handleCurrentChange = (val) => { pageQuery.value.page = val; - initData(); + if (isactive.value == 1) { + initData(); + } else { + getRole(); + } }; -//鍒嗛〉椤甸潰澶у皬鏀瑰彉 -const RoleSizeChange = (val) => { - pageQuery.value.rows = val; - getRole(); +const handleAvatarSuccess = (val) => { + formUser.value.headImageUrl = "/image/" + val.data; +}; +//閲嶇疆琛ㄥ崟 +const resetForm = (formEl) => { + if (!formEl) return; + formEl.resetFields(); + formUser.value = { + user_Id: undefined, + userName: "", + role_Id: 21, + roleName: "", + phoneNo: "", + remark: "", + userPwd: "123456", + userTrueName: "", + dept_Id: 0, + enable: 1, + headImageUrl: "", + newPwd: "", + }; +}; +const resetForm1 = (formEl) => { + if (!formEl) return; + formEl.resetFields(); + formRole.value = { + roleName: "", + description: "", + }; }; -//鍒嗛〉椤甸潰鏀瑰彉 -const RoleCurrentChange = (val) => { - pageQuery.value.page = val; - getRole(); -}; const handlePictureCardPreview = (uploadFile) => { dialogImageUrl.value = uploadFile.url; imgdialogVisible.value = true; }; -const handleAvatarSuccess = (val) => { - console.log(val); +const handleRemove = (val) => { + fileList.value = []; + //绉婚櫎宸蹭笂浼犵殑鍥剧墖 + formUser.value.headImageUrl = ""; }; const beforeAvatarUpload = (val) => { console.log(val); }; +// const submitUpload = () => { +// let promise = new Promise((resolve, reject) => { +// setTimeout(async () => { +// await uploadRef.value.submit(); +// resolve("涓婁紶鎴愬姛"); +// }); +// }); +// return promise; +// }; + //鏂板缓鐢ㄦ埛璐﹀彿 -const saveObj = () => { - formRef.value.validate((valid) => { +const saveObj = async (formEl) => { + // submitUpload(); + if (!formEl) return; + await formEl.validate((valid, fields) => { if (valid) { if (formUser.value.user_Id != undefined) { UpdateUser(formUser.value).then((res) => { @@ -933,6 +1096,8 @@ initData(); }); } + } else { + console.log("error submit!", fields); } }); }; @@ -958,26 +1123,47 @@ }; //缂栬緫鐢ㄦ埛璐﹀彿 const Edit = (val) => { - console.log(val); let obj = Object.assign({}, val); + formUser.value = { + ...obj, + }; + if (obj.headImageUrl != "") { + fileList.value = [ + { + name: "1", + url: "http://192.168.0.80:5000" + obj.headImageUrl, + }, + ]; + } + dialogVisible.value = true; - formUser.value = obj; }; const newobj = ref({}); //淇敼瀵嗙爜 const Editpassword = (val) => { + let obj = Object.assign({}, val); + formUser.value = obj; formpassword.value = val; - newobj.value = val; + newobj.value = Object.assign({}, val); + console.log(newobj.value); + dialogVisible1.value = true; }; //淇濆瓨淇敼瀵嗙爜 const savePassword = async (formEl) => { let obj = Object.assign({}, newobj); - obj.password = formpassword.value.password; + // obj.password = formpassword.value.password; + console.log(formUser.value); + + let formdata = { + id: formUser.value.user_Id, + oldPwd: formUser.value.userPwd, + newPwd: formUser.value.newPwd, + }; if (!formEl) return; await formEl.validate((valid, fields) => { if (valid) { - UpdateUser(obj).then((res) => { + UpdatePwd(formdata).then((res) => { ElMessage({ message: "淇敼瀵嗙爜鎴愬姛", type: "success" }); dialogVisible1.value = false; initData(); @@ -1003,7 +1189,10 @@ const formRole = ref({ roleName: "", description: "", + createDate: formatTime(new Date()), //鍒涘缓鏃堕棿 + creater: JSON.parse(localStorage.getItem("user")).userName, //鍒涘缓浜� }); + //鏂板缓瑙掕壊 const AddRole = () => { Roletype.value = "鏂板缓"; @@ -1040,29 +1229,25 @@ formRole.value = obj; dialogVisible2.value = true; }; +//鑾峰彇瑙掕壊 const getRole = () => { - GetPageDataApi({ - page: 1, - rows: 10, - total: 100, - tableName: "", - sort: "", - order: "", - wheres: "", - export: true, - value: "", - filter: [ - { - name: "string", - value: "string", - displayType: "string", - }, - ], - }).then((res) => { + const startTime = formatTime(queryForm.value.selectTime[0]); + const endTime = formatTime(queryForm.value.selectTime[1]); + const filter = [ + { + name: queryForm.value.selectType, + value: queryForm.value.selectInput, + displayType: "like", + }, + { name: "createDate", value: startTime, displayType: "ThanOrEqual" }, + { name: "createDate", value: endTime, displayType: "LessOrEqual" }, + ]; + GetPageDataApi({ ...pageQuery.value, filter }).then((res) => { grideData.value = res.rows; pageTotal.value = res.total; }); }; +//鎵撳嵃鏁版嵁 const printExcel = () => { // 鏌ヨ鏉′欢 const startTime = formatTime(queryForm.selectTime[0]); @@ -1094,6 +1279,17 @@ }); } }; +//鍒囨崲椤甸潰 +const changeactive = (index) => { + isactive.value = index; + if (isactive.value == 1) { + selectoptions.value = userOptions; + initData(); + } else { + selectoptions.value = roleOptions; + getRole(); + } +}; //鎵归噺鍒犻櫎 const ids = ref([]); @@ -1122,6 +1318,11 @@ }); } }; +//绠$悊 +//璺敱璺宠浆 +const toDetail = (row) => { + router.push({ name: "permission", state: { info: JSON.stringify(row) } }); +}; onMounted(() => { initData(); @@ -1131,16 +1332,19 @@ .Usermanagement { display: flex; background-color: #fff; + .content { width: 100%; display: flex; flex-direction: column; + .checkbox { width: 11rem; display: flex; justify-content: space-between; margin-top: 1rem; margin-left: 1.31rem; + .item { width: 5rem; height: 1.88rem; @@ -1152,20 +1356,24 @@ line-height: 1.88rem; cursor: pointer; } + .isactive { background-color: rgba(16, 16, 16, 1); color: rgba(255, 255, 255, 1); } } + .serch { display: flex; margin-top: 1.31rem; align-items: center; + .time_box { display: flex; align-items: center; text-align: center; margin-left: 0.98rem; + .time { box-sizing: border-box; width: 6.88rem; @@ -1179,12 +1387,14 @@ justify-content: center; } } + .serch_box { display: flex; align-items: center; text-align: center; margin-left: 0.98rem; border-radius: 0.38rem; + .serchb { box-sizing: border-box; width: 6.88rem; @@ -1195,6 +1405,7 @@ align-items: center; justify-content: center; } + input { box-sizing: border-box; outline: none; @@ -1207,6 +1418,7 @@ } } } + .btns { display: flex; justify-content: space-between; @@ -1217,17 +1429,20 @@ box-sizing: border-box; } } + .my-header { height: 3.84rem; display: flex; justify-content: space-between; border-bottom: 0.06rem solid rgba(233, 233, 233, 1); } + .avatar-uploader .avatar { width: 7rem; height: 7rem; display: block; } + :deep(.avatar-uploader .el-upload) { width: 7rem; height: 7rem; @@ -1238,10 +1453,12 @@ overflow: hidden; transition: var(--el-transition-duration-fast); } + :deep(.el-upload-list__item) { width: 7rem; height: 7rem; } + .avatar-uploader .el-upload:hover { border-color: var(--el-color-primary); } @@ -1259,6 +1476,7 @@ .confirmButtonClass { margin-right: 10px; } + .el-message-box .el-message-box__btns { flex-direction: row-reverse !important; justify-content: normal !important; -- Gitblit v1.9.3