-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathPublishHistory.vue
More file actions
168 lines (154 loc) · 5.01 KB
/
PublishHistory.vue
File metadata and controls
168 lines (154 loc) · 5.01 KB
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
<template>
<div class="workflow-publish-history border-l white-bg">
<h4 class="border-b p-16-24">{{ $t('views.workflow.setting.releaseHistory') }}</h4>
<div class="list-height pt-0">
<el-scrollbar>
<div class="p-8 pt-0">
<common-list
:data="LogData"
class="mt-8"
v-loading="loading"
@click="clickListHandle"
@mouseenter="mouseenter"
@mouseleave="mouseId = ''"
>
<template #default="{ row, index }">
<div class="flex-between">
<div style="max-width: 80%">
<h5 :class="index === 0 ? 'primary' : ''" class="flex align-center">
<ReadWrite
@change="editName($event, row)"
:data="row.name || datetimeFormat(row.update_time)"
trigger="manual"
:write="row.writeStatus"
@close="closeWrite(row)"
/>
<el-tag v-if="index === 0" class="default-tag ml-4">{{
$t('views.workflow.setting.latestRelease')
}}</el-tag>
</h5>
<el-text type="info" class="color-secondary flex align-center mt-8">
<el-avatar :size="20" class="avatar-grey mr-4">
<el-icon><UserFilled /></el-icon>
</el-avatar>
{{ row.publish_user_name }}
</el-text>
</div>
<div @click.stop v-show="mouseId === row.id">
<el-dropdown trigger="click" :teleported="false">
<el-button text>
<AppIcon iconName="app-more"></AppIcon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-if="permissionPrecise.workflow_edit(id)"
@click.stop="openEditVersion(row)"
>
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
{{ $t('common.edit') }}
</el-dropdown-item>
<el-dropdown-item @click="refreshVersion(row)">
<el-icon class="color-secondary"><RefreshLeft /></el-icon>
{{ $t('views.workflow.setting.restoreCurrentVersion') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</template>
<template #empty>
<div class="text-center">
<el-text type="info"> {{ $t('chat.noHistory') }}</el-text>
</div>
</template>
</common-list>
</div>
</el-scrollbar>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { datetimeFormat } from '@/utils/time'
import { MsgSuccess, MsgError } from '@/utils/message'
import { t } from '@/locales'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import permissionMap from '@/permission'
const route = useRoute()
const {
params: { id, folderId },
} = route as any
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const permissionPrecise = computed(() => {
return permissionMap['knowledge'][apiType.value]
})
const emit = defineEmits(['click', 'refreshVersion'])
const loading = ref(false)
const LogData = ref<any[]>([])
const mouseId = ref('')
function mouseenter(row: any) {
mouseId.value = row.id
}
function clickListHandle(item: any) {
emit('click', item)
}
function refreshVersion(item: any) {
emit('refreshVersion', item)
}
function openEditVersion(item: any) {
item['writeStatus'] = true
}
function closeWrite(item: any) {
item['writeStatus'] = false
}
function editName(val: string, item: any) {
if (val) {
const obj = {
name: val,
}
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.updateKnowledgeVersion(id as string, item.id, obj, loading)
.then(() => {
MsgSuccess(t('common.modifySuccess'))
item['writeStatus'] = false
getList()
})
} else {
MsgError(t('views.workflow.tip.nameMessage'))
}
}
function getList() {
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.listKnowledgeVersion(id, loading)
.then((res: any) => {
LogData.value = res.data
})
}
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
.workflow-publish-history {
width: 320px;
position: absolute;
right: 0;
top: 57px;
height: calc(100vh - 57px);
z-index: 9;
.list-height {
height: calc(100vh - 120px);
}
}
</style>