<template>
  <div>
      <button @click="get">test</button>
  </div>
</template>

<script>
import CryptoJS from "crypto-js";
export default {
  data() {
    return {
      timer: "",
      value: 0,
    };
  },
  methods: {
    get() {
      this.$store.dispatch("Getsendmessagelist", "").then((r) => {
          if(r.length > 0){
                let systemconfig = {
                    actUserName : '调取OA地址',
                    taskActorName : '调取地产云地址',
                    opinionText : '第三方注册系统编码',
                    opinionDate : '',
                };
                let updatedatalist = [];
                let updatedata = {
                    flowid : '',
                    isdelete : '',
                    pcurl : '',
                    appurl : '',
                }
                this.$store.dispatch("GetSystemURL",systemconfig).then((rsc) => {
                    for(let o of r){
                        if(o.status == "Begin" && o.issend == "0" && o.isdelete == "0"){
                            let key = CryptoJS.enc.Utf8.parse("absoietlj32fai12");
                            let encryptedcasedoce = CryptoJS.AES.encrypt(o.casecode, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, });
                            let encryptedactcode = CryptoJS.AES.encrypt(o.actcode, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, });
                            let encryptedapplicantion = CryptoJS.AES.encrypt(o.applicantion, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, });
                            let encryptedusercode = CryptoJS.AES.encrypt(o.receiveusercode, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, });
                            let encryptedusername = CryptoJS.AES.encrypt(o.receiveusername, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7, });
                            let DB = {
                                syscode:rsc.opinionText,
                                flowid:o.flowid,
                                requestname:o.requestname,
                                workflowname:o.workflowname,
                                nodename:o.nodename,
                                pcurl:`${rsc.taskActorName}reception?&amp;type=1&amp;userCode=${encryptedusercode.toString()}&amp;frameType=info&amp;caseCode=${encryptedcasedoce.toString()}&amp;actCode=${encryptedactcode.toString()}&amp;applicantion=${encryptedapplicantion.toString()}&amp;PName=${encodeURIComponent(o.workflowname)}`,
                                appurl:`${rsc.taskActorName}reception?&amp;type=0&amp;userCode=${encryptedusercode.toString()}&amp;actCode=${encryptedactcode.toString()}&amp;un=${encryptedusername.toString()}&amp;PName=${encodeURIComponent(o.workflowname)}`,
                                creator:o.creator,
                                createdatetime:o.createdatetime,
                                receiver:o.receiver,
                                receivedatetime:o.createdatetime,
                            };
                            this.$axios({
                                url:`${rsc.actUserName}`,
                                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>' +
                                JSON.stringify(DB).toString() +
                                "</web:in0></web:receiveTodoRequestByJson></soapenv:Body></soapenv:Envelope>",
                                headers: {"Content-Type": "text/xml; charset=utf-8",}
                            }).then( (rdb) => {
                                if (JSON.parse(rdb.data.split("<ns1:out>")[1].split("</ns1:out>")[0]).operResult == "1"){
                                    updatedata.flowid = o.flowid;
                                    updatedata.isdelete = 1;
                                    updatedata.pcurl = DB.pcurl;
                                    updatedata.appurl = DB.appurl;
                                    updatedatalist.push(updatedata);
                                    this.$store.dispatch("updatesendmessagelist",updatedatalist).then((ru) => {});
                                }
                            })


                        }
                        else if(o.status == "End" && o.issend == "1" && o.isdelete == "0"){
                            let DBGX = {
                                syscode : rsc.opinionText,
                                flowid : o.flowid,
                                requestname : o.requestname,
                                workflowname : o.workflowname,
                                nodename : o.nodename,
                                receiver : o.receiver,

                            };
                            this.$axios({
                                url:`${rsc.actUserName}`,
                                method:"post",
                                data:'<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><processDoneRequestByJson xmlns="webservices.ofs.weaver.com.cn"><in0>' +
                                JSON.stringify(DBGX).toString() +
                                '</in0></processDoneRequestByJson></soapenv:Body></soapenv:Envelope>',
                                headers: {"Content-Type": "text/xml; charset=utf-8",}
                            }).then((rdbgx) => {
                                if (JSON.parse(rdbgx.data.split("<ns1:out>")[1].split("</ns1:out>")[0]).operResult == "1"){
                                    updatedata.flowid = o.flowid;
                                    updatedata.isdelete = 2;
                                    updatedatalist.push(updatedata);
                                    this.$store.dispatch("updatesendmessagelist",updatedatalist).then((ru) => {});
                                }
                            })
                        }
                        else if(o.issend == "1" && o.isdelete == "1"){
                            let DBSC = {
                                syscode : rsc.opinionText,
                                flowid : o.flowid,
                                userid : o.receiver,

                            };
                            this.$axios({
                                url:`${rsc.actUserName}`,
                                method:"post",
                                data:'<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><deleteUserRequestInfoByJson xmlns="webservices.ofs.weaver.com.cn"><in0>' +
                                JSON.stringify(DBSC).toString() +
                                '</in0></deleteUserRequestInfoByJson></soapenv:Body></soapenv:Envelope>',
                                headers: {"Content-Type": "text/xml; charset=utf-8",}
                            }).then((rdbgx) => {
                                if (JSON.parse(rdbgx.data.split("<ns1:out>")[1].split("</ns1:out>")[0]).operResult == "1"){
                                    updatedata.flowid = o.flowid;
                                    updatedata.isdelete = 3;
                                    updatedatalist.push(updatedata);
                                    this.$store.dispatch("updatesendmessagelist",updatedatalist).then((ru) => {});
                                }
                            })
                        }
                    }
                    
                    

                })
                

            }
      });
    },
  },
  mounted() {
    this.timer = setInterval(this.get, 60000);
  },
  beforeDestroy() {
    clearInterval(this.timer);
  },
};
</script>