app-form-json-da-chart.vue 5.0 KB
Newer Older
sq3536's avatar
sq3536 committed
1 2 3 4
<script lang='tsx'>
import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { VNode, CreateElement } from "vue";
import { interval, Subject, Subscription } from "rxjs";
sq3536's avatar
sq3536 committed
5
import { Http,Util } from '@/utils';
sq3536's avatar
sq3536 committed
6 7 8 9 10 11 12
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';

sq3536's avatar
sq3536 committed
13

sq3536's avatar
sq3536 committed
14 15 16 17 18
@Component({
    components: {
         
    }
})
sq3536's avatar
sq3536 committed
19
export default class AppFormJsonDaReport extends AppFormJson {
sq3536's avatar
sq3536 committed
20 21
  public codeListService:CodeListService = new CodeListService({ $store: this.$store });

sq3536's avatar
sq3536 committed
22
  public async  getSchema(): Promise<any>{
sq3536's avatar
sq3536 committed
23
            let _schema = {
sq3536's avatar
sq3536 committed
24
                "title": "图表配置",
sq3536's avatar
sq3536 committed
25
                "type": "array",
sq3536's avatar
sq3536 committed
26
                "format": "table",
sq3536's avatar
sq3536 committed
27 28 29 30
                "required": ["headerName"],
                "items": {
                    "$ref": "#/definitions/columnDefs"
                    },
sq3536's avatar
sq3536 committed
31
                "default":{headerName:"指标名称"},
sq3536's avatar
sq3536 committed
32 33 34 35 36 37 38 39 40 41
                "definitions": {
                    "columnDefs": {
                        "id" : "arr_columnDefs",
                        "type": "object",
                        "title": "展现",
                        "headerTemplate": "{{ self.headerName }}",
                        "required": ["headerName","entity","field"],
                        "properties": {
                            "headerName": {
                                "type": "string",
sq3536's avatar
sq3536 committed
42 43
                                "title": "指标自定义名称",
                                "default": "指标名称",
sq3536's avatar
sq3536 committed
44 45 46 47
                                 options: {
                                     grid_columns: 4,
                                    input_width: 250
                                },
sq3536's avatar
sq3536 committed
48 49 50 51 52
                            },
                            "entity": {
                                "type": "string",
                                "title": "模型",
                                options: {
sq3536's avatar
sq3536 committed
53
                                      grid_columns: 4,
sq3536's avatar
sq3536 committed
54 55 56 57 58 59 60 61
                                    select2_options: {
                                        width: 200,
                                        value: ''
                                    }
                                },
                                enumSource: []
                            },
                            "field":{
sq3536's avatar
sq3536 committed
62
                                "type": "selectnew",
sq3536's avatar
sq3536 committed
63 64 65 66 67 68 69
                                "title": "属性",
                                "watch": {
                                    "entity12":  "arr_columnDefs.entity" ,
                                },
                                "links": [
                                    {
                                        "rel": "查看",
sq3536's avatar
sq3536 committed
70
                                        "href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
sq3536's avatar
sq3536 committed
71 72 73
                                    }
                                ],
                                options: {
sq3536's avatar
sq3536 committed
74
                                      grid_columns: 4,
sq3536's avatar
sq3536 committed
75 76 77 78 79
                                    select2_options: {
                                        width: 350,
                                        value: ''
                                    }
                                },
sq3536's avatar
sq3536 committed
80 81 82
                                "enumSource":[{"source":[...[{metric_name:"--",metric_id:""}]],  
                                    "p0":"entity12" ,"url":'/dabuilds/${p0}/dametrics/fetchdefault',
                                    "title": "{{item.metric_name}}", "value": "{{item.metric_id}}"}]
sq3536's avatar
sq3536 committed
83 84 85 86 87 88
                            }
                        }
                    }
                }
            };

sq3536's avatar
sq3536 committed
89 90 91 92 93 94 95
            let _eset: Array<any> = [];
            try{
              
              let cond={};
              const localdata = window.localStorage.getItem('localdata');
              if(localdata) cond={"n_systemid_eq":localdata["dstsystemid"]};   
              const res = await this.codeListService.getItems("CLModel",{},cond);
sq3536's avatar
sq3536 committed
96
              _eset.push(...res);
sq3536's avatar
sq3536 committed
97 98
            }catch(er){}
            
sq3536's avatar
sq3536 committed
99 100 101 102 103 104 105 106 107 108
            if (_eset) {
                    let _items = [...[{text:"--",id:""}],..._eset];
                    let sourceobj={"source":_items,"title": "{{item.text}}", "value": "{{item.id}}"};
                    _schema.definitions.columnDefs.properties.entity.enumSource=[sourceobj];
            }





sq3536's avatar
sq3536 committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122
            // let _fset: Array<any> = [];

            //  try{
            //   const res = await this.codeListService.getItems("CLMetric");
            //   _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];
            // }
sq3536's avatar
sq3536 committed
123 124 125 126 127
            return _schema;
  }

}
</script>