rsbi 4 年之前
父节点
当前提交
52f29cff5b

+ 0 - 58
src/view/portal/LayoutCenter.vue

@@ -1,58 +0,0 @@
-<template>
-    <div class="layout-center">
-        <layout-param :pageInfo="pageInfo"></layout-param>
-        <layout-optarea :pageInfo="pageInfo"></layout-optarea>
-    </div>
-</template>
-
-<script>
-import {baseUrl} from '@/common/biConfig'
-import $ from 'jquery'
-import layoutParam from "./LayoutParam.vue"
-import LayoutOptarea from './LayoutOptarea.vue'
-
-export default {
-  components:{
-    layoutParam,
-    LayoutOptarea
-  },
-  props:{
-      pageInfo:{
-        type:Object,
-        required:true
-     }
-  },
-  data(){
-    return {
-        
-    }
-  },
-  mounted(){
-
-  },
-  computed: {
-     
-  },
-  methods: {
-     
-  },
-  watch: {
-  },
-  beforeMount(){
-   
-  },
-  beforeDestroy(){
-    
-  }
-}
-</script>
-
-<style lang="less" scoped>
-    @import "../../style/mixin";
-    
-    .layout-center {
-        position: inherit;
-        margin: 0 0 0 223px;
-        height: calc(100% - 35px);
-    }
-</style>

+ 110 - 4
src/view/portal/LayoutLeft.vue

@@ -57,6 +57,7 @@ export default {
   mounted(){
     this.initcubes();
     this.initdset();
+    this.regCompAndParamTree();
   },
   computed: {
      
@@ -68,6 +69,109 @@ export default {
     isActive(p){
         return this.tabActive === p ? "active" : ""
     },
+    regCompAndParamTree(){
+        let ts = this;
+        var dt = [{id:'params', text:'参数', icon:"fa fa-binoculars",state:{opened:true}, children:[
+            {id:"input", text:"输入框",li_attr:{tp:"param",ptp:"text"},icon:"fa fa-tag comp_color"},
+            {id:"radio", text:"单选框",li_attr:{tp:"param", ptp:"radio"},icon:"fa fa-tag comp_color"},
+            {id:"checkbox", text:"多选框",li_attr:{tp:"param",ptp:"checkbox"},icon:"fa fa-tag comp_color"},
+            {id:"dateselect", text:"日历框",li_attr:{tp:"param", ptp:"dateselect"},icon:"fa fa-tag comp_color"},
+            {id:"monthselect", text:"月份框",li_attr:{tp:"param", ptp:"monthselect"},icon:"fa fa-tag comp_color"},
+            {id:"yearselect", text:"年份框",li_attr:{tp:"param", ptp:"yearselect"},icon:"fa fa-tag comp_color"}
+        ]}
+        ];
+        var compDt = [{id:"text", text:"文本",li_attr:{tp:"comp"},icon:"fa fa-file-text-o"},
+            {id:"box", text:"数据块",li_attr:{tp:"comp"},icon:"fa fa-inbox"},
+            {id:"chart", text:"图表",li_attr:{tp:"comp"},icon:"fa fa-line-chart"},
+            {id:"grid", text:"表格",li_attr:{tp:"comp"},icon:"fa fa-table"},
+            {id:"table", text:"交叉表",li_attr:{tp:"comp"},icon:"fa fa-list-alt"}];
+        
+        var dragfunc = function(treeDiv){
+            $("#"+treeDiv+" .jstree-node").draggable({
+                cursor: "point",
+                appendTo: "body",
+                revert: 'invalid',
+                revertDuration: 250,
+                cursorAt: { top: 0, left: 'comptree' == treeDiv ? -10 :-35 },
+                helper:function(e){
+                    var id = $(this).find("a.jstree-anchor:first").text();
+                    return "<div class=\"vakata-dnd\"><span class=\"miconcancel glyphicon glyphicon-remove\"></span>"+id+"</div>";
+                },
+                start:function(e){
+                    var ref = $('#'+treeDiv).jstree(true),node = ref.get_node(this);
+                    if(node.id == 'params'){
+                        return false;
+                    }
+                    if(node.li_attr.tp == 'comp'){
+                        //resetWindows('min');
+                    }
+                    return true;
+                },
+                stop:function(e){
+                    var ref = $('#'+treeDiv).jstree(true),node = ref.get_node(this);
+                    if(node.li_attr.tp == 'comp'){
+                        //resetWindows('max');
+                    }
+                    $(".indicator").hide();
+                }
+            });
+        }
+        $('#paramtree').jstree({
+            core:{
+                data:dt
+            },
+            "plugins" : [
+                "wholerow"
+            ]
+        }).bind("ready.jstree",function(a, b){
+            dragfunc('paramtree');
+        }).bind("after_open.jstree", function(){
+            dragfunc('paramtree');
+        });
+        
+        $('#comptree').jstree({
+            core:{
+                data:compDt
+            },
+            "plugins" : [
+                "wholerow"
+            ]
+        }).bind("ready.jstree",function(a, b){
+            dragfunc('comptree');
+        })
+        
+        //参数接收
+        $("#optparam").droppable({
+            accept:"#paramtree .jstree-node",
+            tolerance:"pointer",
+            over:function(e, ui){
+                var ref = $("#paramtree").jstree(true);
+                var node = ref.get_node(ui.draggable[0]);
+                var tp = node.li_attr.tp;
+                if(tp == "param"){
+                    $("#optparam").css("border", "1px solid #ff0000");
+                    $(ui.helper[0]).find("span").removeClass("glyphicon-remove").addClass("glyphicon-ok");
+                }
+            },
+            out:function(e, ui){
+                $("#optparam").css("border", "1px solid #d3d3d3");
+                $(ui.helper[0]).find("span").removeClass("glyphicon-ok").addClass("glyphicon-remove");
+                
+            },
+            drop:function(e, ui){
+                var ref = $("#paramtree").jstree(true);
+                var node = ref.get_node(ui.draggable[0]);
+                var tp = node.li_attr.tp;
+                if(tp == "param"){
+                    $("#optparam").css("border", "1px solid #d3d3d3");
+                    var node = ref.get_node(ui.draggable[0]);
+                    ts.$parent.$refs['prarmAddForm'].newparam("insert", node.li_attr.ptp);
+                }
+            }
+            
+
+        });
+    },
     initdset(){
         let ref = $("#tabletree").jstree(true);
         if(ref){
@@ -117,13 +221,13 @@ export default {
                 success:(resp)=>{
                     let ret  = resp.rows.cols;
                     for(let i=0; i<ret.length; i++){
-                        dt.children.push({id:ret[i].name, text:ret[i].name, icon:'glyphicon glyphicon-menu-hamburger',li_attr:{id:ret[i].name,name:ret[i].name,dsetId:table.dsetId,dsid:table.dsid, tname:ret[i].tname,type:ret[i].type, expression: ret[i].expression}});
+                        dt.children.push({id:ret[i].name, text:ret[i].name, icon:'icon_kpi glyphicon glyphicon-menu-hamburger',li_attr:{id:ret[i].name,name:ret[i].name,dsetId:table.dsetId,dsid:table.dsid, tname:ret[i].tname,type:ret[i].type, expression: ret[i].expression}});
                     }
                     //添加动态字段
                     let dyna = resp.dynamic;
                     for(let i=0; dyna&&dyna!=null&&i<dyna.length; i++){
                         var r = dyna[i];
-                        dt.children.push({id:r.name, text:r.name, icon:'glyphicon glyphicon-menu-hamburger',li_attr:{id:r.name,name:r.name,dsetId:table.dsetId,dsid:table.dsid, tname:r.tname,type:r.type, expression: r.expression}});
+                        dt.children.push({id:r.name, text:r.name, icon:'icon_kpi glyphicon glyphicon-menu-hamburger',li_attr:{id:r.name,name:r.name,dsetId:table.dsetId,dsid:table.dsid, tname:r.tname,type:r.type, expression: r.expression}});
                     }
                     $('#tabletree').jstree({
                         core: {
@@ -230,7 +334,9 @@ export default {
         color: #555555;
         cursor: default;
     }
-    .icon_kpi {
-    color: #e07900;
+</style>
+<style lang="less">
+    .comp_color {
+        color:#23b7e5;
     }
 </style>

+ 4 - 2
src/view/portal/LayoutParam.vue

@@ -10,7 +10,7 @@ import $ from 'jquery'
 
 export default {
   components:{
-
+    
   },
   props:{
       pageInfo:{
@@ -30,7 +30,9 @@ export default {
      
   },
   methods: {
-     
+     newparam(type, ptype){
+
+     }
   },
   watch: {
   },

+ 223 - 0
src/view/portal/LayoutParamAdd.vue

@@ -0,0 +1,223 @@
+<template>
+    <el-dialog :title="title" :visible.sync="show" :close-on-click-modal="false" custom-class="nopadding">
+         <div class="el-dialog-div">
+           <el-form :model="param" ref="paramForm" :rules="rules" label-position="left">
+             <el-form-item label="参数标识" label-width="100px" prop="paramid">
+              <el-input v-model="param.paramid"></el-input>
+            </el-form-item>
+             <el-form-item label="显示名称" label-width="100px" prop="paramname">
+              <el-input v-model="param.paramname"></el-input>
+            </el-form-item>
+            <el-form-item label="长度" label-width="100px">
+              <el-input-number v-model="param.size" :min="5" :max="30"></el-input-number>
+            </el-form-item>
+            <el-form-item label="日期格式" label-width="100px">
+              <el-select v-model="param.tableId" placeholder="请选择" style="width:100%">
+                <el-option v-for="item in opts.dtformats[datetype]" :key="item" :label="item" :value="item">
+                </el-option>
+              </el-select>				    
+            </el-form-item>
+            <el-form-item label="最小值" label-width="100px">
+              <el-input v-model="param.minval"></el-input>
+            </el-form-item>
+            <el-form-item label="最大值" label-width="100px">
+              <el-input v-model="param.maxval" ></el-input>
+            </el-form-item>
+            <el-form-item label="默认值" label-width="100px">
+              <el-input v-model="param.defvalue"></el-input>
+            </el-form-item>
+            <el-form-item label="隐藏参数" label-width="100px">
+              <el-switch v-model="param.hiddenprm" active-color="#13ce66" inactive-color="#dbdcdc" active-value="y" inactive-value="n">
+              </el-switch>
+              <span class="text-warning"> 隐藏参数不会在页面中显示</span>
+            </el-form-item>
+
+            <fieldset>
+                <legend>值列表</legend>
+                <el-radio v-model="param.valtype" label="static">静态值</el-radio>
+                <el-radio v-model="param.valtype" label="dynamic">动态值</el-radio>
+                <template v-if="param.valtype === 'static'">
+                  <div>
+                  <el-button @click="handleClick()" type="primary" size="small">添加</el-button>
+                  </div>
+                   <el-table :data="param.option" style="width: 100%" border header-row-class-name="tableHeadbg">
+                    <el-table-column
+                      prop="value"
+                      label="Value">
+                    </el-table-column>
+                    <el-table-column
+                      prop="text"
+                      label="Text">
+                    </el-table-column>
+                   <el-table-column
+                    fixed="right"
+                    label="操作">
+                    <template slot-scope="scope">
+                      <el-button @click="handleClick(scope.value)" type="text" size="small">编辑</el-button>
+                      <el-button type="text" size="small">删除</el-button>
+                    </template>
+                  </el-table-column>
+                  </el-table>
+                </template>
+                <template v-if="param.valtype === 'dynamic'">
+                   <el-form-item label="数据" label-width="100px">
+                    <el-select v-model="param.tableId" @change="selectcube()" placeholder="请选择" style="width:100%">
+                      <el-option
+                      v-for="item in opts.datasetlist"
+                      :key="item.value"
+                      :label="item.label"
+                      :value="item.value">
+                      </el-option>
+                    </el-select>				    
+                  </el-form-item>
+                  <el-form-item label="映射字段" label-width="100px" >
+                    <el-select v-model="param.alias" placeholder="请选择" style="width:100%">
+                      <el-option
+                      v-for="item in opts.collist"
+                      :key="item.value"
+                      :label="item.label"
+                      :value="item.value">
+                      </el-option>
+                    </el-select>				    
+                  </el-form-item>
+                </template>
+            </fieldset>            
+           </el-form>
+         </div>
+         <div slot="footer" class="dialog-footer">
+          <el-button type="primary" @click="save()">确 定</el-button>
+          <el-button @click="show = false">取 消</el-button>
+        </div>
+    </el-dialog>
+</template>
+
+<script>
+import {baseUrl, ajax} from '@/common/biConfig'
+import $ from 'jquery'
+
+export default {
+  components:{
+
+  },
+  props:{
+      
+  },
+  data(){
+    return {
+        title:"",
+        show:false,
+        param:{
+          paramid:null,
+          paramname:null,
+          size:20,
+          defvalue:null,
+          hiddenprm:null,
+          valtype:"static",
+          tableId:null,
+          alias:null,
+          option:[{
+            value:1,
+            text:"a"
+          }],
+          dtformat:null,
+          minval:null,
+          maxval:null,
+        },
+        datetype:'day',
+        opts:{
+          datasetlist:[],
+          collist:[],
+          dtformats:{
+            yearselect: ['yyyy', 'yyyy年'],
+            monthselect:['yyyyMM', 'yyyy-MM', 'yyyy年MM月'],
+            dateselect:['yyyyMMdd', 'yyyy-MM-dd', 'yyyy年MM月dd日']
+          }
+        },
+        rules:{
+          paramid:[
+						{ required: true, message: '必填', trigger: 'blur' }
+          ],
+          paramname:[
+						{ required: true, message: '必填', trigger: 'blur' }
+					]
+        }
+    }
+  },
+  mounted(){
+    this.loadCubes();
+  },
+  computed: {
+     
+  },
+  methods: {
+     newparam(type, ptype, paramId){
+       this.title = "创建参数 - " + this.getParamTypeDesc(ptype);
+       this.show = true;
+       this.datetype = ptype;
+     },
+     save(){
+        let ts = this;
+				this.$refs['paramForm'].validate((valid) => {
+           if(valid){
+              this.show = false;
+               this.$destroy();
+           }
+        });
+     },
+     getParamTypeDesc(paramType){
+        var tpname = "";
+        if(paramType == "text"){
+          tpname = "输入框";
+        }else if(paramType == "radio"){
+          tpname = "单选框";
+        }else if(paramType == "checkbox"){
+          tpname = "多选框";
+        }else if(paramType == "dateselect"){
+          tpname = "日历框";
+        }else if(paramType == "monthselect"){
+          tpname = "月份框";
+        }else if(paramType == "yearselect"){
+          tpname = "年份框";
+        }
+        return tpname;
+    },
+    loadCubes(){
+      ajax({
+        url:"model/listCube.action",
+        data:{},
+        type:"GET",
+        success:(resp)=>{
+          this.opts.datasetlist = resp.rows.map(m=>{
+            return {value:m.cubeId, label:m.cubeName}
+          });
+          //清空字段列表
+          this.param.alias = null;
+        }
+      }, this);
+    },
+    selectcube(){
+      ajax({
+        url:"bireport/queryDims.action",
+        data:{cubeId:this.param.tableId},
+        type:"GET",
+        success:resp=>{
+          this.opts.collist = resp.rows.map(m=>{
+            return {value:m.alias, label:m.col_name}
+          });
+        }
+      }, this);
+    }
+  },
+  watch:{
+    show:(v)=>{
+      if(v === false){
+       
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+    @import "../../style/mixin";
+</style>

+ 14 - 4
src/view/portal/PortalIndexCustomiz.vue

@@ -11,22 +11,28 @@
         </el-submenu>
       </el-menu>
       <layout-left :pageInfo="pageInfo" ref="layoutleftForm"></layout-left>
-      <layout-center :pageInfo="pageInfo"></layout-center>
+      <div class="layout-center">
+        <layout-param ref="paramForm" :pageInfo="pageInfo"></layout-param>
+        <layout-optarea ref="optarea" :pageInfo="pageInfo"></layout-optarea>
+      </div>
       <portal-layout :pageInfo="pageInfo" ref="layout"></portal-layout>
       <selectCube ref="selectCubeForm" :callback="selectCubeCallback"></selectCube>
       <select-dset ref="selectDsetForm"></select-dset>
+       <layout-param-add ref="prarmAddForm"></layout-param-add>
   </div> 
 </template>
 <script>
 import layoutLeft from "./LayoutLeft.vue"
-import LayoutCenter from "./LayoutCenter.vue"
 import PortalLayout from "./PortalLayoutDailog.vue"
 import selectCube from "@/view/bireport/SelectCube"
 import SelectDset from "./SelectDset"
+import layoutParam from "./LayoutParam.vue"
+import LayoutOptarea from './LayoutOptarea.vue'
+import LayoutParamAdd from './LayoutParamAdd.vue'
 
 export default {
   name: "customizer",
-  components: {layoutLeft, LayoutCenter, PortalLayout, selectCube, SelectDset},
+  components: {layoutLeft, PortalLayout, selectCube, SelectDset, layoutParam, LayoutOptarea, LayoutParamAdd},
   props: {
 
   },
@@ -54,7 +60,6 @@ export default {
       this.pageInfo.selectDs = cubeId;
       var o = this.$refs['layoutleftForm'];
       o.tabActive = 'data-tab-2';
-      console.log(cubeId);
       o.initcubes();
     }
   },
@@ -74,4 +79,9 @@ export default {
     height: 100%;
     width: 100%;
   }
+  .layout-center {
+        position: inherit;
+        margin: 0 0 0 223px;
+        height: calc(100% - 35px);
+    }
 </style>