import Api from "~/service/Api"
import Utils from "../utils"
 
export default {
    data(){
        return {}
    },
    mounted(){
        //this.restoreDisplay()
    },
    methods:{
        init(params){
            params = params||{}
            return Api.post(this.declareParams.trnName+"/init",{params})
        },
        save(params){
            params = params||{}
            let data = Utils.flatObject(this.model)
            return Api.post(this.declareParams.trnName+"/saveData",{...data,params})
        },
        exeuteCheck(rulePath,params){
            params = params||{}
            let data = Utils.flatObject(this.model)
            return Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath,{...data,params})
        },
        executeDefault(rulePath,params)
        {
            params = params||{}
            let data = Utils.flatObject(this.model)
            return Api.post(this.declareParams.trnName+"/default/"+rulePath,{...data,params})
        },
        executeRule(rulePath,params)
        {
            params = params||{}
            let data = Utils.flatObject(this.model)
            return Api.post(this.declareParams.trnName+"/executeRule/"+rulePath,{...data,params})
        },
        async checkAll(params){
            params = params||{}
            let data = Utils.flatObject(this.model)
            const res = await Api.post(this.declareParams.trnName+"/checkAll",{...data,params})
            return res
        },
        pedding(params){
            params = params||{}
            let data = Utils.flatObject(this.model)
            return Api.post(this.declareParams.trnName+"/pending",{...data,params})
        },
        async restoreDisplay()
        {
            let inr = this.$route.query.trn
            if(!inr)
                return
            let data =await Api.post("display/"+inr)
            Utils.copyValueFromVO(this.model,JSON.parse(data.data))
        }
    }
} 