提交 45e338d4 编写于 作者: sq3536's avatar sq3536

arg

上级 c502eae8
...@@ -114,6 +114,7 @@ export default class CLMetric { ...@@ -114,6 +114,7 @@ export default class CLMetric {
Object.assign(itemdata,{value:item.metric_id}); Object.assign(itemdata,{value:item.metric_id});
Object.assign(itemdata,{text:item.metric_name}); Object.assign(itemdata,{text:item.metric_name});
Object.assign(itemdata,{label:item.metric_name}); Object.assign(itemdata,{label:item.metric_name});
Object.assign(itemdata,{filter:item.build_id});
...@@ -174,7 +175,7 @@ export default class CLMetric { ...@@ -174,7 +175,7 @@ export default class CLMetric {
Object.assign(tempData, { [name]: value }); Object.assign(tempData, { [name]: value });
}); });
} }
Object.assign(tempData,{page: 0, size: 1000}); Object.assign(tempData,{page: 0, size: 100000});
if(this.queryParamNames && Object.keys(this.queryParamNames).length > 0){ if(this.queryParamNames && Object.keys(this.queryParamNames).length > 0){
Object.assign(tempData,this.queryParamNames); Object.assign(tempData,this.queryParamNames);
} }
......
...@@ -113,8 +113,7 @@ export default class CLModel { ...@@ -113,8 +113,7 @@ export default class CLModel {
Object.assign(itemdata,{value:item.build_id}); Object.assign(itemdata,{value:item.build_id});
Object.assign(itemdata,{text:item.build_name}); Object.assign(itemdata,{text:item.build_name});
Object.assign(itemdata,{label:item.build_name}); Object.assign(itemdata,{label:item.build_name});
Object.assign(itemdata,{filter:item.system_id});
_items.push(itemdata); _items.push(itemdata);
}); });
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator"; import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { VNode, CreateElement } from "vue"; import { VNode, CreateElement } from "vue";
import { interval, Subject, Subscription } from "rxjs"; import { interval, Subject, Subscription } from "rxjs";
import { Http,Util } from '@/utils';
import JSONEditor from "@json-editor/json-editor"; import JSONEditor from "@json-editor/json-editor";
import BootstrapVue from "bootstrap-vue"; import BootstrapVue from "bootstrap-vue";
import "bootstrap/dist/css/bootstrap.css"; import "bootstrap/dist/css/bootstrap.css";
...@@ -11,7 +12,170 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -11,7 +12,170 @@ import CodeListService from "@/codelist/codelist-service";
import AppFormJson from './app-form-json.vue'; import AppFormJson from './app-form-json.vue';
import "./app-form-json-da-chart.less"; import "./app-form-json-da-chart.less";
JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({
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) { getLink: function(data) {
var holder, link; var holder, link;
...@@ -31,47 +195,7 @@ JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({ ...@@ -31,47 +195,7 @@ JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({
download = this.jsoneditor.compileTemplate(download, this.template_engine); download = this.jsoneditor.compileTemplate(download, this.template_engine);
} }
// Image links {
if(type === 'image') {
holder = this.theme.getBlockLinkHolder();
link = document.createElement('a');
link.setAttribute('target','_blank');
var image = document.createElement('img');
this.theme.createImageLink(holder,link,image);
// When a watched field changes, update the url
this.link_watchers.push(function(vars) {
var url = href(vars);
var rel = relTemplate(vars);
link.setAttribute('href',url);
link.setAttribute('title',rel || url);
image.setAttribute('src',url);
});
}
// Audio/Video links
else if(['audio','video'].indexOf(type) >=0) {
holder = this.theme.getBlockLinkHolder();
link = this.theme.getBlockLink();
link.setAttribute('target','_blank');
var media = document.createElement(type);
media.setAttribute('controls','controls');
this.theme.createMediaLink(holder,link,media);
// When a watched field changes, update the url
this.link_watchers.push(function(vars) {
var url = href(vars);
var rel = relTemplate(vars);
link.setAttribute('href',url);
link.textContent = rel || url;
media.setAttribute('src',url);
});
}
// Text links
else {
link = holder = this.theme.getBlockLink(); link = holder = this.theme.getBlockLink();
//holder.setAttribute('target','_blank'); //holder.setAttribute('target','_blank');
holder.textContent = data.rel; holder.textContent = data.rel;
...@@ -113,7 +237,7 @@ JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({ ...@@ -113,7 +237,7 @@ JSONEditor.defaults.editors.link = JSONEditor.defaults.editors.string.extend({
export default class AppFormJsonDaChart extends AppFormJson { export default class AppFormJsonDaChart extends AppFormJson {
public codeListService:CodeListService = new CodeListService({ $store: this.$store }); public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public async getSchema(): any{ public async getSchema(): Promise<any>{
let _schema = { let _schema = {
"title": "表头配置", "title": "表头配置",
"type": "array", "type": "array",
...@@ -153,7 +277,7 @@ export default class AppFormJsonDaChart extends AppFormJson { ...@@ -153,7 +277,7 @@ export default class AppFormJsonDaChart extends AppFormJson {
enumSource: [] enumSource: []
}, },
"field":{ "field":{
"type": "link", "type": "selectnew",
"title": "属性", "title": "属性",
"watch": { "watch": {
"entity12": "arr_columnDefs.entity" , "entity12": "arr_columnDefs.entity" ,
...@@ -170,8 +294,9 @@ export default class AppFormJsonDaChart extends AppFormJson { ...@@ -170,8 +294,9 @@ export default class AppFormJsonDaChart extends AppFormJson {
value: '' value: ''
} }
}, },
enumSource: [] "enumSource":[{"source":[...[{text:"--",value:""}]],
"url":"/",
"filter3":"entity12" , "title": "{{item.text}}", "value": "{{item.value}}"}]
}, },
"children": { "children": {
"type": "array", "type": "array",
...@@ -205,12 +330,20 @@ export default class AppFormJsonDaChart extends AppFormJson { ...@@ -205,12 +330,20 @@ export default class AppFormJsonDaChart extends AppFormJson {
let _fset = JSON.parse(JSON.stringify(this.$store.getters.getCodeList("CLMetric"))); // let _fset: Array<any> = [];
if (_fset) {
let _items = [...[{text:"--",id:""}],..._fset.items]; // try{
let sourceobj={"source":_items,"filterText":"entity12","title": "{{item.text}}", "value": "{{item.id}}"}; // const res = await this.codeListService.getItems("CLMetric");
_schema.definitions.columnDefs.properties.field.enumSource=[sourceobj]; // _fset.push(...res);
} // }catch(er){
// }
// if (_fset) {
// let _items = [...[{text:"--",id:""}],..._fset];
// let sourceobj={"source":_items,"filterText":"entity12","title": "{{item.text}}", "value": "{{item.id}}"};
// _schema.definitions.columnDefs.properties.field.enumSource=[sourceobj];
// }
return _schema; return _schema;
} }
......
...@@ -215,14 +215,14 @@ export default class AppFormJson extends Vue { ...@@ -215,14 +215,14 @@ export default class AppFormJson extends Vue {
public editor: any; public editor: any;
public async getSchema(): any{ public async getSchema(): Promise<any>{
if(this.schema) if(this.schema)
return this.schema; return this.schema;
else else
return {}; return {};
} }
public async getOptions(): any{ public async getOptions(): Promise<any>{
let _options={ let _options={
theme: "bootstrap3", theme: "bootstrap3",
iconlib: "fontawesome4", iconlib: "fontawesome4",
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册