vio_casefile_info.js 4.54 KB
import {getViolationCaseFile,
  updateViolationCaseFile} from "@/api/casefile/violationCaseFile";
import {listReplyApprovalProcess} from "@/api/casefile/replyApprovalProcess";

import {historyFromData} from '@/api/activiti/historyFormdata'
export default {
  name: "violationWarningInformationInfo",
  props: {
    businessKey: {
      type: String
    },
    idInfo: {
      type: String
    },
    entryType: {
      type: Number
    },
  },
  data() {
    return {
      form: {},
      fileEntityList: [],
      open: false,
      replyApprovalProcessList: [],
      openImg: false,
      img: [],
      showPic: null,
      picImage: null,
      slide1: [],
      videoSrc: [],
    }
  },
  created() {
    this.listData({dictType:"vio_casefile"}).then(res=>{
      this.caseType = res.rows;
    });
    this.init();
  },
  methods: {
    getCaseType(type){
      for(let i in this.caseType){
        if(this.caseType[i].dictValue == type){
          return this.caseType[i].dictLabel;
        }
      }
      return type;
    },
    submit(){
        let postData = {};

        postData.tableName = "workflow_casefile:" + this.form.id;
        postData.replyImg = this.form.replyImg + "";
        postData.reply = this.form.reply;


        addReplyApprovalProcess(postData).then(res => {
          this.videoSrc1 = [];
          this.slides1 = [];

          updateViolationCaseFile({id: this.form.id,status:1}).then(res => {

          })
        });
    },
    init() {

      let id = this.idInfo.split(":");

      if (id.length == 2) {
        id = id[1];
      }


      getViolationCaseFile(id).then(response => {
        this.form = response.data.violationCaseFile;
        let files = JSON.stringify(response.data.uploadFiles);
        this.fileEntityList = JSON.parse(files.replaceAll("filePath", "url").replaceAll("fileName", "name"));
        this.fileEntityList.map(item => {


          if (item.name.indexOf(".jpg") > -1 || item.name.indexOf(".png") > -1 || item.name.indexOf(".jpeg") > -1) {
            if(item.url.startsWith("https:")){
              this.slide1.push(item.url);
            }else{
              this.slide1.push(process.env.VUE_APP_BASE_API + item.url);
            }


          }
          if (item.name.indexOf(".mp4") > -1 || item.name.indexOf(".avi") > -1) {
            if(item.url.startsWith("https:")){
              this.videoSrc.push(item.url);
            }else{
              this.videoSrc.push(process.env.VUE_APP_BASE_API + item.url);
            }
          }
        })

      });
        listReplyApprovalProcess({tableName: "workflow_casefile" + ":" + id}).then(response => {
          let array = response.rows;
            historyFromData("workflow_casefile" + ":" + id).then(response => {
                let newRep = [];




                let obj = response.data[0];
               if(obj){
                 let data  = {
                   reply:obj.controlValue,
                   replyPeople:obj.createBy,
                   replyTime:obj.createTime
                 };

                 newRep.push(data);
               }

                for(let j in array){
                    newRep.push(array[j]);
                }

                if(response.data.length - array.length == 2){
                  let obj = response.data[response.data.length -1];
                  let data  = {
                    reply:obj.controlValue,
                    replyPeople:obj.createBy,
                    replyTime:obj.createTime
                  };
                    newRep.push(data);
                }

                this.replyApprovalProcessList = newRep;
                this.$forceUpdate();
            });

        });


    },
    /** 文件下载 */
    downloadFA(row) {
      let name = row.name;
      let url = row.url;
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')

      if(url.startsWith("http")){

        a.setAttribute('href', url);
      }else{

        a.setAttribute('href', process.env.VUE_APP_BASE_API + url);
      }

      a.click()
    },
    openImage(path) {
      this.img = [];
      this.openImg = true;
      let files = path.split(",");
      for(let i=0;i<files.length;i++){
        this.img.push(files[i]);
      }
    },
    downloadFile(path) {
      debugger;
      if(path.startsWith("http")){
        window.location.href = path;
        return;
      }
      window.location.href = process.env.VUE_APP_BASE_API + "/business/threestep/download?path=" + encodeURI(path);
    },
    showFile(path) {
      return process.env.VUE_APP_BASE_API + path;
    },
  }
}