app-wf-step-trace.vue 4.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
<template>
  <div class="app-wf-step-trace">
    <template v-for="(usertask, usertaskIndex) in data.usertasks">
      <div
        class="app-wf-step-trace__item"
        v-if="usertask.comments.length > 0"
        :key="usertaskIndex"
      >
        <div class="app-wf-step-trace__item__top">
          <div class="item__time">
            {{
              usertask.comments[usertask.comments.length - 1] &&
              formatDate(
                usertask.comments[usertask.comments.length - 1].time,
                "MM月DD日 HH:mm:ss"
              )
            }}
          </div>
          <div class="item__border">
            <div class="item__action-line"></div>
          </div>
          <div class="item__text">
            <span class="name" v-if="usertask.comments && usertask.comments.length>0">{{usertask.comments[0].authorName}} </span>
            <span class="action">执行了 </span>
            <span class="action-name">{{ usertask.userTaskName }} </span>
            <span>操作</span>
          </div>
        </div>
      </div>
      {{data.usertasks.length}}
      <div
        :class="{'app-wf-step-trace__item':true,'app-wf-step-trace__item--action':true}"
        v-if="usertask.identitylinks.length > 0"
        :key="usertaskIndex"
      >
        <div class="app-wf-step-trace__item__top">
          <div class="item__time">
            当前
          </div>
          <div class="item__border">
          </div>
          <div class="item__action-text">
            <span class="action-name">{{ usertask.userTaskName }}</span>
          </div>
        </div>
      </div>
    </template>
  </div>
</template>

<script lang="ts">
import { DataServiceHelp } from "ibiz-core";
import moment from "moment";
import { Vue, Component, Prop } from "vue-property-decorator";

@Component({})
export default class AppWfStepTrace extends Vue {
  /**
   * 数据
   *
   *  @memberof AppWfStepTrace
   */
  public data: any = {};

  /**
   *  初始化memo
   *
   *  @memberof AppWfStepTrace
   */
  public initmemo: string = "";

  /**
   *  子项索引初始值
   *
   *  @memberof AppWfStepTrace
   */
  public usertasksIndex: number = 1;

  /**
   *  子项长度初始值
   *
   *  @memberof AppWfStepTrace
   */
  public usertasksLength: number = 1;

  /**
   * 应用实体名称
   *
   * @memberof AppWfStepTrace
   */
  @Prop() public appEntityCodeName!: string;
  /**
   * 应用实体名称
   *
   * @memberof AppWfStepTrace
   */
  @Prop() public appEntity!: any;

  /**
   *  上下文
   *
   *  @memberof AppWfStepTrace
   */
  @Prop() public context: any;

  /**
   *  视图参数
   *
   *  @memberof AppWfStepTrace
   */
  @Prop() public viewparams: any;

  /**
   * 初始化数据
   *
   *  @memberof AppWfStepTrace
   */
  public created() {
    if (this.appEntityCodeName) {
      DataServiceHelp.getInstance()
        .getService(this.appEntity, this.context)
        .then((service: any) => {
          if (service) {
            service.GetWFHistory(this.context,this.viewparams).then((res: any) => {
              if (res && res.status === 200) {
                this.data = res.data;
                this.initUIStateData();
              }
            });
          }
        });
    }
  }

  /**
   * 初始化数据添加标记
   *
   *  @memberof AppWfStepTrace
   */
  public initUIStateData() {
    if (this.data && this.data.usertasks) {
      this.usertasksIndex = 1;
      for (let i in this.data.usertasks) {
        this.data.usertasks[i].isShow = false;
        this.data.usertasks[i].index = this.usertasksIndex;
        this.usertasksIndex++;
      }
      this.usertasksLength = this.usertasksIndex - 1;
      this.$forceUpdate();
    }
  }

  /**
   * 时间转换
   *
   *  @memberof AppWfStepTrace
   */
  public formatDate(date: string, format: string) {
    return moment(date).format(format);
  }

  /**
   * 点击事件
   *
   *  @memberof AppWfStepTrace
   */
  public changeExpand(usertask: any) {
    usertask.isShow = !usertask.isShow;
    this.$forceUpdate();
  }

  /**
   * 办理人员名称显示去重
   *
   * @param tag 需要去重的名称标识
   * @param datas 需要去重数据集
   * @memberof AppWfStepTrace
   */
  public acceptingOfficerNodup(tag: string, datas: any[]): any[] {
    let tempData: any[] = [];
    if (datas?.length > 0 && tag) {
      datas.forEach((data: any) => {
        tempData.push(data[tag]);
      });
    }
    const nodup = [...new Set(tempData)];
    return nodup;
  }
}
</script>