import Api from "~/service/Api"
import Utils from "~/utils/index"
export default {
    async onSeaown() {
        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;
            })
    },
    async onSeajbh() {
        const that = this.root;
            that.executeRule("seajbh").then(res => {
                //TODO 处理数据逻辑
                that.$refs.inftrnps.stmData.data = res.data.trncorco_trnstm.rows;
            })
    },
    async onSeactr() {
        let rtnmsg = await this.executeRule("seactr")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onSearow() {
        let rtnmsg = await this.executeRule("searow")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onDsp() {
        let rtnmsg = await this.executeRule("dsp")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onImgmodNewimg() {
        let rtnmsg = await this.executeRule("imgmod_newimg")
        if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

        }
        else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
        }
    },
    async onImgmodNewhisimg() {
        let rtnmsg = await this.executeRule("imgmod_newhisimg")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onDiaconButdia() {
        let rtnmsg = await this.executeRule("diacon_butdia")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onImgmodHisimg() {
        let rtnmsg = await this.executeRule("imgmod_hisimg")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onRelrow() {
        const that = this
        that.model.trncorco.selinr.empty = false
        that.model.trncorco.selinr.rows = that.multipleSelection.map(idx => that.model.trncorco.trnstm.rows[idx])
        let rtnmsg = await this.executeRule("relrow")
        if (rtnmsg.respCode == SUCCESS) {
            //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)
        })
      },
      async onPrinte() {
        let rtnmsg = await this.executeRule("printe")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onReprow() {
        let rtnmsg = await this.executeRule("reprow")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

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

        this.model.trncorco.selinr['rows'] = this.getSelectedData();
            let rtnmsg = await Api.post("trnrel/rejrow", this.wrapper())
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑
                // var cacheFileName = rtnmsg.data.cacheFileName;
                // let rejrowRtnmsg = await Api.post("trncor/init", {params:{"cacheFileName":cacheFileName}})
                // if(rejrowRtnmsg.respCode == SUCCESS){
                //     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: '服务请求失败!' });
            }
    },
    async onRelcor() {
        let rtnmsg = await this.executeRule("relcor")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onExi() {
        let rtnmsg = await this.executeRule("exi")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    
    async onRecpanDet() {
        let rtnmsg = await this.executeRule("recpan_det")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onSyswrnButshw() {
        let rtnmsg = await this.executeRule("syswrn_butshw")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onRecpanNotmap() {
        let rtnmsg = await this.executeRule("recpan_notmap")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onRecpanButspt() {
        let rtnmsg = await this.executeRule("recpan_butspt")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onRecpanInc() {
        let rtnmsg = await this.executeRule("recpan_inc")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onRecpanButord() {
        let rtnmsg = await this.executeRule("recpan_butord")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async  onImgmodImage() {
        let rtnmsg = await this.executeRule("imgmod_image")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async  onRecpanIncben() {
        let rtnmsg = await this.executeRule("recpan_incben")
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑

            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
    },
    async onInftxtButtxmsel() {
        let rtnmsg = await this.executeRule("inftxt_buttxmsel")
            if (rtnmsg.respCode == SUCCESS) {
                //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');
    }
}