|
@@ -2,61 +2,49 @@
|
2
|
2
|
* @Author: ysh
|
3
|
3
|
* @Date: 2025-03-12 10:06:03
|
4
|
4
|
* @LastEditors: Please set LastEditors
|
5
|
|
- * @LastEditTime: 2025-03-13 16:20:48
|
|
5
|
+ * @LastEditTime: 2025-03-14 15:36:05
|
6
|
6
|
-->
|
7
|
7
|
<template>
|
8
|
8
|
<div class="app-container">
|
9
|
|
- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
10
|
|
- <el-form-item label="资料名称" prop="title">
|
11
|
|
- <el-input v-model="queryParams.title" placeholder="请输入资料名称" clearable @keyup.enter.native="handleQuery" />
|
12
|
|
- </el-form-item>
|
13
|
|
- <el-form-item label="类型" prop="title">
|
14
|
|
- <el-select v-model="queryParams.type" @change="handleQuery" clearable>
|
15
|
|
- <el-option label="视频" value="视频"></el-option>
|
16
|
|
- <el-option label="文档" value="文档"></el-option>
|
17
|
|
- </el-select>
|
18
|
|
- </el-form-item>
|
19
|
|
- <el-form-item label="姓名" prop="userId">
|
20
|
|
- <el-select v-model="queryParams.userId" clearable filterable placeholder="请输入姓名" style="width: 160px"
|
21
|
|
- @change="handleQuery">
|
22
|
|
- <el-option v-for="item in $store.state.user.userList" :key="item.userId" :label="item.nickName"
|
23
|
|
- :value="item.userId">
|
24
|
|
- </el-option>
|
25
|
|
- </el-select>
|
26
|
|
- </el-form-item>
|
27
|
|
- <el-form-item label="学习年份" prop="lastTime" label-width="100px">
|
28
|
|
- <el-date-picker clearable v-model="queryParams.lastTime" type="year" value-format="yyyy-MM-dd"
|
29
|
|
- placeholder="请选择学习年份" @change="handleQuery">
|
30
|
|
- </el-date-picker>
|
31
|
|
- </el-form-item>
|
32
|
|
- <el-form-item>
|
33
|
|
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
34
|
|
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
35
|
|
- </el-form-item>
|
36
|
|
- </el-form>
|
37
|
|
-
|
38
|
|
- <el-row :gutter="10" class="mb8">
|
39
|
|
- <!-- <el-col :span="1.5">
|
40
|
|
- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
41
|
|
- v-hasPermi="['oa:study:add']">新增</el-button>
|
42
|
|
- </el-col>
|
43
|
|
- <el-col :span="1.5">
|
44
|
|
- <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
45
|
|
- v-hasPermi="['oa:study:edit']">修改</el-button>
|
46
|
|
- </el-col>
|
47
|
|
- <el-col :span="1.5">
|
48
|
|
- <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
49
|
|
- v-hasPermi="['oa:study:remove']">删除</el-button>
|
50
|
|
- </el-col> -->
|
51
|
|
- <el-col :span="1.5">
|
52
|
|
- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
53
|
|
- v-hasPermi="['oa:study:export']">导出</el-button>
|
54
|
|
- </el-col>
|
55
|
|
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
56
|
|
- </el-row>
|
57
|
9
|
<el-row>
|
58
|
|
- <el-col :span="14" class="left">
|
59
|
|
- <el-table v-loading="loading" :data="studyList" @selection-change="handleSelectionChange">
|
|
10
|
+ <el-col :span="12">
|
|
11
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
|
|
12
|
+ label-width="68px">
|
|
13
|
+ <el-form-item label="资料名称" prop="title">
|
|
14
|
+ <el-input v-model="queryParams.title" placeholder="请输入资料名称" clearable @keyup.enter.native="handleQuery" />
|
|
15
|
+ </el-form-item>
|
|
16
|
+ <el-form-item label="类型" prop="title">
|
|
17
|
+ <el-select v-model="queryParams.type" @change="handleQuery" clearable>
|
|
18
|
+ <el-option label="视频" value="视频"></el-option>
|
|
19
|
+ <el-option label="文档" value="文档"></el-option>
|
|
20
|
+ </el-select>
|
|
21
|
+ </el-form-item>
|
|
22
|
+ <el-form-item label="姓名" prop="userId">
|
|
23
|
+ <el-select v-model="queryParams.userId" clearable filterable placeholder="请输入姓名" style="width: 160px"
|
|
24
|
+ @change="handleQuery">
|
|
25
|
+ <el-option v-for="item in $store.state.user.userList" :key="item.userId" :label="item.nickName"
|
|
26
|
+ :value="item.userId">
|
|
27
|
+ </el-option>
|
|
28
|
+ </el-select>
|
|
29
|
+ </el-form-item>
|
|
30
|
+ <el-form-item label="学习年份" prop="lastTime">
|
|
31
|
+ <el-date-picker clearable v-model="queryParams.lastTime" type="year" value-format="yyyy-MM-dd"
|
|
32
|
+ placeholder="请选择学习年份" @change="handleQuery">
|
|
33
|
+ </el-date-picker>
|
|
34
|
+ </el-form-item>
|
|
35
|
+ <el-form-item>
|
|
36
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
37
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
38
|
+ </el-form-item>
|
|
39
|
+ </el-form>
|
|
40
|
+ <el-row :gutter="10" class="mb8">
|
|
41
|
+ <el-col :span="1.5">
|
|
42
|
+ <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
|
43
|
+ v-hasPermi="['oa:study:export']">导出</el-button>
|
|
44
|
+ </el-col>
|
|
45
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
46
|
+ </el-row>
|
|
47
|
+ <el-table v-loading="loading" :data="studyList">
|
60
|
48
|
<el-table-column type="selection" width="55" align="center" />
|
61
|
49
|
<el-table-column type="index" label="序号" width="55" align="center" />
|
62
|
50
|
<!-- <el-table-column label="学习id" align="center" prop="studyId" /> -->
|
|
@@ -75,56 +63,60 @@
|
75
|
63
|
</template>
|
76
|
64
|
</el-table-column>
|
77
|
65
|
<el-table-column label="已获学时" align="center" prop="getHours" />
|
78
|
|
- <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
79
|
|
- <template slot-scope="scope">
|
80
|
|
- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
81
|
|
- v-hasPermi="['oa:study:edit']">修改</el-button>
|
82
|
|
- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
83
|
|
- v-hasPermi="['oa:study:remove']">删除</el-button>
|
84
|
|
- </template>
|
85
|
|
- </el-table-column> -->
|
86
|
66
|
</el-table>
|
87
|
67
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
|
88
|
68
|
:limit.sync="queryParams.pageSize" @pagination="getList" />
|
89
|
69
|
</el-col>
|
90
|
|
- <el-col :span="10">
|
91
|
|
-
|
|
70
|
+ <el-col :span="12">
|
|
71
|
+ <div>
|
|
72
|
+ <el-row>
|
|
73
|
+ <el-col :span="12" class=" left">
|
|
74
|
+ <h2 class="text-center">部门学习情况</h2>
|
|
75
|
+ <el-tree :data="deptTree" :props="treeProps" node-key="$treeNodeId" :expand-on-click-node="false">
|
|
76
|
+ <div slot-scope="{ node, data }" class="custom-tree-node">
|
|
77
|
+ <!-- 部门节点 -->
|
|
78
|
+ <span v-if="data.type === 'department'">
|
|
79
|
+ <!-- <i class="el-icon-office-building"></i> -->
|
|
80
|
+ {{ data.deptName }}
|
|
81
|
+ <span class="total-hours">(总学时:{{ data.totalHours }}h)</span>
|
|
82
|
+ </span>
|
|
83
|
+ <!-- 人员节点 -->
|
|
84
|
+ <span v-else class="user-node">
|
|
85
|
+ <i class="el-icon-user"></i>
|
|
86
|
+ {{ `${data.user.nickName} (学时:${data.getHours}h)` }}
|
|
87
|
+ </span>
|
|
88
|
+ </div>
|
|
89
|
+ </el-tree>
|
|
90
|
+ </el-col>
|
|
91
|
+ <el-col :span="12" class="left">
|
|
92
|
+ <div class="text-right">
|
|
93
|
+ <el-date-picker clearable v-model="rankParams.lastTime" type="year" value-format="yyyy-MM-dd"
|
|
94
|
+ placeholder="请选择学习年份" @change="getListByYear()">
|
|
95
|
+ </el-date-picker>
|
|
96
|
+ </div>
|
|
97
|
+ <h2 class="text-center">学习排名</h2>
|
|
98
|
+ <el-table v-loading="rankLoading" :data="rankList">
|
|
99
|
+ <el-table-column prop="rankIndex" label="排名" />
|
|
100
|
+ <el-table-column prop="user.nickName" label="姓名" />
|
|
101
|
+ <el-table-column prop="getHours" label="总学时" />
|
|
102
|
+ </el-table>
|
|
103
|
+ <div class="mt20 text-right">
|
|
104
|
+ <el-pagination layout="prev, pager, next" :total="rankTotal" :current-page.sync="rankParams.pageNum"
|
|
105
|
+ @current-change="getRankList">
|
|
106
|
+ </el-pagination>
|
|
107
|
+ </div>
|
|
108
|
+
|
|
109
|
+ </el-col>
|
|
110
|
+ </el-row>
|
|
111
|
+ </div>
|
92
|
112
|
</el-col>
|
93
|
113
|
</el-row>
|
94
|
|
-
|
95
|
|
-
|
96
|
|
-
|
97
|
|
-
|
98
|
|
- <!-- 添加或修改cmc学习记录对话框 -->
|
99
|
|
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
100
|
|
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
101
|
|
- <el-form-item label="学习资料id" prop="resourceId">
|
102
|
|
- <el-input v-model="form.resourceId" placeholder="请输入学习资料id" />
|
103
|
|
- </el-form-item>
|
104
|
|
- <el-form-item label="用户id" prop="userId">
|
105
|
|
- <el-input v-model="form.userId" placeholder="请输入用户id" />
|
106
|
|
- </el-form-item>
|
107
|
|
- <el-form-item label="上次位置" prop="lastPoint">
|
108
|
|
- <el-input v-model="form.lastPoint" placeholder="请输入上次位置" />
|
109
|
|
- </el-form-item>
|
110
|
|
- <el-form-item label="上次时间" prop="lastTime">
|
111
|
|
- <el-date-picker clearable v-model="form.lastTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择上次时间">
|
112
|
|
- </el-date-picker>
|
113
|
|
- </el-form-item>
|
114
|
|
- <el-form-item label="可获学时" prop="getHours">
|
115
|
|
- <el-input v-model="form.getHours" placeholder="请输入可获学时" />
|
116
|
|
- </el-form-item>
|
117
|
|
- </el-form>
|
118
|
|
- <div slot="footer" class="dialog-footer">
|
119
|
|
- <el-button type="primary" @click="submitForm">确 定</el-button>
|
120
|
|
- <el-button @click="cancel">取 消</el-button>
|
121
|
|
- </div>
|
122
|
|
- </el-dialog>
|
123
|
114
|
</div>
|
124
|
115
|
</template>
|
125
|
116
|
|
126
|
117
|
<script>
|
127
|
|
-import { listStudy, getStudy, delStudy, addStudy, updateStudy } from "@/api/oa/study/myStudy";
|
|
118
|
+import { listStudy, getStudy, delStudy, addStudy, updateStudy, getStudyStatistic } from "@/api/oa/study/myStudy";
|
|
119
|
+import { listDept } from '@/api/system/dept'
|
128
|
120
|
|
129
|
121
|
export default {
|
130
|
122
|
name: "Study",
|
|
@@ -132,22 +124,12 @@ export default {
|
132
|
124
|
return {
|
133
|
125
|
// 遮罩层
|
134
|
126
|
loading: true,
|
135
|
|
- // 选中数组
|
136
|
|
- ids: [],
|
137
|
|
- // 非单个禁用
|
138
|
|
- single: true,
|
139
|
|
- // 非多个禁用
|
140
|
|
- multiple: true,
|
141
|
127
|
// 显示搜索条件
|
142
|
128
|
showSearch: true,
|
143
|
129
|
// 总条数
|
144
|
130
|
total: 0,
|
145
|
131
|
// cmc学习记录表格数据
|
146
|
132
|
studyList: [],
|
147
|
|
- // 弹出层标题
|
148
|
|
- title: "",
|
149
|
|
- // 是否显示弹出层
|
150
|
|
- open: false,
|
151
|
133
|
// 查询参数
|
152
|
134
|
queryParams: {
|
153
|
135
|
pageNum: 1,
|
|
@@ -162,11 +144,32 @@ export default {
|
162
|
144
|
form: {},
|
163
|
145
|
// 表单校验
|
164
|
146
|
rules: {
|
165
|
|
- }
|
|
147
|
+ },
|
|
148
|
+ rankList: [], //排行列表
|
|
149
|
+ rankLoading: true,
|
|
150
|
+ rankTotal: 0,
|
|
151
|
+ rankParams: {
|
|
152
|
+ pageNum: 1,
|
|
153
|
+ pageSize: 10,
|
|
154
|
+ },
|
|
155
|
+ deptRankList: [], //部门排行列表
|
|
156
|
+ deptRankLoading: true,
|
|
157
|
+ deptRankTotal: 0,
|
|
158
|
+ deptRankParams: {
|
|
159
|
+ pageNum: 1,
|
|
160
|
+ pageSize: 10,
|
|
161
|
+ },
|
|
162
|
+ deptTree: [],
|
|
163
|
+ treeProps: {
|
|
164
|
+ children: 'children',
|
|
165
|
+ label: 'deptName' // 默认label字段,实际使用插槽自定义
|
|
166
|
+ },
|
166
|
167
|
};
|
167
|
168
|
},
|
168
|
169
|
created() {
|
169
|
170
|
this.getList();
|
|
171
|
+ this.getRankList();
|
|
172
|
+ this.getDeptRankList();
|
170
|
173
|
},
|
171
|
174
|
methods: {
|
172
|
175
|
/** 查询cmc学习记录列表 */
|
|
@@ -178,10 +181,35 @@ export default {
|
178
|
181
|
this.loading = false;
|
179
|
182
|
});
|
180
|
183
|
},
|
181
|
|
- // 取消按钮
|
182
|
|
- cancel() {
|
183
|
|
- this.open = false;
|
184
|
|
- this.reset();
|
|
184
|
+ getRankList() {
|
|
185
|
+ this.rankLoading = true;
|
|
186
|
+ getStudyStatistic(this.rankParams).then(res => {
|
|
187
|
+ this.rankList = res.rows.map((item, index) => ({
|
|
188
|
+ ...item,
|
|
189
|
+ getHours: item.getHours ? item.getHours : 0,
|
|
190
|
+ rankIndex: (this.rankParams.pageNum - 1) * this.rankParams.pageSize + index + 1
|
|
191
|
+ }));
|
|
192
|
+ this.rankTotal = res.total;
|
|
193
|
+ this.rankLoading = false;
|
|
194
|
+ })
|
|
195
|
+ },
|
|
196
|
+ async getDeptRankList() {
|
|
197
|
+ this.deptRankParams.pageSize = 300
|
|
198
|
+ this.deptRankParams.lastTime = this.rankParams.lastTime
|
|
199
|
+ let res = await getStudyStatistic(this.deptRankParams)
|
|
200
|
+ let userList = res.rows.map((item, index) => ({
|
|
201
|
+ ...item,
|
|
202
|
+ getHours: item.getHours ? item.getHours : 0,
|
|
203
|
+ rankIndex: index + 1
|
|
204
|
+ }));
|
|
205
|
+ let deptRes = await listDept();
|
|
206
|
+ let deptList = deptRes.data.filter(dept => dept.deptId != 100);
|
|
207
|
+ this.deptTree = this.buildDeptTree(deptList, userList);
|
|
208
|
+ console.log(this.deptTree);
|
|
209
|
+ },
|
|
210
|
+ getListByYear() {
|
|
211
|
+ this.getRankList();
|
|
212
|
+ this.getDeptRankList();
|
185
|
213
|
},
|
186
|
214
|
// 表单重置
|
187
|
215
|
reset() {
|
|
@@ -205,65 +233,12 @@ export default {
|
205
|
233
|
this.resetForm("queryForm");
|
206
|
234
|
this.handleQuery();
|
207
|
235
|
},
|
208
|
|
- // 多选框选中数据
|
209
|
|
- handleSelectionChange(selection) {
|
210
|
|
- this.ids = selection.map(item => item.studyId)
|
211
|
|
- this.single = selection.length !== 1
|
212
|
|
- this.multiple = !selection.length
|
213
|
|
- },
|
214
|
|
- /** 新增按钮操作 */
|
215
|
|
- handleAdd() {
|
216
|
|
- this.reset();
|
217
|
|
- this.open = true;
|
218
|
|
- this.title = "添加cmc学习记录";
|
219
|
|
- },
|
220
|
|
- /** 修改按钮操作 */
|
221
|
|
- handleUpdate(row) {
|
222
|
|
- this.reset();
|
223
|
|
- const studyId = row.studyId || this.ids
|
224
|
|
- getStudy(studyId).then(response => {
|
225
|
|
- this.form = response.data;
|
226
|
|
- this.open = true;
|
227
|
|
- this.title = "修改cmc学习记录";
|
228
|
|
- });
|
229
|
|
- },
|
230
|
|
- /** 提交按钮 */
|
231
|
|
- submitForm() {
|
232
|
|
- this.$refs["form"].validate(valid => {
|
233
|
|
- if (valid) {
|
234
|
|
- if (this.form.studyId != null) {
|
235
|
|
- updateStudy(this.form).then(response => {
|
236
|
|
- this.$modal.msgSuccess("修改成功");
|
237
|
|
- this.open = false;
|
238
|
|
- this.getList();
|
239
|
|
- });
|
240
|
|
- } else {
|
241
|
|
- addStudy(this.form).then(response => {
|
242
|
|
- this.$modal.msgSuccess("新增成功");
|
243
|
|
- this.open = false;
|
244
|
|
- this.getList();
|
245
|
|
- });
|
246
|
|
- }
|
247
|
|
- }
|
248
|
|
- });
|
249
|
|
- },
|
250
|
|
- /** 删除按钮操作 */
|
251
|
|
- handleDelete(row) {
|
252
|
|
- const studyIds = row.studyId || this.ids;
|
253
|
|
- this.$modal.confirm('是否确认删除cmc学习记录编号为"' + studyIds + '"的数据项?').then(function () {
|
254
|
|
- return delStudy(studyIds);
|
255
|
|
- }).then(() => {
|
256
|
|
- this.getList();
|
257
|
|
- this.$modal.msgSuccess("删除成功");
|
258
|
|
- }).catch(() => { });
|
259
|
|
- },
|
260
|
236
|
/** 导出按钮操作 */
|
261
|
237
|
handleExport() {
|
262
|
238
|
this.download('oa/study/export', {
|
263
|
239
|
...this.queryParams
|
264
|
240
|
}, `study_${new Date().getTime()}.xlsx`)
|
265
|
241
|
},
|
266
|
|
-
|
267
|
242
|
formatStatus(row) {
|
268
|
243
|
if (!row) {
|
269
|
244
|
row = 0
|
|
@@ -279,6 +254,36 @@ export default {
|
279
|
254
|
return 'success'
|
280
|
255
|
}
|
281
|
256
|
},
|
|
257
|
+ buildDeptTree(deptObjList, recordList) {
|
|
258
|
+ // 1. 创建部门映射表(使用Map提高查询效率)
|
|
259
|
+ const deptMap = new Map();
|
|
260
|
+ // 初始化部门节点并存入Map
|
|
261
|
+ deptObjList.forEach(dept => {
|
|
262
|
+ deptMap.set(dept.deptId, {
|
|
263
|
+ ...dept, // 展开原有属性
|
|
264
|
+ children: [], // 存放子节点(人员)
|
|
265
|
+ totalHours: 0, // 学习时长合计
|
|
266
|
+ type: 'department' // 添加类型标识(可选)
|
|
267
|
+ });
|
|
268
|
+ });
|
|
269
|
+ // 2. 处理学习记录
|
|
270
|
+ recordList.forEach(record => {
|
|
271
|
+ const dept = deptMap.get(record.deptId);
|
|
272
|
+ if (dept) {
|
|
273
|
+ // 构造人员节点
|
|
274
|
+ const userNode = {
|
|
275
|
+ ...record, // 展开记录属性
|
|
276
|
+ type: 'user' // 添加类型标识(可选)
|
|
277
|
+ };
|
|
278
|
+ // 添加人员到部门子节点
|
|
279
|
+ dept.children.push(userNode);
|
|
280
|
+ // 累加学习时长
|
|
281
|
+ dept.totalHours += record.getHours || 0;
|
|
282
|
+ }
|
|
283
|
+ });
|
|
284
|
+ // 3. 将Map转换为数组
|
|
285
|
+ return Array.from(deptMap.values());
|
|
286
|
+ }
|
282
|
287
|
}
|
283
|
288
|
};
|
284
|
289
|
</script>
|
|
@@ -287,4 +292,42 @@ export default {
|
287
|
292
|
padding: 10px;
|
288
|
293
|
border-right: 1px solid #ececec;
|
289
|
294
|
}
|
|
295
|
+
|
|
296
|
+.dept-tree-container {
|
|
297
|
+ padding: 10px;
|
|
298
|
+}
|
|
299
|
+
|
|
300
|
+.custom-tree-node {
|
|
301
|
+ flex: 1;
|
|
302
|
+ display: flex;
|
|
303
|
+ align-items: center;
|
|
304
|
+ font-size: 14px;
|
|
305
|
+ padding: 2px 0;
|
|
306
|
+
|
|
307
|
+ .el-icon-office-building {
|
|
308
|
+ color: #409EFF;
|
|
309
|
+ margin-right: 5px;
|
|
310
|
+ }
|
|
311
|
+
|
|
312
|
+ .el-icon-user {
|
|
313
|
+ color: #67C23A;
|
|
314
|
+ margin-right: 5px;
|
|
315
|
+ }
|
|
316
|
+
|
|
317
|
+ .total-hours {
|
|
318
|
+ color: #909399;
|
|
319
|
+ font-size: 12px;
|
|
320
|
+ margin-left: 10px;
|
|
321
|
+ }
|
|
322
|
+
|
|
323
|
+ .user-node {
|
|
324
|
+ color: #606266;
|
|
325
|
+ }
|
|
326
|
+}
|
|
327
|
+
|
|
328
|
+/* 调整树节点缩进 */
|
|
329
|
+::v-deep .el-tree-node__content {
|
|
330
|
+ height: auto;
|
|
331
|
+ padding: 2px 0;
|
|
332
|
+}
|
290
|
333
|
</style>
|