index.vue
19.5 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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<template>
<div class="app-container Document-container nohead">
<el-tabs tab-position="left" style="height:100%" v-model="activeTab">
<el-tab-pane name="allPanel">
<span slot="label"><i class="icon-ym icon-ym-extend-folder-open"></i>全部文档</span>
<div class="main NCC-flex-main">
<div class="NCC-common-head">
<el-breadcrumb>
<el-breadcrumb-item v-if="levelList.length>1">
<a @click="jump(levelList[levelList.length-2],levelList.length-2)">返回上一级</a>
</el-breadcrumb-item>
<el-breadcrumb-item v-for="(item,i) in levelList" :key="i">
<span v-if="i+1>=levelList.length">{{item.fullName}}</span>
<a v-else @click="jump(item,i)">{{item.fullName}}</a>
</el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="关键词">
<el-input v-model="keyword" placeholder="请输入关键词查询" clearable
@keyup.enter.native="search()" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{$t('common.search')}}</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">{{$t('common.reset')}}
</el-button>
</el-form-item>
</el-col>
</el-form>
<div class="NCC-common-search-box-right">
<el-button @click="addFolder()" style="margin-right:10px">新建文件夹</el-button>
<el-upload :action="uploadUrl" :headers="uploadHeaders" :on-success="handleSuccess"
:data='{parentId: parentId}' multiple :show-file-list="false" class="upload-box"
:before-upload="beforeUpload">
<el-button type="primary" icon="el-icon-upload2" :loading="receiveing">上传文件
</el-button>
</el-upload>
</div>
</el-row>
<NCC-table v-loading="listLoading" :data="list" empty-text="该文件夹为空" size="mini">
<el-table-column label="文件名">
<template slot-scope="scope">
<span v-if="scope.row.type">
<i :class='"icon-ym " + toFileExt(scope.row.fileExtension) + " i-default"' />
{{scope.row.fullName}}
</span>
<span class='cursor-pointer' v-else @click="openFolder(scope.row)">
<i class='icon-ym icon-ym-extend-folder text-warning' />
{{scope.row.fullName}}
</span>
</template>
</el-table-column>
<el-table-column label="" width="35">
<template slot-scope="scope">
<span v-if="scope.row.type && scope.row.isShare" title='共享文件'><i
class="icon-ym icon-ym-extend-thumbs-up i-default"></i></span>
</template>
</el-table-column>
<el-table-column prop="fileSize" label="大小" width="90">
<template slot-scope="scope">{{scope.row.fileSize | toFileSize()}}</template>
</el-table-column>
<el-table-column prop="creatorTime" label="创建日期" :formatter="ncc.tableDateFormat"
width="120" />
<el-table-column label="操作" fixed="right" width="150">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="handleDownLoad(scope.row.id)"
:disabled="!scope.row.type">下载</el-button>
<el-button size="mini" type="text" class="NCC-table-delBtn"
@click="handleDel(scope.$index,scope.row.id)">删除</el-button>
<el-dropdown>
<el-button type="text" size="mini">
{{$t('common.moreBtn')}}<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="shareFolder(scope.row.id)"
v-if="scope.row.type">
共享
</el-dropdown-item>
<el-dropdown-item @click.native="getFolder(scope.row.id)">重命名
</el-dropdown-item>
<el-dropdown-item @click.native="moveTo(scope.row.id,scope.row.parentId)">
移动到
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</NCC-table>
</div>
</el-tab-pane>
<el-tab-pane name="shareoutPanel">
<span slot="label"><i class="icon-ym icon-ym-extend-thumbs-up"></i>我的共享</span>
<div class="main NCC-flex-main">
<div class="NCC-common-head">
<el-breadcrumb>
<el-breadcrumb-item>我的共享</el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="文件名">
<el-input v-model="keyword" placeholder="搜索我的文件" clearable />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{$t('common.search')}}</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">{{$t('common.reset')}}
</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<NCC-table v-loading="listLoading" :data="list" empty-text="该文件夹为空" size="mini">
<el-table-column label="文件名">
<template slot-scope="scope">
<i :class='"icon-ym " + toFileExt(scope.row.fileExtension) + " i-default"' />
{{scope.row.fullName}}
</template>
</el-table-column>
<el-table-column prop="fileSize" label="大小" width="90">
<template slot-scope="scope">{{scope.row.fileSize | toFileSize()}}</template>
</el-table-column>
<el-table-column prop="shareTime" label="共享日期" :formatter="ncc.tableDateFormat"
width="120" />
<el-table-column label="操作" fixed="right" width="70">
<template slot-scope="scope">
<el-button size="mini" type="text" class="NCC-table-delBtn"
@click="unshare(scope.$index,scope.row.id)">取消共享</el-button>
</template>
</el-table-column>
</NCC-table>
</div>
</el-tab-pane>
<el-tab-pane name="sharetomePanel">
<span slot="label"><i class="icon-ym icon-ym-extend-share"></i>共享给我</span>
<div class="main NCC-flex-main">
<div class="NCC-common-head">
<el-breadcrumb>
<el-breadcrumb-item>共享给我</el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="文件名">
<el-input v-model="keyword" placeholder="搜索我的文件" clearable />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{$t('common.search')}}</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">{{$t('common.reset')}}
</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<NCC-table v-loading="listLoading" :data="list" empty-text="该文件夹为空" size="mini">
<el-table-column label="文件名">
<template slot-scope="scope">
<i :class='"icon-ym " + toFileExt(scope.row.fileExtension) + " i-default"' />
{{scope.row.fullName}}
</template>
</el-table-column>
<el-table-column prop="fileSize" label="大小" width="90">
<template slot-scope="scope">{{scope.row.fileSize | toFileSize()}}</template>
</el-table-column>
<el-table-column prop="shareTime" label="共享日期" :formatter="ncc.tableDateFormat"
width="120" />
<el-table-column label="共享人员" width="120" prop="creatorUserId" />
<el-table-column label="操作" fixed="right" width="50">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="handleDownLoad(scope.row.id)">下载
</el-button>
</template>
</el-table-column>
</NCC-table>
</div>
</el-tab-pane>
<el-tab-pane name="trashPanel">
<span slot="label"><i class="icon-ym icon-ym-extend-trash"></i>回收站</span>
<div class="main NCC-flex-main">
<div class="NCC-common-head">
<el-breadcrumb>
<el-breadcrumb-item>回收站</el-breadcrumb-item>
</el-breadcrumb>
</div>
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="文件名">
<el-input v-model="keyword" placeholder="搜索我的文件" clearable />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{$t('common.search')}}</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">{{$t('common.reset')}}
</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<NCC-table v-loading="listLoading" :data="list" empty-text="该文件夹为空" size="mini">
<el-table-column label="文件名">
<template slot-scope="scope">
<span v-if="scope.row.type">
<i :class='"icon-ym " + toFileExt(scope.row.fileExtension) + " i-default"' />
{{scope.row.fullName}}
</span>
<span v-else>
<i class='icon-ym icon-ym-extend-folder text-warning' />
{{scope.row.fullName}}
</span>
</template>
</el-table-column>
<el-table-column prop="fileSize" label="大小" width="90">
<template slot-scope="scope">{{scope.row.fileSize | toFileSize()}}</template>
</el-table-column>
<el-table-column prop="deleteTime" label="删除日期" :formatter="ncc.tableDateFormat"
width="120" />
<el-table-column label="操作" fixed="right" width="100">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="recovery(scope.$index,scope.row.id)">
还原</el-button>
<el-button size="mini" type="text" class="NCC-table-delBtn"
@click="trashDel(scope.$index,scope.row.id)">删除</el-button>
</template>
</el-table-column>
</NCC-table>
</div>
</el-tab-pane>
</el-tabs>
<userBox v-if="userBoxVisible" ref="userBox" @refresh="initData" />
<folderTree v-if="folderTreeVisible" ref="folderTree" @refresh="initData" />
</div>
</template>
<script>
import { AllList, Create, Delete, Download, DocumentInfo, ShareCancel, ShareOutList, ShareTomeList, TrashDelete, TrashList, TrashRecovery, Update } from '@/api/extend/document'
import userBox from './UserBox'
import folderTree from './FolderTree'
export default {
name: 'extend-document',
components: { userBox, folderTree },
data() {
return {
receiveing: false,
userBoxVisible: false,
folderTreeVisible: false,
detailVisible: false,
activeTab: 'allPanel',
keyword: '',
parentId: '0',
listLoading: true,
list: [],
levelList: [{
id: '0',
fullName: '全部文档'
}],
uploadUrl: process.env.VUE_APP_BASE_API + '/api/extend/Document/Uploader',
uploadHeaders: { Authorization: this.$store.getters.token }
}
},
watch: {
activeTab(val) {
if (val === 'allPanel') {
this.levelList = [{
id: "0",
fullName: '全部文档'
}]
this.parentId = "0"
}
this.reset()
}
},
created() {
this.initData()
},
methods: {
reset() {
this.list = []
this.keyword = ''
this.initData()
},
initData() {
this.listLoading = true
let data = { keyword: this.keyword }
if (this.activeTab === 'allPanel') {
data = { ...data, parentId: this.parentId }
AllList(data).then(res => {
this.list = res.data.list
this.listLoading = false
})
}
if (this.activeTab === 'shareoutPanel') {
ShareOutList(data).then(res => {
this.list = res.data.list
this.listLoading = false
})
}
if (this.activeTab === 'sharetomePanel') {
ShareTomeList(data).then(res => {
this.list = res.data.list
this.listLoading = false
})
}
if (this.activeTab === 'trashPanel') {
TrashList(data).then(res => {
this.list = res.data.list
this.listLoading = false
})
}
},
search() {
this.initData()
},
handleDel(index, id) {
this.$confirm('您确定要把所选文件放入回收站, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
Delete(id).then(res => {
this.list.splice(index, 1);
this.$message({
type: 'success',
message: res.msg
});
})
}).catch(() => { });
},
unshare(index, id) {
this.$confirm('您确定要取消共享, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
ShareCancel(id).then(res => {
this.list.splice(index, 1);
this.$message({
type: 'success',
message: res.msg
});
})
}).catch(() => { });
},
recovery(index, id) {
this.$confirm('您确定要还原选中的文件?', '提示', {
type: 'warning'
}).then(() => {
TrashRecovery(id).then(res => {
this.list.splice(index, 1);
this.$message({
type: 'success',
message: res.msg
});
})
}).catch(() => { });
},
trashDel(index, id) {
this.$confirm('文件删除后将无法恢复,您确定要彻底删除所选文件吗?', '提示', {
type: 'warning'
}).then(() => {
TrashDelete(id).then(res => {
this.list.splice(index, 1);
this.$message({
type: 'success',
message: res.msg
});
})
}).catch(() => { });
},
moveTo(id, parentId) {
this.folderTreeVisible = true
this.$nextTick(() => {
this.$refs.folderTree.init(id, parentId)
})
},
shareFolder(id) {
this.userBoxVisible = true
this.$nextTick(() => {
this.$refs.userBox.init(id)
})
},
getFolder(id) {
DocumentInfo(id).then(res => {
this.addFolder(res.data)
})
},
// 新建文件夹
addFolder(info) {
let inputValue = ""
if (info) { inputValue = info.fullName }
let title = info ? (info.type ? '重命名文件' : '重命名文件夹') : '新建文件夹'
this.$prompt('', title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPlaceholder: '输入名称',
inputErrorMessage: '请正确输入文件夹名称',
inputValue: inputValue,
// inputPattern: /^[\u4e00-\u9fa5_a-zA-Z0-9]+$/,
closeOnClickModal: false
}).then(({ value }) => {
let data = {
type: info && info.type ? info.type : "0",
parentId: this.parentId,
fullName: value
}
if (info && info.id) {
Object.assign(data, { id: info.id })
Update(data).then(res => {
this.$message({
type: 'success',
message: res.msg
});
this.initData()
})
} else {
Create(data).then(res => {
this.$message({
type: 'success',
message: res.msg
});
this.initData()
})
}
}).catch(() => { });
},
handleSuccess(res, file) {
this.receiveing = false
if (res.code == 200) {
this.$message({
message: res.msg,
type: 'success',
duration: 1000
})
this.reset()
} else {
this.$message({
message: res.msg,
type: 'error',
duration: 1000
})
}
},
beforeUpload() { this.receiveing = true },
// 下载文件
handleDownLoad(id) {
Download(id).then(res => {
window.location.href = this.define.comUrl + res.data.url
})
},
// 打开文件夹
openFolder(item) {
this.parentId = item.id
this.levelList.push(item)
this.reset()
},
jump(item, i) {
this.parentId = item.id
this.reset()
this.levelList = this.levelList.slice(0, i + 1)
},
toFileExt(ext) {
if (ext) ext = ext.replace('.', '')
if (ext == "doc" || ext == "docx") {
return "icon-ym-file-word";
}
if (ext == "xls" || ext == "xlsx") {
return "icon-ym-file-excel";
}
if (ext == "ppt" || ext == "pptx") {
return "icon-ym-file-ppt";
}
if (ext == "rar" || ext == "zip") {
return "icon-ym-file-zip";
}
if (ext == "txt" || ext == "log") {
return "icon-ym-file-text";
}
if (ext == "html" || ext == "cs" || ext == "xml") {
return "icon-ym-file-code";
}
if (ext == "gif" || ext == "jpg" || ext == "jpeg" || ext == "bmp" || ext == "png") {
return "icon-ym-file-image1";
}
if (ext == "pdf") {
return "icon-ym-file-pdf";
}
if (ext == "mp3") {
return "icon-ym-file-audio";
}
if (ext == "mp4") {
return "icon-ym-file-movie";
}
return "icon-ym-file-blank";
},
}
}
</script>
<style lang="scss" scoped>
.Document-container {
position: relative;
.NCC-common-search-box {
margin-bottom: 0;
padding-left: 0;
}
.NCC-common-head {
padding: 14px 0 10px;
}
>>> .el-tabs__item {
text-align: left !important;
width: 160px;
.icon-ym {
font-size: 14px;
margin-right: 8px;
}
}
>>> .el-tabs__content {
height: 100%;
.el-tab-pane {
height: 100%;
overflow: hidden;
}
}
.main {
height: 100%;
.icon-ym {
font-size: 14px;
}
.cursor-pointer {
cursor: pointer;
}
}
.upload-box {
display: inline-block;
}
}
</style>