Explorar o código

feat: 重置密码

wanggaokun hai 1 ano
pai
achega
f6bc154b13
Modificáronse 1 ficheiros con 24 adicións e 4 borrados
  1. 24 4
      src/views/system/user/index.vue

+ 24 - 4
src/views/system/user/index.vue

@@ -30,9 +30,9 @@
         </template>
         <!-- 表格操作 -->
         <template #operation="scope">
-          <el-button type="primary" link v-if="scope.row.userId !== 1" :icon="View" @click="openDialog(3, '用户查看', scope.row)">查看</el-button>
           <el-button type="primary" link v-if="scope.row.userId !== 1" :icon="EditPen" @click="openDialog(2, '用户编辑', scope.row)">编辑</el-button>
           <el-button type="primary" link v-if="scope.row.userId !== 1" :icon="Delete" @click="deleteAccount(scope.row)">删除</el-button>
+          <el-button type="primary" link v-if="scope.row.userId !== 1" :icon="View" @click="handleResetPwd(scope.row)">重置密码</el-button>
         </template>
       </ProTable>
       <FormDialog ref="formDialogRef" />
@@ -46,7 +46,7 @@ import { onMounted, reactive, ref } from 'vue'
 import { User } from '@/api/interface'
 import { useDownload } from '@/hooks/useDownload'
 import { useHandleData } from '@/hooks/useHandleData'
-import { ElMessageBox } from 'element-plus'
+import { ElMessageBox, ElMessage } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import TreeFilter from '@/components/TreeFilter/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
@@ -63,7 +63,8 @@ import {
   importDataApi,
   exportApi,
   getUserApi,
-  deptTreeSelectApi
+  deptTreeSelectApi,
+  resetUserPwdApi
 } from '@/api/modules/system/user'
 import { getDictsApi } from '@/api/modules/system/dictData'
 onMounted(() => {
@@ -110,6 +111,25 @@ const batchDelete = async (ids: string[]) => {
   proTable.value?.getTableList()
 }
 
+function handleResetPwd(row: any) {
+  ElMessageBox.prompt('请输入"' + row.userName + '"的新密码', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    closeOnClickModal: false,
+    inputPattern: /^.{5,20}$/,
+    inputErrorMessage: '用户密码长度必须介于 5 和 20 之间'
+  })
+    .then(({ value }: any) => {
+      resetUserPwdApi({ userId: row.userId, password: value }).then(res => {
+        if (res.code == 200) ElMessage.success('修改成功,新密码是:' + value)
+        else ElMessage.error(res.msg)
+      })
+    })
+    .catch((e: any) => {
+      console.log(e)
+    })
+}
+
 // 导出用户列表
 const downloadFile = async () => {
   ElMessageBox.confirm('确认导出用户数据?', '温馨提示', { type: 'warning' }).then(() =>
@@ -309,6 +329,6 @@ const columns = reactive<ColumnProps<User.ResUserList>[]>([
     }
   },
   { prop: 'createTime', label: '创建时间', width: 180 },
-  { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
+  { prop: 'operation', label: '操作', width: 240, fixed: 'right' }
 ])
 </script>