Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
4f00d072
提交
4f00d072
编写于
9月 22, 2020
作者:
llz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
扩展子表单数据传输方式。
上级
05effede
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
51 行增加
和
13 行删除
+51
-13
avue-custom-form.vue
src/components/avue-custom-form/avue-custom-form.vue
+51
-13
未找到文件。
src/components/avue-custom-form/avue-custom-form.vue
浏览文件 @
4f00d072
...
...
@@ -20,7 +20,7 @@ export default class AvueCustomForm extends Vue {
/**
* 编辑器参数传入组件配置
*
* @type {
any
}
* @type {
*
}
* @memberof AvueCustomForm
*/
@
Prop
()
public
options
?:
any
;
...
...
@@ -47,7 +47,7 @@ export default class AvueCustomForm extends Vue {
* @type {any}
* @memberof AvueCustomForm
*/
@
Model
(
'change'
)
public
value
:
any
;
@
Model
(
"change"
)
public
value
:
any
;
/**
* 是否将表单数据通过组件配置带入组件中
...
...
@@ -57,13 +57,22 @@ export default class AvueCustomForm extends Vue {
*/
@
Prop
()
public
isFormData
?:
boolean
;
/**
* 是否为子表单
*
* @type {boolean}
* @memberof AvueCustomForm
*/
@
Prop
()
public
isSubForm
?:
boolean
;
/**
* 表单数据
*
* @type {
any
}
* @type {
*
}
* @memberof AvueCustomForm
*/
@
Prop
()
public
formData
:
any
;
@
Prop
()
public
formData
:
any
;
/**
* 表单状态
...
...
@@ -81,10 +90,11 @@ export default class AvueCustomForm extends Vue {
*/
get
formVal
()
{
let
obj
:
any
=
{};
if
(
this
.
value
)
{
if
(
this
.
isParseString
)
obj
=
JSON
.
parse
(
this
.
value
);
else
obj
=
this
.
value
;
}
if
(
this
.
value
)
{
if
(
this
.
isParseString
)
obj
=
JSON
.
parse
(
this
.
value
);
else
obj
=
this
.
value
;
if
(
this
.
isSubForm
&&
obj
instanceof
Array
)
obj
=
this
.
loadSubFormData
(
obj
);
}
return
obj
;
}
...
...
@@ -110,7 +120,7 @@ export default class AvueCustomForm extends Vue {
/**
* 当前组件配置设置属性
*
* @type {
any
}
* @type {
*
}
* @memberof AvueCustomForm
*/
public
formOption
:
any
=
null
;
...
...
@@ -118,7 +128,7 @@ export default class AvueCustomForm extends Vue {
/**
* avue-form默认配置
*
* @type {
any
}
* @type {
*
}
* @memberof AvueCustomForm
*/
public
defaultOptions
:
any
=
{
...
...
@@ -239,19 +249,47 @@ export default class AvueCustomForm extends Vue {
* @memberof AvueCustomForm
*/
public
setValue
(
value
:
any
)
{
if
(
this
.
isSubForm
)
value
=
this
.
getSubFormData
(
value
);
if
(
this
.
isParseString
)
this
.
$emit
(
"change"
,
JSON
.
stringify
(
value
));
else
this
.
$emit
(
"change"
,
value
);
}
/**
* 提取第一个属性值
*
* @memberof AvueCustomForm
* @return {Array<any>}
*/
public
getSubFormData
(
value
:
any
):
Array
<
any
>
{
let
arr
:
Array
<
any
>
=
[];
for
(
let
val
in
value
)
{
arr
=
value
[
val
];
break
;
}
return
arr
;
}
/**
* 加载子表单值
*
* @memberof AvueCustomForm
* @return {*}
*/
public
loadSubFormData
(
arr
:
Array
<
any
>
):
any
{
let
value
:
any
=
{};
value
[
this
.
formOption
.
column
[
0
].
prop
]
=
arr
;
return
value
;
}
/**
* 销毁组件(vue生命周期)
*
* @type {Subject<any>}
* @memberof AvueCustomForm
*/
public
destroy
(){
if
(
this
.
formStateEvent
)
{
this
.
formStateEvent
.
unsubscribe
();
public
destroy
()
{
if
(
this
.
formStateEvent
)
{
this
.
formStateEvent
.
unsubscribe
();
}
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录