Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
da49b944
Commit
da49b944
authored
Nov 25, 2018
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db: 导出查询数据
parent
779e20b7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
10 deletions
+83
-10
en.js
source/language/en.js
+4
-0
zh.js
source/language/zh.js
+4
-0
index.js
source/modules/database/asp/index.js
+20
-1
index.js
source/modules/database/custom/index.js
+20
-1
index.js
source/modules/database/index.js
+13
-6
index.js
source/modules/database/php/index.js
+22
-2
No files found.
source/language/en.js
View file @
da49b944
...
@@ -398,6 +398,10 @@ module.exports = {
...
@@ -398,6 +398,10 @@ module.exports = {
query
:
(
err
)
=>
antSword
.
noxss
(
`Failure to execute SQL!\n
${
err
}
`
),
query
:
(
err
)
=>
antSword
.
noxss
(
`Failure to execute SQL!\n
${
err
}
`
),
parse
:
'Return data format is incorrect!'
,
parse
:
'Return data format is incorrect!'
,
noresult
:
'No query results!'
noresult
:
'No query results!'
},
dump
:
{
title
:
"Export Data"
,
success
:
"Export success"
,
}
}
},
},
notsupport
:
'Not support the current database type'
,
notsupport
:
'Not support the current database type'
,
...
...
source/language/zh.js
View file @
da49b944
...
@@ -399,6 +399,10 @@ module.exports = {
...
@@ -399,6 +399,10 @@ module.exports = {
query
:
(
err
)
=>
antSword
.
noxss
(
`执行SQL失败!\n
${
err
}
`
),
query
:
(
err
)
=>
antSword
.
noxss
(
`执行SQL失败!\n
${
err
}
`
),
parse
:
'返回数据格式不正确!'
,
parse
:
'返回数据格式不正确!'
,
noresult
:
'没有查询结果!'
noresult
:
'没有查询结果!'
},
dump
:
{
title
:
"导出查询结果"
,
success
:
"导出成功"
,
}
}
},
},
notsupport
:
'该功能暂不支持当前类型数据库'
,
notsupport
:
'该功能暂不支持当前类型数据库'
,
...
...
source/modules/database/asp/index.js
View file @
da49b944
...
@@ -543,13 +543,32 @@ class ASP {
...
@@ -543,13 +543,32 @@ class ASP {
'rows'
:
grid_data
'rows'
:
grid_data
},
'json'
);
},
'json'
);
// 启用导出按钮
// 启用导出按钮
// this.manager.result.toolbar[grid_data.length > 0 ? 'enableItem' : 'disableItem']('dump');
this
.
manager
.
result
.
toolbar
[
grid_data
.
length
>
0
?
'enableItem'
:
'disableItem'
](
'dump'
);
}
// 导出查询数据
dumpResult
()
{
const
grid
=
this
.
manager
.
result
.
layout
.
getAttachedObject
();
let
filename
=
`
${
this
.
core
.
__opts__
.
ip
}
_
${
new
Date
().
format
(
"yyyyMMddhhmmss"
)}
.csv`
;
antSword
[
'test'
]
=
this
;
dialog
.
showSaveDialog
({
title
:
LANG
[
'result'
][
'dump'
][
'title'
],
defaultPath
:
filename
},(
filePath
)
=>
{
if
(
!
filePath
)
{
return
;
};
let
headerStr
=
grid
.
hdrLabels
.
join
(
','
);
let
dataStr
=
grid
.
serializeToCSV
();
let
tempDataBuffer
=
new
Buffer
(
headerStr
+
'
\
n'
+
dataStr
);
fs
.
writeFileSync
(
filePath
,
tempDataBuffer
);
toastr
.
success
(
LANG
[
'result'
][
'dump'
][
'success'
],
LANG_T
[
'success'
]);
});
}
}
// 禁用toolbar按钮
// 禁用toolbar按钮
disableToolbar
()
{
disableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
result
.
toolbar
.
disableItem
(
'dump'
);
}
}
// 启用toolbar按钮
// 启用toolbar按钮
...
...
source/modules/database/custom/index.js
View file @
da49b944
...
@@ -543,13 +543,32 @@ class CUSTOM {
...
@@ -543,13 +543,32 @@ class CUSTOM {
'rows'
:
grid_data
'rows'
:
grid_data
},
'json'
);
},
'json'
);
// 启用导出按钮
// 启用导出按钮
// this.manager.result.toolbar[grid_data.length > 0 ? 'enableItem' : 'disableItem']('dump');
this
.
manager
.
result
.
toolbar
[
grid_data
.
length
>
0
?
'enableItem'
:
'disableItem'
](
'dump'
);
}
// 导出查询数据
dumpResult
()
{
const
grid
=
this
.
manager
.
result
.
layout
.
getAttachedObject
();
let
filename
=
`
${
this
.
core
.
__opts__
.
ip
}
_
${
new
Date
().
format
(
"yyyyMMddhhmmss"
)}
.csv`
;
antSword
[
'test'
]
=
this
;
dialog
.
showSaveDialog
({
title
:
LANG
[
'result'
][
'dump'
][
'title'
],
defaultPath
:
filename
},(
filePath
)
=>
{
if
(
!
filePath
)
{
return
;
};
let
headerStr
=
grid
.
hdrLabels
.
join
(
','
);
let
dataStr
=
grid
.
serializeToCSV
();
let
tempDataBuffer
=
new
Buffer
(
headerStr
+
'
\
n'
+
dataStr
);
fs
.
writeFileSync
(
filePath
,
tempDataBuffer
);
toastr
.
success
(
LANG
[
'result'
][
'dump'
][
'success'
],
LANG_T
[
'success'
]);
});
}
}
// 禁用toolbar按钮
// 禁用toolbar按钮
disableToolbar
()
{
disableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
result
.
toolbar
.
disableItem
(
'dump'
);
}
}
// 启用toolbar按钮
// 启用toolbar按钮
...
...
source/modules/database/index.js
View file @
da49b944
...
@@ -158,14 +158,21 @@ class Database {
...
@@ -158,14 +158,21 @@ class Database {
layout
.
setText
(
`<i class="fa fa-inbox"></i>
${
LANG
[
'result'
][
'title'
]}
`
);
layout
.
setText
(
`<i class="fa fa-inbox"></i>
${
LANG
[
'result'
][
'title'
]}
`
);
// layout.hideHeader();
// layout.hideHeader();
// const toolbar = layout.attachToolbar();
const
toolbar
=
layout
.
attachToolbar
();
// toolbar.loadStruct([
toolbar
.
loadStruct
([
// { id: 'dump', text: '导出', icon: 'upload', type: 'button', disabled: true },
{
id
:
'dump'
,
text
:
'导出'
,
icon
:
'upload'
,
type
:
'button'
,
disabled
:
true
},
// { type: 'separator' }
{
type
:
'separator'
}
// ]);
]);
toolbar
.
attachEvent
(
'onClick'
,
(
id
)
=>
{
switch
(
id
)
{
case
'dump'
:
this
.
drive
.
dumpResult
();
break
;
}
});
return
{
return
{
layout
:
layout
,
layout
:
layout
,
//
toolbar: toolbar
toolbar
:
toolbar
};
};
}
}
...
...
source/modules/database/php/index.js
View file @
da49b944
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
const
LANG
=
antSword
[
'language'
][
'database'
];
const
LANG
=
antSword
[
'language'
][
'database'
];
const
LANG_T
=
antSword
[
'language'
][
'toastr'
];
const
LANG_T
=
antSword
[
'language'
][
'toastr'
];
const
dialog
=
antSword
.
remote
.
dialog
;
const
fs
=
require
(
'fs'
);
class
PHP
{
class
PHP
{
...
@@ -1485,13 +1487,31 @@ class PHP {
...
@@ -1485,13 +1487,31 @@ class PHP {
'rows'
:
grid_data
'rows'
:
grid_data
},
'json'
);
},
'json'
);
// 启用导出按钮
// 启用导出按钮
// this.manager.result.toolbar[grid_data.length > 0 ? 'enableItem' : 'disableItem']('dump');
this
.
manager
.
result
.
toolbar
[
grid_data
.
length
>
0
?
'enableItem'
:
'disableItem'
](
'dump'
);
}
// 导出查询数据
dumpResult
()
{
const
grid
=
this
.
manager
.
result
.
layout
.
getAttachedObject
();
let
filename
=
`
${
this
.
core
.
__opts__
.
ip
}
_
${
new
Date
().
format
(
"yyyyMMddhhmmss"
)}
.csv`
;
antSword
[
'test'
]
=
this
;
dialog
.
showSaveDialog
({
title
:
LANG
[
'result'
][
'dump'
][
'title'
],
defaultPath
:
filename
},(
filePath
)
=>
{
if
(
!
filePath
)
{
return
;
};
let
headerStr
=
grid
.
hdrLabels
.
join
(
','
);
let
dataStr
=
grid
.
serializeToCSV
();
let
tempDataBuffer
=
new
Buffer
(
headerStr
+
'
\
n'
+
dataStr
);
fs
.
writeFileSync
(
filePath
,
tempDataBuffer
);
toastr
.
success
(
LANG
[
'result'
][
'dump'
][
'success'
],
LANG_T
[
'success'
]);
});
}
}
// 禁用toolbar按钮
// 禁用toolbar按钮
disableToolbar
()
{
disableToolbar
()
{
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'del'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
list
.
toolbar
.
disableItem
(
'edit'
);
this
.
manager
.
result
.
toolbar
.
disableItem
(
'dump'
);
}
}
// 启用toolbar按钮
// 启用toolbar按钮
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment