feat: 7月迭代
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m21s

This commit is contained in:
luo
2026-07-28 14:00:22 +08:00
parent f0a2b84e53
commit 2706c52a47
63 changed files with 4113 additions and 3945 deletions

View File

@@ -213,6 +213,75 @@
</div>
</template>
</ElDialog>
<!-- 绑定企微账号对话框 -->
<ElDialog
v-model="wecomBindingDialogVisible"
title="绑定企微账号"
width="520px"
destroy-on-close
@closed="resetWecomBindingForm"
>
<ElForm
ref="wecomBindingFormRef"
:model="wecomBindingForm"
:rules="wecomBindingRules"
label-width="100px"
>
<ElFormItem label="账号名称">
<span>{{ currentWecomAccount?.username || '-' }}</span>
</ElFormItem>
<ElFormItem label="企微应用" prop="application_id">
<ElSelect
v-model="wecomBindingForm.application_id"
placeholder="请选择企微应用"
filterable
clearable
style="width: 100%"
:loading="wecomApplicationsLoading"
@change="handleWecomApplicationChange"
>
<ElOption
v-for="application in wecomApplications"
:key="application.id"
:label="application.name"
:value="application.id"
/>
</ElSelect>
</ElFormItem>
<ElFormItem label="企微成员" prop="userid">
<ElSelect
v-model="wecomBindingForm.userid"
placeholder="请先选择企微应用"
filterable
clearable
style="width: 100%"
:loading="wecomMembersLoading"
:disabled="!wecomBindingForm.application_id"
>
<ElOption
v-for="member in wecomMembers"
:key="member.userid"
:label="member.name"
:value="member.userid"
/>
</ElSelect>
</ElFormItem>
</ElForm>
<template #footer>
<div class="dialog-footer">
<ElButton @click="wecomBindingDialogVisible = false">取消</ElButton>
<ElButton
v-permission="JULY_PERMISSIONS.wecom.binding"
type="primary"
:loading="wecomBindingSubmitting"
@click="submitWecomBinding"
>
确认绑定
</ElButton>
</div>
</template>
</ElDialog>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -237,11 +306,16 @@
import { useAuth } from '@/composables/useAuth'
import { AccountService } from '@/api/modules/account'
import { RoleService } from '@/api/modules/role'
import { ShopService, EnterpriseService } from '@/api/modules'
import { ShopService, EnterpriseService, WecomService } from '@/api/modules'
import type { SearchFormItem } from '@/types'
import type { PlatformRole } from '@/types/api'
import type { PlatformRole, WecomApplication, WecomMember } from '@/types/api'
import { formatDateTime } from '@/utils/business/format'
import { CommonStatus, getStatusText, STATUS_SELECT_OPTIONS } from '@/config/constants'
import {
CommonStatus,
getStatusText,
JULY_PERMISSIONS,
STATUS_SELECT_OPTIONS
} from '@/config/constants'
defineOptions({ name: 'Account' }) // 定义组件名称,用于 KeepAlive 缓存控制
@@ -252,6 +326,7 @@
const dialogType = ref('add')
const dialogVisible = ref(false)
const roleDialogVisible = ref(false)
const wecomBindingDialogVisible = ref(false)
const loading = ref(false)
const currentAccountId = ref<number>(0)
const currentAccountName = ref<string>('')
@@ -262,6 +337,21 @@
const roleToAdd = ref<number | undefined>(undefined) // 单选时使用
const leftRoleFilter = ref('')
const rightRoleFilter = ref('')
const currentWecomAccount = ref<any | null>(null)
const wecomApplications = ref<WecomApplication[]>([])
const wecomMembers = ref<WecomMember[]>([])
const wecomApplicationsLoading = ref(false)
const wecomMembersLoading = ref(false)
const wecomBindingSubmitting = ref(false)
const wecomBindingFormRef = ref<FormInstance>()
const wecomBindingForm = reactive({
application_id: undefined as number | undefined,
userid: ''
})
const wecomBindingRules = reactive<FormRules>({
application_id: [{ required: true, message: '请选择企微应用', trigger: 'change' }],
userid: [{ required: true, message: '请选择企微成员', trigger: 'change' }]
})
// 是否为平台用户(平台用户可多选,其他单选)
const isPlatformUser = computed(() => currentAccountType.value === 2)
@@ -541,6 +631,14 @@
const getActions = (row: any) => {
const actions: any[] = []
if (hasAuth(JULY_PERMISSIONS.wecom.binding)) {
actions.push({
label: '绑定账号',
handler: () => showWecomBindingDialog(row),
type: 'primary'
})
}
if (hasAuth('account:patch_role')) {
actions.push({
label: '分配角色',
@@ -568,6 +666,75 @@
return actions
}
const showWecomBindingDialog = (row: any) => {
currentWecomAccount.value = row
wecomBindingForm.application_id = undefined
wecomBindingForm.userid = ''
wecomMembers.value = []
wecomBindingDialogVisible.value = true
void loadWecomApplications()
}
const loadWecomApplications = async () => {
wecomApplicationsLoading.value = true
try {
const response = await WecomService.getApplications({ page: 1, page_size: 100 })
if (response.code === 0) wecomApplications.value = response.data.items || []
} finally {
wecomApplicationsLoading.value = false
}
}
const handleWecomApplicationChange = async (applicationId?: number) => {
wecomBindingForm.userid = ''
wecomMembers.value = []
if (!applicationId) return
wecomMembersLoading.value = true
try {
const response = await WecomService.getMembers(applicationId, {
page: 1,
page_size: 100
})
if (response.code === 0) wecomMembers.value = response.data.items || []
} finally {
wecomMembersLoading.value = false
}
}
const submitWecomBinding = async () => {
const valid = await wecomBindingFormRef.value?.validate().catch(() => false)
if (!valid || !currentWecomAccount.value || !wecomBindingForm.application_id) return
const accountId = Number(currentWecomAccount.value.id ?? currentWecomAccount.value.ID)
if (!accountId) {
ElMessage.error('当前账号缺少账号标识,无法绑定企微')
return
}
wecomBindingSubmitting.value = true
try {
const response = await AccountService.bindWecom(accountId, {
application_id: wecomBindingForm.application_id,
userid: wecomBindingForm.userid
})
if (response.code === 0) {
ElMessage.success('账号企微绑定成功')
wecomBindingDialogVisible.value = false
}
} finally {
wecomBindingSubmitting.value = false
}
}
const resetWecomBindingForm = () => {
currentWecomAccount.value = null
wecomBindingForm.application_id = undefined
wecomBindingForm.userid = ''
wecomMembers.value = []
wecomBindingFormRef.value?.clearValidate()
}
// 表单实例
const formRef = ref<FormInstance>()