You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
242 lines
9.8 KiB
242 lines
9.8 KiB
;!(function () { |
|
var tableInfo = BI.inherit(BI.Widget, { |
|
props: { |
|
add: true, |
|
infoId:"" |
|
}, |
|
_store: function () { |
|
return BI.Models.getModel("dec.hw.table.info.model",{ |
|
infoId:this.options.infoId, |
|
aliasName:this.options.aliasName |
|
}); |
|
}, |
|
beforeInit: function (callback) { |
|
this.store.initData(callback) |
|
}, |
|
watch: { |
|
sheetItems: function (v) { |
|
if (v.show) { |
|
this.showSheetSelect(v.items); |
|
} else { |
|
this.hideSheetSelect() |
|
} |
|
}, |
|
importStatus: function (v) { |
|
switch (v) { |
|
case "importing": |
|
this._startImport(); |
|
break; |
|
case "abort": |
|
this._stopImport(); |
|
break; |
|
case "finish": |
|
default: |
|
this._finishImport(); |
|
} |
|
} |
|
}, |
|
render: function () { |
|
var self = this, o = this.options; |
|
var file = { |
|
type: "bi.multifile_editor", |
|
ref: function (_ref) { |
|
self.file = _ref; |
|
}, |
|
url: Dec.fineServletURL + "/url/hw/file/upload?width=32&height=32", |
|
listeners: [ |
|
{ |
|
eventName: BI.MultifileEditor.EVENT_ERROR, |
|
action: function (args) { |
|
/* self.fireEvent("EVENT_ERROR"); |
|
self._closeUpload();*/ |
|
} |
|
}, { |
|
eventName: BI.MultifileEditor.EVENT_UPLOADED, |
|
action: function (args) { |
|
console.log("EVENT_UPLOADED"); |
|
var files = this.getValue(); |
|
if (files[files.length - 1].errorCode) { |
|
BI.Msg.toast(BI.i18nText(files[files.length - 1].errorMsg), { |
|
level: "error" |
|
}); |
|
self.store.setImportStatus("abort"); |
|
return; |
|
} |
|
var filename = files[files.length - 1].filename; |
|
// 新增文件格式判断 |
|
if ( !BI.endWith(filename,".xls") && !BI.endWith(filename,".xlsx")){ |
|
BI.Msg.toast(BI.i18nText("上传文件格式不正确, 请重新上传excel文件"), { |
|
level: "error" |
|
}); |
|
self.store.setImportStatus("abort"); |
|
return; |
|
} |
|
self.uploadButton.setEnable(false); |
|
self.uploadButton.setText("已上传"); |
|
var id = files[files.length - 1].attach_id; |
|
self.store.getExcelSheetNumber(id, filename); |
|
} |
|
}, { |
|
eventName: BI.MultifileEditor.EVENT_CHANGE, |
|
action: function () { |
|
self.store.setImportStatus("importing"); |
|
this.upload(); |
|
/*self._startUpload();*/ |
|
} |
|
} |
|
] |
|
}; |
|
var header = { |
|
type: "bi.htape", |
|
height: 24, |
|
items: [ |
|
{ |
|
el:{ |
|
type: "bi.button", |
|
textAlign: "center", |
|
height: 24, |
|
text: "上传文件", |
|
ref: function (_ref) { |
|
self.uploadButton = _ref; |
|
}, |
|
handler: function () { |
|
self.file.select(); |
|
} |
|
} |
|
}, { |
|
el: file |
|
} |
|
] |
|
}; |
|
return { |
|
type: "bi.absolute", |
|
items: [{ |
|
el: { |
|
type: "bi.vtape", |
|
items: [ |
|
{ |
|
el: header, |
|
height: 24 |
|
}, |
|
{ |
|
type: "bi.absolute", |
|
items: [{ |
|
el: { |
|
type: "bi.vtape", |
|
items: [{ |
|
height: 0.3, |
|
el: { |
|
type: "dec.card.vertical", |
|
showButtons: false, |
|
text: "表信息", |
|
content: { |
|
type: "dec.hw.table.attr", |
|
add:o.add, |
|
ref:function(_ref){ |
|
self.table = _ref; |
|
}, |
|
info:{ |
|
connection:self.model.connection, |
|
schema:self.model.schema, |
|
tableName:self.model.tableName, |
|
aliasName:o.aliasName |
|
} |
|
} |
|
} |
|
}, { |
|
height: 0.7, |
|
el: { |
|
type: "dec.card.vertical", |
|
showButtons: false, |
|
text: "列信息", |
|
content: { |
|
type: "dec.hw.table.col.attr", |
|
add:o.add |
|
} |
|
} |
|
}] |
|
}, |
|
top: 0, bottom: 0, left: 0, right: 0 |
|
}] |
|
} |
|
] |
|
}, |
|
top: 0, bottom: 0, left: 10, right: 10 |
|
}] |
|
} |
|
}, |
|
showSheetSelect: function (items) { |
|
var self=this; |
|
var name = this.getName() + "sheet"; |
|
BI.Maskers.create(name, null, { |
|
render: { |
|
type: "dec.hw.sheet.select", |
|
items: items, |
|
onClickConfirm:function(val,callback){ |
|
self.store.getSheetFiledWithNo(val,callback) |
|
}, |
|
listeners: [ |
|
{ |
|
eventName: "EVENT_CLOSE", |
|
action: function () { |
|
BI.Maskers.hide(name); |
|
BI.Maskers.remove(name); |
|
} |
|
} |
|
] |
|
} |
|
}); |
|
BI.Maskers.show(name); |
|
}, |
|
hideSheetSelect: function () { |
|
var name = this.getName() + "sheet"; |
|
BI.Maskers.hide(name); |
|
BI.Maskers.remove(name); |
|
}, |
|
getValue: function () { |
|
return { |
|
items: this.model.items, |
|
connection: this.model.connection, |
|
schema: this.model.schema, |
|
aliasName: this.model.aliasName, |
|
tableName: this.model.tableName, |
|
infoId: this.model.infoId, |
|
sheetInfo:this.model.result |
|
} |
|
}, |
|
_startImport: function () { |
|
var self = this, name = this.getName() + "status"; |
|
var upload = { |
|
type: "dec.test.status", |
|
waitingText: "导入中", |
|
successText: "导入成功", |
|
failText: "导入失败", |
|
listeners: [{ |
|
eventName: "EVENT_CLOSE", |
|
action: function () { |
|
BI.Maskers.hide(name); |
|
BI.Maskers.remove(name); |
|
} |
|
}], |
|
ref: function (_ref) { |
|
self.uploadMasker = _ref; |
|
} |
|
}; |
|
BI.Maskers.create(name, null, { |
|
render: upload |
|
}); |
|
BI.Maskers.show(name); |
|
}, |
|
_stopImport: function () { |
|
var name = this.getName() + "status"; |
|
BI.Maskers.hide(name); |
|
BI.Maskers.remove(name); |
|
}, |
|
_finishImport: function () { |
|
this.uploadMasker && this.uploadMasker.setStatus({ |
|
status: DecCst.TestStatus.SUCCESS |
|
}); |
|
} |
|
}); |
|
BI.shortcut("dec.hw.table.info", tableInfo); |
|
})(); |