f075068f
“wangming”
对考勤这块功能进行开发
|
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
|
<template>
<el-dialog
title="配置历史记录"
:visible.sync="visible"
width="1080px"
append-to-body
:close-on-click-modal="false"
@close="handleClose"
>
<div class="history-head">
<div class="history-head__title">{{ historyTitle || '未命名配置' }}</div>
<div class="history-head__desc">保留每次新增、编辑、删除时的快照,可用于追溯考勤规则变更。</div>
</div>
<div class="history-layout">
<div class="history-layout__table">
<NCC-table
v-loading="listLoading"
:data="tableData"
border
size="mini"
height="420"
highlight-current-row
@current-change="handleCurrentChange"
>
<el-table-column prop="versionNo" label="版本" width="80" align="left" />
<el-table-column prop="operateTypeText" label="操作" width="90" align="left" />
<el-table-column prop="title" label="标题" min-width="170" align="left" show-overflow-tooltip />
<el-table-column prop="operateUserName" label="操作人" width="110" align="left">
<template slot-scope="scope">
<span>{{ scope.row.operateUserName || '系统' }}</span>
</template>
</el-table-column>
<el-table-column prop="operateTime" label="操作时间" width="160" align="left" />
<el-table-column prop="changeReason" label="变更原因" min-width="180" align="left" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.changeReason || '无' }}</span>
</template>
</el-table-column>
</NCC-table>
<div v-if="!listLoading && !tableData.length" class="history-empty">
<el-empty :image-size="56" description="暂无历史记录" />
</div>
<pagination
:hidden="!total"
:total="total"
:page.sync="query.currentPage"
:limit.sync="query.pageSize"
@pagination="loadData"
/>
</div>
<div class="history-layout__preview">
<div class="preview-card">
<div class="preview-card__title">快照预览</div>
<div class="preview-card__meta">
<span>当前版本:{{ currentRow ? `V${currentRow.versionNo}` : '无' }}</span>
<span v-if="currentRow">{{ currentRow.operateTypeText }}</span>
</div>
<el-scrollbar class="preview-card__scroll">
<pre class="preview-card__code">{{ previewText }}</pre>
</el-scrollbar>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
import { getAttendanceConfigHistory } from '@/api/extend/attendanceSetting'
export default {
name: 'AttendanceConfigHistoryDialog',
data() {
return {
visible: false,
moduleType: '',
bizId: '',
historyTitle: '',
listLoading: false,
tableData: [],
total: 0,
currentRow: null,
query: {
currentPage: 1,
pageSize: 10
}
}
},
computed: {
previewText() {
if (!this.currentRow || !this.currentRow.snapshotJson) {
return '暂无快照数据'
}
try {
return JSON.stringify(JSON.parse(this.currentRow.snapshotJson), null, 2)
} catch (error) {
return this.currentRow.snapshotJson
}
}
},
methods: {
open({ moduleType, bizId, title }) {
this.visible = true
this.moduleType = moduleType
this.bizId = bizId
this.historyTitle = title || ''
this.query.currentPage = 1
this.query.pageSize = 10
this.currentRow = null
this.tableData = []
this.total = 0
this.loadData()
},
async loadData() {
if (!this.moduleType || !this.bizId) return
this.listLoading = true
try {
const res = await getAttendanceConfigHistory({
moduleType: this.moduleType,
bizId: this.bizId,
currentPage: this.query.currentPage,
pageSize: this.query.pageSize
})
const data = res.data || {}
this.tableData = data.list || []
this.total = data.pagination ? data.pagination.total : 0
this.currentRow = this.tableData[0] || null
} finally {
this.listLoading = false
}
},
handleCurrentChange(row) {
this.currentRow = row || null
},
handleClose() {
this.visible = false
this.moduleType = ''
this.bizId = ''
this.historyTitle = ''
this.tableData = []
this.total = 0
this.currentRow = null
}
}
}
</script>
<style lang="scss" scoped>
.history-head {
margin-bottom: 12px;
}
.history-head__title {
color: #303133;
font-size: 16px;
font-weight: 600;
}
.history-head__desc {
margin-top: 4px;
color: #909399;
font-size: 12px;
}
.history-layout {
display: grid;
grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
gap: 14px;
min-height: 480px;
}
.history-layout__table,
.history-layout__preview {
min-width: 0;
}
.history-empty {
padding-top: 12px;
}
.preview-card {
display: flex;
flex-direction: column;
height: 100%;
padding: 14px;
border: 1px solid #ebeef5;
border-radius: 12px;
background: #fafbfd;
}
.preview-card__title {
color: #303133;
font-size: 14px;
font-weight: 600;
}
.preview-card__meta {
display: flex;
justify-content: space-between;
margin-top: 6px;
color: #909399;
font-size: 12px;
}
.preview-card__scroll {
flex: 1;
margin-top: 10px;
}
.preview-card__code {
margin: 0;
min-height: 100%;
padding: 12px;
border-radius: 10px;
background: #1f2937;
color: #f8fafc;
font-size: 12px;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
</style>
|