Browse Source

优化 新增用户时手机号校验通过且账号未填,自动将手机号作为账号使用。
密码必填项去除,默认可不填使用系统默认密码,新增密码提示

zhontai 2 years ago
parent
commit
09c688ba58

+ 32 - 26
src/api/admin/data-contracts.ts

@@ -3054,6 +3054,11 @@ export interface TaskUpdateInput {
 
 /** 添加 */
 export interface TenantAddInput {
+  /**
+   * 租户Id
+   * @format int64
+   */
+  id?: number
   /**
    * 企业名称
    * @minLength 1
@@ -3070,10 +3075,12 @@ export interface TenantAddInput {
    */
   realName: string
   /**
-   * 手机号码
+   * 账号
    * @minLength 1
    */
-  phone: string
+  userName: string
+  /** 手机号码 */
+  phone?: string | null
   /** 邮箱地址 */
   email?: string | null
   /** 数据库注册键 */
@@ -3127,23 +3134,20 @@ export interface TenantEntity {
   modifiedTime?: string | null
   /** 是否删除 */
   isDeleted?: boolean
-  /** 企业名称 */
-  name?: string | null
-  /** 编码 */
-  code?: string | null
-  /** 姓名 */
-  realName?: string | null
-  /** 手机号码 */
-  phone?: string | null
-  /** 邮箱地址 */
-  email?: string | null
   /**
    * 授权用户
    * @format int64
    */
-  userId?: number | null
+  userId?: number
   /** 用户 */
   user?: UserEntity
+  /**
+   * 授权部门
+   * @format int64
+   */
+  orgId?: number
+  /** 组织架构 */
+  org?: OrgEntity
   /** 租户类型:Platform=1,Tenant=2 */
   tenantType?: TenantType
   /** 数据库注册键 */
@@ -3175,10 +3179,12 @@ export interface TenantGetOutput {
    */
   realName: string
   /**
-   * 手机号码
+   * 账号
    * @minLength 1
    */
-  phone: string
+  userName: string
+  /** 手机号码 */
+  phone?: string | null
   /** 邮箱地址 */
   email?: string | null
   /** 数据库注册键 */
@@ -3192,7 +3198,7 @@ export interface TenantGetOutput {
   /** 说明 */
   description?: string | null
   /**
-   * 接口Id
+   * 租户Id
    * @format int64
    */
   id: number
@@ -3209,12 +3215,14 @@ export interface TenantListOutput {
    * @format int64
    */
   id?: number
-  /** 企业编码 */
-  code?: string | null
   /** 企业名称 */
   name?: string | null
+  /** 企业编码 */
+  code?: string | null
   /** 姓名 */
   realName?: string | null
+  /** 账号 */
+  userName?: string | null
   /** 手机号码 */
   phone?: string | null
   /** 邮箱地址 */
@@ -3269,10 +3277,12 @@ export interface TenantUpdateInput {
    */
   realName: string
   /**
-   * 手机号码
+   * 账号
    * @minLength 1
    */
-  phone: string
+  userName: string
+  /** 手机号码 */
+  phone?: string | null
   /** 邮箱地址 */
   email?: string | null
   /** 数据库注册键 */
@@ -3286,7 +3296,7 @@ export interface TenantUpdateInput {
   /** 说明 */
   description?: string | null
   /**
-   * 接口Id
+   * 租户Id
    * @format int64
    */
   id: number
@@ -3326,11 +3336,7 @@ export interface UserAddInput {
   managerUserName?: string | null
   /** 员工添加 */
   staff?: StaffAddInput
-  /**
-   * 密码
-   * @minLength 1
-   */
-  password: string
+  password?: string | null
   /** 启用 */
   enabled?: boolean
 }

+ 2 - 2
src/views/admin/logs/opration-log.vue

@@ -17,8 +17,8 @@
           <template #default="{ row }"> {{ row.createdUserName }}<br />{{ row.nickName }} </template>
         </el-table-column>
         <el-table-column prop="ip" label="IP地址" width="130" />
-        <el-table-column prop="apiLabel" label="操作名称" width />
-        <el-table-column prop="apiPath" label="操作接口" width />
+        <el-table-column prop="apiLabel" label="操作名称" min-width="220" />
+        <el-table-column prop="apiPath" label="操作接口" min-width="260" />
         <el-table-column prop="elapsedMilliseconds" label="耗时(毫秒)" width="100" />
         <el-table-column prop="status" label="操作状态" width="80">
           <template #default="{ row }">

+ 16 - 4
src/views/admin/tenant/components/tenant-form.vue

@@ -27,10 +27,15 @@
                 { validator: testMobile, trigger: ['blur', 'change'] },
               ]"
             >
-              <el-input v-model="form.phone" autocomplete="off" maxlength="11" />
+              <el-input v-model="form.phone" autocomplete="off" maxlength="11" @blur="onBlurMobile" />
             </el-form-item>
           </el-col>
-          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
+            <el-form-item label="账号" prop="userName" :rules="[{ required: true, message: '请输入管理员账号', trigger: ['blur', 'change'] }]">
+              <el-input v-model="form.userName" autocomplete="off" />
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
             <el-form-item label="邮箱" prop="email" :rules="[{ validator: testEmail, trigger: ['blur', 'change'] }]">
               <el-input v-model="form.email" autocomplete="off" />
             </el-form-item>
@@ -56,7 +61,7 @@
 import { reactive, toRefs, getCurrentInstance, ref } from 'vue'
 import { TenantAddInput, TenantUpdateInput } from '/@/api/admin/data-contracts'
 import { TenantApi } from '/@/api/admin/Tenant'
-import { testMobile, testEmail } from '/@/utils/test'
+import { isMobile, testMobile, testEmail } from '/@/utils/test'
 import eventBus from '/@/utils/mitt'
 
 defineProps({
@@ -87,11 +92,18 @@ const open = async (row: any = {}) => {
       state.form = res.data as TenantAddInput & TenantUpdateInput
     }
   } else {
-    state.form = {} as TenantAddInput & TenantUpdateInput
+    state.form = { enabled: true } as TenantAddInput & TenantUpdateInput
   }
   state.showDialog = true
 }
 
+//手机号失去焦点
+const onBlurMobile = () => {
+  if (!state.form.userName && state.form.phone && isMobile(state.form.phone)) {
+    state.form.userName = state.form.phone
+  }
+}
+
 // 取消
 const onCancel = () => {
   state.showDialog = false

+ 3 - 3
src/views/admin/tenant/index.vue

@@ -18,8 +18,8 @@
         <el-table-column prop="code" label="企业编码" width="120" show-overflow-tooltip />
         <el-table-column prop="realName" label="姓名" width="120" show-overflow-tooltip />
         <el-table-column prop="phone" label="手机号" width="120" show-overflow-tooltip />
-        <el-table-column prop="email" label="邮箱" min-width="120" show-overflow-tooltip />
-        <el-table-column label="状态" width="80" align="center">
+        <el-table-column prop="email" label="邮箱" min-width="180" show-overflow-tooltip />
+        <el-table-column label="状态" width="80" align="center" fixed="right">
           <template #default="{ row }">
             <el-switch
               v-if="auth('api:admin:tenant:set-enable')"
@@ -38,7 +38,7 @@
             </template>
           </template>
         </el-table-column>
-        <el-table-column label="操作" width="160" fixed="right" header-align="center" align="center">
+        <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
           <template #default="{ row }">
             <el-button v-auth="'api:admin:tenant:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
             <my-dropdown-more v-auths="['api:admin:permission:assign', 'api:admin:tenant:delete']">

+ 28 - 7
src/views/admin/user/components/user-form.vue

@@ -17,7 +17,7 @@
                 { validator: testMobile, trigger: ['blur', 'change'] },
               ]"
             >
-              <el-input v-model="form.mobile" autocomplete="off" maxlength="11" />
+              <el-input v-model="form.mobile" autocomplete="off" maxlength="11" @blur="onBlurMobile" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
@@ -49,12 +49,18 @@
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
-            <el-form-item label="用户名" prop="userName" :rules="[{ required: true, message: '请输入用户名', trigger: ['blur', 'change'] }]">
+            <el-form-item label="账号" prop="userName" :rules="[{ required: true, message: '请输入账号', trigger: ['blur', 'change'] }]">
               <el-input v-model="form.userName" autocomplete="off" />
             </el-form-item>
           </el-col>
-          <el-col v-if="!(form.id > 0)" :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-            <el-form-item label="密码" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: ['blur', 'change'] }]">
+          <el-col v-if="!isUpdate" :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
+            <el-form-item prop="password">
+              <template #label
+                ><div class="my-flex-y-center">
+                  密码<el-tooltip effect="dark" content="选填,不填则使用系统默认密码" placement="top" hide-after="0">
+                    <SvgIcon name="ele-InfoFilled" class="ml5" />
+                  </el-tooltip></div
+              ></template>
               <el-input key="password" v-model="form.password" show-password autocomplete="off" />
             </el-form-item>
           </el-col>
@@ -82,7 +88,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
+          <el-col :xs="24" :sm="span" :md="span" :lg="span" :xl="span">
             <el-form-item label="邮箱" prop="email" :rules="[{ validator: testEmail, trigger: ['blur', 'change'] }]">
               <el-input v-model="form.email" autocomplete="off" />
             </el-form-item>
@@ -100,14 +106,14 @@
 </template>
 
 <script lang="ts" setup name="admin/user/form">
-import { reactive, toRefs, getCurrentInstance, ref, watch, defineAsyncComponent } from 'vue'
+import { reactive, toRefs, getCurrentInstance, ref, watch, defineAsyncComponent, computed } from 'vue'
 import { UserAddInput, UserUpdateInput, OrgListOutput, RoleGetListOutput } from '/@/api/admin/data-contracts'
 import { UserApi } from '/@/api/admin/User'
 import { OrgApi } from '/@/api/admin/Org'
 import { RoleApi } from '/@/api/admin/Role'
 import { listToTree, treeToList } from '/@/utils/tree'
 import { cloneDeep } from 'lodash-es'
-import { testMobile, testEmail } from '/@/utils/test'
+import { isMobile, testMobile, testEmail } from '/@/utils/test'
 import eventBus from '/@/utils/mitt'
 
 // 引入组件
@@ -137,6 +143,14 @@ const state = reactive({
 })
 const { form } = toRefs(state)
 
+const isUpdate = computed(() => {
+  return state.form.id > 0
+})
+
+const span = computed(() => {
+  return isUpdate.value ? 12 : 24
+})
+
 watch(
   () => state.form.orgIds,
   (value) => {
@@ -220,6 +234,13 @@ const open = async (row: any = {}) => {
   state.showDialog = true
 }
 
+//手机号失去焦点
+const onBlurMobile = () => {
+  if (!state.form.userName && state.form.mobile && isMobile(state.form.mobile)) {
+    state.form.userName = state.form.mobile
+  }
+}
+
 // 取消
 const onCancel = () => {
   state.showDialog = false

+ 5 - 4
src/views/admin/user/index.vue

@@ -27,17 +27,18 @@
 
         <el-card shadow="never" style="margin-top: 8px">
           <el-table v-loading="state.loading" :data="state.userListData" row-key="id" style="width: 100%">
+            <el-table-column prop="userName" label="账号" width="120" show-overflow-tooltip />
             <el-table-column prop="name" label="姓名" width="120" show-overflow-tooltip>
               <template #default="{ row }"> {{ row.name }} <el-tag v-if="row.isManager" type="success">主管</el-tag> </template>
             </el-table-column>
             <el-table-column prop="mobile" label="手机号" width="120" show-overflow-tooltip />
-            <el-table-column prop="email" label="邮箱" min-width="120" show-overflow-tooltip />
-            <el-table-column prop="roleNames" label="角色" min-width="120" show-overflow-tooltip>
+            <el-table-column prop="email" label="邮箱" min-width="180" show-overflow-tooltip />
+            <el-table-column prop="roleNames" label="角色" min-width="140" show-overflow-tooltip>
               <template #default="{ row }">
                 {{ row.roleNames ? row.roleNames.join(',') : '' }}
               </template>
             </el-table-column>
-            <el-table-column label="状态" width="80" align="center">
+            <el-table-column label="状态" width="80" align="center" fixed="right">
               <template #default="{ row }">
                 <el-switch
                   v-if="auth('api:admin:user:set-enable')"
@@ -56,7 +57,7 @@
                 </template>
               </template>
             </el-table-column>
-            <el-table-column label="操作" width="160" fixed="right" header-align="center" align="center">
+            <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
               <template #default="{ row }">
                 <el-button v-auth="'api:admin:user:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
                 <my-dropdown-more v-auths="['api:admin:user:set-manager', 'api:admin:user:reset-password', 'api:admin:user:delete']">