app-form-json-da-report.vue 8.1 KB
<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 });


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


  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": "展现",
                        "format": "grid",
                        "headerTemplate": "{{ self.headerName }}",
                        "required": ["headerName","entity","field"],
                        "properties": {
                            "headerName": {
                                "type": "string",
                                "title": "列头",
                                "default": "列名称",
                                 options: {
                                     grid_columns: 3,
                                    input_width: 250
                                },
                            },
                            "width": {
                                "type": "integer",
                                "title": "宽度",
                                "default": "50",
                                 options: {
                                       grid_columns: 3,
                                    input_width: 50
                                },
                            },
                            "entity": {
                                "type": "string",
                                "title": "模型",
                                options: {
                                      grid_columns: 3,
                                    select2_options: {
                                        width: 250,
                                        value: ''
                                    }
                                },
                                enumSource: []
                            },
                            "field":{
                                "type": "selectnew",
                                "title": "属性",
                                "watch": {
                                    "entity12":  "arr_columnDefs.entity" ,
                                },
                                "links": [
                                    {
                                        "rel": "查看 {{self}}",
                                        "href": "javascript:window.showdetail('dametric-edit-view',{'dametric':'{{self}}'})"
                                    }
                                ],
                                options: {
                                      grid_columns: 3,
                                    select2_options: {
                                        width: 250,
                                        value: ''
                                    }
                                },
                                "enumSource":[{"source":[...[{metric_name:"--",metric_id:""}]],  
                                    "p0":"entity12" ,"url":'/dabuilds/${p0}/dametrics/fetchdefault',
                                    "title": "{{item.metric_name}}", "value": "{{item.metric_id}}"}]
                            },
                           "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
                           		},
                           	},
                            "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>