Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cy-admin-ui
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
webpack
cy-admin-ui
Commits
16e54241
Commit
16e54241
authored
Feb 18, 2022
by
廖伟胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改上传组件
parent
243c82f3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
28 deletions
+115
-28
upload-audio.vue
packages/form/upload/src/upload-audio.vue
+4
-2
upload-file.vue
packages/form/upload/src/upload-file.vue
+1
-1
upload-img.vue
packages/form/upload/src/upload-img.vue
+1
-1
upload-video.vue
packages/form/upload/src/upload-video.vue
+21
-19
upload.vue
packages/form/upload/src/upload.vue
+57
-5
layout-form.vue
packages/layout/src/layout-form.vue
+31
-0
No files found.
packages/form/upload/src/upload-audio.vue
View file @
16e54241
<
template
>
<div>
<el-upload
ref=
"upload
"
:show-file-list=
"false"
:on-preview=
"handler().handlePreview()"
:list-type=
"listType"
:on-exceed=
"(files, fileList)=>handler().handleExceed(files,fileList)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(file) => handler().imageSuccess(file)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<el-upload
ref=
"upload
-audio"
:show-file-list=
"false"
:on-preview=
"handler().handlePreview()"
:list-type=
"listType"
:on-exceed=
"(files, fileList)=>handler().handleExceed(files,fileList)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(file) => handler().imageSuccess(file)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<!--音频-->
<div
v-if=
"list.length >0 && !isList"
style=
"display:inline"
>
<div
v-for=
"(item,index) in list"
:key=
"index"
style=
"float:left;margin-right:10px;"
@
click
.
stop=
"handler().getIndex(index)"
>
...
...
@@ -388,7 +388,7 @@ export default{
src:link
}
this.data = this.list.push(attrs);
this.$refs.upload.clearFiles();
//
this.$refs.upload.clearFiles();
},
//获取索引
getIndex:(index)=>{
...
...
@@ -396,6 +396,8 @@ export default{
},
// 文件个数超出
handleExceed:(file,fileList)=>{
console.log(file,fileList);
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
},
handlePreview:(file)=>{
...
...
packages/form/upload/src/upload-file.vue
View file @
16e54241
<
template
>
<div>
<el-upload
ref=
"upload"
:show-file-list=
"false"
:on-preview=
"handler().handlePreview()"
:list-type=
"listType"
:on-exceed=
"(files, fileList)=>handler().handleExceed(files,fileList)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(file,files) => handler().imageSuccess(file,files)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<el-upload
ref=
"upload
-file
"
:show-file-list=
"false"
:on-preview=
"handler().handlePreview()"
:list-type=
"listType"
:on-exceed=
"(files, fileList)=>handler().handleExceed(files,fileList)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(file,files) => handler().imageSuccess(file,files)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<i
class=
"el-icon-upload"
v-if=
"uploadStyle === 'drag'"
></i>
<div
class=
"el-upload__text"
v-if=
"uploadStyle === 'drag'"
>
将文件拖到此处,或
<em>
点击上传
</em></div>
<!--文件上传-->
...
...
packages/form/upload/src/upload-img.vue
View file @
16e54241
...
...
@@ -95,8 +95,8 @@ export default{
return
uploadDomain
},
src
()
{
const
{
data
,
imgDomain
}
=
this
console
.
log
(
data
);
const
reg
=
/^
([
hH
][
tT
]{2}[
pP
]
:
\/\/
|
[
hH
][
tT
]{2}[
pP
][
sS
]
:
\/\/)(([
A-Za-z0-9-~
]
+
)\.)
+
([
A-Za-z0-9-~
\/])
+$/
if
(
reg
.
test
(
data
))
{
...
...
packages/form/upload/src/upload-video.vue
View file @
16e54241
<
template
>
<div>
<el-upload
ref=
"upload
"
:show-file-list=
"false"
:on-progress=
"(event, file)=>handler().uploadVideoProcess(event, file)"
:list-type=
"listType"
:on-exceed=
"(files)=>handler().handleExceed(files)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(file) => handler().imageSuccess(file
)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<el-upload
ref=
"upload
-video"
:show-file-list=
"false"
:on-progress=
"(event, file)=>handler().uploadVideoProcess(event, file)"
:list-type=
"listType"
:on-exceed=
"(files)=>handler().handleExceed(files)"
:drag=
"uploadStyle === 'drag' ? true : false"
:limit=
"limit"
:on-success=
"(data,file,fileList) => handler().imageSuccess(data,file,fileList
)"
:action=
"uploadDomain"
:before-upload=
"init().beforeUpload"
:multiple=
"multiple"
:headers=
"headers"
class=
"avatar-uploader"
>
<!--视频-->
<div
v-if=
"list.length >0"
style=
"display:inline"
@
click
.
stop=
"handler().getIndex(index)"
>
<div
v-for=
"(item,index) in list"
:key=
"index"
style=
"float:left;"
@
click
.
stop=
"handler().getIndex(index)"
>
<div
:style=
"style"
class=
"avatar video-box"
>
<i
class=
"el-icon-close delete-icon"
title=
"删除"
@
click
.
stop=
"handler().handelDelete(index)"
/>
<video
id=
"myVideo"
:src=
"item
.url
"
:src=
"item"
:autoplay=
"autoplay == true ? 'autoplay' : false"
:loop=
"loop == true ? 'loop' : false"
:controls=
"controls == true ? 'controls' : false"
...
...
@@ -187,6 +187,10 @@ export default{
break
}
return
uploadDomain
},
computedDataType
()
{
const
{
dataType
,
limit
}
=
this
return
limit
===
1
?
'string'
:
dataType
},
src
()
{
const
{
data
,
imgDomain
}
=
this
...
...
@@ -234,12 +238,11 @@ export default{
},
watch: {
value(value) {
this.list =
this.init().data(value)
this.list =
this.init().data(this.value);
},
data() {
this.data = this.list;
this.$emit('
input
', this.init().value(this.data))
this.$emit('
on
-
success
', this.data)
this.$emit('
input
', this.init().value(this.list))
this.$emit('
on
-
success
', this.list)
},
},
created() {
...
...
@@ -250,10 +253,10 @@ export default{
methods: {
init() {
return {
// 初始化返回数据
// 初始化返回数据
value: (list) => {
let value = ''
const {
dataType } = this
const {
computedDataType: dataType } = this
switch(dataType) {
case '
string
': // 字符串类型以逗号隔开
value = list.join('
,
')
...
...
@@ -269,17 +272,18 @@ export default{
},
// 初始化数据
data: (value) => {
let data = ''
const { dataType } = this
let val = value;
let data = ''
const { computedDataType: dataType } = this
switch(dataType) {
case '
string
': // 字符串类型以逗号隔开
data = value ? value.split('
,
') : []
//
data = value ? value.split('
,
') : []
break
case '
json
':
data = val
ue ? JSON.parse(value
) : []
data = val
? JSON.parse(val
) : []
break
case '
array
':
data = val
ue
data = val
break
}
data = Array.isArray(data) ? data : []
...
...
@@ -354,16 +358,14 @@ export default{
handler() {
return {
// 图片上传成功回调
imageSuccess: (data,file) => {
imageSuccess: (data,file
,fileList
) => {
const link = data.url;
// this.data = url
let attr = {
url:link,
}
this.isShowUploadVideo = true;
this.videoFlag = false;
this.videoUploadPercent = 0;
this.data = this.index != null ? this.list.splice(this.index,1,attr) : this.list.push(attr);
this.videoUploadPercent = 0;
this.list.push(link);
this.data= this.list;
// this.$refs.upload.clearFiles();
},
//进度条
...
...
packages/form/upload/src/upload.vue
View file @
16e54241
...
...
@@ -5,7 +5,7 @@
:label=
"label"
:limit=
"limit"
:edit=
"edit"
v-model=
"
value
"
v-model=
"
data
"
:showDel=
"showDel"
:dialog=
"dialog"
:data-type=
"dataType"
...
...
@@ -17,7 +17,7 @@
<UploadFile
v-if=
"type === 'file'"
:label=
"label"
:limit=
"limit"
v-model=
"
value
"
v-model=
"
data
"
:edit=
"edit"
:data-type=
"dataType"
:dialog=
"dialog"
...
...
@@ -30,7 +30,7 @@
:limit=
"limit"
:edit=
"edit"
:showDel=
"showDel"
v-model=
"
value
"
v-model=
"
data
"
:dialog=
"dialog"
:data-type=
"dataType"
:tips=
"tips"
...
...
@@ -48,7 +48,7 @@
:limit=
"limit"
:edit=
"edit"
:showDel=
"showDel"
v-model=
"
value
"
v-model=
"
data
"
:dialog=
"dialog"
:tips=
"tips"
:source=
"source"
...
...
@@ -92,7 +92,7 @@ export default {
},
limit
:
{
// 图片上传数量限制,默认10
type
:
Number
,
default
:
1
0
,
default
:
1
,
},
value
:
{
type
:
[
String
,
Object
,
Array
],
...
...
@@ -216,5 +216,57 @@ export default {
default
:
false
,
},
},
data
(){
return
{
data
:
''
,
}
},
watch
:{
value
(
value
)
{
this
.
data
=
value
;
},
},
methods
:{
init
()
{
return
{
// 初始化返回数据
value
:
(
list
)
=>
{
let
value
=
''
const
{
computedDataType
:
dataType
}
=
this
switch
(
dataType
)
{
case
'string'
:
// 字符串类型以逗号隔开
value
=
list
.
join
(
','
)
break
case
'json'
:
value
=
JSON
.
stringify
(
list
)
break
case
'array'
:
value
=
list
break
}
return
value
},
// 初始化数据
data
:
(
value
)
=>
{
let
val
=
value
;
let
data
=
''
const
{
computedDataType
:
dataType
}
=
this
switch
(
dataType
)
{
case
'string'
:
// 字符串类型以逗号隔开
// data = value ? value.split(',') : []
break
case
'json'
:
data
=
val
?
JSON
.
parse
(
val
)
:
[]
break
case
'array'
:
data
=
val
break
}
data
=
Array
.
isArray
(
data
)
?
data
:
[]
return
data
},
}
},
},
}
</
script
>
packages/layout/src/layout-form.vue
View file @
16e54241
...
...
@@ -83,6 +83,37 @@
:size=
"(item.upload && item.upload.size) || 100"
:dataType=
"(item.upload && item.upload.dataType) || 'string'"
v-model=
"form[item.field]"
/>
-->
<!--
<cyupload
:ref=
"form[item.field]"
v-model=
"form[item.field]"
:type=
"item.type"
:limit=
"item.limit|| 1"
:size=
"item.size || 100"
:dataType=
"item.dataType || 'array'"
:edit=
"item.edit || true"
:showDel=
"item.showDel || true"
:label=
"item.label || ''"
:multiple=
"item.multiple || false"
:tips=
"item.tips || ''"
:source=
"item.source || ''"
:fileType=
"item.fileType || ''"
:autoplay=
"item.autoplay || false"
:loop=
"item.loop || false"
:controls=
"item.controls || true"
:muted=
"item.muted || false"
:poster=
"item.poster || false"
:preload=
"item.preload || false"
:isList=
"item.isList || false"
:mini=
"item.mini || false"
:float=
"item.float || false"
:showLrc=
"item.showLrc || false"
:mutex=
"item.mutex || false"
:themeColor=
"item.themeColor"
:shuffle=
"item.shuffle || false"
:repeat=
"item.repeat"
:listMaxHeight=
"item.listMaxHeight"
:listFolded=
"item.listFolded || false"
/>
-->
</div>
<el-date-picker
v-else-if=
"item.type === 'date'"
...
...
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