Files
geg-gas-web/src/components/SecondDev/FlowHistory.vue

158 lines
4.0 KiB
Vue
Raw Normal View History

2024-03-04 14:21:38 +08:00
<template>
<div class="geg-flow-history">
<div v-for="(item, index) in comments" :class="{ sep: index !== 0 }" class="item">
<template v-if="mode === 'simple'">
<div class="row">
<div class="col-node">{{ item.taskName }}</div>
2024-08-15 11:36:08 +08:00
<div class="col-1" style="display: flex;">
{{ item.approveUserName }}
<a-image v-if="item.approveStampUrl" class="signature" :src="item.approveStampUrl"></a-image>
</div>
<div class="col-2">{{ parseTime(item.approveTime) }}</div>
2024-08-15 11:36:08 +08:00
<div class="col-3">
<span :class="getTagCls(item)">
[{{ item.approveResult }}]
<template v-if="item.approveComment != '' && item.approveComment != null">
[补充意见]
</template>
</span>
{{ item.approveComment }}
</div>
</div>
</template>
2024-03-04 14:21:38 +08:00
<template v-if="mode === 'complex'">
<div class="row">
<div class="col-1">{{ item.approveUserName }}</div>
2024-03-04 14:21:38 +08:00
<div class="col-2">用时1小时10分</div>
<div class="col-3 agree">{{ item.taskName }}</div>
2024-03-04 14:21:38 +08:00
</div>
<div class="row">
<div class="col-1 position"></div>
<div class="col-2">{{ parseTime(item.approveTime) }}</div>
<div class="col-3">{{ item.approveComment }}</div>
2024-03-04 14:21:38 +08:00
</div>
</template>
</div>
</div>
</template>
<style lang="less">
.geg-flow-history {
2024-08-15 11:36:08 +08:00
.signature {
height: 20px;
width: 50px;
}
2024-03-04 14:21:38 +08:00
.row {
display: flex;
flex-direction: row;
margin: 6px 0;
line-height: 20px;
font-size: 14px;
}
.col-1 {
2024-08-15 11:36:08 +08:00
width: 160px;
2024-03-04 14:21:38 +08:00
}
.col-2 {
width: 130px;
2024-03-04 14:21:38 +08:00
color: #5a6875;
}
.col-3 {
flex: 1;
&.agree {
color: #52c41a;
}
}
.tag {
padding-right: 4px;
&.agree {
color: #52c41a;
}
&.reject {
color: #eaa63c;
}
}
.col-node {
width: 120px;
}
.position {
2024-03-04 14:21:38 +08:00
color: #90a0af;
}
.item {
padding: 8px 0;
&.sep {
border-top: 1px solid #e9e9e9;
}
}
}
</style>
<script setup>
import { defineProps, onMounted, ref, watch } from 'vue';
import dayjs from 'dayjs';
2024-03-04 14:21:38 +08:00
const props = defineProps({
mode: {
type: String,
default: 'simple'
2024-03-04 14:21:38 +08:00
},
items: Array,
autoHide: {
type: Boolean,
default: true
},
sort: {
type: String,
default: 'desc'
}
});
const comments = ref([]);
function parseTime(t) {
return dayjs(t).format('YYYY-MM-DD HH:mm');
}
onMounted(() => {
if (props.items?.length) {
sortList();
}
});
watch(
() => props.items,
() => {
sortList();
}
);
function sortList() {
const newList = props.items.map((item) => {
item.ts = dayjs(item.approveTime).valueOf();
return item;
});
newList.sort((item1, item2) => {
return props.sort === 'desc' ? item2.ts - item1.ts : item1.ts - item2.ts;
});
comments.value = newList;
}
function getTagCls(item) {
return {
agree: item.approveType === 0,
reject: item.approveType === 2,
tag: true
};
}
2024-03-04 14:21:38 +08:00
</script>