Browse Source

refactor: 补充提交

master
Zhenfei.Li 4 years ago
parent
commit
e3d4ecf553
  1. BIN
      fr-plugin-hwExcelExport-1.8.3.zip
  2. 6
      src/main/java/com/fr/plugin/decision/HWUtils.java
  3. 2
      src/main/java/com/fr/plugin/decision/http/IfTableExistHttpHandler.java
  4. 133
      src/main/resources/com/fr/plugin/hw/decision/js/attr/col.attr.js
  5. 17
      src/main/resources/com/fr/plugin/hw/decision/js/attr/col.attr.model.js
  6. 13
      src/main/resources/com/fr/plugin/hw/decision/js/hw.option.js
  7. 5
      src/main/resources/com/fr/plugin/hw/decision/js/pane/left.js
  8. 11
      src/main/resources/com/fr/plugin/hw/decision/js/pane/right.table.model.js
  9. 5
      src/main/resources/com/fr/plugin/hw/decision/js/table.info.js
  10. 45
      src/main/resources/com/fr/plugin/hw/decision/js/table.info.model.js

BIN
fr-plugin-hwExcelExport-1.8.3.zip

Binary file not shown.

6
src/main/java/com/fr/plugin/decision/HWUtils.java

@ -65,11 +65,7 @@ public class HWUtils {
XSSFCell cell = (XSSFCell) cellIterator.next();
String value = getString(cell);
if (StringUtils.isNotBlank(value)) {
JSONObject o = JSONObject.create().
put("titleRow", titleRow).
put("type", "12").
put("value", cell.getColumnIndex()).
put("text", value);
JSONObject o = JSONObject.create().put("titleRow", titleRow).put("value", cell.getColumnIndex()).put("text", value);
result.add(o);
}
}

2
src/main/java/com/fr/plugin/decision/http/IfTableExistHttpHandler.java

@ -40,7 +40,7 @@ public class IfTableExistHttpHandler extends BaseHttpHandler {
try {
if (conn == null){
FineLoggerFactory.getLogger().error("HW_excel导入:" + connection + "数据连接创建失败");
WebUtils.printAsJSON(res,new JSONObject().put("status","fail").put("errorText",connection + "数据连接创建失败,请检查数据连接是否正常!"));
WebUtils.printAsJSON(res,new JSONObject().put("status","fail").put("errorText",connection + "数据连接创建失败,请检查数据连接是否正常!"));
return;
}
smt = conn.createStatement();

133
src/main/resources/com/fr/plugin/hw/decision/js/attr/col.attr.js

@ -10,64 +10,88 @@
add: this.options.add
});
},
/*beforeInit: function (callback) {
this.store.initData(callback)
},*/
watch: {
count: function (v) {
this.table.setCount(v);
this.pager.setCount(v);
},
pages: function (v) {
this.pager.setAllPages(v);
},
perItems: function () {
this.table.populate(this._formatItems(this.model.perItems));
this.table.setPage(this.model.page);
this.table.populate(this._getFieldItems(), this._getFieldHeader(), {freezeScroll: true});
this.pager.setVPage(this.model.page);
},
page:function () {
this.table.setPage(this.model.page);
//this.popularExcelBox(this.model.excelItems);
this.pager.setVPage(this.model.page);
},
excelItems:function () {
this.popularExcelBox(this.model.excelItems);
}
},
mounted: function () {
this.table.setCount(this.model.count);
this.table.populate(this._formatItems(this.model.perItems));
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.absolute",
type: "bi.vertical",
items: [{
el: {
type: "dec.page.table",
header: [{text: "字段名"}, {text: "字段类型"}],
columnSize: ["0.6", "0.4"],
perPage: 5,
type: "bi.components.preview_table",
items: this._getFieldItems(),
header: this._getFieldHeader(),
columnSize: [480, 150],
height: 300,
tgap: 10,
ref: function (_ref) {
self.table = _ref;
},
items: self.model.perItems,
}
}, {
type: "bi.all_count_pager",
cls: "page-table-pager",
count: this.model.count,
curr: this.model.page,
pages: this.model.pages,
listeners: [{
eventName: "EVENT_CHANGE",
action: function (v) {
self.store.setPage(v);
eventName: BI.Pager.EVENT_CHANGE,
action: function () {
self.store.setPage(this.getCurrentPage());
}
}]
// }, {
// type: "bi.components.preview_table",
// items: this._getFieldItems(),
// header: this._getFieldHeader(),
// columnSize: ["0.6", "0.4"],
// ref: function (ref) {
// self.table = _ref;
// }
}],
ref: function (_ref) {
self.pager = _ref;
},
top: 0, bottom: 0, left: 0, right: 0
}]
};
},
_getFieldHeader: function () {
return [
BI.map(BI.Constants.getConstant("bi.conf.pack.excel.field.header"), function (idx, item) {
return {
text: item.text,
textAlign: "left",
hgap: 5
};
})
];
},
_getFieldItems: function () {
var self = this;
console.log("fieldItems", this.model.perItems)
return BI.map(this.model.perItems, function (idx, field) {
var items = [{
type: "bi.label",
text: field.colName,
title: field.colName,
textAlign: "left",
hgap: 5
}, {
type: "bi.icon_text_item",
cls: BI.Utils.getFieldIconByFieldType(field.colType),
text: BI.Utils.getTextByFieldType(field.colType)
}];
return items;
});
},
_formatItems: function (items) {
console.log("_formatItems");
var allResult=[];
@ -86,39 +110,22 @@
value: item.colName
};
result.push(colName);
// var colType = {
// type: "bi.text_value_combo",
// disabled: !o.add,
// widgetType: "bi.text_value_combo",
// value: item.colType+"",
// items: BI.Constants.getConstant("dec.hw.col.type"),
// id: item.id,
// listeners: [
// {
// eventName: "EVENT_CHANGE",
// action: function () {
// self.store.updateItemColType(this.options.id,this.getValue()[0]);
// }
// }
// ]
// };
var colType = {
type: "bi.component.field_type_combo",
value: item.colType,
listeners: [{
type: "bi.text_value_combo",
disabled: !o.add,
widgetType: "bi.text_value_combo",
value: item.colType+"",
items: BI.Constants.getConstant("dec.hw.col.type"),
id: item.id,
listeners: [
{
eventName: "EVENT_CHANGE",
action: function (v) {
self.store.setFieldType(idx, v);
action: function () {
self.store.updateItemColType(this.options.id,this.getValue()[0]);
}
}]
}
]
};
// var colType = {
// type: "bi.icon_text_item",
// cls: "custom-add-group-font bi-list-item",
// text: BI.i18nText("BI-Basic_Add_Group"),
// textRgap: 5
// value: item.colType
// }
result.push(colType);
allResult.push(result);
}

17
src/main/resources/com/fr/plugin/hw/decision/js/attr/col.attr.model.js

@ -6,7 +6,7 @@
state: function () {
return {
perCount: 5,
perCount: 10,
page: 1
};
},
@ -19,24 +19,15 @@
var start = (self.model.page - 1) * self.model.perCount;
var end = self.model.page * self.model.perCount;
var self = this;
console.log("items", self.model.items)
return BI.filter(self.model.items, function (index, item) {
return index + 1 > start && index + 1 <= end;
})
},
count: function () {
return this.model.items.length;
}
},
watch:{
count: function () {
var allPageCount = Math.ceil(this.model.count/ this.model.perCount);
if(allPageCount<=0){
allPageCount=1;
}
if (allPageCount < this.model.page) {
this.setPage(allPageCount);
}
pages: function () {
return Math.ceil(this.model.count / this.model.perCount);
}
},
@ -52,7 +43,7 @@
id: BI.UUID(),
colName: "",
colType: "12",
colLength: 255,
colLength: "10000",
excelCol: "",
primaryKey: false
})

13
src/main/resources/com/fr/plugin/hw/decision/js/hw.option.js

@ -79,6 +79,19 @@
return data;
};
BI.hwfield2ColTypeDeal = function(data){
BI.each(data, function (index, val) {
if (val.colType === 16) {
val.colType = "12";
} else if (val.colType === 32) {
val.colType = "8";
} else if (val.colType === 48) {
val.colType = "91";
}
});
return data;
};
/**
* tab项
*/

5
src/main/resources/com/fr/plugin/hw/decision/js/pane/left.js

@ -38,8 +38,9 @@
type: "dec.hw.table.add.popup",
add:true,
infoId:"add",
onClickConfirm: function (tableData, callback) {
console.log(tableData);
onClickConfirm: function (table, callback) {
var tableData = BI.deepClone(table);
BI.hwfield2ColTypeDeal(tableData.items);
Dec.HW.importTableData(tableData, function (res) {
if (res.status === "success") {
BI.Utils.addTables2Pack({

11
src/main/resources/com/fr/plugin/hw/decision/js/pane/right.table.model.js

@ -53,17 +53,6 @@
name: self.model.selectedLink
}, function (res) {
self.model.tableData = res.data.tableData;
/*BI.each(res.tabledata.colAttr, function (index, val) {
if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.int"), val.colType)) {
val.colType = 2;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.str"), val.colType)) {
val.colType = 12;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.bool"), val.colType)) {
val.colType = 16;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.date"), val.colType)) {
val.colType = 91;
}
});*/
self.model.headerData = BI.hwColTypeDeal(res.data.colAttr);
BI.isFunction(callback) && callback();
});

5
src/main/resources/com/fr/plugin/hw/decision/js/table.info.js

@ -124,7 +124,7 @@
el: {
type: "bi.vtape",
items: [{
height: 0.35,
height: 0.3,
el: {
type: "dec.card.vertical",
showButtons: false,
@ -144,7 +144,7 @@
}
}
}, {
height: 0.65,
height: 0.7,
el: {
type: "dec.card.vertical",
showButtons: false,
@ -152,7 +152,6 @@
content: {
type: "dec.hw.table.col.attr",
add:o.add
//text: "111"
}
}
}]

45
src/main/resources/com/fr/plugin/hw/decision/js/table.info.model.js

@ -31,7 +31,6 @@
initData: function (callback) {
var self = this, o = this.options;
console.log(self.model.infoId);
if(self.model.infoId === "add"){
callback && callback();
return;
@ -40,20 +39,7 @@
Dec.HW.queryData({
name: o.aliasName
}, function (res) {
/*BI.each(res.tabledata.colAttr, function (index, val) {
if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.int"), val.colType)) {
val.colType = 2;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.str"), val.colType)) {
val.colType = 12;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.bool"), val.colType)) {
val.colType = 16;
} else if (BI.contains(BI.Constants.getConstant("dec.hw.col.type.date"), val.colType)) {
val.colType = 91;
}
});*/
console.log("queryData", self.model.items)
self.model.items = BI.hwColTypeDeal(res.data.colAttr);
console.log("queryData2", self.model.items)
self.model.connection = res.data.tableAttr.connection;
self.model.schema = res.data.tableAttr.schema;
self.model.tableName = res.data.tableAttr.tableName;
@ -79,16 +65,26 @@
attachId: self.model.result.attachId,
sheetNo: 0,
fileName: self.model.result.fileName
});
BI.Utils.getExcelData(self.model.result.attachId, {
name: "",
type: BICst.TABLE.EXCEL,
excelFields: [],
additionalAttach: [],
transferName: "",
reset: true
}, function (res) {
console.log(res);
if (res.success) {
self.model.result.sheetNo=0;
self.model.result.titleRow=res.data[0].titleRow;
self.model.excelItems = res.data;
var fields = res.data.fields;
self.model.result.sheetNo = 0;
self.model.result.titleRow = 0;
self.model.excelItems = fields;
// items 匹配相同的列名
BI.each(self.model.items, function (index, item) {
var sameNameItem = BI.filter(self.model.excelItems, function (i, v) {
return v.text == item.colName
return v.text == item.name
});
if (sameNameItem.length != 0){
item.excelCol = sameNameItem[0].value;
@ -139,16 +135,17 @@
this.model.importStatus=v;
},
addItems:function () {
var self=this;
var result=BI.map(self.model.excelItems,function (index, item) {
var self = this;
var result = BI.map(self.model.excelItems,function (index, item) {
return {
id:BI.UUID(),
colName: item.text,
colType: item.colType,
colLength: 255,
excelCol: item.value
colName: item.name || item.colName,
colType: item.type || 16,
colLength: "10000",
excelCol: index
}
});
console.log("excelAdd", self.model.items)
self.model.items=BI.concat(self.model.items, result);
console.log("excelAdd2", self.model.items)

Loading…
Cancel
Save