ws 1 tahun lalu
induk
melakukan
13cb788d2a

+ 15 - 0
chuanyi_client2/src/api/datasource.js

@@ -412,6 +412,21 @@ export function delDataModelById(id) {
         method: 'post'
     })
 }
+/*
+ * 删除数据模型
+ * @param data
+ * @returns {AxiosPromise}
+ */
+export function delDataModelByIdList(data) {
+    return request({
+        url: '/dataModel/delDataModelByIdList',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data
+    })
+}
 
 /**
  * 根据 ID 查询数据模型

+ 70 - 1
chuanyi_client2/src/utils/luckysheettool.js

@@ -73,6 +73,9 @@ export function insertLuckysheetEChart({
     n('.'+u).mousedown(function(){return false});
     let S = r.init(document.getElementsByClassName(u)[0]);
     f.animation = false;
+	const height = getLegendHeight(j, f.legend.data)
+	console.log(height)
+	f.grid.bottom = height + 40
     S.on('finished', function() {
         // const imgBase = n(`.${u} canvas`)[0].toDataURL('image/png');
         // console.log(imgBase);
@@ -312,4 +315,70 @@ function changeValStr(str) {
     } else {
         return str;
     }
-}
+}
+
+function getLegendHeight(clazzw, data){
+        var height =0;
+
+        var legend = [];
+        console.log('legend',legend);
+        //主算法,将legend中的设置渲染为DOM元素,用dom元素的宽高来模拟legend组件在echarts内部的高度
+        var icongap = 5;//legend图形左右两边各有5个px的间隔
+        var left = 10,right = 10;
+        //计算legend组件的可用宽度
+        var chartWidth = legend.width||clazzw-left-right;
+		console.log(chartWidth)
+        //legend的padding
+        var padding = legend.padding || 0;
+        if($.isArray(padding)) padding = padding.join('px ')+'px';
+        else padding+='px';
+        //每个legend item之间的间隙(包括水平和垂直)
+        var itemGap = 5;
+        //创建一个不可见的模拟盒子
+        var $legendbox = $('<div class="legend-simulate-box"></div>').css({
+            width: (chartWidth+itemGap) +'px',
+            padding: padding,
+            'line-height': '1',
+            'box-sizing': 'border-box',
+            overflow: 'hidden',
+            'position': 'absolute',
+            'z-index': '-1',
+            'opacity': '0',
+            'filter': 'alpha(opacity=0)',
+            '-ms-filter': 'alpha(opacity=0)'
+        }).appendTo('body');
+        //模拟绘制单个legend item
+        var itemHeight = 14,itemWidth = 25;
+        console.log('itemHeight',itemHeight);
+        if(itemHeight%2!=0) itemHeight++;
+        if(itemWidth%2!=0) itemWidth++;
+        var fontSize = 12;
+        var fontWeight = 'normal';
+        $.each(data,function(i,name){
+            var $icon = $('<span></span>').css({
+                display: 'inline-block',
+                padding: '0 '+icongap+'px',
+                'box-sizing': 'content-box',
+                'width': itemWidth+'px',
+                'height': itemHeight+'px'
+            });
+            var $item = $('<div></div>').css({
+                'display': 'inline-block',
+                'float': 'left',
+                'margin-right': itemGap+'px',
+                'margin-bottom': itemGap+'px',
+                'font-size': fontSize+'px',
+                'font-weight': fontWeight,
+				'max-width': chartWidth - 30,
+				'white-space': 'nowrap',
+				'text-overflow': 'clip'
+            }).append($icon).append(name).appendTo($legendbox);
+        });
+        //得到模拟高度
+        console.log('legendbox',$legendbox.innerHeight());
+        console.log('itemGap',itemGap);
+        height = $legendbox.innerHeight()-itemGap;
+        //善后工作
+        $legendbox.remove();
+        return height;
+    }

+ 52 - 4
chuanyi_client2/src/views/data_model/index.vue

@@ -9,6 +9,12 @@
       </el-input>
       <el-button style="margin-left: 5px;" @click="searchRuleEvent">查询</el-button>
     </div>
+	<el-button type="danger"
+				class="cy-nav-btn"
+	           icon="el-icon-delete"
+	           size="mini"
+			    @click="multipleDelModel"
+	           style="float: right;">批量删除</el-button>
     <el-button type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline" size="mini" @click="handleAdd">新增四则运算</el-button>
     <el-button type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline" size="mini" @click="handleReplace">新增值替换</el-button>
     <el-divider></el-divider>
@@ -16,8 +22,11 @@
       <el-table
           :data="tableData" border :stripe="true"
           :header-cell-style="{background: '#E8E8E8'}"
+		  @selection-change="selectionLineChangeHandle"
           @sort-change="sortChange"
           style="width: 100%;">
+		  <el-table-column type="selection" width="55" align="center"/>
+		  <el-table-column type="index" label="序号" width="60" fixed align="center"/>
         <el-table-column
             align="center"
             sortable="custom"
@@ -168,7 +177,7 @@
                     placeholder="请输入值" style="width: 110px; margin: 0 10px;"></el-input>
           <span>时,则替换成</span>
           <el-input-number v-model="dataModelForm.replacingValue" size="mini" placeholder="请输入替换值"
-                           :min="0" :max="99" :controls="false" :precision="0" style="width: 110px; margin-left: 10px;"></el-input-number>
+                            :controls="false" :precision="0" style="width: 110px; margin-left: 10px;"></el-input-number>
         </el-form-item>
         <el-form-item label="替换规则②" prop="operationRuleTwo">
           <span>当数据项值为</span>
@@ -176,7 +185,7 @@
                     placeholder="请输入值" style="width: 110px; margin: 0 10px;"></el-input>
           <span>时,则替换成</span>
           <el-input-number v-model="dataModelForm.replacingValueTwo" size="mini" placeholder="请输入替换值"
-                           :min="0" :max="99" :controls="false" :precision="0" style="width: 110px; margin-left: 10px;"></el-input-number>
+                            :controls="false" :precision="0" style="width: 110px; margin-left: 10px;"></el-input-number>
         </el-form-item>
         <el-form-item style="text-align: center;">
           <el-button type="primary" @click="saveDataModelEvent">确定</el-button>
@@ -230,7 +239,7 @@ import {
   delDataModelById,
   getAllDataModel, getDataModelById,
   testDataModelById, testDataModelByModel,
-  updateDataModel
+  updateDataModel, delDataModelByIdList
 } from "@/api/datasource";
 
 export default {
@@ -240,6 +249,7 @@ export default {
   },
   data() {
     return {
+		selectionItems: [],
       breadcrumbList: ['数据模型'],
       dialogDataModelVisible: false,
       dialogDataModelTestVisible: false,
@@ -491,6 +501,16 @@ export default {
     saveDataModelEvent() {
       this.$refs['dataModelForm'].validate((valid) => {
         if (valid) {
+			const val1 = parseInt(this.dataModelForm.replacingValue);
+			if (val1 < 0 || val1 > 99) {
+				showAlertMsgWin(this, null, '替换规则①的替换值只能为0到99的整数,请重新输入!')
+				return
+			}
+			const val2 = parseInt(this.dataModelForm.replacingValueTwo);
+			if (val2 < 0 || val2 > 99) {
+				showAlertMsgWin(this, null, '替换规则②的替换值只能为0到99的整数,请重新输入!')
+				return
+			}
           if (this.dataModelForm.operationRule == this.dataModelForm.operationRuleTwo) {
             showAlertMsgWin(this, null, '值替换时两个规则不能一致!')
             return
@@ -584,7 +604,35 @@ export default {
         if (this.$refs['dataModelForm']) this.$refs['dataModelForm'].resetFields()
         if (this.$refs['dataModelTestForm']) this.$refs['dataModelTestForm'].resetFields()
       }
-    }
+    },
+	/** 多选事件 */
+	selectionLineChangeHandle(val) {
+	  this.selectionItems = val
+	},
+	/** 批量删除组数据中数据项 */
+	multipleDelModel() {
+	  if (!this.selectionItems || this.selectionItems.length == 0) {
+	    showAlertMsgWin(this, null, '请至少选择一条表达式!')
+	    return
+	  }
+	  showConfirmWin(this, null, '您确定要删除已选择的表达式吗?', () => {
+	    let ids = Array.from(this.selectionItems, ({ id }) => id)
+	    this.delItems(ids)
+	  })
+	},
+	/** 删除数据项 */
+	delItems(ids) {
+	  const loading = showLoading(this, '删除中,请稍候···')
+	  delDataModelByIdList(ids).then(res => {
+	    loading.close()
+	    showAlertMsgWin(this, null, '删除成功!')
+	    this.tablePage = 1
+	    this.getAllDataModel()
+	  }).catch((e) => {
+	    loading.close()
+	    showAlertWin(this, null, e)
+	  })
+	},
   }
 }
 </script>

+ 8 - 2
chuanyi_client2/src/views/report_template/index.vue

@@ -2404,11 +2404,17 @@ export default {
           subtext: this.barChartForm.subtitle,
           left: 'center'
         },
-        tooltip: {},
+		grid: {
+			
+		},
+        tooltip: {
+			top: 0
+		},
         legend: {
           show: this.barChartForm.showLegend == '1',
           orient: 'vertical',
-          left: 'left',
+          left: 0,
+		  bottom: 0,
           data: []
         },
         series: []