vio_warning_info.js 3.71 KB
import {getViolationWarningInformation} from "@/api/casefile/violationWarningInformation";
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_warning"}).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;
    },
    init() {
      let id = this.idInfo.split(":");

      if (id.length == 2) {
        id = id[1];
      }
      getViolationWarningInformation(id).then(response => {
        this.form = response.data.violationWarningInformation;
        let files = JSON.stringify(response.data.uploadFiles);
        this.fileEntityList = JSON.parse(files.replaceAll("filePath", "url").replaceAll("fileName", "name"));
        this.fileEntityList.map(item => {
          if (item.url.indexOf(".jpg") > -1 || item.url.indexOf(".png") > -1 || item.url.indexOf(".jpeg") > -1 || item.url.indexOf(".jpg") > -1) {
            this.slide1.push(process.env.VUE_APP_BASE_API + item.url);
          }
          if (item.url.indexOf(".mp4") > -1 || item.url.indexOf(".avi") > -1) {
            this.videoSrc.push(process.env.VUE_APP_BASE_API + item.url);
          }
        })


      });

        listReplyApprovalProcess({tableName: "violation_warning" + ":" + id}).then(response => {
          let array = response.rows;
            historyFromData("violation_warning" + ":" + 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')
      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) {
      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;
    },
  }
}