Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
filemanage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vanke
filemanage
Commits
9dccdeeb
Commit
9dccdeeb
authored
Jul 07, 2020
by
wangyalan-git
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文档列表,文档类型,文件上传,文件下载
parent
8699b5ea
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
223 additions
and
78 deletions
+223
-78
doc.js
src/api/doc.js
+87
-0
permission.js
src/store/modules/permission.js
+15
-15
request.js
src/utils/request.js
+6
-1
DocList.vue
src/views/doc/DocList.vue
+45
-24
DocType.vue
src/views/doc/DocType.vue
+5
-5
addType.vue
src/views/doc/modules/addType.vue
+2
-2
importFileModal.vue
src/views/doc/modules/importFileModal.vue
+63
-31
No files found.
src/api/doc.js
0 → 100644
View file @
9dccdeeb
import
request
from
'@/utils/request'
// 万科后台_文件分页操作
export
function
getFileList
(
params
)
{
return
request
({
url
:
'/vankeFile/list'
,
method
:
'get'
,
params
})
}
// 万科后台_文件新增操作
export
function
addFile
(
data
)
{
return
request
({
url
:
'/vankeFile/insertFile'
,
method
:
'post'
,
data
})
}
// 万科后台_根据id修改文件
export
function
updateFile
(
data
)
{
return
request
({
url
:
'/vankeFile/updateFile'
,
method
:
'post'
,
data
})
}
// 万科后台_文件类型分页操作
export
function
getTypeList
(
params
)
{
return
request
({
url
:
'/vankeFileType/list'
,
method
:
'get'
,
params
})
}
// 万科后台_文件类型新增操作
export
function
addFileType
(
data
)
{
return
request
({
url
:
'/vankeFileType/insertFileType'
,
method
:
'post'
,
data
})
}
// 万科后台_根据id修改文件类型对象
export
function
updateFileType
(
data
)
{
return
request
({
url
:
'/vankeFileType/updateById'
,
method
:
'post'
,
data
})
}
// 文件下载
export
function
downloadFile
(
params
)
{
return
request
({
url
:
'/file/download'
,
method
:
'post'
,
params
,
responseType
:
'blob'
})
}
// 文件删除
export
function
deleteFile
(
params
)
{
return
request
({
url
:
'/file/deleteFile'
,
method
:
'post'
,
params
})
}
// 文件上传
export
function
uploadFile
(
formData
)
{
return
request
({
url
:
'/file/upload'
,
method
:
'post'
,
data
:
formData
,
headers
:
{
'Content-Type'
:
'multipart/form-data'
//值得注意的是,这个地方一定要把请求头更改一下
}
})
}
src/store/modules/permission.js
View file @
9dccdeeb
...
@@ -81,21 +81,21 @@ const permission = {
...
@@ -81,21 +81,21 @@ const permission = {
const
{
username
}
=
data
const
{
username
}
=
data
const
accessedRouters
=
asyncRouterMap
.
filter
(
v
=>
{
const
accessedRouters
=
asyncRouterMap
.
filter
(
v
=>
{
// admin帐号直接返回所有菜单
// admin帐号直接返回所有菜单
if
(
username
===
'admin'
)
return
true
//
if (username === 'admin') return true
//
if (hasPermission(menus, v)) {
if
(
hasPermission
(
menus
,
v
))
{
//
if (v.children && v.children.length > 0) {
if
(
v
.
children
&&
v
.
children
.
length
>
0
)
{
//
v.children = v.children.filter(child => {
v
.
children
=
v
.
children
.
filter
(
child
=>
{
//
if (hasPermission(menus, child)) {
if
(
hasPermission
(
menus
,
child
))
{
//
return child
return
child
//
}
}
//
return false
return
false
//
})
})
//
return v
return
v
//
} else {
}
else
{
//
return v
return
v
//
}
}
//
}
}
//
return false
return
false
})
})
//对菜单进行排序
//对菜单进行排序
sortRouters
(
accessedRouters
)
sortRouters
(
accessedRouters
)
...
...
src/utils/request.js
View file @
9dccdeeb
...
@@ -6,7 +6,7 @@ import { getToken } from '@/utils/auth'
...
@@ -6,7 +6,7 @@ import { getToken } from '@/utils/auth'
const
service
=
axios
.
create
({
const
service
=
axios
.
create
({
// baseURL: process.env.BASE_API,
// baseURL: process.env.BASE_API,
withCredentials
:
true
,
withCredentials
:
true
,
baseURL
:
'http://192.168.31.127:8
2
01/mall-admin'
,
baseURL
:
'http://192.168.31.127:8
4
01/mall-admin'
,
// baseURL: 'http://hhg.api.jsonpro.cn:8201/mall-admin',
// baseURL: 'http://hhg.api.jsonpro.cn:8201/mall-admin',
timeout
:
60000
// 请求超时时间
timeout
:
60000
// 请求超时时间
})
})
...
@@ -31,6 +31,11 @@ service.interceptors.response.use(
...
@@ -31,6 +31,11 @@ service.interceptors.response.use(
/**
/**
* code为非200是抛错 可结合自己业务进行修改
* code为非200是抛错 可结合自己业务进行修改
*/
*/
// 下载文件另外处理
const
headers
=
response
.
headers
if
(
headers
[
'content-type'
]
==
'application/octet-stream'
)
{
return
response
.
data
}
const
res
=
response
.
data
const
res
=
response
.
data
if
(
res
.
code
!==
200
)
{
if
(
res
.
code
!==
200
)
{
Message
({
Message
({
...
...
src/views/doc/DocList.vue
View file @
9dccdeeb
...
@@ -44,22 +44,22 @@
...
@@ -44,22 +44,22 @@
</el-table-column>
</el-table-column>
<el-table-column
label=
"文档类型"
<el-table-column
label=
"文档类型"
align=
"center"
>
align=
"center"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
goodsNo
}}
</
template
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
fileTypeName
}}
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"创建者"
<el-table-column
label=
"创建者"
align=
"center"
>
align=
"center"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
goodsCategory
Name
}}
</
template
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
admin
Name
}}
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"发布时间"
<el-table-column
label=
"发布时间"
align=
"center"
>
align=
"center"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
create
T
ime
|
formatTime
}}
</
template
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
create
t
ime
|
formatTime
}}
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"操作"
<el-table-column
label=
"操作"
align=
"center"
>
align=
"center"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<el-button
size=
"mini"
<el-button
size=
"mini"
type=
"primary"
type=
"primary"
@
click=
"handleDown(scope.row.
id
)"
>
下载
@
click=
"handleDown(scope.row.
fileName
)"
>
下载
</el-button>
</el-button>
<el-button
size=
"mini"
<el-button
size=
"mini"
type=
"danger"
type=
"danger"
...
@@ -83,28 +83,24 @@
...
@@ -83,28 +83,24 @@
</div>
</div>
</el-card>
</el-card>
<!-- 弹窗-->
<!-- 弹窗-->
<import-
goods-modal
ref=
"importGoods"
@
ok=
"getList"
></import-goods
-modal>
<import-
file-modal
ref=
"importFile"
@
ok=
"getList"
></import-file
-modal>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
moment
from
'moment/moment'
import
moment
from
'moment/moment'
import
{
getGoodsList
,
getGoodsCategoryList
,
getStockRooms
,
editGoods
}
from
'@/api/inventory'
import
{
getFileList
,
downloadFile
,
updateFile
}
from
'@/api/doc'
import
{
getSuppliersList
}
from
'@/api/supplier'
import
ImportFileModal
from
'./modules/importFileModal'
import
ImportGoodsModal
from
'./modules/importGoodsModal'
// 列表查询参数默认值
// 列表查询参数默认值
const
defaultListQuery
=
{
const
defaultListQuery
=
{
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
name
:
''
,
name
:
''
goodsCategoryId
:
''
,
supplierId
:
''
,
stockRoomId
:
''
}
}
export
default
{
export
default
{
name
:
'DocList'
,
name
:
'DocList'
,
components
:
{
components
:
{
Import
Goods
Modal
Import
File
Modal
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -152,7 +148,7 @@ export default {
...
@@ -152,7 +148,7 @@ export default {
this
.
listLoading
=
true
this
.
listLoading
=
true
//请求数据
//请求数据
console
.
log
(
'listQuery'
,
this
.
listQuery
)
console
.
log
(
'listQuery'
,
this
.
listQuery
)
get
Goods
List
(
this
.
listQuery
).
then
(
res
=>
{
get
File
List
(
this
.
listQuery
).
then
(
res
=>
{
this
.
listLoading
=
false
this
.
listLoading
=
false
this
.
list
=
res
.
data
.
list
this
.
list
=
res
.
data
.
list
this
.
total
=
res
.
data
.
total
this
.
total
=
res
.
data
.
total
...
@@ -160,25 +156,50 @@ export default {
...
@@ -160,25 +156,50 @@ export default {
this
.
listLoading
=
false
this
.
listLoading
=
false
})
})
},
},
// 新增
// 上传
handleAdd
()
{
this
.
$refs
.
addGoods
.
add
()
},
// 导入
handleImport
()
{
handleImport
()
{
this
.
$refs
.
import
Goods
.
add
()
this
.
$refs
.
import
File
.
add
()
},
},
handleDown
(){
handleDown
(
fileName
){
downloadFile
({
fileName
:
fileName
}).
then
(
res
=>
{
console
.
log
(
'res'
,
res
)
var
blob
=
new
Blob
([
res
],{
type
:
"application/octet-stream"
});
if
(
window
.
navigator
.
msSaveOrOpenBlob
)
{
//msSaveOrOpenBlob方法返回bool值
navigator
.
msSaveBlob
(
blob
,
fileName
);
//本地保存
}
else
{
var
link
=
document
.
createElement
(
'a'
);
//a标签下载
link
.
href
=
window
.
URL
.
createObjectURL
(
blob
);
link
.
download
=
fileName
;
link
.
click
();
window
.
URL
.
revokeObjectURL
(
link
.
href
);
}
// const content = res
// console.log('res')
// const blob = new Blob([content])
// const fileName = '导出信息.xlsx'
// if ('download' in document.createElement('a')) { // 非IE下载
// const elink = document.createElement('a')
// elink.download = fileName
// elink.style.display = 'none'
// elink.href = URL.createObjectURL(blob)
// document.body.appendChild(elink)
// elink.click()
// URL.revokeObjectURL(elink.href) // 释放URL 对象
// document.body.removeChild(elink)
// } else { // IE10+下载
// navigator.msSaveBlob(blob, fileName)
// }
})
},
},
// 删除
// 删除
handleDelete
(
id
){
handleDelete
(
id
){
this
.
$confirm
(
'是否删除该
物品
?'
,
'提示'
,
{
this
.
$confirm
(
'是否删除该
文档
?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
type
:
'warning'
}).
then
(()
=>
{
}).
then
(()
=>
{
editGoods
({
id
:
id
,
deleteStatus
:
0
}).
then
(
res
=>
{
updateFile
({
id
:
id
,
deleteStatus
:
0
}).
then
(
res
=>
{
this
.
getList
()
this
.
getList
()
})
})
}).
catch
(()
=>
{
}).
catch
(()
=>
{
...
...
src/views/doc/DocType.vue
View file @
9dccdeeb
...
@@ -46,12 +46,12 @@
...
@@ -46,12 +46,12 @@
</div>
</div>
</el-card>
</el-card>
<!-- 弹窗-->
<!-- 弹窗-->
<add-type
ref=
"add
Category
"
@
ok=
"getList"
></add-type>
<add-type
ref=
"add
Type
"
@
ok=
"getList"
></add-type>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
moment
from
'moment'
import
moment
from
'moment'
import
{
get
GoodsCategoryList
,
editGoodsCategory
}
from
'@/api/inventory
'
import
{
get
TypeList
,
updateFileType
}
from
'@/api/doc
'
import
AddType
from
'./modules/addType'
import
AddType
from
'./modules/addType'
// 列表查询参数默认值
// 列表查询参数默认值
const
defaultListQuery
=
{
const
defaultListQuery
=
{
...
@@ -108,7 +108,7 @@ export default {
...
@@ -108,7 +108,7 @@ export default {
this
.
listLoading
=
true
this
.
listLoading
=
true
//请求数据
//请求数据
console
.
log
(
'listQuery'
,
this
.
listQuery
)
console
.
log
(
'listQuery'
,
this
.
listQuery
)
get
GoodsCategory
List
(
this
.
listQuery
).
then
(
res
=>
{
get
Type
List
(
this
.
listQuery
).
then
(
res
=>
{
this
.
listLoading
=
false
this
.
listLoading
=
false
this
.
list
=
res
.
data
.
list
this
.
list
=
res
.
data
.
list
this
.
total
=
res
.
data
.
total
this
.
total
=
res
.
data
.
total
...
@@ -118,7 +118,7 @@ export default {
...
@@ -118,7 +118,7 @@ export default {
},
},
// 添加
// 添加
handleAdd
(){
handleAdd
(){
this
.
$refs
.
add
Category
.
add
()
this
.
$refs
.
add
Type
.
add
()
},
},
// 删除
// 删除
handleDelete
(
id
){
handleDelete
(
id
){
...
@@ -127,7 +127,7 @@ export default {
...
@@ -127,7 +127,7 @@ export default {
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
type
:
'warning'
}).
then
(()
=>
{
}).
then
(()
=>
{
editGoodsCategory
({
id
:
id
,
deleteStatus
:
0
}).
then
(
res
=>
{
updateFileType
({
id
:
id
,
deleteStatus
:
0
}).
then
(
res
=>
{
this
.
getList
()
this
.
getList
()
})
})
}).
catch
(()
=>
{
}).
catch
(()
=>
{
...
...
src/views/doc/modules/addType.vue
View file @
9dccdeeb
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</el-dialog>
</el-dialog>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
add
GoodsCategory
}
from
'@/api/inventory
'
import
{
add
FileType
}
from
'@/api/doc
'
// 移动属性
// 移动属性
export
default
{
export
default
{
name
:
'addType'
,
name
:
'addType'
,
...
@@ -73,7 +73,7 @@ export default {
...
@@ -73,7 +73,7 @@ export default {
this
.
$refs
.
attributeForm
.
validate
((
valid
)
=>
{
this
.
$refs
.
attributeForm
.
validate
((
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
// 验证通过
// 验证通过
add
GoodsCategory
(
this
.
model
).
then
(
res
=>
{
add
FileType
(
this
.
model
).
then
(
res
=>
{
this
.
loading
=
false
this
.
loading
=
false
this
.
visible
=
false
this
.
visible
=
false
this
.
$emit
(
'ok'
)
this
.
$emit
(
'ok'
)
...
...
src/views/doc/modules/import
Goods
Modal.vue
→
src/views/doc/modules/import
File
Modal.vue
View file @
9dccdeeb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<el-dialog
:visible
.
sync=
"visible"
<el-dialog
:visible
.
sync=
"visible"
:title=
"title"
:title=
"title"
center
center
width=
"
5
00px"
width=
"
6
00px"
:close-on-click-modal=
"false"
>
:close-on-click-modal=
"false"
>
<div
class=
"scroll-container no-bottom"
<div
class=
"scroll-container no-bottom"
ref=
"scrollContainer"
>
ref=
"scrollContainer"
>
...
@@ -13,26 +13,27 @@
...
@@ -13,26 +13,27 @@
<el-input
v-model=
"modal.name"
class=
"input-width"
<el-input
v-model=
"modal.name"
class=
"input-width"
placeholder=
"请输入文档名称"
></el-input>
placeholder=
"请输入文档名称"
></el-input>
</el-form-item>
</el-form-item>
<el-form-item
prop=
"type
"
<el-form-item
prop=
"typeId
"
label=
"文档类型"
label=
"文档类型"
:rules=
"[
{required: true,trigger: '
blur
',message: '请选择文档类型'}]">
:rules=
"[
{required: true,trigger: '
change
',message: '请选择文档类型'}]">
<el-select
v-model=
"modal.type"
class=
"input-width"
<el-select
v-model=
"modal.type
Id
"
class=
"input-width"
placeholder=
"请选择文档类型"
>
placeholder=
"请选择文档类型"
>
<el-option
v-for=
"item in category
Options"
<el-option
v-for=
"item in type
Options"
:key=
"item.id"
:key=
"item.id"
:label=
"item.name"
:label=
"item.name"
:value=
"item.id"
></el-option>
:value=
"item.id"
></el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
prop=
"doc
"
<el-form-item
prop=
"fileName
"
label=
"文档"
label=
"文档"
:rules=
"[
{required: true,trigger: 'blur',message: '请选择文档
类型
'}]">
:rules=
"[
{required: true,trigger: 'blur',message: '请选择文档'}]">
<el-upload
<el-upload
class=
"upload-demo"
ref=
"upload"
:action=
"actionURL"
action=
"string"
:limit=
"1"
:on-change=
"handleChange"
:on-success=
"afterSuccess"
:on-remove=
"handleRemove"
name=
'file'
>
:http-request=
"UploadImage"
:file-list=
"fileList"
>
<el-button
size=
"small"
type=
"primary"
>
选择文档
</el-button>
<el-button
size=
"small"
type=
"primary"
>
选择文档
</el-button>
<div
slot=
"tip"
class=
"el-upload__tip"
>
只能上传不超过20MB的文件
</div>
<div
slot=
"tip"
class=
"el-upload__tip"
>
只能上传不超过20MB的文件
</div>
</el-upload>
</el-upload>
...
@@ -51,42 +52,45 @@
...
@@ -51,42 +52,45 @@
</el-dialog>
</el-dialog>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getGoodsCategoryList
,
addGoodList
,
getStockRooms
,
getGoodsList
}
from
'@/api/inventory'
import
{
addFile
,
getTypeList
,
uploadFile
,
deleteFile
}
from
'@/api/doc'
import
XLSX
from
'xlsx'
// 添加编辑属性
// 添加编辑属性
export
default
{
export
default
{
name
:
'import
Goods
Modal'
,
name
:
'import
File
Modal'
,
data
()
{
data
()
{
return
{
return
{
actionURL
:
''
,
actionURL
:
''
,
files
:
null
,
//文件列表
files
:
null
,
//文件列表
visible
:
false
,
visible
:
false
,
title
:
null
,
title
:
null
,
loading
:
false
,
loading
:
false
,
modal
:
{},
modal
:
{},
categoryOptions
:[]
typeOptions
:
[],
fileList
:
[],
fileName
:
null
,
filePath
:
null
}
}
},
},
methods
:
{
methods
:
{
// 物品类别
getTypeList
()
{
getGoodsCategoryList
()
{
getTypeList
().
then
(
res
=>
{
getGoodsCategoryList
().
then
(
res
=>
{
this
.
typeOptions
=
res
.
data
.
list
this
.
categoryOptions
=
res
.
data
.
list
})
})
},
},
init
()
{
init
()
{
this
.
modal
=
{
this
.
modal
=
{
name
:
''
,
name
:
''
,
type
:
''
,
typeId
:
''
,
doc
:
''
fileName
:
''
,
filePath
:
''
}
}
this
.
getGoodsCategoryList
()
this
.
fileList
=
[]
this
.
getTypeList
()
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
$refs
.
modal
.
clearValidate
()
this
.
$refs
.
scrollContainer
.
scrollTop
=
0
this
.
$refs
.
scrollContainer
.
scrollTop
=
0
})
})
},
},
add
()
{
add
()
{
this
.
init
()
this
.
init
()
...
@@ -96,11 +100,42 @@ export default {
...
@@ -96,11 +100,42 @@ export default {
close
()
{
close
()
{
this
.
visible
=
false
this
.
visible
=
false
},
},
handleRemove
(
file
,
fileList
)
{
console
.
log
(
'删除'
,
file
,
fileList
)
},
handleChange
(
file
,
fileList
)
{
if
(
fileList
.
length
>
0
)
{
this
.
fileList
=
[
fileList
[
fileList
.
length
-
1
]]
// 这一步,是 展示最后一次选择的csv文件
}
},
// 文件提交
UploadImage
(
param
)
{
console
.
log
(
'文件上传'
,
param
)
var
file
=
param
.
file
// const isLt2M = file.size / 1024 / 1024
<
20
;
// if (!isLt2M) {
// this.$message.error('上传文件大小不能超过 20MB!');
// return
// }
let
fd
=
new
FormData
()
fd
.
append
(
'file'
,
file
)
// 要提交给后台的文件
uploadFile
(
fd
).
then
(
res
=>
{
// uploadFile 是封装的接口
if
(
this
.
modal
.
fileName
)
{
deleteFile
({
fileName
:
this
.
modal
.
fileName
}).
then
(
res
=>
{
console
.
log
(
'删除'
)
})
}
this
.
modal
.
fileName
=
res
.
data
.
fileName
this
.
modal
.
filePath
=
res
.
data
.
filePath
console
.
log
(
'this.modal'
,
this
.
modal
)
})
},
submit
(
formName
)
{
submit
(
formName
)
{
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
add
GoodList
({
vankeGoodsList
:
this
.
modal
.
tableData
}
).
then
(
res
=>
{
add
File
(
this
.
modal
).
then
(
res
=>
{
this
.
$emit
(
'ok'
)
this
.
$emit
(
'ok'
)
this
.
visible
=
false
this
.
visible
=
false
})
})
...
@@ -108,9 +143,6 @@ export default {
...
@@ -108,9 +143,6 @@ export default {
this
.
$message
.
warning
(
'请检查必填项是否输入'
)
this
.
$message
.
warning
(
'请检查必填项是否输入'
)
}
}
})
})
},
afterSuccess
(
response
,
file
,
fileList
)
{
console
.
log
(
response
)
//返回的是上传之后后台返回的结果
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment