import { queryWrPerformancePlanStep } from "@/services/go/wrtrade";
import { QueryWrPerformancePlanStepReq, WrPerformancePlan, WrPerformancePlanStep } from "@/services/go/wrtrade/interface";
import { ref } from "vue";

// 获取当前履约步骤
export function handlePerformancePlanStep(selectedRow: WrPerformancePlan, isAll = false) {
    const performancePlanStep = ref<WrPerformancePlanStep>()
    const performancePlanStepList = ref<WrPerformancePlanStep[]>([])

    const stepamount = ref<string>('--')

    const param: QueryWrPerformancePlanStepReq = isAll ? { planid: selectedRow.performanceplanid } : { planid: selectedRow.performanceplanid, curstepid: selectedRow.curstepid }
    queryWrPerformancePlanStep(param).then(res => {
        console.log('获取当前履约步骤', res)
        if (res.length) {
            performancePlanStepList.value = res;
            performancePlanStep.value = res[0]
            stepamount.value = res[0].stepamount.toFixed(2).toString()
        }
    })
    return { performancePlanStep, stepamount, performancePlanStepList }
}