import { reactive } from 'vue'
import { WorkFlowDataHelper } from './WorkFlowDataHelper'
import type { IPage } from '../../Presentation/Interfaces/IPage'

/**
 * 授权相关数据存取帮助类
 */
export class AuthDataHelper extends WorkFlowDataHelper {
    constructor(page: IPage) {
        super(page)
    }

    // 授权类型:preauth预授权；auth 授权
    get AuthType(): string {
        return this.tradeBusData["AuthType"] || ""
    }
    set AuthType(value: string) {
        this.tradeBusData["AuthType"] = value
    }

    // 授权记录ID
    get AuthId(): string {
        return this.tradeBusData["AuthId"] || ""
    }
    set AuthId(value: string) {
        this.tradeBusData["AuthId"] = value
    }

    // 预授权记录ID
    get PreAuthId(): string {
        return this.tradeBusData["PreAuthId"] || ""
    }
    set PreAuthId(value: string) {
        this.tradeBusData["PreAuthId"] = value
    }

    // 授权方式：local 本地授权;remote 远程授权
    get AuthWay(): string {
        return this.tradeBusData["AuthWay"] || ""
    }
    set AuthWay(value: string) {
        this.tradeBusData["AuthWay"] = value
    }

    // 授权模式(一定规则的表达式)
    get AuthMode(): string {
        return this.tradeBusData["AuthMode"] || ""
    }
    set AuthMode(value: string) {
        this.tradeBusData["AuthMode"] = value
    }

    // 授权柜员
    get AuthTeller(): string {
        return this.tradeBusData["AuthTeller"] || ""
    }
    set AuthTeller(value: string) {
        this.tradeBusData["AuthTeller"] = value
    }

    // 授权柜员姓名
    get AuthTellerName(): string {
        return this.tradeBusData["AuthTellerName"] || ""
    }
    set AuthTellerName(value: string) {
        this.tradeBusData["AuthTellerName"] = value
    }

    // 授权柜员2
    get AuthTeller2(): string {
        return this.tradeBusData["AuthTeller2"] || ""
    }
    set AuthTeller2(value: string) {
        this.tradeBusData["AuthTeller2"] = value
    }

    // 授权附言
    get Comments(): string {
        return this.tradeBusData["Comments"] || ""
    }
    set Comments(value: string) {
        this.tradeBusData["Comments"] = value
    }

    // 授权结果：true 通过；false 不通过
    get AuthFlag(): string {
        return this.tradeBusData["AuthFlag"] || ""
    }
    set AuthFlag(value: string) {
        this.tradeBusData["AuthFlag"] = value
    }

    // 指定授权柜员
    get AppointTeller(): string {
        return this.tradeBusData["AppointTeller"] || ""
    }
    set AppointTeller(value: string) {
        this.tradeBusData["AppointTeller"] = value
    }

    // 授权原因描述
    get AuthReason(): string {
        return this.tradeBusData["AuthReason"] || ""
    }
    set AuthReason(value: string) {
        this.tradeBusData["AuthReason"] = value
    }

    // 授权人数
    get AuthPersonNum(): string {
        return this.tradeBusData["AuthPersonNum"] || ""
    }
    set AuthPersonNum(value: string) {
        this.tradeBusData["AuthPersonNum"] = value
    }

    /**
     * 清理总线中授权相关数据
     */
    public ClearAuthData(): void {
        super.ClearWorkFlowData()
        delete this.tradeBusData["AuthType"]
        delete this.tradeBusData["AuthId"]
        delete this.tradeBusData["AuthWay"]
        delete this.tradeBusData["AuthMode"]
        delete this.tradeBusData["Comments"]
        delete this.tradeBusData["AuthFlag"]
        delete this.tradeBusData["AppointTeller"]
        delete this.tradeBusData["AuthReason"]
        delete this.tradeBusData["AuthTeller"]
        delete this.tradeBusData["AuthPersonNum"]
        delete this.tradeBusData["AuthTeller2"]
        delete this.tradeBusData["AuthTellerName"]
        delete this.tradeBusData["PreAuthId"]
    }
}

// Vue组合式API封装
export const useAuthDataHelper = (page: IPage) => {
    return reactive(new AuthDataHelper(page))
}