<template>
    <div style="height:100%;background-color:#FAFAFA;">
        
        <div style="text-align:center;">
            
            <Input v-model="userid"  clearable prefix="ios-contact" placeholder="用户编码" style="width: auto"   />
            <br>
            <br>
            <Input v-model="flowid" clearable prefix="ios-contact" placeholder="审批流水号" style="width: auto" />
            
            
            <br>
            <Button style="margin:40px;" @click="Click_7">更新代办</Button>
            <Button style="margin:40px;" @click="Click_4">督办事项</Button>
        </div>

    </div>
</template>

<script>
import CryptoJS from "crypto-js";

export default {
    data() {
        return {
            userid : '',
            flowid : '',
        }
    },
    created() {

    },
    methods: {
        Click_7(){
            let userinfo = {
                opinionConfirm : '',
                opinionDate : '',
                actUserName : this.userid,

            }
            this.$store.dispatch("GetUserVM",userinfo).then(r=>{
                userinfo.opinionConfirm = this.flowid;
                userinfo.opinionDate = r.userCode;
                
                
                this.$store.dispatch("GetWorkFlowNew",userinfo).then(r1=>{
                    
                    for (let i = 0; i < r1.data.length; i++){
                        let GX ={//OA更新接口数据参数
                                    syscode:'dichanerp',//注册编码
                                    flowid:'',
                                    requestname:'',
                                    workflowname:'地产业务事项', 
                                    receiver:this.userid,           
                                } 
                        GX.flowid = r1.data[i].messageUrl+r1.data[i].picUrl;
                        GX.requestname = r1.data[i].title;
                        if(JSON.stringify(GX)!='{}'){
                        this.$store.dispatch('GetDongLong',encodeURIComponent('调取OA地址')).then(res=>{
                            let b = JSON.stringify(GX);
                                this.$axios({
                                url: `${res}`,
                                method:'post',
                                data:'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="webservices.ofs.weaver.com.cn"><soapenv:Header/><soapenv:Body><web:processOverRequestByJson><web:in0>'+b.toString()+'</web:in0></web:processOverRequestByJson></soapenv:Body></soapenv:Envelope>',
                                headers:{'Content-Type': 'text/xml; charset=utf-8'}
                                }).then(r=>{                                  
                                            
                                            })  
                        })                
                   
                        }
                    }
                })
            })
        },
        Click_4(){
            let opinion ={
                actUserName:this.userid,
                opinionText:this.flowid,
            } 
            this.$store.dispatch("Getoamessagedblist",opinion).then(r=>{
                
                if(r.data.length > 0){
                    let FWQ ={
                                taskActorName:'第三方注册系统编码',
                                actUserName:'调取地产云地址',
                                opinionDate:'调取OA地址',
                                opinionConfirm:'',
                                opinionText:'Web接口',
                            };
                            this.$store.dispatch('GetSystemURL',FWQ).then(r1=>{
                                
                        for (let o of r.data){
                            let DB = {
                                syscode: 'dichanerp',
                                flowid: '',
                                requestname: '',
                                workflowname: '地产业务事项',
                                nodename: '',
                                pcurl: '',
                                appurl: '',
                                creator: '',
                                createdatetime: '',
                                receiver: '',
                                receivedatetime: '',                                      
                            }
                            let key = CryptoJS.enc.Utf8.parse('absoietlj32fai12');
                            let encrypted1 = CryptoJS.AES.encrypt(o.userCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//加密userCode
                            let encrypted2 = CryptoJS.AES.encrypt(o.actCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//加密actCode
                            let encrypted3 = CryptoJS.AES.encrypt(o.userName, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//加密userName
                            let encrypted4 = CryptoJS.AES.encrypt(o.caseCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//加密caseCode
                            let encrypted5 = CryptoJS.AES.encrypt(o.applicationCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//加密ApplicationCode
                            
                            DB.flowid = o.actCode + o.fromDate.replace(/-/g,'').replace(/:/g,'').replace(/ /g,'');
                            DB.requestname = o.title.replace(/ /g,'');
                            DB.nodename = o.procedureName;
                            DB.pcurl = `${r1.actUserName}reception?&amp;type=1&amp;userCode=${encrypted1.toString()}&amp;frameType=info&amp;caseCode=${encrypted4.toString()}&amp;actCode=${encrypted2.toString()}&amp;applicantion=${encrypted5.toString()}&amp;PName=${encodeURIComponent(o.procedureName)}`;
                            DB.appurl = `${r1.actUserName}reception?&amp;type=0&amp;userCode=${encrypted1.toString()}&amp;actCode=${encrypted2.toString()}&amp;un=${encrypted3.toString()}&amp;PName=${encodeURIComponent(o.procedureName)}`,
                            DB.creator = o.creater;
                            DB.createdatetime = o.fromDate;
                            DB.receiver = o.receiver;
                            let nowDate = new Date();
                            DB.receivedatetime = nowDate.getFullYear()+'-'+((nowDate.getMonth()+1)<10?'0'+(nowDate.getMonth()+1):(nowDate.getMonth()+1))+'-'+(nowDate.getDate()<10?'0'+nowDate.getDate():nowDate.getDate())+' '+(nowDate.getHours()<10?'0'+nowDate.getHours():nowDate.getHours())+':'+(nowDate.getMinutes()<10?'0'+nowDate.getMinutes():nowDate.getMinutes())+':'+(nowDate.getSeconds()<10?'0'+nowDate.getSeconds():nowDate.getSeconds());
                            
                            let b = JSON.stringify(DB)
                                                        this.$axios({
                                                            url: `${r1.opinionDate}`,
                                                            method:'post',
                                                            data:'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="webservices.ofs.weaver.com.cn"><soapenv:Header/><soapenv:Body><web:receiveTodoRequestByJson><web:in0>'+b.toString()+'</web:in0></web:receiveTodoRequestByJson></soapenv:Body></soapenv:Envelope>',
                                                            headers:{
                                                                'Content-Type': 'text/xml; charset=utf-8'
                                                            }
                                                        }).then(r=>{
                                                            if(r.data.indexOf("自动更新办结成功") >= 0){
                                                                this.$Message.success("已发送");
                                                            }
                                                        })

                        }
                    })
                }

            })

        }
        
          
        
    },
}
</script>

<style>

</style>
