import Api from "~/service/Api"
import Utils from "~/utils/index"
export default {
    onSeaown() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            const that = this.root;
            that.executeRule("searow").then(res => {
                //TODO 处理数据逻辑
                that.$refs.inftrnps.stmData.data = res.data.trncorco_trnstm.rows;
                this.model.trncorco.trnstm = res.data.trncorco_trnstm;
            })
            // let rtnmsg = await Api.post("trnrel/executeRule/searow", Utils.getRequestDataFn.call(this))
            // if (rtnmsg.respCode == "AAAAAA") {
            //     //TODO 处理数据逻辑
            //     this.stmData.data = rtnmsg.data.trncorco_trnstm.rows;
            // }
            // else {
            //     this.$notify.error({ title: '错误', message: '服务请求失败！' });
            // }
        })
    },
    onSeajbh() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            const that = this.root;
            that.executeRule("seajbh").then(res => {
                //TODO 处理数据逻辑
                that.$refs.inftrnps.stmData.data = res.data.trncorco_trnstm.rows;
            })
        })
    },
    onSeactr() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/seactr", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onSearow() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;

            let rtnmsg = await Api.post("trnrel/searow", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onDsp() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/dsp", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onImgmodNewimg() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/imgmod_newimg", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onImgmodNewhisimg() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/imgmod_newhisimg", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onDiaconButdia() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/diacon_butdia", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onImgmodHisimg() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/imgmod_hisimg", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRelrow() {
        const that = this
        that.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            that.model.trncorco.selinr = {
                "rows": that.multipleSelection.map(idx => that.model.trncorco.trnstm.rows[idx])
            }
            const data = Utils.getRequestDataFn.call(this)
            let rtnmsg = await Api.post("/trnrel/executeRule/relrow", data)
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

                this.$message({
                    type: 'success',
                    message: 'Release成功！'
                });
                await this.sleep(2000);
                this.$router.go(0);
                    
                
            }
            else {
                that.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    sleep (ms) {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve()
          }, ms)
        })
      },
    onPrinte() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/printe", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onReprow() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/reprow", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRejrow() {
        console.log(this.getSelectedData())

        this.model.trncorco.selinr['rows'] = this.getSelectedData();
        this.root.$refs.modelForm.validate(async valid => {
            // if (!valid)
            //     return;
            let rtnmsg = await Api.post("trnrel/rejrow", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑
                // var cacheFileName = rtnmsg.data.cacheFileName;
                // let rejrowRtnmsg = await Api.post("trncor/init", {params:{"cacheFileName":cacheFileName}})
                // if(rejrowRtnmsg.respCode == "AAAAAA"){
                //     this.$message({
                //         type: 'success',
                //         message: 'Reject成功！'
                //     });
                //     await this.sleep(2000);
                //     this.$router.go(0);
                // }

                this.$message({
                    type: 'success',
                    message: 'Reject成功！'
                });
                // await this.sleep(2000);
                // this.$router.go(0);

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRelcor() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/relcor", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onExi() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/exi", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    
    onRecpanDet() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_det", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onSyswrnButshw() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/syswrn_butshw", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRecpanNotmap() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_notmap", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRecpanButspt() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_butspt", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRecpanInc() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_inc", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRecpanButord() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_butord", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onImgmodImage() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/imgmod_image", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onRecpanIncben() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/recpan_incben", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onInftxtButtxmsel() {
        this.root.$refs.modelForm.validate(async valid => {
            if (!valid)
                return;
            let rtnmsg = await Api.post("trnrel/inftxt_buttxmsel", Utils.getRequestDataFn.call(this))
            if (rtnmsg.respCode == "AAAAAA") {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败！' });
            }
        })
    },
    onSeainf() {

    },
    display(index, row){
        const d = this.stmData.data[index]
        const ds = d.split("\t")
        let viewurl ="/#/display/"+ds['10'].toLowerCase()+"?trn="+ds['1']
        window.open(viewurl, 'newwindow', 'height=1200,width=900,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
    }
}