Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
dfdd07e4
o2oa
项目概览
fuyue82
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dfdd07e4
编写于
2月 02, 2021
作者:
傻
傻拖
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、增加自建表数据导出到Excel文件
2、从Excel文件中导入数据到自建表
上级
ee679d9d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
194 addition
and
6 deletion
+194
-6
o2web/package.json
o2web/package.json
+2
-1
o2web/source/x_component_query_TableDesigner/$Main/default/toolbar/formExcelExplode.png
..._TableDesigner/$Main/default/toolbar/formExcelExplode.png
+0
-0
o2web/source/x_component_query_TableDesigner/$Main/default/toolbar/formExcelImplode.png
..._TableDesigner/$Main/default/toolbar/formExcelImplode.png
+0
-0
o2web/source/x_component_query_TableDesigner/$Main/default/toolbars.html
...component_query_TableDesigner/$Main/default/toolbars.html
+4
-3
o2web/source/x_component_query_TableDesigner/Main.js
o2web/source/x_component_query_TableDesigner/Main.js
+6
-0
o2web/source/x_component_query_TableDesigner/Table.js
o2web/source/x_component_query_TableDesigner/Table.js
+181
-2
o2web/source/x_component_query_TableDesigner/lp/zh-cn.js
o2web/source/x_component_query_TableDesigner/lp/zh-cn.js
+1
-0
未找到文件。
o2web/package.json
浏览文件 @
dfdd07e4
...
...
@@ -50,6 +50,7 @@
"readline-sync"
:
"^1.4.10"
},
"dependencies"
:
{
"gulp-cli"
:
"^2.3.0"
"gulp-cli"
:
"^2.3.0"
,
"gulp-git"
:
"^2.10.1"
}
}
o2web/source/x_component_query_TableDesigner/$Main/default/toolbar/formExcelExplode.png
0 → 100644
浏览文件 @
dfdd07e4
1.1 KB
o2web/source/x_component_query_TableDesigner/$Main/default/toolbar/formExcelImplode.png
0 → 100644
浏览文件 @
dfdd07e4
1.5 KB
o2web/source/x_component_query_TableDesigner/$Main/default/toolbars.html
浏览文件 @
dfdd07e4
...
...
@@ -4,14 +4,15 @@
<span
MWFnodetype=
"MWFToolBarSeparator"
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"build.png"
title=
"发布数据表,进入可编译状态"
MWFButtonAction=
"statusBuild"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"draft.png"
title=
"取消数据库编译,重新编译时会删除已编译的数据表"
MWFButtonAction=
"statusDraft"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarSeparator"
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"run.png"
title=
"编译所有数据表"
MWFButtonAction=
"buildAllView"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarSeparator"
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"formExplode.gif"
title=
"数据导出"
MWFButtonAction=
"tableExplode"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"formImplode.gif"
title=
"数据导入"
MWFButtonAction=
"tableImplode"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"formExcelExplode.png"
title=
"Excel导出"
MWFButtonAction=
"tableExcelExplode"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"formExcelImplode.png"
title=
"Excel导入"
MWFButtonAction=
"tableExcelImplode"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarButton"
MWFButtonImage=
"clear.png"
title=
"清空表数据"
MWFButtonAction=
"tableClear"
MWFButtonText=
""
></span>
<span
MWFnodetype=
"MWFToolBarSeparator"
></span>
...
...
o2web/source/x_component_query_TableDesigner/Main.js
浏览文件 @
dfdd07e4
...
...
@@ -178,6 +178,12 @@ MWF.xApplication.query.TableDesigner.Main = new Class({
tableImplode
:
function
(){
this
.
view
.
tableImplode
();
},
tableExcelExplode
:
function
(){
this
.
view
.
tableExcelExplode
();
},
tableExcelImplode
:
function
(){
this
.
view
.
tableExcelImplode
();
},
tableClear
:
function
(){
this
.
view
.
tableClear
();
},
...
...
o2web/source/x_component_query_TableDesigner/Table.js
浏览文件 @
dfdd07e4
...
...
@@ -533,6 +533,41 @@ MWF.xApplication.query.TableDesigner.Table = new Class({
this
.
close
();
},
null
);
},
tableExcelImplode
:
function
(
e
){
var
_self
=
this
;
if
(
!
e
)
e
=
this
.
node
;
this
.
designer
.
confirm
(
"
warn
"
,
e
,
MWF
.
APPDTBD
.
LP
.
tableExcelImplodeTitle
,
MWF
.
APPDTBD
.
LP
.
tableExcelImplodeInfo
,
480
,
120
,
function
(){
_self
.
implodeExcelLocal
();
this
.
close
();
},
function
(){
this
.
close
();
},
null
);
},
implodeExcelLocal
:
function
(){
var
ExcelUtils
=
new
MWF
.
xApplication
.
query
.
TableDesigner
.
Table
.
ExcelUtils
();
var
uploadFileAreaNode
=
new
Element
(
"
div
"
);
var
html
=
"
<input name=
\"
file
\"
type=
\"
file
\"
accept=
\"
*
\"
/>
"
;
uploadFileAreaNode
.
set
(
"
html
"
,
html
);
var
fileUploadNode
=
uploadFileAreaNode
.
getFirst
();
fileUploadNode
.
addEvent
(
"
change
"
,
function
()
{
var
files
=
fileNode
.
files
;
if
(
files
.
length
)
{
var
file
=
files
.
item
(
0
);
//第三个参数是日期的列
ExcelUtils
.
import
(
file
,
function
(
json
){
console
.
log
(
JSON
.
stringify
(
json
));
this
.
designer
.
actions
.
rowSave
(
this
.
data
.
id
,
json
[
0
],
function
(
json
){
this
.
designer
.
notice
(
this
.
designer
.
lp
.
tableImplode_success
,
"
success
"
,
this
.
node
,
{
"
x
"
:
"
left
"
,
"
y
"
:
"
bottom
"
});
}.
bind
(
this
));
}.
bind
(
this
)
);
}
}.
bind
(
this
));
var
fileNode
=
uploadFileAreaNode
.
getFirst
();
fileNode
.
click
();
},
implodeLocal
:
function
(){
if
(
!
this
.
uploadFileAreaNode
){
this
.
uploadFileAreaNode
=
new
Element
(
"
div
"
);
...
...
@@ -582,6 +617,48 @@ MWF.xApplication.query.TableDesigner.Table = new Class({
this
.
close
();
},
null
);
},
tableExcelExplode
:
function
(
e
){
var
ExcelUtils
=
new
MWF
.
xApplication
.
query
.
TableDesigner
.
Table
.
ExcelUtils
();
var
_self
=
this
;
if
(
!
e
)
e
=
this
.
node
;
this
.
designer
.
confirm
(
"
warn
"
,
e
,
MWF
.
APPDTBD
.
LP
.
tableExcelExplodeTitle
,
MWF
.
APPDTBD
.
LP
.
tableExplodeInfo
,
480
,
120
,
function
(){
var
fieldList
=
JSON
.
parse
(
_self
.
view
.
data
.
data
).
fieldList
;
var
fieldArr
=
[];
var
resultArr
=
[];
fieldList
.
each
(
function
(
field
){
fieldArr
.
push
(
field
.
name
);
resultArr
.
push
(
"
o.
"
+
field
.
name
);
})
var
array
=
[
fieldArr
];
var
jpql
=
{
"
data
"
:
"
select
"
+
resultArr
.
join
()
+
"
from
"
+
_self
.
data
.
name
+
"
o
"
,
"
type
"
:
"
select
"
,
"
firstResult
"
:
0
,
"
maxResults
"
:
1000
}
_self
.
designer
.
actions
.
executeJpql
(
_self
.
data
.
id
,
jpql
,
function
(
json
){
json
.
data
.
each
(
function
(
d
){
var
f
=
[];
if
(
o2
.
typeOf
(
json
.
data
[
0
])
===
"
string
"
){
f
=
[
d
];
}
else
{
d
.
each
(
function
(
dd
){
if
(
!
dd
){
f
.
push
(
""
);
}
else
{
f
.
push
(
dd
);
}
})
}
array
.
push
(
f
);
})
ExcelUtils
.
export
(
array
,
"
导出数据
"
+
(
new
Date
).
format
(
"
db
"
));
}.
bind
(
this
));
this
.
close
();
},
function
(){
this
.
close
();
},
null
);
},
setContentHeight
:
function
(){
var
size
=
this
.
areaNode
.
getSize
();
var
titleSize
=
this
.
viewTitleNode
.
getSize
()
...
...
@@ -680,8 +757,6 @@ MWF.xApplication.query.TableDesigner.Table = new Class({
}
});
MWF
.
xApplication
.
query
.
TableDesigner
.
Table
.
Column
=
new
Class
({
Extends
:
MWF
.
xApplication
.
query
.
ViewDesigner
.
ViewBase
.
Column
,
initialize
:
function
(
json
,
view
,
next
){
...
...
@@ -1218,3 +1293,107 @@ MWF.xApplication.query.TableDesigner.Table.JPQLRunner = new Class({
}
}
});
MWF
.
xApplication
.
query
.
TableDesigner
.
Table
.
ExcelUtils
=
new
Class
({
_loadResource
:
function
(
callback
){
var
uri
=
"
/x_component_Template/framework/xlsx/xlsx.full.js
"
;
var
uri2
=
"
/x_component_Template/framework/xlsx/xlsxUtils.js
"
;
COMMON
.
AjaxModule
.
load
(
uri
,
function
(){
COMMON
.
AjaxModule
.
load
(
uri2
,
function
(){
callback
();
}.
bind
(
this
))
}.
bind
(
this
))
},
_openDownloadDialog
:
function
(
url
,
saveName
){
/**
* 通用的打开下载对话框方法,没有测试过具体兼容性
* @param url 下载地址,也可以是一个blob对象,必选
* @param saveName 保存文件名,可选
*/
if
(
Browser
.
name
!==
'
ie
'
){
if
(
typeof
url
==
'
object
'
&&
url
instanceof
Blob
){
url
=
URL
.
createObjectURL
(
url
);
// 创建blob地址
}
var
aLink
=
document
.
createElement
(
'
a
'
);
aLink
.
href
=
url
;
aLink
.
download
=
saveName
||
''
;
// HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
var
event
;
if
(
window
.
MouseEvent
&&
typeOf
(
window
.
MouseEvent
)
==
"
function
"
)
event
=
new
MouseEvent
(
'
click
'
);
else
{
event
=
document
.
createEvent
(
'
MouseEvents
'
);
event
.
initMouseEvent
(
'
click
'
,
true
,
false
,
window
,
0
,
0
,
0
,
0
,
0
,
false
,
false
,
false
,
false
,
0
,
null
);
}
aLink
.
dispatchEvent
(
event
);
}
else
{
window
.
navigator
.
msSaveBlob
(
url
,
saveName
);
}
},
export
:
function
(
array
,
fileName
){
this
.
_loadResource
(
function
(){
data
=
xlsxUtils
.
format2Sheet
(
array
,
0
,
0
,
null
);
//偏移3行按keyMap顺序转换
var
wb
=
xlsxUtils
.
format2WB
(
data
,
"
sheet1
"
,
undefined
);
var
wopts
=
{
bookType
:
'
xlsx
'
,
bookSST
:
false
,
type
:
'
binary
'
};
var
dataInfo
=
wb
.
Sheets
[
wb
.
SheetNames
[
0
]];
var
widthArray
=
[];
array
[
0
].
each
(
function
(
v
,
i
){
widthArray
.
push
(
{
wpx
:
100
}
);
var
at
=
String
.
fromCharCode
(
97
+
i
).
toUpperCase
();
var
di
=
dataInfo
[
at
+
"
1
"
];
// di.v = v;
// di.t = "s";
di
.
s
=
{
//设置副标题样式
font
:
{
//name: '宋体',
sz
:
12
,
color
:
{
rgb
:
"
#FFFF0000
"
},
bold
:
true
,
italic
:
false
,
underline
:
false
},
alignment
:
{
horizontal
:
"
center
"
,
vertical
:
"
center
"
}
};
}.
bind
(
this
));
dataInfo
[
'
!cols
'
]
=
widthArray
,
this
.
_openDownloadDialog
(
xlsxUtils
.
format2Blob
(
wb
),
fileName
+
"
.xlsx
"
);
}.
bind
(
this
))
},
import
:
function
(
file
,
callback
,
dateColArray
){
this
.
_loadResource
(
function
(){
var
reader
=
new
FileReader
();
var
workbook
,
data
;
reader
.
onload
=
function
(
e
)
{
//var data = data.content;
if
(
!
e
)
{
data
=
reader
.
content
;
}
else
{
data
=
e
.
target
.
result
;
}
workbook
=
XLSX
.
read
(
data
,
{
type
:
'
binary
'
});
//wb.SheetNames[0]是获取Sheets中第一个Sheet的名字
//wb.Sheets[Sheet名]获取第一个Sheet的数据
var
sheet
=
workbook
.
SheetNames
[
0
];
var
jsonList
=
[];
for
(
var
sheet
in
workbook
.
Sheets
)
{
if
(
workbook
.
Sheets
.
hasOwnProperty
(
sheet
))
{
fromTo
=
workbook
.
Sheets
[
sheet
][
'
!ref
'
];
console
.
log
(
fromTo
);
var
json
=
XLSX
.
utils
.
sheet_to_json
(
workbook
.
Sheets
[
sheet
]);
console
.
log
(
JSON
.
stringify
(
json
));
jsonList
.
push
(
json
);
// break; // 如果只取第一张表,就取消注释这行
}
}
if
(
callback
)
callback
(
jsonList
);
};
reader
.
readAsBinaryString
(
file
);
})
}
});
o2web/source/x_component_query_TableDesigner/lp/zh-cn.js
浏览文件 @
dfdd07e4
...
...
@@ -67,6 +67,7 @@ MWF.xApplication.query.TableDesigner.LP = {
"
tableImplodeTitle
"
:
"
导入数据
"
,
"
tableImplodeInfo
"
:
"
导入的数据会覆盖。确认是否导入?
"
,
"
tableExcelImplodeInfo
"
:
"
导入的数据如果有id字段,会覆盖,否则会新增。确认是否导入?
"
,
"
tableImplode_success
"
:
"
导入成功
"
,
"
tableClearTitle
"
:
"
清空数据
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录