Parcourir la source

企业账户禁用、启用

Xiao_123 il y a 6 mois
Parent
commit
8dc1963720

+ 5 - 4
.env.local

@@ -4,14 +4,15 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径
-# VITE_BASE_URL='https://www.menduner.com:1443/'
-VITE_BASE_URL='http://192.168.3.80'
+VITE_BASE_URL='https://www.menduner.com:1443/' # 生产环境
+# VITE_BASE_URL='http://192.168.3.80' # 测试环境
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server
+
 # 上传路径
-# VITE_UPLOAD_URL='https://www.menduner.com:1443/admin-api/infra/file/upload'
-VITE_UPLOAD_URL='http://192.168.3.80/admin-api/infra/file/upload'
+VITE_UPLOAD_URL='https://www.menduner.com:1443/admin-api/infra/file/upload' # 生产环境
+# VITE_UPLOAD_URL='http://192.168.3.80/admin-api/infra/file/upload' # 测试环境
 
 # 接口地址
 VITE_API_URL=/admin-api

+ 2 - 2
src/api/menduner/system/enterprise/userBind/index.ts

@@ -79,8 +79,8 @@ export const EnterpriseUserBindApi = {
   },
 
   // 禁用账户
-  disabledEnterpriseAccount: async (ids: array) => {
-    return await request.post({ url: `/menduner/system/enterprise-user-bind/disable?ids=${ids}` })
+  disabledEnterpriseAccount: async (id: number) => {
+    return await request.post({ url: `/menduner/system/enterprise-user-bind/disable?id=${id}` })
   },
 
   // 启用账户

+ 11 - 1
src/api/menduner/system/madUser/index.ts

@@ -45,5 +45,15 @@ export const MdeUserApi = {
   // 导出门墩儿-用户登录 Excel
   exportMdeUser: async (params) => {
     return await request.download({ url: `/menduner/system/mde-user/export-excel`, params })
-  }
+  },
+
+  // 禁用账户
+  disabledUserAccount: async (id: number) => {
+    return await request.post({ url: `/menduner/system/mde-user/disable?id=${id}` })
+  },
+
+  // 启用账户
+  enableUserAccount: async (id: number) => {
+    return await request.post({ url: `/menduner/system/mde-user/enable?id=${id}` })
+  },
 }

+ 11 - 11
src/views/menduner/system/enterprise/userbind/index.vue

@@ -136,7 +136,7 @@
           >
             修改登录密码
           </el-button>
-          <!-- <el-button
+          <el-button
             v-if="scope.row.status === '0'"
             link
             type="danger"
@@ -151,7 +151,7 @@
             @click="handleActions(scope.row.id, 'enable')"
           >
             启用
-          </el-button> -->
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -183,7 +183,6 @@ import EditPassword from './EditPassword.vue'
 defineOptions({ name: 'EnterpriseUserBind' })
 
 const message = useMessage() // 消息弹窗
-const { t } = useI18n() // 国际化
 const enterpriseList = ref([])
 
 const loading = ref(true) // 列表的加载中
@@ -271,14 +270,15 @@ const handleExport = async () => {
 }
 
 // 禁用、启用账户
-// const handleActions = async (id: number, type: string) => {
-//   try {
-//     type === 'disabled' ? await EnterpriseUserBindApi.disabledEnterpriseAccount([id]) : await EnterpriseUserBindApi.enableEnterpriseAccount([id])
-//     message.success('操作成功')
-//     // 刷新列表
-//     await getList()
-//   } catch {}
-// }
+const handleActions = async (id: number, type: string) => {
+  try {
+    await message.confirm(type === 'disabled' ? '确定要禁用该账户吗?' : '确定要启用该账户吗?')
+    type === 'disabled' ? await EnterpriseUserBindApi.disabledEnterpriseAccount(id) : await EnterpriseUserBindApi.enableEnterpriseAccount([id])
+    message.success('操作成功')
+    // 刷新列表
+    await getList()
+  } catch {}
+}
 
 /** 初始化 **/
 onMounted(() => {

+ 25 - 0
src/views/menduner/system/madUser/index.vue

@@ -134,6 +134,22 @@
           >
             删除
           </el-button>
+          <!-- <el-button
+            v-if="scope.row.status === '1'"
+            link
+            type="primary"
+            @click="handleAction(scope.row.id, 'enable')"
+          >
+            启用
+          </el-button>
+          <el-button
+            v-if="scope.row.status === '0'"
+            link
+            type="danger"
+            @click="handleAction(scope.row.id, 'disabled')"
+          >
+            禁用
+          </el-button> -->
         </template>
       </el-table-column>
     </el-table>
@@ -236,6 +252,15 @@ const handleExport = async () => {
   }
 }
 
+const handleAction = async (id: number, type: string) => {
+  try {
+    await message.confirm(`确认${type === 'disabled' ? '禁用' : '启用'}该账户吗?`)
+    await MdeUserApi[type === 'disabled' ? 'disabledUserAccount' : 'enableUserAccount'](id)
+    message.success('操作成功')
+    await getList()
+  } catch {}
+}
+
 /** 初始化 **/
 onMounted(() => {
   getList()