Files
PayrollManagementSystem/frontend/src/views/system/tplus/CreateTaskDialog.vue
T
liuwenxin 1e53792ad6 feat(T+): 完成数据贯通与自动接入闭环
打通 T+ 快照、业务、发货、回款和核算准备链路,保留来源差异并提供待补状态。
新增业务自动接入任务、跨平台读取服务托管、权限复核、来源关联和前端核对页面。
补充迁移、隔离集成测试、浏览器模拟验收及角色授权边界修复。
2026-11-05 18:47:13 +08:00

65 lines
3.5 KiB
Vue

<script setup lang="ts">
import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import * as api from '@/api/tplus'
import { handledError } from '@/utils/error'
import { newRequestKey } from '@/utils/uuid'
import { entities } from './labels'
const visible = defineModel<boolean>({ required: true })
const props = defineProps<{ configured: boolean }>()
const emit = defineEmits<{ created: [batch: api.TPlusDetail] }>()
const taskType = ref<api.TaskType>('READ')
const selected = ref<api.EntityType[]>(['personnel'])
const pending = ref(false)
let requestKey = newRequestKey()
// 请求失败后保留键,只有意图改变或成功后才换键。
watch([taskType, selected], () => { requestKey = newRequestKey() }, { deep: true, flush: 'sync' })
async function submit(): Promise<void> {
if (pending.value || !props.configured) return
pending.value = true
try {
const batch = await api.createTask({ task_type: taskType.value,
entity_types: taskType.value === 'AUDIT' ? [] : [...selected.value], request_key: requestKey })
requestKey = newRequestKey()
visible.value = false
ElMessage.success('任务已提交,处理结果会自动更新')
emit('created', batch)
} catch (error) { handledError(error) }
finally { pending.value = false }
}
</script>
<template>
<el-dialog v-model="visible" title="新建 T+ 数据任务" width="min(560px, 94vw)" :close-on-click-modal="!pending" :close-on-press-escape="!pending" :show-close="!pending">
<el-form label-position="top" :disabled="pending">
<el-form-item label="任务内容">
<el-radio-group v-model="taskType">
<el-radio-button value="READ">读取数据</el-radio-button>
<el-radio-button value="AUDIT">关联检查</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="taskType === 'READ'">
<template #label><span>读取范围</span><span class="selection-count">已选 {{ selected.length }} 项</span></template>
<el-checkbox-group v-model="selected" class="entity-options">
<el-checkbox v-for="item in entities" :key="item.value" :value="item.value">{{ item.label }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<p class="task-note">{{ taskType === 'READ' ? '读取所选范围内的数据,自动跳过未变化的记录。读取完成后可预览导入,不会自动生成工资。' : '检查收付款单据与订单、销货单的关联情况,供导入前核对;不会修改业务数据。' }}</p>
</el-form>
<template #footer>
<el-button :disabled="pending" @click="visible = false">取消</el-button>
<el-button type="primary" :loading="pending" :disabled="!configured || (taskType === 'READ' && !selected.length)" @click="submit">创建任务</el-button>
</template>
</el-dialog>
</template>
<style scoped>
.entity-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
.entity-options :deep(.el-checkbox) { margin: 0; min-height: 40px; height: auto; padding: 8px 10px; border: 1px solid var(--ys-line); border-radius: var(--ys-radius-sm); }
.entity-options :deep(.el-checkbox.is-checked) { border-color: var(--el-color-primary-light-7); background: var(--ys-indigo-wash); }
.selection-count { margin-left: auto; color: var(--ys-ink-3); font-size: 12px; }
.task-note { margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--ys-line-soft); color: var(--ys-ink-2); font-size: 13px; line-height: 1.7; }
</style>