extend-action-timeline.vue 9.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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
<template>
    <div class="extend-action-timeline">
        <div class="extend-action-timeline-table">
            <div class="extend-action-timeline-thead"></div>
            <div class="extend-action-timeline-body" v-if="data.length > 0">
                <div class="timeline-draw extend-action-timeline-body__timeline timeline-head">
                    <div class="timeline-wrapper">
                        <div class="timeline-wrapper__timeline-index">{{ $t('components.timeline.index') }}</div>
                        <div class="timeline-wrapper__usertaskname">{{ $t('components.timeline.node') }}</div>
                        <div class="timeline-wrapper__authorname">{{ $t('components.timeline.author') }}</div>
                        <div class="timeline-wrapper__type">{{ $t('components.timeline.type') }}</div>
                        <div class="timeline-wrapper__last-time">{{ $t('components.timeline.lasttime') }}</div>
                        <div class="timeline-wrapper__fullmessage">{{ $t('components.timeline.opinion') }}</div>
                    </div>
                    <div class="timeline-arrow"></div>
                </div>
                <template v-for="(usertask, index) in data">
                    <div class="timeline-content" :key="index">
                        <div class="extend-action-timeline-body__timeline">
                            <div class="timeline-wrapper">
                                <div class="timeline-wrapper__timeline-index">
                                    <span>{{ usertask.index }}</span>
                                    <div class="icon-bottom" v-if="usertask.index != 1">
                                        <i class="el-icon-bottom"></i>
                                    </div>
                                    <div class="icon-top" v-if="usertask.index < usertasksLength"></div>
                                </div>
                                <div class="timeline-wrapper__usertaskname">{{ usertask.usertaskname }}</div>
                                <div class="timeline-wrapper__authorname">{{usertask.displayNames ? usertask.displayNames.join(' , ') : usertask.authorName}}</div>
                                <div class="timeline-wrapper__type" v-if="usertask.type">
                                    <div
                                        class="dot"
                                    ></div>
                                    <span>{{usertask.type}}</span>
                                </div>
                                <div class="timeline-wrapper__last-time" v-if="usertask.time">
                                    {{
                                        formatDate(
                                            usertask.time,
                                            'MM月DD日 HH:mm:ss',
                                        )
                                    }}
                                </div>
                                <el-popover class="timeline-wrapper__tooltip" placement="top" :width="500" trigger="hover">
                                    <div slot="reference">
                                        {{ usertask.fullMessage }}
                                    </div>
                                    <div class="fullmessage">
                                        {{ usertask.fullMessage }}
                                    </div>
                                </el-popover>
                            </div>
                            <div v-if="usertask.displayNames && usertask.displayNames.length > 1" class="timeline-arrow" @click="changeExpand(usertask)">
                                <i :class="usertask.isShow ? 'el-icon-minus' : 'el-icon-plus'" />
                            </div>
                        </div>
                        <div v-if="usertask.isShow">
                            <template v-for="(displayName, index) in usertask.displayNames">
                                <div class="timeline-draw extend-action-timeline-body__timeline" :key="index">
                                    <div class="timeline-wrapper">
                                        <div class="timeline-wrapper__timeline-index">
                                            <div v-if="usertask.index < usertasksLength" class="icon-line"></div>
                                        </div>
                                        <div class="timeline-wrapper__usertaskname"></div>
                                        <div class="timeline-wrapper__authorname">
                                            {{ displayName }}
                                        </div>
                                    </div>
                                    <div class="timeline-arrow"></div>
                                </div>
                            </template>
                        </div>
                    </div>
                </template>
            </div>
        </div>
    </div>
</template>

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

@Component({})
export default class ExtendActionTimeline extends Vue {

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

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

    /**
     *  实体名称
     *
     *  @memberof ExtendActionTimeline
     */
    @Prop() public appDeCodeName!: string;

    /**
     * 数据
     *
     *  @memberof ExtendActionTimeline
     */
    public data: any[] = [];

    /**
     *  初始化memo
     *
     *  @memberof ExtendActionTimeline
     */
    public initmemo: string = '';

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

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

    /**
     *  实体服务
     *
     *  @memberof ExtendActionTimeline
     */
    public appEntityService: any;

    /**
     * 初始化数据
     *
     *  @memberof ExtendActionTimeline
     */
    public async created() {
        this.appEntityService = await window.entityServiceRegister.getService(this.appDeCodeName.toLowerCase());
        if (this.appEntityService) {
            this.appEntityService.GetWFHistory(this.context).then((response: any) => {
                if (response && response.status === 200) {
                    this.formatData(response.data);
                    this.initUIStateData(this.data);
                } else {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response });
                }
            }).catch((error: any) => {
                const message = error.message ? error.message : '加载数据错误';
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: message });
            })
        }
    }

    /**
     * 初始化数据添加标记
     *
     *  @memberof ExtendActionTimeline
     */
    public initUIStateData(items: any) {
        if (items.length > 0) {
            this.usertasksIndex = 1;
            items.forEach((item: any) => {
                item.isShow = false;
                item.index = this.usertasksIndex;
                this.usertasksIndex++;
            })
            this.usertasksLength = this.usertasksIndex - 1;
            this.$forceUpdate();
        }
    }

    /**
     * 格式化数据
     *
     *  @memberof ExtendActionTimeline
     */
    public formatData(data: any) {
        const historyTasks = data.historytasks || [];
        const waitTasks = data.waittasks || [];
        if (historyTasks.length > 0) {
            this.data.push(...historyTasks);
        }
        if (waitTasks.length > 0) {
            const taskItems: any[] = [];
            waitTasks.forEach((task: any) => {
                const index = taskItems.findIndex((item: any) => Object.is(task.usertaskid, item.usertaskid));
                if (task.usertaskid && index == -1) {
                    task.displayNames = [task.displayname];
                    taskItems.push(task);
                }
                if (index != -1) {
                    const index = taskItems.findIndex((item: any) => Object.is(item.usertaskid, task.usertaskid));
                    taskItems[index].displayNames.push(task.displayname);
                }
            })
            this.data.push(...taskItems);
        }
    }

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

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

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

250 251
<style lang='scss'>
@import './extend-action-timeline.scss';
252
</style>