Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
V
vue-form
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
vue-form
Commits
3e009fef
提交
3e009fef
authored
12月 28, 2019
作者:
GOD_ZYX
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
a670e096
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
176 行增加
和
11 行删除
+176
-11
App.vue
examples/App.vue
+2
-2
file.js
examples/sofia-form/file.js
+14
-3
index.js
src/components/elem-form/index.js
+2
-0
elemInfo.md
src/components/elem-form/upload-form/elemInfo.md
+1
-1
ajax.js
src/components/elem-form/upload-form/src/ajax.js
+37
-0
uploadForm.vue
src/components/elem-form/upload-form/src/uploadForm.vue
+120
-5
没有找到文件。
examples/App.vue
浏览文件 @
3e009fef
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
registerForm
from
'./kelley-form'
//
import registerForm from './kelley-form'
// import sofia
Form from './sofia-form'
import
register
Form
from
'./sofia-form'
export
default
{
export
default
{
name
:
'app'
,
name
:
'app'
,
...
...
examples/sofia-form/file.js
浏览文件 @
3e009fef
...
@@ -6,13 +6,22 @@ export default {
...
@@ -6,13 +6,22 @@ export default {
get
:
{
get
:
{
action
:
'/zws/v1/enrollment/attachments?project_id=1001'
,
action
:
'/zws/v1/enrollment/attachments?project_id=1001'
,
callback
(
data
)
{
callback
(
data
)
{
data
.
date_of_starting_to_work
=
data
.
date_of_starting_to_work
+
''
let
_data
=
{
return
data
uploadArrs
:
[]
}
data
.
forEach
((
item
,
index
)
=>
{
_data
.
uploadArrs
.
push
({
url
:
item
.
file
,
id
:
item
.
id
,
'sso_file_name'
:
item
.
sso_file_name
})
})
return
_data
}
}
},
},
update
:
{
update
:
{
action
:
'/zws/v1/enrollment/profiles'
,
action
:
'/zws/v1/enrollment/profiles'
,
data
:
{
project_id
:
100
1
},
data
:
{
project_id
:
100
0
},
callback
(
data
)
{
callback
(
data
)
{
return
data
return
data
}
}
...
@@ -24,7 +33,9 @@ export default {
...
@@ -24,7 +33,9 @@ export default {
{
{
type
:
'upload-form'
,
type
:
'upload-form'
,
label
:
'有效身份证件(正面)'
,
label
:
'有效身份证件(正面)'
,
'model'
:
'uploadArrs'
,
'action'
:
'/zws/v1/enrollment/attachments'
,
'action'
:
'/zws/v1/enrollment/attachments'
,
'deleteAction'
:
'/zws/v1/enrollment/attachments'
,
'data'
:
{
'data'
:
{
'file_type'
:
10
,
'file_type'
:
10
,
'project_id'
:
1001
'project_id'
:
1001
...
...
src/components/elem-form/index.js
浏览文件 @
3e009fef
...
@@ -20,6 +20,7 @@ import {
...
@@ -20,6 +20,7 @@ import {
Tabs
,
Tabs
,
TabPane
,
TabPane
,
Upload
,
Upload
,
Avatar
,
Progress
,
Progress
,
ColorPicker
ColorPicker
}
from
'element-ui'
}
from
'element-ui'
...
@@ -68,6 +69,7 @@ const install = function(Vue, opts = {}) {
...
@@ -68,6 +69,7 @@ const install = function(Vue, opts = {}) {
Vue
.
use
(
Tabs
)
Vue
.
use
(
Tabs
)
Vue
.
use
(
TabPane
)
Vue
.
use
(
TabPane
)
Vue
.
use
(
Upload
)
Vue
.
use
(
Upload
)
Vue
.
use
(
Avatar
)
Vue
.
use
(
Progress
)
Vue
.
use
(
Progress
)
Vue
.
use
(
ColorPicker
)
Vue
.
use
(
ColorPicker
)
...
...
src/components/elem-form/upload-form/elemInfo.md
浏览文件 @
3e009fef
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
'label-width': '160px',
'label-width': '160px',
'required': true,
'required': true,
'disabled': false,
'disabled': false,
'model': '
real_name_cn
',
'model': '
uploadArrs
',
'action': '',
'action': '',
'data': {
'data': {
...
...
src/components/elem-form/upload-form/src/ajax.js
浏览文件 @
3e009fef
...
@@ -28,6 +28,43 @@ function getBody(xhr) {
...
@@ -28,6 +28,43 @@ function getBody(xhr) {
}
}
}
}
export
function
deleteFile
(
option
)
{
if
(
typeof
XMLHttpRequest
===
'undefined'
)
{
return
}
const
xhr
=
new
XMLHttpRequest
()
let
action
=
option
.
action
xhr
.
onerror
=
function
error
(
e
)
{
option
.
onError
(
e
)
}
xhr
.
onload
=
function
onload
()
{
if
(
xhr
.
status
<
200
||
xhr
.
status
>=
300
)
{
return
option
.
onError
(
getError
(
action
,
option
,
xhr
))
}
option
.
onSuccess
(
getBody
(
xhr
))
}
xhr
.
open
(
'delete'
,
action
,
true
)
if
(
option
.
withCredentials
&&
'withCredentials'
in
xhr
)
{
xhr
.
withCredentials
=
true
}
const
headers
=
option
.
headers
||
{}
for
(
let
item
in
headers
)
{
if
(
headers
.
hasOwnProperty
(
item
)
&&
headers
[
item
]
!==
null
)
{
xhr
.
setRequestHeader
(
item
,
headers
[
item
])
}
}
xhr
.
send
()
return
xhr
}
export
default
function
upload
(
option
)
{
export
default
function
upload
(
option
)
{
if
(
typeof
XMLHttpRequest
===
'undefined'
)
{
if
(
typeof
XMLHttpRequest
===
'undefined'
)
{
return
return
...
...
src/components/elem-form/upload-form/src/uploadForm.vue
浏览文件 @
3e009fef
...
@@ -15,13 +15,37 @@
...
@@ -15,13 +15,37 @@
:before-upload=
"beforeUploadFile"
:before-upload=
"beforeUploadFile"
:on-success=
"onSuccessFile"
:on-success=
"onSuccessFile"
:with-credentials=
"true"
:with-credentials=
"true"
:show-file-list=
"false"
v-bind=
"item.attrs ||
{}">
v-bind=
"item.attrs ||
{}">
<el-button
type=
"primary"
>
点击上传
</el-button>
<el-button
type=
"primary"
>
点击上传
</el-button>
<template
v-if=
"formData[item.model]"
>
</el-upload>
<div
style=
"overflow: hidden; padding: 20px 0 0 0;"
>
<template
v-if=
"filesArr.length"
>
<!-- 遍历显示文件 -->
<!-- 遍历显示文件 -->
<template
v-for=
"(item, index) in filesArr"
>
<template
v-if=
"/(jpeg)|(jpg)|(png)|(gif)/gi.test(item.url)"
>
<div
v-bind:key=
"item.id"
class=
"show-file"
>
<div
class=
"close"
@
click=
"deleteFile(index)"
>
X
</div>
<el-avatar
shape=
"square"
:size=
"100"
fit=
"contain"
:src=
"item.url"
></el-avatar>
<span
class=
"title"
>
{{
item
.
sso_file_name
}}
</span>
<div
class=
"hover"
>
<a
target=
"_blank"
:href=
"item.url"
>
下载
</a>
</div>
</div>
</
template
>
<
template
v-else
>
<div
v-bind:key=
"item.id"
class=
"show-file"
>
<div
class=
"close"
>
X
</div>
<el-avatar
shape=
"square"
:size=
"100"
fit=
"contain"
:src=
"item.url"
></el-avatar>
<span
class=
"title"
>
{{
item
.
sso_file_name
}}
</span>
<div
class=
"hover"
>
<a
target=
"_blank"
:href=
"item.url"
>
下载
</a>
</div>
</div>
</
template
>
</template>
</template>
</template>
</
el-upload
>
</
div
>
<div
class=
'info'
style=
"line-height: 1.5;"
v-html=
"item.html"
></div>
<div
class=
'info'
style=
"line-height: 1.5;"
v-html=
"item.html"
></div>
<!-- <el-input :style="{ width: item.modelWidth || item['model-width'] || '100%' }"
<!-- <el-input :style="{ width: item.modelWidth || item['model-width'] || '100%' }"
...
@@ -36,7 +60,7 @@
...
@@ -36,7 +60,7 @@
</template>
</template>
<
script
>
<
script
>
// import ajax
from './ajax'
import
{
deleteFile
}
from
'./ajax'
export
default
{
export
default
{
name
:
'UploadForm'
,
name
:
'UploadForm'
,
...
@@ -57,14 +81,105 @@ export default {
...
@@ -57,14 +81,105 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
'project_id'
:
''
,
filesArr
:
[]
filesArr
:
[]
}
}
},
},
methods
:
{
methods
:
{
beforeUploadFile
(
file
)
{},
beforeUploadFile
(
file
)
{},
onSuccessFile
(
response
,
file
,
fileList
)
{
onSuccessFile
(
response
,
file
,
fileList
)
{
debugger
response
.
url
=
response
.
file
||
''
response
.
sso_file_name
=
file
.
name
this
.
filesArr
.
push
(
response
)
},
deleteFile
(
index
)
{
let
temp
=
this
.
filesArr
[
index
]
deleteFile
({
action
:
this
.
item
.
deleteAction
+
'/'
+
temp
.
id
+
'?project_id='
+
this
.
project_id
,
onError
:
()
=>
{},
onSuccess
:
(
res
)
=>
{
if
(
res
.
status
===
200
)
{
this
.
filesArr
.
splice
(
index
,
1
)
}
}
})
}
},
watch
:
{
formData
:
{
immediate
:
true
,
deep
:
true
,
handler
(
value
)
{
/* 单独处理 - ajax结果在组件渲染之后 */
if
(
value
[
this
.
item
.
model
]
&&
value
[
this
.
item
.
model
].
length
&&
!
this
.
filesArr
.
length
)
{
this
.
filesArr
=
value
[
this
.
item
.
model
]
this
.
project_id
=
this
.
item
.
data
.
project_id
}
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
>
.show-file
{
position
:
relative
;
float
:
left
;
margin-right
:
10px
;
.close
{
position
:
absolute
;
z-index
:
10
;
right
:
-10px
;
top
:
-10px
;
width
:
20px
;
height
:
20px
;
color
:
#fff
;
font-size
:
12px
;
line-height
:
20px
;
text-align
:
center
;
background
:
#efefef
;
border-radius
:
50%
;
cursor
:
pointer
;
}
.el-avatar
{
img
{
width
:
100%
;
}
}
.title
{
position
:
absolute
;
left
:
0
;
bottom
:
16px
;
width
:
100%
;
padding-left
:
5px
;
font-size
:
12px
;
line-height
:
20px
;
background
:
#efefef
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
word-break
:
break-all
;
box-sizing
:
border-box
;
}
.hover
{
display
:
none
;
position
:
absolute
;
z-index
:
9
;
top
:
0
;
left
:
0
;
height
:
100px
;
width
:
100%
;
background
:
rgba
(
0
,
0
,
0
,
0
.2
);
line-height
:
100px
;
text-align
:
center
;
a
{
color
:
#f1f1f1
;
}
}
&
:hover
{
.hover
{
display
:
block
;
}
}
}
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论