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(); XSSFCell cell = (XSSFCell) cellIterator.next();
String value = getString(cell); String value = getString(cell);
if (StringUtils.isNotBlank(value)) { if (StringUtils.isNotBlank(value)) {
JSONObject o = JSONObject.create(). JSONObject o = JSONObject.create().put("titleRow", titleRow).put("value", cell.getColumnIndex()).put("text", value);
put("titleRow", titleRow).
put("type", "12").
put("value", cell.getColumnIndex()).
put("text", value);
result.add(o); result.add(o);
} }
} }

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

@ -40,7 +40,7 @@ public class IfTableExistHttpHandler extends BaseHttpHandler {
try { try {
if (conn == null){ if (conn == null){
FineLoggerFactory.getLogger().error("HW_excel导入:" + connection + "数据连接创建失败"); 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; return;
} }
smt = conn.createStatement(); 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 add: this.options.add
}); });
}, },
/*beforeInit: function (callback) {
this.store.initData(callback)
},*/
watch: { watch: {
count: function (v) { count: function (v) {
this.table.setCount(v); this.pager.setCount(v);
},
pages: function (v) {
this.pager.setAllPages(v);
}, },
perItems: function () { perItems: function () {
this.table.populate(this._formatItems(this.model.perItems)); this.table.populate(this._getFieldItems(), this._getFieldHeader(), {freezeScroll: true});
this.table.setPage(this.model.page); this.pager.setVPage(this.model.page);
}, },
page:function () { page:function () {
this.table.setPage(this.model.page); this.pager.setVPage(this.model.page);
//this.popularExcelBox(this.model.excelItems);
}, },
excelItems:function () { excelItems:function () {
this.popularExcelBox(this.model.excelItems); this.popularExcelBox(this.model.excelItems);
} }
}, },
mounted: function () {
this.table.setCount(this.model.count);
this.table.populate(this._formatItems(this.model.perItems));
},
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
type: "bi.absolute", type: "bi.vertical",
items: [{ items: [{
el: { type: "bi.components.preview_table",
type: "dec.page.table", items: this._getFieldItems(),
header: [{text: "字段名"}, {text: "字段类型"}], header: this._getFieldHeader(),
columnSize: ["0.6", "0.4"], columnSize: [480, 150],
perPage: 5, height: 300,
tgap: 10,
ref: function (_ref) { ref: function (_ref) {
self.table = _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: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: BI.Pager.EVENT_CHANGE,
action: function (v) { action: function () {
self.store.setPage(v); self.store.setPage(this.getCurrentPage());
} }
}] }],
ref: function (_ref) {
// }, { self.pager = _ref;
// type: "bi.components.preview_table",
// items: this._getFieldItems(),
// header: this._getFieldHeader(),
// columnSize: ["0.6", "0.4"],
// ref: function (ref) {
// self.table = _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) { _formatItems: function (items) {
console.log("_formatItems"); console.log("_formatItems");
var allResult=[]; var allResult=[];
@ -86,39 +110,22 @@
value: item.colName value: item.colName
}; };
result.push(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 = { var colType = {
type: "bi.component.field_type_combo", type: "bi.text_value_combo",
value: item.colType, disabled: !o.add,
listeners: [{ widgetType: "bi.text_value_combo",
value: item.colType+"",
items: BI.Constants.getConstant("dec.hw.col.type"),
id: item.id,
listeners: [
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function (v) { action: function () {
self.store.setFieldType(idx, v); 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); result.push(colType);
allResult.push(result); allResult.push(result);
} }

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

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

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

@ -79,6 +79,19 @@
return data; 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项 * tab项
*/ */

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

@ -38,8 +38,9 @@
type: "dec.hw.table.add.popup", type: "dec.hw.table.add.popup",
add:true, add:true,
infoId:"add", infoId:"add",
onClickConfirm: function (tableData, callback) { onClickConfirm: function (table, callback) {
console.log(tableData); var tableData = BI.deepClone(table);
BI.hwfield2ColTypeDeal(tableData.items);
Dec.HW.importTableData(tableData, function (res) { Dec.HW.importTableData(tableData, function (res) {
if (res.status === "success") { if (res.status === "success") {
BI.Utils.addTables2Pack({ 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 name: self.model.selectedLink
}, function (res) { }, function (res) {
self.model.tableData = res.data.tableData; 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); self.model.headerData = BI.hwColTypeDeal(res.data.colAttr);
BI.isFunction(callback) && callback(); BI.isFunction(callback) && callback();
}); });

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

@ -124,7 +124,7 @@
el: { el: {
type: "bi.vtape", type: "bi.vtape",
items: [{ items: [{
height: 0.35, height: 0.3,
el: { el: {
type: "dec.card.vertical", type: "dec.card.vertical",
showButtons: false, showButtons: false,
@ -144,7 +144,7 @@
} }
} }
}, { }, {
height: 0.65, height: 0.7,
el: { el: {
type: "dec.card.vertical", type: "dec.card.vertical",
showButtons: false, showButtons: false,
@ -152,7 +152,6 @@
content: { content: {
type: "dec.hw.table.col.attr", type: "dec.hw.table.col.attr",
add:o.add 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) { initData: function (callback) {
var self = this, o = this.options; var self = this, o = this.options;
console.log(self.model.infoId);
if(self.model.infoId === "add"){ if(self.model.infoId === "add"){
callback && callback(); callback && callback();
return; return;
@ -40,20 +39,7 @@
Dec.HW.queryData({ Dec.HW.queryData({
name: o.aliasName name: o.aliasName
}, function (res) { }, 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); self.model.items = BI.hwColTypeDeal(res.data.colAttr);
console.log("queryData2", self.model.items)
self.model.connection = res.data.tableAttr.connection; self.model.connection = res.data.tableAttr.connection;
self.model.schema = res.data.tableAttr.schema; self.model.schema = res.data.tableAttr.schema;
self.model.tableName = res.data.tableAttr.tableName; self.model.tableName = res.data.tableAttr.tableName;
@ -79,16 +65,26 @@
attachId: self.model.result.attachId, attachId: self.model.result.attachId,
sheetNo: 0, sheetNo: 0,
fileName: self.model.result.fileName fileName: self.model.result.fileName
});
BI.Utils.getExcelData(self.model.result.attachId, {
name: "",
type: BICst.TABLE.EXCEL,
excelFields: [],
additionalAttach: [],
transferName: "",
reset: true
}, function (res) { }, function (res) {
console.log(res);
if (res.success) { if (res.success) {
self.model.result.sheetNo=0; var fields = res.data.fields;
self.model.result.titleRow=res.data[0].titleRow; self.model.result.sheetNo = 0;
self.model.excelItems = res.data; self.model.result.titleRow = 0;
self.model.excelItems = fields;
// items 匹配相同的列名 // items 匹配相同的列名
BI.each(self.model.items, function (index, item) { BI.each(self.model.items, function (index, item) {
var sameNameItem = BI.filter(self.model.excelItems, function (i, v) { var sameNameItem = BI.filter(self.model.excelItems, function (i, v) {
return v.text == item.colName return v.text == item.name
}); });
if (sameNameItem.length != 0){ if (sameNameItem.length != 0){
item.excelCol = sameNameItem[0].value; item.excelCol = sameNameItem[0].value;
@ -139,16 +135,17 @@
this.model.importStatus=v; this.model.importStatus=v;
}, },
addItems:function () { addItems:function () {
var self=this; var self = this;
var result=BI.map(self.model.excelItems,function (index, item) { var result = BI.map(self.model.excelItems,function (index, item) {
return { return {
id:BI.UUID(), id:BI.UUID(),
colName: item.text, colName: item.name || item.colName,
colType: item.colType, colType: item.type || 16,
colLength: 255, colLength: "10000",
excelCol: item.value excelCol: index
} }
}); });
console.log("excelAdd", self.model.items) console.log("excelAdd", self.model.items)
self.model.items=BI.concat(self.model.items, result); self.model.items=BI.concat(self.model.items, result);
console.log("excelAdd2", self.model.items) console.log("excelAdd2", self.model.items)

Loading…
Cancel
Save