Merge branch 'dev' into pr@dev_st_fix

This commit is contained in:
dataeaseShu 2023-07-21 10:49:48 +08:00
commit 3e2c6b4c4b
16 changed files with 276 additions and 612 deletions

View File

@ -1,557 +0,0 @@
package io.dataease.commons.utils;
import io.dataease.dto.dataset.ExcelSheetData;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.base.domain.DatasetTableField;
import io.dataease.plugins.common.dto.datasource.TableField;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.InputStream;
import java.util.*;
/**
* @author y
* @create 2018-01-18 14:28
* @desc POI读取excel有两种模式一种是用户模式一种是事件驱动模式
* 采用SAX事件驱动模式解决XLSX文件可以有效解决用户模式内存溢出的问题
* 该模式是POI官方推荐的读取大数据的模式
* 在用户模式下数据量较大Sheet较多或者是有很多无用的空行的情况下容易出现内存溢出
* <p>
* 用于解决.xlsx2007版本大数据量问题
**/
public class ExcelXlsxReader extends DefaultHandler {
/**
* 自定义获取表格某些信
*/
public Map map = new TreeMap<String, String>();
/**
* 单元格中的数据可能的数据类型
*/
enum CellDataType {
BOOL, ERROR, FORMULA, INLINESTR, SSTINDEX, NUMBER, DATE, NULL
}
/**
* 共享字符串表
*/
private SharedStringsTable sst;
/**
* 上一次的索引值
*/
private String lastIndex;
/**
* 总行数
*/
private int totalRows = 0;
/**
* 一行内cell集合
*/
private List<String> cellList = new ArrayList<String>();
/**
* 判断整行是否为空行的标记
*/
private boolean flag = false;
/**
* 当前行
*/
private int curRow = 1;
/**
* 当前列
*/
private int curCol = 0;
/**
* T元素标识
*/
private boolean isTElement;
/**
* 单元格数据类型默认为字符串类型
*/
private CellDataType nextDataType = CellDataType.SSTINDEX;
private final DataFormatter formatter = new DataFormatter();
/**
* 单元格日期格式的索引
*/
private short formatIndex;
/**
* 日期格式字符串
*/
private String formatString;
//定义前一个元素和当前元素的位置用来计算其中空的单元格数量如A6和A8等
private String preRef = null, ref = null;
//定义该文档一行最大的单元格数用来补全一行最后可能缺失的单元格
private String maxRef = null;
public List<DatasetTableField> getDatasetTableFields() {
return datasetTableFields;
}
public void setDatasetTableFields(List<DatasetTableField> datasetTableFields) {
this.datasetTableFields = datasetTableFields;
}
private List<DatasetTableField> datasetTableFields = null;
/**
* 单元格
*/
private StylesTable stylesTable;
public List<TableField> fields = new ArrayList<>();
public List<List<String>> data = new ArrayList<>();
public List<ExcelSheetData> totalSheets = new ArrayList<>();
/**
* 是否为日期
*/
private boolean isDateFormat = false;
public Integer getObtainedNum() {
return obtainedNum;
}
public void setObtainedNum(Integer obtainedNum) {
this.obtainedNum = obtainedNum;
}
private Integer obtainedNum = null;
public List<TableField> getFields() {
return fields;
}
public void setFields(List<TableField> fields) {
this.fields = fields;
}
public List<List<String>> getData() {
return data;
}
public void setData(List<List<String>> data) {
this.data = data;
}
public int process(InputStream inputStream) throws Exception {
OPCPackage pkg = OPCPackage.open(inputStream);
XSSFReader xssfReader = new XSSFReader(pkg);
stylesTable = xssfReader.getStylesTable();
SharedStringsTable sst = xssfReader.getSharedStringsTable();
XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
parser.setFeature("http://xml.org/sax/features/external-general-entities", false);
parser.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
this.sst = sst;
parser.setContentHandler(this);
XSSFReader.SheetIterator sheets = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
while (sheets.hasNext()) { //遍历sheet
curRow = 1; //标记初始行为第一行
fields.clear();
data.clear();
InputStream sheet = sheets.next(); //sheets.next()和sheets.getSheetName()不能换位置否则sheetName报错
InputSource sheetSource = new InputSource(sheet);
parser.parse(sheetSource); //解析excel的每条记录在这个过程中startElement()characters()endElement()这三个函数会依次执行
ExcelSheetData excelSheetData = new ExcelSheetData();
excelSheetData.setData(new ArrayList<>(data));
excelSheetData.setExcelLabel(sheets.getSheetName());
excelSheetData.setFields(new ArrayList<>(fields));
totalSheets.add(excelSheetData);
sheet.close();
}
return totalRows; //返回该excel文件的总行数不包括首列和空行
}
/**
* 第一个执行
*
* @param uri
* @param localName
* @param name
* @param attributes
* @throws SAXException
*/
@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
if (this.obtainedNum != null && curRow > this.obtainedNum) {
return;
}
if (name.equalsIgnoreCase("mergeCell")) {
throw new RuntimeException(Translator.get("i18n_excel_have_merge_region"));
}
//c => 单元格
if ("c".equals(name)) {
//当前单元格的位置
ref = attributes.getValue("r");
//设定单元格类型
this.setNextDataType(attributes);
}
//当元素为t时
if ("t".equals(name)) {
isTElement = true;
} else {
isTElement = false;
}
//置空
lastIndex = "";
}
/**
* 第二个执行
* 得到单元格对应的索引值或是内容值
* 如果单元格类型是字符串INLINESTR数字日期lastIndex则是索引值
* 如果单元格类型是布尔值错误公式lastIndex则是内容值
*
* @param ch
* @param start
* @param length
* @throws SAXException
*/
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
if (this.obtainedNum != null && curRow > this.obtainedNum) {
return;
}
lastIndex += new String(ch, start, length);
}
/**
* 第三个执行
*
* @param uri
* @param localName
* @param name
* @throws SAXException
*/
@Override
public void endElement(String uri, String localName, String name) throws SAXException {
if (this.obtainedNum != null && curRow > this.obtainedNum) {
return;
}
//t元素也包含字符串
if (isTElement) { //这个程序没经过
//将单元格内容加入rowlist中在这之前先去掉字符串前后的空白符
String value = lastIndex.trim();
if (curRow == 1) {
TableField tableField = new TableField();
tableField.setFieldType("TEXT");
tableField.setFieldSize(65533);
tableField.setFieldName(value);
tableField.setRemarks(value);
this.fields.add(tableField);
}
cellList.add(curCol, value);
curCol++;
isTElement = false;
//如果里面某个单元格含有值则标识该行不为空行
if (value != null && !"".equals(value)) {
flag = true;
}
} else if ("v".equals(name)) {
//v => 单元格的值如果单元格是字符串则v标签的值为该字符串在SST中的索引
String value = this.getDataValue(lastIndex.trim(), "");//根据索引值获取对应的单元格值
if (preRef == null) {
preRef = "A" + curRow;
if (!preRef.equalsIgnoreCase(ref)) {
cellList.add(curCol, "");
// curCol++;
}
}
//补全单元格之间的空单元格
if (!"A".equals(preRef.substring(0, 1)) && curRow == 1 && preRef.equalsIgnoreCase(ref)) {
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
} else if (!ref.equals(preRef)) {
int len = countNullCell(ref, preRef);
for (int i = 0; i < len; i++) {
if (curCol < this.fields.size()) {
cellList.add(curCol, "");
if (curRow == 1) {
addField("", curCol);
}
curCol++;
}
}
}
if (curCol < this.fields.size()) {
cellList.add(curCol, value);
}
curCol++;
//如果里面某个单元格含有值则标识该行不为空行
if (value != null && !"".equals(value)) {
flag = true;
}
preRef = ref;
} else {
//如果标签名称为row这说明已到行尾
if ("row".equals(name)) {
//默认第一行为表头以该行单元格数目为最大数目
if (curRow == 1) {
maxRef = ref;
}
if (curRow > 1) {
for (int i = cellList.size(); i < this.fields.size(); i++) {
cellList.add("");
}
List<String> tmp = new ArrayList<>(cellList);
this.getData().add(tmp);
}
totalRows++;
cellList.clear();
curRow++;
curCol = 0;
preRef = null;
ref = null;
flag = false;
}
}
}
/**
* 处理数据类型
*
* @param attributes
*/
public void setNextDataType(Attributes attributes) {
nextDataType = CellDataType.NUMBER; //cellType为空则表示该单元格类型为数字
formatIndex = -1;
formatString = null;
isDateFormat = false;
String cellType = attributes.getValue("t"); //单元格类型
if ("b".equals(cellType)) { //处理布尔值
nextDataType = CellDataType.BOOL;
} else if ("e".equals(cellType)) { //处理错误
nextDataType = CellDataType.ERROR;
} else if ("inlineStr".equals(cellType)) {
nextDataType = CellDataType.INLINESTR;
} else if ("s".equals(cellType)) { //处理字符串
nextDataType = CellDataType.SSTINDEX;
} else if ("str".equals(cellType)) {
nextDataType = CellDataType.SSTINDEX;
}
String cellStyleStr = attributes.getValue("s"); //
if (cellStyleStr != null) {
int styleIndex = Integer.parseInt(cellStyleStr);
XSSFCellStyle style = this.stylesTable.getStyleAt(styleIndex);
formatIndex = style.getDataFormat();
formatString = style.getDataFormatString();
short format = this.formatIndex;
if ((14 <= format && format <= 17) || format == 20 || format == 22 || format == 31 || format == 35 || format == 45 || format == 46 || format == 47 || (57 <= format && format <= 59)
|| (175 < format && format < 178) || (182 <= format && format <= 196) || (210 <= format && format <= 213) || (208 == format)) { // 日期
isDateFormat = true;
}
}
}
/**
* 对解析出来的数据进行类型处理
*
* @param value 单元格的值
* value代表解析BOOL的为0或1 ERROR的为内容值FORMULA的为内容值INLINESTR的为索引值需转换为内容值
* SSTINDEX的为索引值需转换为内容值 NUMBER为内容值DATE为内容值
* @param thisStr 一个空字符串
* @return
*/
@SuppressWarnings("deprecation")
public String getDataValue(String value, String thisStr) {
String type = null;
switch (nextDataType) {
// 这几个的顺序不能随便交换交换了很可能会导致数据错误
case BOOL: //布尔值
char first = value.charAt(0);
thisStr = first == '0' ? "FALSE" : "TRUE";
type = "LONG";
break;
case ERROR: //错误
thisStr = "\"ERROR:" + value.toString() + '"';
break;
case FORMULA: //公式
thisStr = '"' + value.toString() + '"';
type = getType(thisStr);
break;
case INLINESTR:
XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
thisStr = rtsi.toString();
rtsi = null;
break;
case SSTINDEX: //字符串
String sstIndex = value.toString();
try {
int idx = Integer.parseInt(sstIndex);
if (sst != null) {
XSSFRichTextString rtss = new XSSFRichTextString(sst.getEntryAt(idx));//根据idx索引值获取内容值
thisStr = rtss.toString();
rtss = null;
} else {
thisStr = value.toString();
}
} catch (NumberFormatException ex) {
thisStr = value.toString();
}
break;
case NUMBER: //数字
if (formatString != null && isDateFormat) {
if (getDatasetTableFields() != null && getDatasetTableFields().get(curCol).getDeExtractType() == 1) {
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, "yyyy-mm-dd hh:mm:ss").trim();
} else {
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim();
}
} else {
thisStr = value;
}
thisStr = thisStr.replace("_", "").trim();
if (isDateFormat) {
type = "DATETIME";
isDateFormat = false;
if (formatString != null && formatString.contains("%")) {
type = getType(thisStr);
}
} else {
type = getType(thisStr);
}
break;
case DATE: //日期
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString);
// 对日期字符串作特殊处理去掉T
thisStr = thisStr.replace("T", " ");
type = "DATETIME";
break;
default:
thisStr = " ";
break;
}
if (curRow == 1) {
addField(thisStr, null);
} else {
if (CollectionUtils.isEmpty(this.getFields())) {
throw new RuntimeException(Translator.get("i18n_excel_header_empty"));
}
if (curCol >= this.fields.size()) {
return thisStr;
}
if (curRow == 2) {
if (type != null) {
this.getFields().get(curCol).setFieldType(type);
}
} else {
if (type != null) {
if (type.equalsIgnoreCase("TEXT")) {
this.getFields().get(curCol).setFieldType(type);
}
if (type.equalsIgnoreCase("DOUBLE") && this.getFields().get(curCol).getFieldType().equalsIgnoreCase("LONG")) {
this.getFields().get(curCol).setFieldType(type);
}
if (type.equalsIgnoreCase("DATETIME")) {
this.getFields().get(curCol).setFieldType(type);
}
}
}
}
return thisStr;
}
private void addField(String columeName, Integer index) {
TableField tableField = new TableField();
tableField.setFieldType("TEXT");
tableField.setFieldSize(65533);
tableField.setFieldName(columeName);
tableField.setRemarks(columeName);
if (index != null) {
this.fields.add(index, tableField);
} else {
this.fields.add(tableField);
}
}
private String getType(String thisStr) {
if (totalRows == 0) {
return "TEXT";
}
try {
if (thisStr.endsWith("%")) {
thisStr = thisStr.substring(0, thisStr.length() - 1);
thisStr = String.valueOf(Double.valueOf(thisStr) / 100);
}
Long.valueOf(thisStr);
return "LONG";
} catch (Exception e) {
try {
Double.valueOf(thisStr);
return "DOUBLE";
} catch (Exception ignore) {
}
}
return "TEXT";
}
public int countNullCell(String ref, String preRef) {
//excel2007最大行数是1048576最大列数是16384最后一列列名是XFD
String xfd = ref.replaceAll("\\d+", "");
String xfd_1 = preRef.replaceAll("\\d+", "");
xfd = fillChar(xfd, 3, '@', true);
xfd_1 = fillChar(xfd_1, 3, '@', true);
char[] letter = xfd.toCharArray();
char[] letter_1 = xfd_1.toCharArray();
int res = (letter[0] - letter_1[0]) * 26 * 26 + (letter[1] - letter_1[1]) * 26 + (letter[2] - letter_1[2]);
return res - 1;
}
public String fillChar(String str, int len, char let, boolean isPre) {
int len_1 = str.length();
if (len_1 < len) {
if (isPre) {
for (int i = 0; i < (len - len_1); i++) {
str = let + str;
}
} else {
for (int i = 0; i < (len - len_1); i++) {
str = str + let;
}
}
}
return str;
}
}

View File

@ -1,5 +1,11 @@
package io.dataease.service.dataset;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@ -51,6 +57,7 @@ import io.dataease.service.chart.util.ChartDataBuild;
import io.dataease.service.datasource.DatasourceService;
import io.dataease.service.engine.EngineService;
import io.dataease.service.sys.SysAuthService;
import lombok.Data;
import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.expression.BinaryExpression;
import net.sf.jsqlparser.expression.Expression;
@ -68,7 +75,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -2419,7 +2425,92 @@ public class DataSetTableService {
return excelFileData;
}
private List<ExcelSheetData> parseExcel(String filename, InputStream inputStream, boolean isPreview)
// public List<ExcelSheetData> parseExcel(String filename, InputStream inputStream, boolean isPreview) throws Exception {
// List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
// try {
// String suffix = filename.substring(filename.lastIndexOf(".") + 1);
// if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
//
// }
//
// if (StringUtils.equalsIgnoreCase(suffix, "csv")) {
// List<TableField> fields = new ArrayList<>();
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
// String s = reader.readLine();// first line
// String[] split = s.split(",");
// for (String s1 : split) {
// TableField tableFiled = new TableField();
// tableFiled.setName(s1);
// tableFiled.setOriginName(s1);
// tableFiled.setFieldType("TEXT");
// fields.add(tableFiled);
// }
// List<String[]> data = csvData(reader, isPreview);
// ExcelSheetData excelSheetData = new ExcelSheetData();
// String[] fieldArray = fields.stream().map(TableField::getName).toArray(String[]::new);
// excelSheetData.setFields(fields);
// excelSheetData.setData(data);
// excelSheetData.setExcelLabel(filename.substring(0, filename.lastIndexOf('.')));
// excelSheetDataList.add(excelSheetData);
// }
// inputStream.close();
// for (ExcelSheetData excelSheetData : excelSheetDataList) {
// List<String[]> data = excelSheetData.getData();
// String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getName).toArray(String[]::new);
//
// List<Map<String, Object>> jsonArray = new ArrayList<>();
// if (data != null) {
// jsonArray = data.stream().map(ele -> {
// Map<String, Object> map = new HashMap<>();
// for (int i = 0; i < fieldArray.length; i++) {
// map.put(fieldArray[i], i < ele.length ? ele[i] : "");
// }
// return map;
// }).collect(Collectors.toList());
// }
// excelSheetData.setJsonArray(jsonArray);
// };
// } catch (Exception e) {
// DEException.throwException(e);
// }
// return excelSheetDataList;
// }
public List<ExcelSheetData> excelSheetDataList(InputStream inputStream, boolean isPreview) {
List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
NoModelDataListener noModelDataListener = new NoModelDataListener();
ExcelReader excelReader = EasyExcel.read(inputStream, noModelDataListener).build();
List<ReadSheet> sheets = excelReader.excelExecutor().sheetList();
for (ReadSheet readSheet : sheets) {
noModelDataListener.clear();
List<TableField> fields = new ArrayList<>();
excelReader.read(readSheet);
for (String s : noModelDataListener.getHeader()) {
TableField tableFiled = new TableField();
tableFiled.setFieldType("TEXT");
tableFiled.setFieldName(s);
tableFiled.setRemarks(s);
fields.add(tableFiled);
}
List<List<String>> data = (isPreview && noModelDataListener.getData().size() > 1000 ? new ArrayList<>(noModelDataListener.getData().subList(0, 1000)) : noModelDataListener.getData());
if (isPreview) {
for (List<String> datum : data) {
for (int i = 0; i < datum.size(); i++) {
if (i < fields.size()) {
cellType(datum.get(i), i, fields.get(i));
}
}
}
}
ExcelSheetData excelSheetData = new ExcelSheetData();
excelSheetData.setFields(fields);
excelSheetData.setData(data);
excelSheetData.setExcelLabel(readSheet.getSheetName());
excelSheetDataList.add(excelSheetData);
}
return excelSheetDataList;
}
public List<ExcelSheetData> parseExcel(String filename, InputStream inputStream, boolean isPreview)
throws Exception {
List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
String suffix = filename.substring(filename.lastIndexOf(".") + 1);
@ -2430,10 +2521,7 @@ public class DataSetTableService {
excelSheetDataList = excelXlsReader.totalSheets;
}
if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
ExcelXlsxReader excelXlsxReader = new ExcelXlsxReader();
excelXlsxReader.setObtainedNum(1000);
excelXlsxReader.process(inputStream);
excelSheetDataList = excelXlsxReader.totalSheets;
excelSheetDataList = excelSheetDataList(inputStream, isPreview);
}
if (StringUtils.equalsIgnoreCase(suffix, "csv")) {
@ -3019,4 +3107,85 @@ public class DataSetTableService {
DataEaseException.throwException(e);
}
}
private String cellType(String value) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.parse(value);
return "DATETIME";
} catch (Exception e1) {
try {
Double d = Double.valueOf(value);
double eps = 1e-10;
if (d - Math.floor(d) < eps) {
return "LONG";
} else {
return "DOUBLE";
}
} catch (Exception e2) {
return "TEXT";
}
}
}
private void cellType(String value, int i, TableField tableFiled) {
if (StringUtils.isEmpty(value)) {
return;
}
if (i == 0) {
tableFiled.setFieldType(cellType(value));
} else {
String type = cellType(value);
if (type.equalsIgnoreCase("TEXT")) {
tableFiled.setFieldType(type);
}
if (type.equalsIgnoreCase("DOUBLE") && tableFiled.getFieldType().equalsIgnoreCase("LONG")) {
tableFiled.setFieldType(type);
}
}
}
@Data
public class NoModelDataListener extends AnalysisEventListener<Map<Integer, String>> {
private List<List<String>> data = new ArrayList<>();
private List<String> header = new ArrayList<>();
@Override
public void invokeHead(Map<Integer, CellData> headMap, AnalysisContext context) {
super.invokeHead(headMap, context);
for (Integer key : headMap.keySet()) {
CellData cellData = headMap.get(key);
String value = cellData.getStringValue();
if (StringUtils.isEmpty(value)) {
value = "none_" + key;
}
header.add(value);
}
}
@Override
public void invoke(Map<Integer, String> dataMap, AnalysisContext context) {
List<String> line = new ArrayList<>();
for (Integer key : dataMap.keySet()) {
String value = dataMap.get(key);
if (StringUtils.isEmpty(value)) {
value = "none";
}
line.add(value);
}
data.add(line);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
public void clear() {
data.clear();
header.clear();
}
}
}

View File

@ -739,10 +739,7 @@ public class ExtractDataService {
totalSheets = excelXlsReader.totalSheets;
}
if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
ExcelXlsxReader excelXlsxReader = new ExcelXlsxReader();
excelXlsxReader.setDatasetTableFields(datasetTableFields);
excelXlsxReader.process(new FileInputStream(excelSheetData.getPath()));
totalSheets = excelXlsxReader.totalSheets;
totalSheets = dataSetTableService.excelSheetDataList(new FileInputStream(excelSheetData.getPath()), false);
}
if (StringUtils.equalsIgnoreCase(suffix, "csv")) {

View File

@ -360,7 +360,7 @@ export default {
computed: {
// 使filter
initLoad() {
return !(this.isEdit && this.currentCanvasNewId.includes(this.element.id)) && this.isFirstLoad
return !(this.isEdit && this.currentCanvasNewId.includes(this.element.id)) && this.isFirstLoad && this.canvasId === 'canvas-main'
},
scaleCoefficient() {
if (this.terminal === 'pc' && !this.mobileLayoutStatus) {

View File

@ -6,7 +6,16 @@
class="item-axis"
@close="removeItem"
>
{{ item.name }}
<el-tooltip
v-if="toolTip"
class="item"
effect="dark"
:content="toolTip || item.name"
placement="top"
>
<span>{{ item.name }}</span>
</el-tooltip>
<span v-else>{{ item.name }}</span>
</el-tag>
</span>
</template>
@ -22,6 +31,11 @@ export default {
index: {
type: Number,
required: true
},
toolTip: {
type: String,
required: false,
default: ''
}
},

View File

@ -410,7 +410,7 @@ export default {
},
_filterFun(value, data, node) {
if (!value) return true
return data[this.propsLabel].indexOf(value) !== -1
return data[this.propsLabel?.toLocaleUpperCase()].indexOf(value.toLocaleUpperCase()) !== -1
},
_treeNodeClickFun(data, node, vm) {
const { multiple } = this.selectParams

View File

@ -121,7 +121,7 @@ export default {
},
keyWord(val, old) {
if (val === old) return
const results = val ? this.list.filter(item => item.text.includes(val)) : null
const results = val ? this.vagueFilter(val, this.list) : null
this.resetList(results)
this.reCacularHeight()
this.$nextTick(() => {
@ -136,6 +136,11 @@ export default {
})
},
methods: {
vagueFilter(val, nodes) {
if (!val || !val.trim()) return nodes
const results = nodes.filter(item => item.text?.toLocaleUpperCase().includes(val.toLocaleUpperCase()))
return results
},
resetSelectAll() {
this.selectAll = false
},
@ -148,7 +153,7 @@ export default {
selectAllChange(val) {
let vals = val ? [...this.list.map(ele => ele.id)] : []
if (this.keyWord.trim() && val) {
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id)
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id)
}
this.visualChange(vals)
this.selectValue = vals
@ -233,14 +238,14 @@ export default {
isAllSelect() {
let vals = this.list.length
if (this.keyWord.trim()) {
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id).filter(ele => this.selectValue.includes(ele)).length
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id).filter(ele => this.selectValue.includes(ele)).length
}
return vals
},
halfSelect() {
let vals = this.list.length
if (this.keyWord.trim()) {
vals = this.list.filter(item => item.text.includes(this.keyWord.trim())).map(ele => ele.id).length
vals = this.vagueFilter(this.keyWord.trim(), this.list).map(ele => ele.id).length
}
return vals
},

View File

@ -31,7 +31,7 @@
v-model="value"
@change="handleCheckedChange"
>
<template v-for="item in data.filter(node => !keyWord || (node.id && node.id.includes(keyWord)))">
<template v-for="item in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))">
<el-checkbox
:key="item.id"
:label="item.id"
@ -51,7 +51,7 @@
@change="changeRadioBox"
>
<el-radio
v-for="(item, index) in data.filter(node => !keyWord || (node.id && node.id.includes(keyWord)))"
v-for="(item, index) in data.filter(node => !keyWord || (node.id && node.id.toLocaleUpperCase().includes(keyWord.toLocaleUpperCase())))"
:key="index"
:label="item.id"
@click.native.prevent="testChange(item)"

View File

@ -381,7 +381,7 @@ export default {
_filterFun(value, data, node) {
if (!value) return true
return data.id.toString().indexOf(value.toString()) !== -1
return data.id.toString().toLocaleUpperCase().indexOf(value.toString().toLocaleUpperCase()) !== -1
},
//
_nodeClickFun(data, node, vm) {

View File

@ -626,7 +626,8 @@ export default {
status: 'Authorization status',
valid: 'Valid',
invalid: 'Invalid',
expired: 'Expired'
expired: 'Expired',
expired_msg: 'license has expired since {0}. It is recommended to update the license, which does not affect the use of enterprise version functions'
},
member: {
create: 'Add members',

View File

@ -626,7 +626,8 @@ export default {
status: '授權狀態',
valid: '有效',
invalid: '無效',
expired: '已過期'
expired: '已過期',
expired_msg: 'License已過期過期時間{0}為了不影響企業版功能的使用建議您更新License'
},
member: {
create: '添加成員',

View File

@ -625,7 +625,8 @@ export default {
status: '授权状态',
valid: '有效',
invalid: '无效',
expired: '已过期'
expired: '已过期',
expired_msg: 'License已过期过期时间{0}为了不影响企业版功能的使用建议您更新License'
},
member: {
create: '添加成员',

View File

@ -1,9 +1,18 @@
<template>
<div
v-if="!licValidate && licStatus !== 'no_record'"
class="lic"
v-if="!licValidate && licStatus !== 'no_record' && !tipClosed"
class="lic_tips"
>
<strong>{{ $t(licMsg) }}</strong>
<el-alert
class="lic_alert"
:title="$t(licMsg)"
type="warning"
show-icon
center
@close="closeTip"
/>
</div>
</template>
@ -20,9 +29,7 @@ export default {
}
},
computed: {
/* theme() {
return this.$store.state.settings.theme
}, */
licValidate() {
return this.$store.state.lic.validate
},
@ -30,40 +37,40 @@ export default {
return this.$store.state.lic.licStatus || ''
},
licMsg() {
if (this.$store.state.lic?.licMsg?.includes('expired')) {
const message = this.$store.state.lic.licMsg
const exp = message.substring(message.indexOf('since ') + 6, message.indexOf(','))
return this.$t('license.expired_msg').replace('{0}', exp)
}
return this.$store.state.lic.licMsg ? ('license.' + this.$store.state.lic.licMsg) : null
},
tipClosed() {
return localStorage.getItem('lic_closed')
}
},
mounted() {
// this.validate()
},
methods: {
// validate() {
// validateLic().then(res => {
// this.lic = true
// this.$store.dispatch('lic/setValidate', true)
// }).catch((e) => {
// this.msg = e.response.data.message
// this.lic = false
// this.$store.dispatch('lic/setValidate', false)
// })
// }
closeTip() {
localStorage.setItem('lic_closed', true)
}
}
}
</script>
<style lang="scss" scoped>
.lic {
height: 24px;
background-color: #c92100;
color: #fff;
text-align: center;
/* padding: 6px 11px; */
position: fixed;
z-index: 1002;
top: 0;
width: 100%;
}
.lic_tips {
position: absolute;
z-index: 2000;
position:absolute;
top: 0;left:0;right:0;
margin: auto;
}
.lic_alert ::v-deep .el-icon-close{
top: 16px !important;
right: 10px !important;
}
</style>

View File

@ -481,9 +481,11 @@ export default {
trackClick(trackAction) {
const param = this.pointParam
if (!param || !param.data || !param.data.dimensionList) {
//
if (this.chart.type === 'map') {
this.$warning(this.$t('panel.no_drill_field'))
const zoom = this.myChart.getOption().geo[0].zoom
if (zoom <= 1) {
this.$warning(this.$t('panel.no_drill_field'))
}
}
return
}

View File

@ -266,6 +266,7 @@
<div v-if="currentElement.options && currentElement.options.attrs">
<filter-head
:element="currentElement"
@dataset-name="dataSetName"
/>
<filter-control
@ -463,6 +464,23 @@ export default {
bus.$off('valid-values-change', this.validateFilterValue)
},
methods: {
dataSetName(tableId, callback) {
let result = null
if (tableId) {
const stack = [...this.defaultData]
while (stack.length) {
const tableNode = stack.pop()
if (tableNode.id === tableId) {
result = tableNode.name
break
}
if (tableNode.children?.length) {
tableNode.children.forEach(kid => stack.push(kid))
}
}
}
callback && callback(result)
},
async checkSuperior(list, anotherTableIds) {
let fieldValid = false
const fieldId = this.myAttrs?.fieldId

View File

@ -25,6 +25,7 @@
:key="item.id"
:item="item"
:index="index"
:tool-tip="getTableName(item.tableId)"
@closeItem="closeItem"
/>
@ -70,7 +71,12 @@ export default {
},
methods: {
getTableName(tableId) {
let tableName = null
this.$emit('dataset-name', tableId, t => { tableName = t })
console.log(tableName)
return tableName
},
onMove(e, originalEvent) {
return true
},