All files / src/components/u-process-info.vue index.vue

68.42% Statements 13/19
25% Branches 2/8
33.33% Functions 1/3
72.22% Lines 13/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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      1x   1x     1x                                                                                                                                                                                                                            
<template>
    <div :class="$style.root">
        <div :class="$style.item">
            <div :class="$style.label">{{ $tt('startBy') }}:</div>
            <div :class="$style.value" v-ellipsis-title>{{ detail.procInstStartBy || '-' }}</div>
        </div>
        <div :class="$style.item">
            <div :class="$style.label">{{ $tt('processStartTime') }}:</div>
            <div :class="$style.value" v-ellipsis-title>{{ dateFormatter(detail.procInstStartTime) }}</div>
        </div>
        <div :class="$style.item">
            <div :class="$style.label">{{ $tt('finished') }}:</div>
            <div :class="$style.value" v-ellipsis-title> {{ formatStatus(detail.procInstStatus) }}</div>
        </div>
        <div :class="$style.item">
            <div :class="$style.label">{{ $tt('currentNodes') }}:</div>
            <div :class="$style.value" v-ellipsis-title> {{ formatCurrentNodes(detail.procInstCurrentTask) }}</div>
        </div>
        <div :class="$style.item">
            <div :class="$style.label">{{ $tt('currentCandidateUsers') }}:</div>
            <div :class="$style.value" v-ellipsis-title>{{ formatCurrentAssignee(detail.procInstCurrentTask) }}</div>
        </div>
    </div>
</template>
 
<script>
import i18nMixin from '../../mixins/i18n';
export default {
    name: 'u-process-info',
    mixins: [i18nMixin('u-process-info')],
    data() {
        return {
            detail: {
                startBy: '',
                createTime: '',
                finished: false,
                currentNode: '',
                currentCandidateUsers: [],
            },
            taskId: undefined,
        };
    },
    created() {
        location.search.replace('?', '').split('&').forEach((item) => {
            const [key, value] = item.split('=');
            if (key === 'taskId') {
                this.taskId = value;
            }
        });
        if (this.taskId) {
            this.getProcessInfo();
        }
    },
    methods: {
        async getProcessInfo() {
            if (this.$processV2) {
                const result = await this.$processV2.getProcInstInfo({
                    body: {
                        taskId: this.taskId,
                    },
                });
                this.detail = result.data || {};
            }
        },
        dateFormatter(value) {
            // eslint-disable-next-line new-cap
            return this.$utils ? this.$utils.FormatDateTime(value) : value;
        },
        formatStatus(value) {
            if (value === null || value === undefined) {
                return '-';
            }
            if (value === 'APPROVED') {
                return '已结束';
            } else if (value === 'PENDING') {
                return '进行中';
            } else {
                return value;
            }
        },
        formatCurrentNodes(item) {
            const procInstCurrentTask = item.procInstCurrentTask || [];
            const set = new Set(procInstCurrentTask.map((task) => task.currentTaskTitle));
            return Array.from(set).join(',');
        },
        formatCurrentAssignee(item) {
            const procInstCurrentTask = item.procInstCurrentTask || [];
            const set = new Set(procInstCurrentTask.map((task) => task.currentTaskAssignees));
            return Array.from(set).join(',');
        },
    },
};
</script>
 
<style module>
.root {
 
}
 
.item {
    width: 20%;
    display: inline-flex;
}
 
.item + .item {
    padding-left: 10px;
}
.label {
    color: var(--process-info-label-color);
}
 
.value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
</style>