import Api from "~/service/Api"
import Utils from "../utils"

export default {
    data() {
        return {}
    },
    mounted() {
        //this.restoreDisplay()
    },
    methods: {
        init(params) {
            return Api.post(this.declareParams.trnName + "/init", { params })
        },
        save(params) {
            return Api.post(this.declareParams.trnName + "/saveData", this.wrapper(params))
        },
        executeCheck(rulePath,params){
            return Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath, this.wrapper(params))
        },
        executeDefault(rulePath, params) {
            return Api.post(this.declareParams.trnName + "/executeDefault/" + rulePath, this.wrapper(params))
        },
        executeRule(rulePath, params) {
            return Api.post(this.declareParams.trnName + "/executeRule/" + rulePath, this.wrapper(params))
        },
        async checkAll(params) {
            const res = await Api.post(this.declareParams.trnName + "/checkAll", this.wrapper(params))
            return res
        },
        pedding(params) {
            return Api.post(this.declareParams.trnName + "/pending", this.wrapper(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))
        },
        executeNotify(params) {
            return Api.post(this.declareParams.trnName + "/executeNotify", this.wrapper(params))
        },
    }
}