在系统设置页面的员工同步配置中增加"立即同步"按钮, 允许管理员手动触发钉钉员工数据同步
This commit is contained in:
@@ -140,6 +140,14 @@
|
|||||||
<el-button @click="testSyncConnection" :loading="syncTesting" :disabled="!syncForm.configured">
|
<el-button @click="testSyncConnection" :loading="syncTesting" :disabled="!syncForm.configured">
|
||||||
测试连接
|
测试连接
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
@click="triggerSync"
|
||||||
|
:loading="syncing"
|
||||||
|
:disabled="!syncForm.configured"
|
||||||
|
>
|
||||||
|
立即同步
|
||||||
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@@ -164,6 +172,7 @@ const dingtalkFormRef = ref<FormInstance>()
|
|||||||
const syncLoading = ref(false)
|
const syncLoading = ref(false)
|
||||||
const syncSaving = ref(false)
|
const syncSaving = ref(false)
|
||||||
const syncTesting = ref(false)
|
const syncTesting = ref(false)
|
||||||
|
const syncing = ref(false)
|
||||||
const syncFormRef = ref<FormInstance>()
|
const syncFormRef = ref<FormInstance>()
|
||||||
|
|
||||||
// 钉钉配置表单
|
// 钉钉配置表单
|
||||||
@@ -327,6 +336,31 @@ const testSyncConnection = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 立即执行员工同步
|
||||||
|
*/
|
||||||
|
const triggerSync = async () => {
|
||||||
|
syncing.value = true
|
||||||
|
try {
|
||||||
|
const response = await request.post('/api/v1/employee-sync/sync')
|
||||||
|
if (response.success) {
|
||||||
|
const data = response.data
|
||||||
|
ElMessage.success(
|
||||||
|
`同步完成!共处理 ${data.total_employees || 0} 名员工,` +
|
||||||
|
`创建 ${data.users_created || 0} 个账号,` +
|
||||||
|
`跳过 ${data.users_skipped || 0} 个`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.message || '同步失败')
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('员工同步失败:', error)
|
||||||
|
ElMessage.error(error?.response?.data?.detail || '员工同步失败')
|
||||||
|
} finally {
|
||||||
|
syncing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 页面加载时获取配置
|
// 页面加载时获取配置
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadDingtalkConfig()
|
loadDingtalkConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user