Преглед изворни кода

添加用户管理查询列表和新增/编辑 接口调用

lm пре 1 месец
родитељ
комит
345baa1a7b

+ 67 - 0
src/api/userManage.ts

@@ -0,0 +1,67 @@
+// src/api/login.ts
+import request from '../utils/request.js'
+let adminPrefix = import.meta.env.VITE_API_ADMIN_PRE
+
+
+// 新增用户
+export const addUserApi = (data:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/add`,
+        method: 'post',
+        data
+    })
+}
+
+// 修改用户
+export const editUserApi = (id:any,data:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/update`,
+        method: 'post',
+        data
+    })
+}
+
+
+// 删除用户
+export const deleteUserApi = (userId:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/delete/${userId}`,
+        method: 'get',
+    })
+}
+
+
+// 查询用户列表
+export const getUserListApi = (data:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/userLists`,
+        method: 'post',
+        data
+    })
+}
+
+// 启用/禁用 用户
+export const openOrCloseUserAccountApi = (userId:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/status/${userId}`,
+        method: 'get',
+    })
+}
+
+// 重置某用户密码
+export const resetUserPasswordApi = (data:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/updatePwd`,
+        method: 'post',
+        data
+    })
+}
+
+// 启用/关闭   公海/历史 跟进状态
+//  followType : 公海跟进固定值(publicFollow),历史跟进固定值(historyFollow)
+export const openOrCloseUserFollowStatusApi = (userId:any,followType:any) => {
+    return request({
+        url: `${adminPrefix}/api/v1/sys/users/follow/${userId}/${followType}`,
+        method: 'get',
+    })
+}

+ 4 - 3
src/baseComponents/TableRowStatus.vue

@@ -7,11 +7,12 @@
 
 <script setup lang="ts">
 interface statusItm {
-  statusFlag:Number | String,
-  title:String,
+  statusFlag:number | string,
+  title:string,
   themeClass: 'not_included_icon' | 'no_release_icon' 
               | 'normal_icon' | 'abnormal_icon' | 'audit_icon' 
-              | 'yes_release_icon' | 'right_icon' | 'ready_close_icon' | 'need_summary_icon'
+              | 'yes_release_icon' | 'right_icon' | 'ready_close_icon' 
+              | 'need_summary_icon' | string
 }
 
 const props = defineProps({

+ 51 - 0
src/components/dict.ts

@@ -0,0 +1,51 @@
+import { ref } from "vue"
+const genderList = ref([
+    {
+        label:"男",
+        value:0
+    },
+    {
+        label:"女",
+        value:1
+    },
+    {
+        label:"未知",
+        value:null
+    },
+])
+
+export const genderNumToName = (num)=>{
+    return genderList.value.find(item=>{
+        return item.value === num
+    })?.label
+}
+
+const accountStatusList = ref([
+    {
+        label:'启用',
+        value:1
+    },
+    {
+        label:'禁用',
+        value:0
+    },
+])
+export const accountStatusMsg = ref([
+    {
+        statusFlag:1,
+        title:'启用',
+        themeClass: 'normal_icon',
+    },
+    {
+        statusFlag:0,
+        title:'禁用',
+        themeClass: 'not_included_icon',
+    },
+])
+
+export const accountNumToName = (num)=>{
+    return accountStatusList.value.find(item=>{
+        return item.value === num 
+    })?.label
+}
+

+ 0 - 4
src/layout/components/header.vue

@@ -147,8 +147,6 @@ const loginOutFn = async () => {
     localStorage.removeItem('token')
     localStorage.removeItem('userInfo')
     GoToLogin()
-  }else {
-    ElMessage.error(res?.msg)
   }
 }
 const submitLoading = ref(false)
@@ -172,8 +170,6 @@ const confirmPassWord = async (formEl: FormInstance | undefined) => {
           localStorage.removeItem('userInfo')
           // 跳转登录页面
           GoToLogin()
-        }else {
-          ElMessage.error(res.msg)
         }
       }catch {}finally {
         submitLoading.value = false

+ 9 - 0
src/utils/request.ts

@@ -31,6 +31,15 @@ service.interceptors.request.use(
 service.interceptors.response.use(
   (response: AxiosResponse) => {
     const res = response.data
+
+    if(res.code !== 200){
+      if(res.code == 406 && res.data.message){
+          ElMessage.warning(res.data.message)
+      }else{
+        ElMessage.warning(res.msg)
+      }
+    }
+    
     /*
     if (res.code !== 200) {
       ElMessage({

+ 0 - 8
src/views/login/login.vue

@@ -234,8 +234,6 @@ const ReplaceGraphCode = async ()=>{
   if(res?.code == 200){
     graphCaptchaCode.img = res.data.captchaImage
     graphCaptchaCode.id = res.data.captchaId
-  }else{
-    ElMessage.warning(res?.msg)
   }
 }
 
@@ -276,12 +274,6 @@ const SubmitLogin = async () => {
     if(res.code !== 200){
       loginFormData.value.captchaCode = ''
 
-      if(res.code == 406 && res.data.message){
-          ElMessage.warning(res.data.message)
-      }else{
-        ElMessage.warning(res.msg)
-      }
-
       const {
         captchaVO,  //图形验证码数据
         showPicCode,  //是否需要图形验证码

+ 0 - 5
src/views/login/phoneLogin.vue

@@ -266,8 +266,6 @@ const sendVerificationCode = async ()=>{
         timeCountDown.value = 0
       }
     },1000)
-  }else{
-    ElMessage.warning(res.msg)
   }
 }
 
@@ -278,8 +276,6 @@ const ReplaceGraphCode = async ()=>{
   if(res?.code == 200){
     graphCaptchaCode.img = res.data.captchaImage
     graphCaptchaCode.id = res.data.captchaId
-  }else{
-    ElMessage.warning(res.msg)
   }
 }
 
@@ -306,7 +302,6 @@ const SubmitLogin = async () => {
 
     // 登录失败处理
     if(res?.code !== 200){
-      ElMessage.warning(res.msg)
       formData.value.captchaCode = ''
 
       const {

+ 12 - 11
src/views/userPrivilegeManagement/userManage/formDialog.ts

@@ -6,13 +6,13 @@ export const userFormItemList = ref([
     key: 'account',
     label: '账号',
     type: 'input',
-    placeholder: '请输入手机号',
+    placeholder: '请输入账号',
     rules: [{ required: true, message: '请输入账号', trigger: 'blur' }], 
     custom: false,
     style: {},
   },
   {
-    key: 'name',
+    key: 'username',
     label: '姓名',
     type: 'input',
     placeholder: '请输入姓名',
@@ -25,14 +25,15 @@ export const userFormItemList = ref([
     label: '性别',
     type: 'radio',
     selectList: [
-      { label: '男', value: '1' },
-      { label: '女', value: '0' }
+      { label: '男', value: '0' },
+      { label: '女', value: '1' }
     ],
+    rules: [{ required: true, message: '请选择性别', trigger: 'blur' }], 
     custom: false,
     style: {},
   },
   {
-    key: 'phone',
+    key: 'phoneNo',
     label: '手机号',
     type: 'input',
     placeholder: '请输入手机号',
@@ -41,21 +42,21 @@ export const userFormItemList = ref([
     style: {},
   },
   {
-    key: 'publicSeaFollowRecord',
+    key: 'publicFollowStatus',
     label: '公海跟进记录',
     type: 'switch',
     custom: false,
     style: {},
   },
   {
-    key: 'historyFollowRecord',
+    key: 'historyFollowStatus',
     label: '历史跟进记录',
     type: 'switch',
     custom: false,
     style: {},
   },
   {
-    key: 'customerHoldLimit',
+    key: 'holdTopCount',
     label: '客户持有上限',
     type: 'number',
     placeholder: '请输入',
@@ -64,7 +65,7 @@ export const userFormItemList = ref([
     style: {},
   },
   {
-    key: 'dailyManualReturnLimit',
+    key: 'dayBackTopCount',
     label: '每日手动退回公海上限',
     type: 'number',
     placeholder: '请输入',
@@ -73,7 +74,7 @@ export const userFormItemList = ref([
     style: {},
   },
   {
-    key: 'noFollowAutoReturnDays',
+    key: 'backPublicDayCount',
     label: '无跟进自动退回公海天数',
     type: 'number',
     placeholder: '请输入',
@@ -95,7 +96,7 @@ export const resetPasswordFormItemList =  ref([
     style: {},
   },
   {
-    key: 'name',
+    key: 'username',
     label: '姓名',
     type: 'input',
     disabled: true, 

+ 114 - 71
src/views/userPrivilegeManagement/userManage/index.vue

@@ -3,8 +3,11 @@
         <div class="page_search">
             <div class="search_content">
                 <div class="content_left">
-                    <TabSearch tabType="box" :tabList="tabList" :defaultTabKey="defaultUserType" />
-                    <FormSearchGroup :searchList="formSearhList"></FormSearchGroup>
+                    <TabSearch tabType="box" :tabList="tabList" 
+                        :defaultTabKey="searchParams.defaultUserType" 
+                        @tabChange="HandleUserTypeChange"/>
+                    <FormSearchGroup :searchList="formSearhList" 
+                        @searchChange="HandleBlurSearch" />
                 </div>
                 <div class="content_right">
                     <el-button class="button_border" @click="OpenUserFormDialog()">新增用户</el-button>
@@ -14,29 +17,29 @@
 
         <div class="page_jg_20" />
         <Table :tableColumns="tableColumns" :tableData="userTableData" 
-            :pageNum = "pageNum" :pageSize = "pageSize" :totalNum = "totalNum">
+            :currentPage = "currentPage" :pageSize = "pageSize" :totalNum = "totalNum">
             <template #num="{row,currentIndex}">
-                {{ (pageNum - 1 ) * pageSize + currentIndex }}
+                {{ (currentPage - 1 ) * pageSize + currentIndex }}
             </template>
 
             <template #gender="{row}">
-                {{row.gender === '0' ? '女' : '男'  }}
+                {{ genderNumToName(row.gender) }}
             </template>
             <template #status="{row}">
-                <TableRowStatus :statusMsg="statusMsg" :useStatus="row.status" />
+                <TableRowStatus :statusMsg="accountStatusMsg" :useStatus="row.status" />
             </template>
 
-            <template #publicSeaFollowRecord="{row}">
+            <template #publicFollowStatus="{row}">
                 <el-switch
-                    :model-value="Boolean(row.publicSeaFollowRecord)"
+                    :model-value="Boolean(row.publicFollowStatus)"
                     @change="(val)=>HandleCardSwitchOnOff({id:row.id,onOffVal:val})"
                     style="--el-switch-on-color: #2e64fa; --el-switch-off-color: #bbbbbb"
                 />
             </template>
 
-            <template #historyFollowRecord="{row}">
+            <template #historyFollowStatus="{row}">
                 <el-switch
-                    :model-value="Boolean(row.historyFollowRecord)"
+                    :model-value="Boolean(row.historyFollowStatus)"
                     @change="(val)=>HandleCardSwitchOnOff({id:row.id,onOffVal:val})"
                     style="--el-switch-on-color: #2e64fa; --el-switch-off-color: #bbbbbb"
                 />
@@ -86,7 +89,7 @@
         :submitLoading="forbiddenDialogLoading" 
         @close="HandleForbiddenDialogClose"
         @confirm="HandleForbiddenDialogConfirm">
-        请确认是否{{currentOperationType == 'delete' ? '删除' : '禁用'}} 【{{currentEditRow?.name}}】 {{ currentEditRow?.account }}
+        请确认是否{{currentOperationType == 'delete' ? '删除' : '禁用'}} 【{{currentEditRow?.username}}】 {{ currentEditRow?.account }}
     </Dialog>
 
 
@@ -94,7 +97,7 @@
 
 
 <script setup lang="ts">
-import { ref } from 'vue';
+import { onMounted, ref } from 'vue';
 import FormSearchGroup from '@/baseComponents/FormSearchGroup.vue';
 import {formSearhList} from './formSearch'
 import Table from '@/baseComponents/Table.vue';
@@ -106,58 +109,35 @@ import FormDialog from '@/baseComponents/FormDialog.vue';
 import {userFormItemList, resetPasswordFormItemList} from './formDialog'
 import Dialog from '@/baseComponents/Dialog.vue';
 
+
+import {
+    addUserApi,
+    editUserApi,
+    deleteUserApi,
+    getUserListApi,
+    openOrCloseUserAccountApi,
+    resetUserPasswordApi,
+    openOrCloseUserFollowStatusApi,
+} from '@/api/userManage'
+
+import {genderNumToName, accountStatusMsg} from '@/components/dict'
+import { historyFollowSearchList } from '@/views/myCustomer/myCustomerDetail/customerStatusOverview/searchBlock';
+import { ElMessage } from 'element-plus';
+
 /**
  * 1. 表格 有关数据
  */
-const pageNum = ref(1)
+const currentPage = ref(1)
 const pageSize = ref(20)
 const totalNum = ref(0)
 
-const userTableData = ref([
-    {
-        id:'1',
-        account:'43434',
-        name:'xx1',
-        gender:'1',
-        phone:'xxx',
-        status:0,
-        publicSeaFollowRecord:true,
-        historyFollowRecord:false,
-
-        customerHoldLimit:40,
-        dailyManualReturnLimit:16,
-        noFollowAutoReturnDays:10,
-    },
-    {
-        id:'2',
-        account:'545',
-        name:'xx2',
-        gender:'0',
-        phone:'xxx',
-        status:1,
-        publicSeaFollowRecord:false,
-        historyFollowRecord:true,
-
-        customerHoldLimit:50,
-        dailyManualReturnLimit:20,
-        noFollowAutoReturnDays:30,
-    },
-])
-
-const statusMsg = ref([
-    {
-        statusFlag:0,
-        title:'禁用',
-        themeClass: 'not_included_icon',
-    },
-    {
-        statusFlag:1,
-        title:'启用',
-        themeClass: 'normal_icon',
-    },
-])
-// 默认展示的用户类型
-const defaultUserType = ref('onlinePeople')
+const userTableData = ref([])
+
+
+const searchParams = ref({
+    defaultUserType:1, // 默认展示的用户类型
+    queryStr:"",
+})
 
 /**
  * 2. 新增用户弹窗相关数据
@@ -166,17 +146,21 @@ const userFormDialogVisible = ref(false)
 const userFormDialogSubmiting = ref(false)
 const userFormDialogTitle = ref('')
 const defaultUserFormData = ref({
-    publicSeaFollowRecord:true,
-    historyFollowRecord:true,
-    customerHoldLimit:100,
-    dailyManualReturnLimit:15,
-    noFollowAutoReturnDays:15,
+    publicFollowStatus:true,
+    historyFollowStatus:true,
+    holdTopCount:100,
+    dayBackTopCount:15,
+    backPublicDayCount:15,
 })
 // 打开新增/修改用户弹窗
 const OpenUserFormDialog = (row?:any)=>{
     if(row?.id){
         userFormDialogTitle.value = '修改用户'
-        defaultUserFormData.value = {...row}
+        defaultUserFormData.value = {
+            ...row,
+            publicFollowStatus:Boolean(row.publicFollowStatus),
+            historyFollowStatus:Boolean(row.historyFollowStatus)
+        }
         console.log('当前赋值的form表单值',defaultUserFormData.value)
     }else{
         userFormDialogTitle.value = '新增用户'
@@ -186,17 +170,44 @@ const OpenUserFormDialog = (row?:any)=>{
 // 关闭新增/修改用户弹窗
 const CloseUserFormDialog = ()=>{
     userFormDialogVisible.value = false
+    userFormDialogSubmiting.value = false
     defaultUserFormData.value = {
-        publicSeaFollowRecord:true,
-        historyFollowRecord:true,
-        customerHoldLimit:100,
-        dailyManualReturnLimit:15,
-        noFollowAutoReturnDays:15,
+        publicFollowStatus:true,
+        historyFollowStatus:true,
+        holdTopCount:100,
+        dayBackTopCount:15,
+        backPublicDayCount:15,
     }
 }
 // 保存新增/修改用户弹窗
-const HandleUserFormDialogConfirm = ()=>{
-    CloseUserFormDialog()
+const HandleUserFormDialogConfirm = async (params)=>{
+    userFormDialogSubmiting.value = true
+
+    const { formData,formRef } = params
+    let transferParams = {
+        ...formData,
+        publicFollowStatus:formData.publicFollowStatus ? 1 : 0,
+        historyFollowStatus:formData.historyFollowStatus ? 1 : 0,
+    }
+    let res = undefined
+
+    try{
+        if(formData.id){
+            // 修改
+            res = await editUserApi(formData.id,transferParams)
+        }else{
+            // 新增
+            res = await addUserApi(transferParams)
+        }
+    }catch{}
+
+    if(res?.code == 200){
+        ElMessage.success(res?.msg)
+        CloseUserFormDialog()
+        GetUserList()
+    }else{
+        userFormDialogSubmiting.value = false
+    }
 }
 
 /**
@@ -243,6 +254,38 @@ const OpenForbiddenDialog = (row,type)=>{
     forbiddenDialogVisible.value = true
 }
 
+const HandleUserTypeChange = (val)=>{
+    searchParams.value.defaultUserType = val
+    GetUserList()
+}
+
+const HandleBlurSearch = (params,key)=>{
+    searchParams.value = {
+        ...searchParams.value,
+        ...params,
+    }
+    GetUserList()
+}
+// 获取 启用/禁用 用户
+const GetUserList = async()=>{
+    let params = {
+        queryStr: searchParams.value.queryStr,
+        "status": searchParams.value.defaultUserType,
+        pageNum: currentPage.value,
+        pageSize: pageSize.value
+    }
+    let res = await getUserListApi(params)
+    if(res?.code == 200){
+        userTableData.value = res.data.records
+        totalNum.value = res.data.total
+    }
+}
+
+onMounted(()=>{
+    GetUserList()
+})
+
+
 </script>
 
 

+ 2 - 2
src/views/userPrivilegeManagement/userManage/tabSearch.ts

@@ -3,10 +3,10 @@ import { ref } from "vue";
 export const tabList = ref([
     {
         label:'启用用户',
-        key:'onlinePeople',
+        key:1,
     },
     {
         label:'禁用用户',
-        key:'deadlinePeople',
+        key:0,
     }
 ])

+ 7 - 7
src/views/userPrivilegeManagement/userManage/table.ts

@@ -22,7 +22,7 @@ export const tableColumns = ref([
         custom: false,
     },
     {
-        name: 'name',
+        name: 'username',
         label: '姓名',
         width: '',
         fixed: '',
@@ -40,7 +40,7 @@ export const tableColumns = ref([
         custom: true,
     },
     {
-        name: 'phone',
+        name: 'phoneNo',
         label: '手机号',
         width: '',
         fixed: '',
@@ -58,7 +58,7 @@ export const tableColumns = ref([
         custom: true,
     },
     {
-        name: 'publicSeaFollowRecord',
+        name: 'publicFollowStatus',
         label: '公海跟进',
         width: '100',
         fixed: '',
@@ -67,7 +67,7 @@ export const tableColumns = ref([
         custom: true,
     },
     {
-        name: 'historyFollowRecord',
+        name: 'historyFollowStatus',
         label: '历史跟进',
         width: '100',
         fixed: '',
@@ -76,7 +76,7 @@ export const tableColumns = ref([
         custom: true,
     },
     {
-        name: 'customerHoldLimit',
+        name: 'holdTopCount',
         label: '持有上限',
         width: '100',
         fixed: '',
@@ -85,7 +85,7 @@ export const tableColumns = ref([
         custom: false,
     },
     {
-        name: 'dailyManualReturnLimit',
+        name: 'dayBackTopCount',
         label: '日退上限',
         width: '100',
         fixed: '',
@@ -94,7 +94,7 @@ export const tableColumns = ref([
         custom: false,
     },
     {
-        name: 'noFollowAutoReturnDays',
+        name: 'backPublicDayCount',
         label: '退回公海天数',
         width: '120',
         fixed: '',