Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
71a3a8e1
提交
71a3a8e1
编写于
12月 06, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
model
上级
45e338d4
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
264 行增加
和
239 行删除
+264
-239
app-form-json-da-chart.vue
...b/src/components/app-form-json/app-form-json-da-chart.vue
+4
-239
app-form-json.vue
app_web/src/components/app-form-json/app-form-json.vue
+260
-0
未找到文件。
app_web/src/components/app-form-json/app-form-json-da-chart.vue
浏览文件 @
71a3a8e1
...
...
@@ -6,229 +6,12 @@ import { Http,Util } from '@/utils';
import
JSONEditor
from
"@json-editor/json-editor"
;
import
BootstrapVue
from
"bootstrap-vue"
;
import
"bootstrap/dist/css/bootstrap.css"
;
import
"bootstrap-vue/dist/bootstrap-vue.css"
;
import
CodeListService
from
"@/codelist/codelist-service"
;
import
AppFormJson
from
'./app-form-json.vue'
;
import
"./app-form-json-da-chart.less"
;
JSONEditor
.
defaults
.
resolvers
.
unshift
(
schema
=>
{
if
(
schema
.
type
===
"selectnew"
)
{
return
"selectnew"
;
}
// If no valid editor is returned, the next resolver function will be used
});
JSONEditor
.
defaults
.
editors
.
selectnew
=
JSONEditor
.
defaults
.
editors
.
select
.
extend
({
onWatchedFieldChange
:
function
()
{
var
self
=
this
,
vars
,
j
;
// If this editor uses a dynamic select box
if
(
this
.
enumSource
)
{
vars
=
this
.
getWatchedFieldValues
();
var
select_options
=
[];
var
select_titles
=
[];
for
(
var
i
=
0
;
i
<
this
.
enumSource
.
length
;
i
++
)
{
// Constant values
if
(
Array
.
isArray
(
this
.
enumSource
[
i
]))
{
select_options
=
select_options
.
concat
(
this
.
enumSource
[
i
]);
select_titles
=
select_titles
.
concat
(
this
.
enumSource
[
i
]);
}
else
{
var
items
=
[];
// Static list of items
if
(
Array
.
isArray
(
this
.
enumSource
[
i
].
source
))
{
items
=
this
.
enumSource
[
i
].
source
;
// A watched field
}
else
{
items
=
vars
[
this
.
enumSource
[
i
].
source
];
}
if
(
items
)
{
// Only use a predefined part of the array
if
(
this
.
enumSource
[
i
].
slice
)
{
items
=
Array
.
prototype
.
slice
.
apply
(
items
,
this
.
enumSource
[
i
].
slice
);
}
// Filter the items
if
(
this
.
enumSource
[
i
].
filter
)
{
var
new_items
=
[];
for
(
j
=
0
;
j
<
items
.
length
;
j
++
)
{
if
(
this
.
enumSource
[
i
].
filter
({
i
:
j
,
item
:
items
[
j
],
watched
:
vars
}))
new_items
.
push
(
items
[
j
]);
}
items
=
new_items
;
}
if
(
this
.
enumSource
[
i
].
filter2
)
{
var
xxx
=
vars
[
this
.
enumSource
[
i
].
filter2
];
if
(
xxx
)
{
var
new_items
=
[];
new_items
=
items
.
filter
(
item22
=>
(
item22
.
value
&&
item22
.
value
.
indexOf
(
xxx
)
>=
0
));
new_items
.
unshift
({
text
:
"--"
,
id
:
""
});
items
=
new_items
;
}
}
if
(
this
.
enumSource
[
i
].
filter3
)
{
var
xxx
=
vars
[
this
.
enumSource
[
i
].
filter3
];
var
new_items
=
[];
if
(
xxx
)
{
Http
.
getInstance
().
get
(
`/dabuilds/
${
xxx
}
/dametrics/fetchdefault`
,{},
false
)
.
then
((
response
:
any
)
=>
{
if
(
response
.
status
===
200
&&
response
.
data
)
{
response
.
data
.
forEach
((
item
:
any
)
=>
{
new_items
.
push
(
item
);
});
}
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
error
)
})
}
new_items
.
unshift
({
text
:
"--"
,
id
:
""
});
items
=
new_items
;
}
if
(
this
.
enumSource
[
i
].
filterText
)
{
var
xxx
=
vars
[
this
.
enumSource
[
i
].
filterText
];
if
(
xxx
)
{
var
new_items
=
[];
new_items
=
items
.
filter
(
item22
=>
(
item22
.
text
&&
item22
.
text
.
indexOf
(
xxx
)
>=
0
));
new_items
.
unshift
({
text
:
"--"
,
id
:
""
});
items
=
new_items
;
}
}
var
item_titles
=
[];
var
item_values
=
[];
for
(
j
=
0
;
j
<
items
.
length
;
j
++
)
{
var
item
=
items
[
j
];
// Rendered value
if
(
this
.
enumSource
[
i
].
value
)
{
item_values
[
j
]
=
this
.
typecast
(
this
.
enumSource
[
i
].
value
({
i
:
j
,
item
:
item
}));
}
// Use value directly
else
{
item_values
[
j
]
=
items
[
j
];
}
// Rendered title
if
(
this
.
enumSource
[
i
].
title
)
{
item_titles
[
j
]
=
this
.
enumSource
[
i
].
title
({
i
:
j
,
item
:
item
});
}
// Use value as the title also
else
{
item_titles
[
j
]
=
item_values
[
j
];
}
}
// TODO: sort
select_options
=
select_options
.
concat
(
item_values
);
select_titles
=
select_titles
.
concat
(
item_titles
);
}
}
}
var
prev_value
=
this
.
value
;
this
.
theme
.
setSelectOptions
(
this
.
input
,
select_options
,
select_titles
);
this
.
enum_options
=
select_options
;
this
.
enum_display
=
select_titles
;
this
.
enum_values
=
select_options
;
if
(
this
.
select2
)
{
this
.
select2
.
select2
(
'destroy'
);
}
// If the previous value is still in the new select options, stick with it
if
(
select_options
.
indexOf
(
prev_value
)
!==
-
1
)
{
this
.
input
.
value
=
prev_value
;
this
.
value
=
prev_value
;
}
// Otherwise, set the value to the first select option
else
{
this
.
input
.
value
=
select_options
[
0
];
this
.
value
=
this
.
typecast
(
select_options
[
0
]
||
""
);
if
(
this
.
parent
)
this
.
parent
.
onChildEditorChange
(
this
);
else
this
.
jsoneditor
.
onChange
();
this
.
jsoneditor
.
notifyWatchers
(
this
.
path
);
}
this
.
setupSelect2
();
}
this
.
_super
();
},
getLink
:
function
(
data
)
{
var
holder
,
link
;
// Get mime type of the link
var
mime
=
data
.
mediaType
||
'application/javascript'
;
var
type
=
mime
.
split
(
'/'
)[
0
];
// Template to generate the link href
var
href
=
this
.
jsoneditor
.
compileTemplate
(
data
.
href
,
this
.
template_engine
);
var
relTemplate
=
this
.
jsoneditor
.
compileTemplate
(
data
.
rel
?
data
.
rel
:
data
.
href
,
this
.
template_engine
);
// Template to generate the link's download attribute
var
download
=
null
;
if
(
data
.
download
)
download
=
data
.
download
;
if
(
download
&&
download
!==
true
)
{
download
=
this
.
jsoneditor
.
compileTemplate
(
download
,
this
.
template_engine
);
}
{
link
=
holder
=
this
.
theme
.
getBlockLink
();
//holder.setAttribute('target','_blank');
holder
.
textContent
=
data
.
rel
;
// When a watched field changes, update the url
this
.
link_watchers
.
push
(
function
(
vars
)
{
var
url
=
href
(
vars
);
var
rel
=
relTemplate
(
vars
);
holder
.
setAttribute
(
'href'
,
url
);
holder
.
textContent
=
rel
||
url
;
});
}
if
(
download
&&
link
)
{
if
(
download
===
true
)
{
link
.
setAttribute
(
'download'
,
''
);
}
else
{
this
.
link_watchers
.
push
(
function
(
vars
)
{
link
.
setAttribute
(
'download'
,
download
(
vars
));
});
}
}
if
(
data
.
class
)
link
.
classList
.
add
(
data
.
class
);
if
(
this
.
jsoneditor
.
options
.
no_link_holder
){
holder
.
hidden
=
true
;
}
else
{
holder
.
hidden
=
false
;
}
return
holder
;
}
});
@
Component
({
components
:
{
...
...
@@ -285,7 +68,7 @@ export default class AppFormJsonDaChart extends AppFormJson {
"links"
:
[
{
"rel"
:
"查看"
,
"href"
:
"javascript:window.show
field('{{self}}'
)"
// "/dstweb/index.html#/common_index/analyse_dametriceditview/srfkey={{self}}"
"href"
:
"javascript:window.show
detail('dametric-edit-view',{'dametrics':'{{self}}'}
)"
// "/dstweb/index.html#/common_index/analyse_dametriceditview/srfkey={{self}}"
}
],
options
:
{
...
...
@@ -294,9 +77,9 @@ export default class AppFormJsonDaChart extends AppFormJson {
value
:
''
}
},
"enumSource"
:[{
"source"
:[...[{
text
:
"--"
,
value
:
""
}]],
"url"
:
"/"
,
"filter3"
:
"entity12"
,
"title"
:
"{{item.text}}"
,
"value"
:
"{{item.value
}}"
}]
"enumSource"
:[{
"source"
:[...[{
metric_name
:
"--"
,
metric_id
:
""
}]],
"p0"
:
"entity12"
,
"url"
:
'/dabuilds/${p0}/dametrics/fetchdefault'
,
"title"
:
"{{item.metric_name}}"
,
"value"
:
"{{item.metric_id
}}"
}]
},
"children"
:
{
"type"
:
"array"
,
...
...
@@ -347,23 +130,5 @@ export default class AppFormJsonDaChart extends AppFormJson {
return
_schema
;
}
public
showfield
(
arg
:
any
)
{
const
data
:
any
=
{
"srfkey"
:
arg
};
const
view
:
any
=
{
viewname
:
'dametric-edit-view'
,
height
:
0
,
width
:
0
,
title
:
'指标编辑视图'
,
};
this
.
$appmodal
.
openModal
(
view
,
{
"dametrics"
:
arg
},{});
}
}
</
script
>
\ No newline at end of file
app_web/src/components/app-form-json/app-form-json.vue
浏览文件 @
71a3a8e1
...
...
@@ -9,6 +9,7 @@
import
{
Component
,
Vue
,
Prop
,
Model
,
Watch
}
from
"vue-property-decorator"
;
import
{
VNode
,
CreateElement
}
from
"vue"
;
import
{
interval
,
Subject
,
Subscription
}
from
"rxjs"
;
import
{
Http
,
Util
}
from
'@/utils'
;
import
JSONEditor
from
"@json-editor/json-editor"
;
import
BootstrapVue
from
"bootstrap-vue"
;
import
"bootstrap/dist/css/bootstrap.css"
;
...
...
@@ -16,6 +17,250 @@ import "bootstrap/dist/css/bootstrap.css";
import
"bootstrap-vue/dist/bootstrap-vue.css"
;
import
"../app-form-json/app-form-json.less"
;
JSONEditor
.
defaults
.
resolvers
.
unshift
(
schema
=>
{
if
(
schema
.
type
===
"selectnew"
)
{
return
"selectnew"
;
}
else
if
(
schema
.
type
===
"link"
)
{
return
"link"
;
}
// If no valid editor is returned, the next resolver function will be used
});
JSONEditor
.
defaults
.
editors
.
selectnew
=
JSONEditor
.
defaults
.
editors
.
select
.
extend
({
onWatchedFieldChange
:
function
()
{
var
self
=
this
,
vars
,
j
;
// If this editor uses a dynamic select box
if
(
this
.
enumSource
)
{
vars
=
this
.
getWatchedFieldValues
();
var
select_options
=
[];
var
select_titles
=
[];
for
(
var
i
=
0
;
i
<
this
.
enumSource
.
length
;
i
++
)
{
// Constant values
if
(
Array
.
isArray
(
this
.
enumSource
[
i
]))
{
select_options
=
select_options
.
concat
(
this
.
enumSource
[
i
]);
select_titles
=
select_titles
.
concat
(
this
.
enumSource
[
i
]);
}
else
{
var
items
=
[];
// Static list of items
if
(
Array
.
isArray
(
this
.
enumSource
[
i
].
source
))
{
items
=
this
.
enumSource
[
i
].
source
;
// A watched field
}
else
{
items
=
vars
[
this
.
enumSource
[
i
].
source
];
}
if
(
items
)
{
// Only use a predefined part of the array
if
(
this
.
enumSource
[
i
].
slice
)
{
items
=
Array
.
prototype
.
slice
.
apply
(
items
,
this
.
enumSource
[
i
].
slice
);
}
// Filter the items
if
(
this
.
enumSource
[
i
].
filter
)
{
var
new_items
=
[];
for
(
j
=
0
;
j
<
items
.
length
;
j
++
)
{
if
(
this
.
enumSource
[
i
].
filter
({
i
:
j
,
item
:
items
[
j
],
watched
:
vars
}))
new_items
.
push
(
items
[
j
]);
}
items
=
new_items
;
}
if
(
this
.
enumSource
[
i
].
codelist
)
{
var
codelist
=
this
.
enumSource
[
i
].
codelist
;
if
(
codelist
&&
items
.
length
<=
1
)
{
var
new_items
=
[];
Http
.
getInstance
().
get
(
url
,{},
false
)
.
then
((
response
:
any
)
=>
{
if
(
response
.
status
===
200
&&
response
.
data
)
{
response
.
data
.
forEach
((
item
:
any
)
=>
{
new_items
.
push
(
item
);
});
}
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
error
)
})
new_items
.
unshift
(
JSON
.
parse
(
JSON
.
stringify
(
items
[
0
])));
items
=
new_items
;
}
}
if
(
this
.
enumSource
[
i
].
url
)
{
var
url
=
this
.
enumSource
[
i
].
url
;
var
p0
=
vars
[
this
.
enumSource
[
i
].
p0
];
var
p1
=
vars
[
this
.
enumSource
[
i
].
p1
];
var
p2
=
vars
[
this
.
enumSource
[
i
].
p2
];
if
(
p0
)
url
=
url
.
replace
(
'${p0}'
,
p0
);
if
(
p1
)
url
=
url
.
replace
(
'${p1}'
,
p1
);
if
(
p2
)
url
=
url
.
replace
(
'${p2}'
,
p2
);
var
new_items
=
[];
if
(
p0
)
{
Http
.
getInstance
().
get
(
url
,{},
false
)
.
then
((
response
:
any
)
=>
{
if
(
response
.
status
===
200
&&
response
.
data
)
{
response
.
data
.
forEach
((
item
:
any
)
=>
{
new_items
.
push
(
item
);
});
}
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
error
)
})
}
new_items
.
unshift
(
JSON
.
parse
(
JSON
.
stringify
(
items
[
0
])));
items
=
new_items
;
}
if
(
this
.
enumSource
[
i
].
filterText
)
{
var
filterText
=
vars
[
this
.
enumSource
[
i
].
filterText
];
if
(
filterText
)
{
var
new_items
=
[];
new_items
=
items
.
filter
(
item22
=>
((
item22
.
text
&&
item22
.
text
.
indexOf
(
filterText
)
>=
0
)
||
(
item22
.
value
&&
item22
.
value
.
indexOf
(
filterText
)
>=
0
)
||
(
item22
.
filter
&&
item22
.
filter
.
indexOf
(
filterText
)
>=
0
)));
new_items
.
unshift
({
text
:
"--"
,
id
:
""
});
items
=
new_items
;
}
}
var
item_titles
=
[];
var
item_values
=
[];
for
(
j
=
0
;
j
<
items
.
length
;
j
++
)
{
var
item
=
items
[
j
];
// Rendered value
if
(
this
.
enumSource
[
i
].
value
)
{
item_values
[
j
]
=
this
.
typecast
(
this
.
enumSource
[
i
].
value
({
i
:
j
,
item
:
item
}));
}
// Use value directly
else
{
item_values
[
j
]
=
items
[
j
];
}
// Rendered title
if
(
this
.
enumSource
[
i
].
title
)
{
item_titles
[
j
]
=
this
.
enumSource
[
i
].
title
({
i
:
j
,
item
:
item
});
}
// Use value as the title also
else
{
item_titles
[
j
]
=
item_values
[
j
];
}
}
// TODO: sort
select_options
=
select_options
.
concat
(
item_values
);
select_titles
=
select_titles
.
concat
(
item_titles
);
}
}
}
var
prev_value
=
this
.
value
;
this
.
theme
.
setSelectOptions
(
this
.
input
,
select_options
,
select_titles
);
this
.
enum_options
=
select_options
;
this
.
enum_display
=
select_titles
;
this
.
enum_values
=
select_options
;
if
(
this
.
select2
)
{
this
.
select2
.
select2
(
'destroy'
);
}
// If the previous value is still in the new select options, stick with it
if
(
select_options
.
indexOf
(
prev_value
)
!==
-
1
)
{
this
.
input
.
value
=
prev_value
;
this
.
value
=
prev_value
;
}
// Otherwise, set the value to the first select option
else
{
this
.
input
.
value
=
select_options
[
0
];
this
.
value
=
this
.
typecast
(
select_options
[
0
]
||
""
);
if
(
this
.
parent
)
this
.
parent
.
onChildEditorChange
(
this
);
else
this
.
jsoneditor
.
onChange
();
this
.
jsoneditor
.
notifyWatchers
(
this
.
path
);
}
this
.
setupSelect2
();
}
this
.
_super
();
},
getLink
:
function
(
data
)
{
var
holder
,
link
;
// Get mime type of the link
var
mime
=
data
.
mediaType
||
'application/javascript'
;
var
type
=
mime
.
split
(
'/'
)[
0
];
// Template to generate the link href
var
href
=
this
.
jsoneditor
.
compileTemplate
(
data
.
href
,
this
.
template_engine
);
var
relTemplate
=
this
.
jsoneditor
.
compileTemplate
(
data
.
rel
?
data
.
rel
:
data
.
href
,
this
.
template_engine
);
// Template to generate the link's download attribute
var
download
=
null
;
if
(
data
.
download
)
download
=
data
.
download
;
if
(
download
&&
download
!==
true
)
{
download
=
this
.
jsoneditor
.
compileTemplate
(
download
,
this
.
template_engine
);
}
{
link
=
holder
=
this
.
theme
.
getBlockLink
();
//holder.setAttribute('target','_blank');
holder
.
textContent
=
data
.
rel
;
// When a watched field changes, update the url
this
.
link_watchers
.
push
(
function
(
vars
)
{
var
url
=
href
(
vars
);
var
rel
=
relTemplate
(
vars
);
holder
.
setAttribute
(
'href'
,
url
);
holder
.
textContent
=
rel
||
url
;
});
}
if
(
download
&&
link
)
{
if
(
download
===
true
)
{
link
.
setAttribute
(
'download'
,
''
);
}
else
{
this
.
link_watchers
.
push
(
function
(
vars
)
{
link
.
setAttribute
(
'download'
,
download
(
vars
));
});
}
}
if
(
data
.
class
)
link
.
classList
.
add
(
data
.
class
);
if
(
this
.
jsoneditor
.
options
.
no_link_holder
){
holder
.
hidden
=
true
;
}
else
{
holder
.
hidden
=
false
;
}
return
holder
;
}
});
JSONEditor
.
defaults
.
editors
.
link
=
JSONEditor
.
defaults
.
editors
.
string
.
extend
({
getLink
:
function
(
data
)
{
var
holder
,
link
;
...
...
@@ -188,6 +433,7 @@ export default class AppFormJson extends Vue {
*/
public
destroyed
()
{
if
(
this
.
editor
)
this
.
editor
=
null
;
window
[
"showdetail"
]
=
null
;
}
/**
...
...
@@ -204,6 +450,7 @@ export default class AppFormJson extends Vue {
this
.
renderJsoneditor
();
}
});
window
[
"showdetail"
]
=
this
.
showdetail
;
}
/**
...
...
@@ -280,5 +527,18 @@ export default class AppFormJson extends Vue {
this
.
editor
.
setValue
({});
}
}
public
showdetail
(
path
:
any
,
arg
:
any
)
{
const
view
:
any
=
{
viewname
:
path
,
height
:
0
,
width
:
0
,
title
:
'查看'
,
};
this
.
$appmodal
.
openModal
(
view
,
arg
,{});
}
}
</
script
>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录