<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 AppFormJsonFieldSet extends AppFormJson {
  public codeListService: CodeListService = new CodeListService({
    $store: this.$store,
  });

  public async getSchema(): Promise<any> {
    let _schema = {
      title: "指标",
      type: "object",
      format: "grid",
      id: "arr_columnDefs",
      $ref: "#/definitions/fieldDefs",
      definitions: {
        fieldDefs: {
          type: "object",
          title: "指标",
          required: [
            "metricentity",
            "metricfield",
            "timeentity",
            "timefield",
            "domainsentity",
            "domainsfield",
            "dimentity",
            "dimfield",

            "keyvalueentity",
            "keyvaluefield",
            "businesscatentity",
            "businesscatfield",
            "ext1entity",
            "ext1field",
            "ext2entity",
            "ext2field",

            "modelid",
          ],
          properties: {
            modelid: {
              type: "string",
              title: "模型",
              options: {
                grid_columns: 12,
                hidden: true,
                 select2_options: {
                  width: 350, 
                },
              },
              enumSource: [
                {
                  source: [
                    { id: this.data.modelid, text: this.data.modelname },
                  ],
                  title: "{{item.text}}",
                  value: "{{item.id}}",
                },
              ],
              propertyOrder: 21,
            },
            metricentity: {
              type: "selectnew",
              title: "指标实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 4,
            },
            metricfield: {
              type: "selectnew",
              title: "指标属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.metricentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 5,
            },

            timeentity: {
              type: "selectnew",
              title: "时间实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 6,
            },
            timefield: {
              type: "selectnew",
              title: "时间属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.timeentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 7,
            },

            domainsentity: {
              type: "selectnew",
              title: "分区实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                  grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 8,
            },
            domainsfield: {
              type: "selectnew",
              title: "分区属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.domainsentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 9,
            },

            dimentity: {
              type: "selectnew",
              title: "维度实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                  grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 10,
            },
            dimfield: {
              type: "selectnew",
              title: "维度属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.dimentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 11,
            },

            keyvalueentity: {
              type: "selectnew",
              title: "标示实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                 grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 12,
            },
            keyvaluefield: {
              type: "selectnew",
              title: "标示属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.keyvalueentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                   width: 250,
                  value: "",
                },
              },
              propertyOrder: 13,
            },


            businesscatentity: {
              type: "selectnew",
              title: "业务类别实体",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                 grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 14,
            },
            businesscatfield: {
              type: "selectnew",
              title: "业务类别属性",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.businesscatentity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                   width: 250,
                  value: "",
                },
              },
              propertyOrder: 15,
            },

            ext1entity: {
              type: "selectnew",
              title: "附加实体1",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                grid_columns: 6,
                select2_options: {
                   width: 350,
                  value: "",
                },
              },
              propertyOrder: 16,
            },
            ext1field: {
              type: "selectnew",
              title: "附加属性1",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.ext1entity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6,
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 17,
            },

            ext2entity: {
              type: "selectnew",
              title: "附加实体2",
              watch: {
                modelid: "arr_columnDefs.modelid",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  url: "/dst/datamodels/${p0}/allpropertys",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],
              options: {
                grid_columns: 6,
                select2_options: {
                  width: 350,
                  value: "",
                },
              },
              propertyOrder: 18,
            },
            ext2field: {
              type: "selectnew",
              title: "附加属性2",
              watch: {
                modelid: "arr_columnDefs.modelid",
                entity: "arr_columnDefs.ext2entity",
              },
              enumSource: [
                {
                  source: [...[{ label: "--", id: "" }]],
                  p0: "modelid",
                  p1: "entity",
                  url: "/dst/datamodels/${p0}/allpropertys/${p1}/fields",
                  title: "{{item.label}}",
                  value: "{{item.id}}",
                },
              ],

              options: {
                grid_columns: 6, 
                select2_options: {
                  width: 250,
                  value: "",
                },
              },
              propertyOrder: 19,
            },
          },
        },
      },
    };

    return _schema;
  }
}
</script>