Kaynağa Gözat

fix: 用户信息校验

wanggaokun 3 hafta önce
ebeveyn
işleme
6986d9cbce

+ 8 - 0
src/api/module/system/user.ts

@@ -38,6 +38,14 @@ class UserApi {
     return http.put({ url: '/system/user/edit', data })
   }
 
+  /**
+   * @name 重置密码
+   * @returns returns
+   */
+  static resetPassword = (data: string): Promise<ResultData<any>> => {
+    return http.put({ url: '/system/user/password/reset', data })
+  }
+
   /**
    * @name 删除
    * @returns returns

+ 4 - 2
src/views/system/user/components/UserDrawer.vue

@@ -77,7 +77,7 @@ import { UserBO } from '@/api/interface/system/user'
 import OrgApi from '@/api/module/system/org'
 import PositionApi from '@/api/module/system/position'
 import { ResultEnum } from '@/enums/HttpEnum'
-import { FormInstance } from 'element-plus'
+import { FormInstance, FormRules } from 'element-plus'
 import { useDictOptions } from '@/hooks'
 import { OrgTreeVO } from '@/api/interface/system/org'
 import { PositionVO } from '@/api/interface/system/position'
@@ -85,9 +85,11 @@ import { PositionVO } from '@/api/interface/system/position'
 const commonStatus = useDictOptions('COMMON_STATUS')
 const genders = useDictOptions('USER_GENDER')
 const userTypes = useDictOptions('USER_TYPE')
-const rules = reactive({
+const rules = reactive<FormRules>({
   account: [{ required: true, message: '请填写账号' }],
   userName: [{ required: true, message: '请填写姓名' }],
+  email: [{ type: 'email', message: '请填写正确的邮箱地址', trigger: 'blur' }],
+  phoneNumber: [{ pattern: /^1[3456789]\d{9}$/, message: '手机号码格式不正确', trigger: 'blur' }],
   status: [{ required: true, message: '状态不能为空' }]
 })
 

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

@@ -20,8 +20,24 @@
         </template>
 
         <template #operation="{ row }">
-          <el-button type="primary" link icon="EditPen" @click="openDrawer('编辑', row)"> 编辑 </el-button>
-          <el-button v-if="row.userId !== '1'" type="primary" link icon="Delete" @click="deleteRow(row)"> 删除 </el-button>
+          <div class="operation-group">
+            <el-button type="primary" link icon="EditPen" @click="openDrawer('编辑', row)"> 编辑 </el-button>
+            <el-button v-if="row.userId !== '1'" type="primary" link icon="Delete" @click="deleteRow(row)"> 删除 </el-button>
+            <div>
+              <el-dropdown trigger="click">
+                <el-button type="primary" link icon="DArrowRight"> 更多 </el-button>
+                <template #dropdown>
+                  <el-dropdown-menu>
+                    <el-dropdown-item icon="Refresh" @click="UserApi.resetPassword(row)">重置密码</el-dropdown-item>
+                    <el-dropdown-item icon="CirclePlusFilled"> Action 2 </el-dropdown-item>
+                    <el-dropdown-item icon="CirclePlus">Action 3</el-dropdown-item>
+                    <el-dropdown-item icon="Check">Action 4</el-dropdown-item>
+                    <el-dropdown-item icon="CircleCheck">Action 5</el-dropdown-item>
+                  </el-dropdown-menu>
+                </template>
+              </el-dropdown>
+            </div>
+          </div>
         </template>
       </ProTable>
     </div>
@@ -55,7 +71,7 @@ const changeTree = (val: string) => {
 // 表格配置项
 const columns: ColumnProps<UserVO>[] = [
   { type: 'selection', width: 60, selectable: row => row.userId !== '1' },
-  { prop: 'account', label: '账号', width: 120 },
+  { prop: 'account', label: '账号', width: 130 },
   { prop: 'userName', label: '姓名', width: 120 },
   { prop: 'nickName', label: '昵称', width: 120 },
   {
@@ -76,7 +92,7 @@ const columns: ColumnProps<UserVO>[] = [
     width: 80,
     fieldNames: { label: 'dictLabel', value: 'dictValue', tagType: 'callbackShowStyle' }
   },
-  { prop: 'remark', label: '备注', width: 100 },
+  { prop: 'remark', label: '备注' },
   { prop: 'createByName', label: '创建人', width: 120 },
   { prop: 'createTime', label: '创建时间', width: 160 },
   { prop: 'operation', label: '操作', width: 200, fixed: 'right' }
@@ -125,3 +141,13 @@ const openDrawer = (title: string, row: Partial<UserBO> = {}) => {
   drawerRef.value?.acceptParams(params)
 }
 </script>
+
+<style lang="scss" scoped>
+.operation-group {
+  display: flex;
+  justify-content: center;
+}
+.operation-group > * {
+  margin-left: 8px;
+}
+</style>