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

38.23% Statements 13/34
12.5% Branches 2/16
5.55% Functions 1/18
39.39% Lines 13/33

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 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      1x   1x     1x                                                                                                                                                                                                                                                                                                                                                                    
<template>
    <div>
        <u-tabs appear="line" v-model="tabValue" @select="onSelectTab">
            <u-tab :title="$tt('pendingTasks')" value="pendingTasks"></u-tab>
            <u-tab :title="$tt('processedTasks')" value="processedTasks"></u-tab>
            <u-tab :title="$tt('intiationProcess')" value="intiationProcess"></u-tab>
        </u-tabs>
        <u-linear-layout direction="vertical">
            <u-linear-layout mode="flex" justify="space-between">
                <u-linear-layout :class="$style.left">
                    <u-form layout="inline">
                        <u-form-item :label="$tt('process')">
                            <u-select
                                filterable
                                clearable
                                text-field="procDefTitle"
                                value-field="procDefKey"
                                :data-source="getAllProcessDefList"
                                :value.sync="filter.procDefKey"
                                :initial-load="true">
                            </u-select>
                        </u-form-item>
                        <u-form-item :label="$tt('createTime')">
                            <u-date-picker
                                range
                                picker="date"
                                clearable
                                :placeholder="$tt('createTimeAfter')"
                                :placeholder-right="$tt('createTimeBefore')"
                                converter="json"
                                :start-date.sync="filter.createTimeAfter"
                                :end-date.sync="filter.createTimeBefore">
                            </u-date-picker>
                        </u-form-item>
                        <u-form-item :label="$tt('startBy')" v-if="tabValue !== 'intiationProcess'">
                            <u-select
                                filterable
                                clearable
                                text-field="procInstStartBy"
                                value-field="procInstStartBy"
                                :data-source="getProcessStartByList"
                                :value.sync="filter.procInstStartBy"
                                :initial-load="true">
                            </u-select>
                        </u-form-item>
                    </u-form>
                </u-linear-layout>
                <u-linear-layout>
                    <u-button color="primary" @click="onSearch">{{ $tt('search') }}</u-button>
                </u-linear-layout>
            </u-linear-layout>
            <u-table-view :data-source="load" ref="tableview" :page-size="20" :page-number="1" pagination :initial-load="initialLoad">
                <u-table-view-column :title="$tt('processTitle')">
                    <template #cell="current"> {{ current.item.procInstTitle || '-' }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('processType')">
                    <template #cell="current"> {{ current.item.procDefTitle || '-' }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('currentNodes')">
                    <template #cell="current"> {{ formatCurrentNodes(current.item) }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('currentAssignee')">
                    <template #cell="current"> {{ formatCurrentAssignee(current.item) }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('startBy')">
                    <template #cell="current"> {{ current.item.procInstStartBy || '-' }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('createTime')">
                    <template #cell="current"> {{ dateFormatter(current.item.procInstStartTime) }}</template>
                </u-table-view-column>
                <u-table-view-column :title="$tt('operator')">
                    <template #cell="current">
                        <u-link @click="goToDetail(current.item)">{{ tabValue === 'pendingTasks'? $tt('approval') : $tt('check') }}</u-link>
                    </template>
                </u-table-view-column>
            </u-table-view>
        </u-linear-layout>
    </div>
</template>
 
<script>
import i18nMixin from '../../mixins/i18n';
export default {
    name: 'u-process-myprocess',
    mixins: [i18nMixin('u-process-myprocess')],
    props: {
        taskId: [String, Number],
        initialLoad: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {
            list: [],
            tabValue: 'pendingTasks',
            filter: {
                procDefKey: '',
                createTimeAfter: '',
                createTimeBefore: '',
                procInstStartBy: '',
            },
        };
    },
    methods: {
        async load(params) {
            const typeMap = {
                pendingTasks: 'getMyPendingTaskList',
                processedTasks: 'getMyCompletedTaskList',
                intiationProcess: 'getMyInitiateTaskList',
            };
            if (this.$processV2) {
                const body = {
                    taskId: this.taskId,
                    page: params.page,
                    size: params.size,
                };
                Object.keys(this.filter).forEach((key) => {
                    if (this.filter[key]) {
                        body[key] = this.filter[key];
                    }
                });
                const result = await this.$processV2.getMyTaskList({
                    path: {
                        taskType: typeMap[this.tabValue],
                    },
                    body,
                });
                return result.data;
            }
        },
        onSelectTab() {
            Object.keys(this.filter).forEach((key) => {
                this.filter[key] = '';
            });
            this.$refs.tableview.reload();
        },
        async getAllProcessDefList() {
            if (this.$processV2) {
                const result = await this.$processV2.getProcDefList();
                return result.data;
            }
        },
        async getProcessStartByList() {
            if (this.$processV2) {
                const result = await this.$processV2.getProcInstStartByList();
                return result.data;
            }
        },
        async goToDetail(item) {
            if (this.$processV2) {
                const result = await this.$processV2.getTaskDestinationUrl({
                    body: {
                        taskId: item.taskId,
                    },
                });
                const toUrl = window.location.origin + result.data;
                window.location.href = toUrl;
            }
        },
        onSearch() {
            this.$refs.tableview.reload();
        },
        dateFormatter(value) {
            // eslint-disable-next-line new-cap
            return this.$utils ? this.$utils.FormatDateTime(value) : 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>
.left {
    flex: 1;
}
</style>