app-form-json-da-report.vue 8.1 KB
Newer Older
sq3536's avatar
sq3536 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<script lang='tsx'>
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";
import "bootstrap-vue/dist/bootstrap-vue.css";
import CodeListService from "@/codelist/codelist-service";
import AppFormJson from './app-form-json.vue';


@Component({
    components: {
         
    }
})
export default class AppFormJsonDaChart extends AppFormJson {
  public codeListService:CodeListService = new CodeListService({ $store: this.$store });

sq3536's avatar
sq3536 committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35

  public showdetail(path:any,arg:any)
  {
          const view: any = {
              viewname: path,
              height: 0,
              width: 0,
              title: '查看',
          };
          alert(arg.dametric);
          this.$appmodal.openModal(view, arg, {});
  }


sq3536's avatar
sq3536 committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  public async  getSchema(): Promise<any>{
            let _schema = {
                "title": "表头配置",
                "type": "array",
                "format": "tabs",
                "required": ["headerName"],
                "items": {
                    "$ref": "#/definitions/columnDefs"
                    },
                "default":{headerName:"列名称"},
                "definitions": {
                    "columnDefs": {
                        "id" : "arr_columnDefs",
                        "type": "object",
                        "title": "展现",
sq3536's avatar
sq3536 committed
51
                        "format": "grid",
sq3536's avatar
sq3536 committed
52 53 54 55 56 57 58
                        "headerTemplate": "{{ self.headerName }}",
                        "required": ["headerName","entity","field"],
                        "properties": {
                            "headerName": {
                                "type": "string",
                                "title": "列头",
                                "default": "列名称",
sq3536's avatar
sq3536 committed
59 60 61 62
                                 options: {
                                     grid_columns: 3,
                                    input_width: 250
                                },
sq3536's avatar
sq3536 committed
63 64 65 66 67
                            },
                            "width": {
                                "type": "integer",
                                "title": "宽度",
                                "default": "50",
sq3536's avatar
sq3536 committed
68 69 70 71
                                 options: {
                                       grid_columns: 3,
                                    input_width: 50
                                },
sq3536's avatar
sq3536 committed
72 73 74 75 76
                            },
                            "entity": {
                                "type": "string",
                                "title": "模型",
                                options: {
sq3536's avatar
sq3536 committed
77
                                      grid_columns: 3,
sq3536's avatar
sq3536 committed
78
                                    select2_options: {
sq3536's avatar
sq3536 committed
79
                                        width: 250,
sq3536's avatar
sq3536 committed
80 81 82 83 84 85 86 87 88 89 90 91 92
                                        value: ''
                                    }
                                },
                                enumSource: []
                            },
                            "field":{
                                "type": "selectnew",
                                "title": "属性",
                                "watch": {
                                    "entity12":  "arr_columnDefs.entity" ,
                                },
                                "links": [
                                    {
sq3536's avatar
sq3536 committed
93
                                        "rel": "查看 {{self}}",
sq3536's avatar
sq3536 committed
94 95 96 97
                                        "href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
                                    }
                                ],
                                options: {
sq3536's avatar
sq3536 committed
98
                                      grid_columns: 3,
sq3536's avatar
sq3536 committed
99
                                    select2_options: {
sq3536's avatar
sq3536 committed
100
                                        width: 250,
sq3536's avatar
sq3536 committed
101 102 103 104 105 106 107
                                        value: ''
                                    }
                                },
                                "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
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
                           "hide": {
                           		"type": "boolean",
                           		"title": "隐藏",
                           		"default": false,
                           		options: {
                           			grid_columns: 3,
                           			input_width: 250
                           		},
                           	},
                           	"valueGetter": {
                           		"type": "string",
                           		"title": "计算表达式",
                           		"default": "",
                           		options: {
                           			grid_columns: 12,
                           			input_width: 1000
                           		},
                           	},
                           	"valueSetter": {
                           		"type": "string",
                           		"title": "valueSetter",
                           		"default": "",
                           		options: {
                           			grid_columns: 12,
                           			input_width: 1000
                           		},
                           	},
                           	"valueFormatter": {
                           		"type": "string",
                           		"title": "",
                           		"default": "格式化",
                           		options: {
                           			grid_columns: 12,
                           			input_width: 1000
                           		},
                           	},
                           	"valueParser": {
                           		"type": "string",
                           		"title": "",
                           		"default": "valueParser",
                           		options: {
                           			grid_columns: 12,
                           			input_width: 1000
                           		},
                           	},
sq3536's avatar
sq3536 committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
                            "children": {
                                "type": "array",
                                "format": "tabs",
                                "required": ["headerName","entity","field"],
                                "title": "下级",
                                "items": {
                                    "$ref": "#/definitions/columnDefs"
                                },
                                "default":{headerName:"列名称"}
                            }
                        }
                    }
                }
            };

            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);
              _eset.push(...res);
            }catch(er){}
            
            if (_eset) {
                    let _items = [...[{text:"--",id:""}],..._eset];
                    let sourceobj={"source":_items,"title": "{{item.text}}", "value": "{{item.id}}"};
                    _schema.definitions.columnDefs.properties.entity.enumSource=[sourceobj];
            }





            // 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];
            // }
            return _schema;
  }

}
</script>