60 lines
2.8 KiB
Vue
60 lines
2.8 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 { 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 = crypto.randomUUID()
|
|
// 请求失败后保留键,只有意图改变或成功后才换键。
|
|
watch([taskType, selected], () => { requestKey = crypto.randomUUID() }, { 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 = crypto.randomUUID()
|
|
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" :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'" label="读取范围">
|
|
<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)); width: 100%; }
|
|
.task-note { color: var(--ys-ink-2); line-height: 1.7; }
|
|
</style>
|