Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
658e1dc3
提交
658e1dc3
编写于
9月 11, 2020
作者:
llz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avue配置表单组件
上级
7d933917
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
255 行增加
和
0 行删除
+255
-0
app-register.ts
src/app-register.ts
+2
-0
avue-custom-form.less
src/components/avue-custom-form/avue-custom-form.less
+0
-0
avue-custom-form.vue
src/components/avue-custom-form/avue-custom-form.vue
+253
-0
未找到文件。
src/app-register.ts
浏览文件 @
658e1dc3
...
@@ -90,6 +90,7 @@ import AppPanelField from './components/app-panel-field/app-panel-field.vue'
...
@@ -90,6 +90,7 @@ import AppPanelField from './components/app-panel-field/app-panel-field.vue'
import
AppPanelItem
from
'./components/app-panel-item/app-panel-item.vue'
import
AppPanelItem
from
'./components/app-panel-item/app-panel-item.vue'
import
AppDepartmentPersonnel
from
'./components/app-department-personnel/app-department-personnel.vue'
import
AppDepartmentPersonnel
from
'./components/app-department-personnel/app-department-personnel.vue'
import
DiskFileUpload
from
'./components/disk-file-upload/disk-file-upload.vue'
import
DiskFileUpload
from
'./components/disk-file-upload/disk-file-upload.vue'
import
AvueCustomForm
from
'./components/avue-custom-form/avue-custom-form.vue'
// 全局挂载UI实体服务注册中心
// 全局挂载UI实体服务注册中心
window
[
'uiServiceRegister'
]
=
uiServiceRegister
;
window
[
'uiServiceRegister'
]
=
uiServiceRegister
;
...
@@ -194,5 +195,6 @@ export const AppComponents = {
...
@@ -194,5 +195,6 @@ export const AppComponents = {
v
.
component
(
'cron-editor'
,
CronEditor
);
v
.
component
(
'cron-editor'
,
CronEditor
);
v
.
component
(
'app-message-popover'
,
AppMessagePopover
);
v
.
component
(
'app-message-popover'
,
AppMessagePopover
);
v
.
component
(
'disk-file-upload'
,
DiskFileUpload
);
v
.
component
(
'disk-file-upload'
,
DiskFileUpload
);
v
.
component
(
'avue-custom-form'
,
AvueCustomForm
);
},
},
};
};
\ No newline at end of file
src/components/avue-custom-form/avue-custom-form.less
0 → 100644
浏览文件 @
658e1dc3
src/components/avue-custom-form/avue-custom-form.vue
0 → 100644
浏览文件 @
658e1dc3
<
template
>
<div
v-if=
"formOption!=null"
class=
"app-custom-form"
>
<avue-form
:option=
"formOption"
v-model=
"formvalue"
></avue-form>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Prop
,
Model
,
Emit
,
Watch
,
}
from
"vue-property-decorator"
;
import
{
Subject
,
Subscription
}
from
"rxjs"
;
@
Component
({})
export
default
class
AvueCustomForm
extends
Vue
{
/**
* 编辑器参数传入组件配置
*
* @type {any}
* @memberof AvueCustomForm
*/
@
Prop
()
public
options
?:
any
;
/**
* 是否需要转换为string类型
*
* @type {boolean}
* @memberof AvueCustomForm
*/
@
Prop
()
public
isParseString
?:
boolean
;
/**
* 远端地址
*
* @type {string}
* @memberof AvueCustomForm
*/
@
Prop
()
public
url
?:
string
;
/**
* 表单项值
*
* @type {any}
* @memberof AvueCustomForm
*/
@
Prop
()
public
value
:
any
;
/**
* 是否将表单数据通过组件配置带入组件中
*
* @type {boolean}
* @memberof AvueCustomForm
*/
@
Prop
()
public
isFormData
?:
boolean
;
/**
* 监听事件
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AvueCustomForm
*/
@
Watch
(
"value"
)
public
onValueChange
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
newVal
)
{
let
obj
:
any
=
{};
if
(
newVal
&&
newVal
!=
null
)
{
if
(
this
.
isParseString
)
obj
=
JSON
.
parse
(
newVal
);
else
obj
=
newVal
;
}
if
(
obj
)
this
.
formvalue
=
JSON
.
parse
(
JSON
.
stringify
(
obj
));
}
}
/**
* 表单数据
*
* @type {any}
* @memberof AvueCustomForm
*/
@
Prop
()
public
formData
:
any
;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof AvueCustomForm
*/
@
Prop
()
public
formState
!
:
Subject
<
any
>
;
/**
* 视图状态事件
*
* @protected
* @type {(Subscription | undefined)}
* @memberof AvueCustomForm
*/
protected
formStateEvent
:
Subscription
|
undefined
;
/**
* 当前组件配置设置属性
*
* @type {any}
* @memberof AvueCustomForm
*/
public
formOption
:
any
=
null
;
/**
* avue-form绑定值
*
* @type {any}
* @memberof AvueCustomForm
*/
public
formvalue
:
any
=
{};
/**
* avue-form默认配置
*
* @type {any}
* @memberof AvueCustomForm
*/
public
defaultOptions
:
any
=
{
column
:
[
{
type
:
"dynamic"
,
label
:
"子表单"
,
span
:
24
,
display
:
true
,
children
:
{
align
:
"center"
,
headerAlign
:
"center"
,
index
:
false
,
addBtn
:
true
,
delBtn
:
true
,
column
:
[
{
type
:
"input"
,
label
:
"属性"
,
span
:
24
,
display
:
true
,
prop
:
"property"
,
},
{
type
:
"input"
,
label
:
"值"
,
span
:
24
,
display
:
true
,
prop
:
"value"
,
},
],
},
prop
:
"1599476281048_17916"
,
},
],
labelPosition
:
"left"
,
labelSuffix
:
":"
,
labelWidth
:
120
,
gutter
:
0
,
menuBtn
:
false
,
submitBtn
:
false
,
submitText
:
"提交"
,
emptyBtn
:
false
,
emptyText
:
"清空"
,
menuPosition
:
"center"
,
};
/**
* vue生命周期
*
* @memberof AvueCustomForm
*/
public
mounted
()
{
let
that
:
any
=
this
;
if
(
this
.
formState
)
{
this
.
formStateEvent
=
this
.
formState
.
subscribe
(({
type
,
data
})
=>
{
if
(
Object
.
is
(
"load"
,
type
))
that
.
load
();
});
}
}
/**
* 加载表单配置,配置优先级,依次按优先级加载(表单项值 > 远端请求 > 默认值)
*
* @memberof AvueCustomForm
*/
public
load
()
{
let
that
:
any
=
this
;
if
(
!
this
.
options
&&
this
.
options
==
null
)
{
if
(
this
.
url
&&
this
.
options
==
null
)
{
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
this
.
url
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
data
&&
response
.
data
.
view_config
)
{
that
.
formOption
=
JSON
.
parse
(
response
.
data
.
view_config
)[
"formConfig"
];
if
(
this
.
isFormData
)
that
.
getFormData
();
}
});
}
else
{
this
.
formOption
=
this
.
defaultOptions
;
if
(
this
.
isFormData
)
that
.
getFormData
();
}
}
else
{
this
.
formOption
=
this
.
options
;
if
(
this
.
isFormData
)
that
.
getFormData
();
}
}
/**
* 当组件配置中的属性与表单属性重复时,表单值塞入组件中
*
* @memberof AvueCustomForm
*/
public
getFormData
()
{
let
that
:
any
=
this
;
let
obj
:
any
;
if
(
this
.
value
)
obj
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
value
));
else
obj
=
{};
let
recursionOption
:
any
=
function
(
group
:
any
)
{
group
.
column
.
forEach
((
gItem
:
any
)
=>
{
if
(
group
.
column
&&
group
.
column
.
length
>
0
)
{
if
(
that
.
formData
[
gItem
.
prop
])
obj
[
gItem
.
prop
]
=
that
.
formData
[
gItem
.
prop
];
}
});
if
(
group
.
group
&&
group
.
group
.
length
>
0
)
group
.
group
.
forEach
((
gItem
:
any
)
=>
{
recursionOption
(
gItem
);
});
};
recursionOption
(
this
.
formOption
);
this
.
setValue
(
obj
);
}
/**
* 设置表单值
*
* @param {*} value
* @memberof AvueCustomForm
*/
public
setValue
(
value
:
any
)
{
if
(
this
.
isParseString
)
this
.
$emit
(
"change"
,
JSON
.
stringify
(
value
));
else
this
.
$emit
(
"change"
,
value
);
}
}
</
script
>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录