Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
wanli
evm-store
Commits
2c317d70
Commit
2c317d70
authored
Jul 19, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat(后端接口以及前端工具):
更新后端EPK打包接口、以及前端工具
parent
51356508
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
232 additions
and
241 deletions
+232
-241
tools/build_out/application/signal_manager.py
tools/build_out/application/signal_manager.py
+2
-1
tools/build_out/controllers/__init__.py
tools/build_out/controllers/__init__.py
+3
-2
tools/build_out/controllers/api.py
tools/build_out/controllers/api.py
+33
-26
tools/build_out/views/__init__.py
tools/build_out/views/__init__.py
+3
-1
tools/build_out/views/openapi.py
tools/build_out/views/openapi.py
+105
-39
tools/frontend/src/api/openapi.js
tools/frontend/src/api/openapi.js
+9
-1
tools/frontend/src/views/Application/Tool.vue
tools/frontend/src/views/Application/Tool.vue
+77
-171
No files found.
tools/build_out/application/signal_manager.py
View file @
2c317d70
'''
Author: your name
Date: 2021-06-30 18:03:41
LastEditTime: 2021-07-19 1
4:28:10
LastEditTime: 2021-07-19 1
8:47:22
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\a
pplication
\
signal_manager.py
...
...
@@ -65,6 +65,7 @@ class SignalManager(object):
actionPostFilePaste
=
PySignal
()
# api
actionPostAppReview
=
PySignal
()
actionApplicationBuild
=
PySignal
()
def
__init__
(
self
):
super
()
.
__init__
()
...
...
tools/build_out/controllers/__init__.py
View file @
2c317d70
'''
Author: your name
Date: 2021-06-30 17:43:46
LastEditTime: 2021-07-19 1
4:29:1
0
LastEditTime: 2021-07-19 1
8:47:5
0
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\
__init__.py
...
...
@@ -11,7 +11,7 @@ FilePath: \evm-store\tools\build_out\controllers\__init__.py
from
application.signal_manager
import
signalManager
from
.area
import
areaManager
from
.api
import
appReview
from
.api
import
appReview
,
buildAppResource
from
.app
import
appManager
from
.package
import
packageManager
from
.user
import
userManager
...
...
@@ -79,3 +79,4 @@ def initConnect():
signalManager
.
actionPostFilePaste
.
connect
(
fileManager
.
paste
)
# api
signalManager
.
actionPostAppReview
.
connect
(
appReview
.
post
)
signalManager
.
actionApplicationBuild
.
connect
(
buildAppResource
.
post
)
tools/build_out/controllers/api.py
View file @
2c317d70
'''
Author: your name
Date: 2021-07-12 11:14:48
LastEditTime: 2021-07-19 1
5:19:26
LastEditTime: 2021-07-19 1
9:25:09
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
controllers
\a
ppi.py
...
...
@@ -10,7 +10,8 @@ import os
import
re
import
json
import
shutil
from
urllib
import
parse
from
pprint
import
pprint
from
pathlib
import
Path
from
datetime
import
datetime
from
application.app
import
db
,
config
from
models.annex
import
AnnexModel
...
...
@@ -18,7 +19,6 @@ from models.app import AppModel
from
models.user
import
UserModel
from
models.package
import
PackageModel
from
webcreator.log
import
logger
from
webcreator
import
utils
from
webcreator.utils.epk
import
EpkApp
from
webcreator.response
import
ResponseCode
...
...
@@ -26,50 +26,56 @@ class BuildAppResource(object):
def
__init__
(
self
):
super
()
.
__init__
()
def
post
(
self
,
params
,
jwt
=
{}
):
def
post
(
self
,
params
,
files
=
[]
):
logger
.
info
(
params
)
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
jwt
[
'id'
]
)
user
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
params
.
get
(
"access_key"
))
.
one_or_none
(
)
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
if
params
.
get
(
"access_key"
):
params
.
pop
(
"access_key"
)
print
(
user
)
params
.
update
({
'create_by'
:
user
,
'app_icon'
:
params
.
get
(
'app_icon'
,
''
),
'create_by'
:
user
.
id
,
'create_at'
:
datetime
.
now
(),
'update_by'
:
user
,
'update_by'
:
user
.
id
,
'update_at'
:
datetime
.
now
(),
})
app
=
AppModel
(
**
params
)
props
=
dict
()
for
p
in
params
:
if
hasattr
(
AppModel
,
p
):
props
[
p
]
=
params
[
p
]
# logger.info(props)
# pprint(props)
app
=
AppModel
(
**
props
)
db
.
session
.
add
(
app
)
db
.
session
.
commit
()
dir_format
=
"{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
))
upload_dir
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
"evueapps"
])
target_dir
=
os
.
sep
.
join
([
upload_dir
,
user
.
account
,
dir_format
])
dest_dir
=
os
.
sep
.
join
([
target_dir
,
"src"
])
if
not
os
.
path
.
exists
(
dest_dir
):
os
.
makedirs
(
dest_dir
)
target_dir
=
Path
(
config
.
EPK_DIR
)
.
joinpath
(
user
.
account
)
.
joinpath
(
dir_format
)
dest_dir
=
target_dir
.
joinpath
(
"src"
)
if
not
dest_dir
.
exists
():
os
.
makedirs
(
dest_dir
.
resolve
()
.
as_posix
())
for
target_file
in
params
.
get
(
'files'
)
:
for
target_file
in
files
:
filename
=
os
.
path
.
basename
(
target_file
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
dst_file
=
os
.
path
.
normpath
(
os
.
sep
.
join
([
dest_dir
,
name
+
suffix
])
)
shutil
.
copy
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
dst_file
=
dest_dir
.
joinpath
(
name
+
suffix
)
shutil
.
copy
(
os
.
path
.
normpath
(
target_file
),
dst_file
.
resolve
()
.
as_posix
()
)
res
=
AnnexModel
(
app
=
app
,
title
=
filename
,
path
=
dst_file
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
size
=
os
.
path
.
getsize
(
dst_file
),
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
res
=
AnnexModel
(
app
=
app
.
id
,
title
=
filename
,
path
=
dst_file
.
relative_to
(
config
.
UPLOAD_ROOT_DIR
)
.
resolve
()
.
as_posix
(),
size
=
dst_file
.
stat
()
.
st_size
,
create_by
=
user
.
id
,
create_at
=
datetime
.
now
(),
update_by
=
user
.
id
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
db
.
session
.
commit
()
# 打包成EPK文件
app_info
=
{}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
dest_dir
,
'appVersion'
:
app
.
app_version
,
'output'
:
target_dir
}
if
user
.
role
==
"administrator"
or
user
.
role
==
"community"
:
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
dest_dir
.
resolve
()
.
as_posix
(),
'appVersion'
:
app
.
app_version
,
'output'
:
target_dir
.
resolve
()
.
as_posix
()
}
if
user
.
role
==
1
:
params
[
'algorithm'
]
=
"h"
epk
=
EpkApp
(
**
params
)
app_info
=
epk
.
pack
()
...
...
@@ -77,7 +83,7 @@ class BuildAppResource(object):
# 更新数据库对应文件路径
# 将文件拷贝过去后,需要重新更新数据库文件记录
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
epk_path
=
target_dir
.
relative_to
(
config
.
UPLOAD_ROOT_DIR
)
.
joinpath
(
"{}.epk"
.
format
(
app
.
app_name
))
.
resolve
()
.
as_posix
(
)
result
=
PackageModel
.
query
.
filter
(
PackageModel
.
app
==
app
.
id
)
.
one_or_none
()
if
result
:
...
...
@@ -87,14 +93,15 @@ class BuildAppResource(object):
result
.
update_at
=
datetime
.
now
()
db
.
session
.
commit
()
else
:
result
=
PackageModel
(
app
=
app
.
id
,
file_path
=
epk_path
,
package_info
=
app_info
,
app_version
=
params
.
get
(
"app_version"
),
source
=
2
,
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
result
=
PackageModel
(
app
=
app
.
id
,
file_path
=
epk_path
,
package_info
=
json
.
dumps
(
app_info
,
ensure_ascii
=
False
),
app_version
=
params
.
get
(
"app_version"
,
'1.0.0'
),
source
=
2
,
create_by
=
user
.
id
,
create_at
=
datetime
.
now
(),
update_by
=
user
.
id
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
result
)
db
.
session
.
commit
()
with
open
(
os
.
sep
.
join
([
target_dir
,
"epk.json"
]),
"w"
)
as
f
:
json
.
dump
(
app
.
to_dict
(),
f
)
target_dir
.
joinpath
(
"epk.json"
)
.
write_text
(
json
.
dumps
(
app
.
to_dict
(),
ensure_ascii
=
False
))
# with open(os.sep.join([target_dir, "epk.json"]), "w") as f:
# json.dump(app.to_dict(), f)
return
{
'app_name'
:
app
.
app_name
,
'app_file'
:
"{}.epk"
.
format
(
app
.
app_name
),
'app_url'
:
parse
.
urljoin
(
config
[
'UPLOAD_SERVER'
],
epk_path
)
},
ResponseCode
.
HTTP_SUCCESS
return
{
'app_name'
:
app
.
app_name
,
'app_file'
:
"{}.epk"
.
format
(
app
.
app_name
),
'app_url'
:
epk_path
},
ResponseCode
.
HTTP_SUCCESS
buildAppResource
=
BuildAppResource
()
...
...
tools/build_out/views/__init__.py
View file @
2c317d70
'''
Author: your name
Date: 2021-07-15 03:22:19
LastEditTime: 2021-07-19 1
4:39:33
LastEditTime: 2021-07-19 1
9:27:31
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\v
iews
\
__init__.py
...
...
@@ -38,6 +38,8 @@ api.add_resource(app.AppResource, '/app/<string:uuid>')
api
.
add_resource
(
app
.
AppResourceList
,
'/app'
)
api
.
add_resource
(
openapi
.
AppReviewResource
,
'/api/app-review'
)
api
.
add_resource
(
openapi
.
CStringToolResource
,
'/api/convert-to-c-string'
)
api
.
add_resource
(
openapi
.
BuildAppResource
,
'/evm_store/application/build'
)
api
.
add_resource
(
package
.
PackageResource
,
'/package/<string:uuid>'
)
api
.
add_resource
(
package
.
PackageResourceList
,
'/package'
)
...
...
tools/build_out/views/openapi.py
View file @
2c317d70
'''
Author: your name
Date: 2021-07-19 14:29:33
LastEditTime: 2021-07-19 1
5:31:33
LastEditTime: 2021-07-19 1
9:27:21
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\v
iews
\a
pi.py
...
...
@@ -10,14 +10,20 @@ FilePath: \evm-store\tools\build_out\views\api.py
# -*- coding: utf_8 -*-
import
os
import
traceback
from
pathlib
import
Path
from
datetime
import
datetime
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
werkzeug.utils
import
secure_filename
from
werkzeug.datastructures
import
FileStorage
from
marshmallow.exceptions
import
ValidationError
from
application.config
import
config
from
application.signal_manager
import
signalManager
from
models.login
import
postLoginSchema
,
getListLoginSchema
,
getListLoginsSchema
,
getLoginSchema
from
webcreator.log
import
logger
from
webcreator.utils.ccode
import
convert_string
from
webcreator.response
import
ResponseCode
,
response_result
class
AppReviewResource
(
Resource
):
...
...
@@ -25,21 +31,17 @@ class AppReviewResource(Resource):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
self
.
parser
=
RequestParser
()
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1
)
# self.parser.add_argument("pageSize", type=int, location="args", default=15
)
#
args = self.parser.parse_args()
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
self
.
parser
.
add_argument
(
"review"
,
type
=
int
,
location
=
"json"
,
default
=
0
,
required
=
True
)
self
.
parser
.
add_argument
(
"app"
,
type
=
str
,
location
=
"json"
,
required
=
False
)
args
=
self
.
parser
.
parse_args
()
try
:
json_payload
=
request
.
json
logger
.
warn
(
json_payload
)
data
=
getListLoginSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetListLogin
.
emit
(
data
)
json_dumps
=
getListLoginSchema
.
dump
(
result
)
jwt
=
get_jwt_identity
()
result
,
message
=
signalManager
.
actionPostAppReview
.
emit
(
args
.
app
,
args
.
review
,
jwt
)
if
result
:
json_dumps
=
getListLoginsSchema
.
dump
(
result
.
items
)
return
response_result
(
message
,
data
=
json_dumps
,
count
=
result
.
total
)
return
response_result
(
message
,
data
=
result
)
return
response_result
(
message
)
except
ValidationError
as
e
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
e
.
messages
)
...
...
@@ -47,21 +49,68 @@ class AppReviewResource(Resource):
data
=
None
if
hasattr
(
e
,
'args'
):
data
=
e
.
args
traceback
.
print_exc
()
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
,
data
=
data
)
@
jwt_required
(
locations
=
[
"headers"
])
class
BuildAppResource
(
Resource
):
def
__init__
(
self
):
self
.
parser
=
RequestParser
()
def
post
(
self
):
self
.
parser
.
add_argument
(
"review"
,
type
=
int
,
location
=
"json"
,
default
=
0
,
required
=
True
)
self
.
parser
.
add_argument
(
"app"
,
type
=
str
,
location
=
"json"
,
required
=
False
)
self
.
parser
.
add_argument
(
"access_key"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_name"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_version"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"category"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_desc"
,
type
=
str
,
location
=
"form"
,
required
=
False
)
self
.
parser
.
add_argument
(
"binfiles"
,
type
=
FileStorage
,
location
=
"files"
,
required
=
True
)
args
=
self
.
parser
.
parse_args
()
try
:
jwt
=
get_jwt_identity
()
result
,
message
=
signalManager
.
actionPostAppReview
.
emit
(
args
.
app
,
args
.
review
,
jwt
)
data
=
dict
()
for
key
,
value
in
args
.
items
():
if
value
!=
None
:
data
[
key
]
=
value
if
'binfiles'
in
request
.
files
:
files
=
[]
dt
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
upload_path
=
Path
(
config
.
EPK_DIR
)
.
joinpath
(
args
.
access_key
)
.
joinpath
(
dt
)
if
not
upload_path
.
exists
():
os
.
makedirs
(
upload_path
.
resolve
()
.
as_posix
())
for
f
in
request
.
files
.
getlist
(
'binfiles'
):
file_path
=
upload_path
.
joinpath
(
secure_filename
(
f
.
filename
))
f
.
save
(
file_path
.
resolve
()
.
as_posix
())
files
.
append
(
file_path
.
resolve
()
.
as_posix
())
result
,
message
=
signalManager
.
actionApplicationBuild
.
emit
(
data
,
files
)
if
result
:
return
response_result
(
message
,
data
=
result
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
)
else
:
return
response_result
(
message
)
else
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
msg
=
"files can not be null"
)
except
Exception
as
e
:
traceback
.
print_exc
()
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
class
CStringToolResource
(
Resource
):
def
__init__
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
self
.
parser
=
RequestParser
()
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
self
.
parser
.
add_argument
(
"string"
,
type
=
str
,
location
=
"json"
,
required
=
True
)
args
=
self
.
parser
.
parse_args
()
try
:
jwt
=
get_jwt_identity
()
logger
.
info
(
jwt
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
convert_string
(
args
.
string
))
except
ValidationError
as
e
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
e
.
messages
)
except
Exception
as
e
:
...
...
@@ -71,29 +120,46 @@ class AppReviewResource(Resource):
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
,
data
=
data
)
class
ObfuscatedCode
(
Resource
):
def
__init__
(
self
)
->
None
:
super
()
.
__init__
()
self
.
parser
=
RequestParser
()
class
BuildAppResource
(
Resource
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser = RequestParser()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
,
uuid
):
def
post
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
# self.parser.add_argument("pageSize", type=int, location="args", default=15
)
#
args = self.parser.parse_args()
self
.
parser
.
add_argument
(
"string"
,
type
=
str
,
location
=
"json"
,
required
=
True
)
args
=
self
.
parser
.
parse_args
()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getLoginSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetLogin
.
emit
(
uuid
,
data
)
if
result
:
json_dumps
=
getLoginSchema
.
dump
(
result
)
return
response_result
(
message
,
data
=
json_dumps
)
return
response_result
(
message
)
print
(
args
)
# fname = "./a.c"
# target = os.sep.join(["out", fname])
# if os.path.exists(fname):
# os.remove(fname)
# if os.path.exists(target):
# os.remove(target)
# with open(fname, "w+") as f:
# f.write(data['string'])
# result = os.system("./opqcp {i} ./out".format(i=fname))
# print(result)
# with open(target) as f:
# result = f.read()
# return result
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
)
except
ValidationError
as
e
:
return
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
e
.
messages
)
except
Exception
as
e
:
data
=
None
if
hasattr
(
e
,
'args'
):
data
=
e
.
args
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
,
data
=
data
)
tools/frontend/src/api/openapi.js
View file @
2c317d70
/*
* @Author: your name
* @Date: 2021-07-15 09:33:39
* @LastEditTime: 2021-07-19
18:13:07
* @LastEditTime: 2021-07-19
20:05:01
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\tools\frontend\src\api\openapi.js
...
...
@@ -100,3 +100,11 @@ export function updateDevice(uuid, params) {
data
:
params
,
});
}
export
function
getConvertString
(
params
)
{
return
request
({
url
:
"
/api/v1/api/convert-to-c-string
"
,
method
:
"
post
"
,
data
:
params
,
});
}
tools/frontend/src/views/Application/Tool.vue
View file @
2c317d70
<
template
>
<a-page-header-wrapper
title=
"
查询表格
"
>
<a-page-header-wrapper
title=
"
转换为C语言字符串
"
>
<a-card
:bordered=
"false"
>
<div
class=
"tableList"
>
<div
class=
"tableListForm"
>
<a-form
v-show=
"!expandForm"
layout=
"inline"
>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"设备"
v-decorator=
"['name']"
>
<a-input
placeholder=
"请输入"
/>
</a-form-item>
<a-row
:gutter=
"
{ sm: 24, md: 24, lg: 24, xl: 24 }">
<a-col
:md=
"12"
:sm=
"24"
>
<a-textarea
v-model=
"source"
placeholder=
"请将需要转换的文本粘贴到这里"
:auto-size=
"
{ minRows: 25, maxRows: 25 }"
/>
<div
style=
"margin: 10px"
>
<a-button
@
click=
"getConvertString"
>
开始转换
</a-button>
</div>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"性别"
v-decorator=
"['gender']"
>
<a-select
placeholder=
"请选择"
style=
"width: 100%"
>
<a-option
value=
"male"
>
male
</a-option>
<a-option
value=
"female"
>
female
</a-option>
</a-select>
<a-col
:md=
"12"
:sm=
"24"
>
<a-textarea
v-model=
"target"
:disabled=
"true"
placeholder=
"这里是转换后的结果"
:auto-size=
"
{ minRows: 25, maxRows: 25 }"
/>
<div
style=
"margin: 10px"
>
<a-form
layout=
"inline"
>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"16"
:sm=
"24"
>
<a-form-item
label=
"文件名"
v-decorator=
"['filename']"
:required=
"true"
>
<a-input
v-model=
"filename"
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<span
class=
"submitButtons"
>
<a-button
type=
"primary"
htmlType=
"submit"
>
查询
</a-button>
<a-button
:style=
"
{ marginLeft: '8px' }"> 重置
</a-button>
<a
:style=
"
{ marginLeft: '8px' }" @click="toggleForm">
展开
<a-icon
type=
"down"
/>
</a>
<a-button
type=
"primary"
@
click=
"downloadFile"
>
下载文件
</a-button>
</span>
</a-col>
</a-row>
</a-form>
<a-form
v-show=
"expandForm"
layout=
"inline"
>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"用户"
v-decorator=
"['username']"
>
<a-input
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"性别"
v-decorator=
"['gender']"
>
<a-select
placeholder=
"请选择"
style=
"width: 100%"
>
<a-option
value=
"male"
>
male
</a-option>
<a-option
value=
"female"
>
female
</a-option>
</a-select>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"姓名"
v-decorator=
"['name']"
>
<a-input
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
</a-row>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"时间"
v-decorator=
"['registered']"
>
<a-range-picker
style=
"width: 100%"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"邮箱"
v-decorator=
"['email']"
>
<a-input
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"国籍"
v-decorator=
"['nat']"
>
<a-input
placeholder=
"请输入"
/>
</a-form-item>
</div>
</a-col>
</a-row>
<div
style=
"overflow: hidden"
>
<div
:style=
"
{ float: 'right', marginBottom: '24px' }">
<a-button
type=
"primary"
htmlType=
"submit"
>
查询
</a-button>
<a-button
:style=
"
{ marginLeft: '8px' }"> 重置
</a-button>
<a
:style=
"
{ marginLeft: '8px' }" @click="toggleForm">
收起
<a-icon
type=
"up"
/>
</a>
</div>
</div>
</a-form>
</div>
<div
class=
"tableListOperator"
>
<a-button
icon=
"plus"
type=
"primary"
>
新建
</a-button>
<span
v-show=
"selectedRowKeys.length > 0"
>
<a-button>
批量操作
</a-button>
<!--
<a-dropdown
overlay=
{menu}>
<a-button>
更多操作
<icon
type=
"down"
/>
</a-button>
</a-dropdown>
-->
</span>
</div>
<!--
<StandardTable
selectedRows=
{selectedRows}
loading={loading}
data={data}
columns={this.columns}
onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange}
/> -->
<a-table
:columns=
"columns"
:rowKey=
"(record) => record.uuid"
:dataSource=
"users.data"
:pagination=
"users.pagination"
:loading=
"loading"
@
change=
"handleTableChange"
>
<template
slot=
"action"
slot-scope=
"text, record"
>
<a
href=
"javascript:;"
>
查看
</a>
<a-divider
type=
"vertical"
/>
<a
href=
"javascript:;"
>
配置
</a>
</
template
>
</a-table>
</div>
</a-card>
</a-page-header-wrapper>
</
template
>
...
...
@@ -131,71 +61,32 @@ import {
Dropdown
,
Input
,
Select
,
Modal
,
DatePicker
,
message
,
}
from
"
ant-design-vue
"
;
import
PageHeaderWrapper
from
"
@/components/PageHeaderWrapper
"
;
import
DescriptionItem
from
"
@/components/DescriptionItem
"
;
const
columns
=
[
{
title
:
"
用户名
"
,
dataIndex
:
"
login
"
,
sorter
:
true
,
width
:
"
12%
"
,
scopedSlots
:
{
customRender
:
"
login
"
},
},
{
title
:
"
姓名
"
,
dataIndex
:
"
name
"
,
sorter
:
true
,
width
:
"
15%
"
,
scopedSlots
:
{
customRender
:
"
name
"
},
},
{
title
:
"
性别
"
,
dataIndex
:
"
gender
"
,
filters
:
[
{
text
:
"
Male
"
,
value
:
"
male
"
},
{
text
:
"
Female
"
,
value
:
"
female
"
},
],
},
{
title
:
"
邮箱
"
,
dataIndex
:
"
email
"
,
},
{
title
:
"
国籍
"
,
dataIndex
:
"
nat
"
,
},
{
title
:
"
Action
"
,
key
:
"
action
"
,
scopedSlots
:
{
customRender
:
"
action
"
},
},
];
import
{
getConvertString
}
from
"
@/api/openapi
"
;
export
default
{
name
:
"
Device
Index
"
,
name
:
"
Tool
Index
"
,
data
:
()
=>
({
expandForm
:
false
,
selectedRowKeys
:
[],
columns
,
sya
:
{
fontSize
:
"
16px
"
,
color
:
"
rgba(0,0,0,0.85)
"
,
lineHeight
:
"
24px
"
,
display
:
"
block
"
,
marginBottom
:
"
16px
"
,
},
syb
:
{
marginBottom
:
"
24px
"
,
},
visible
:
false
,
confirmLoading
:
false
,
filename
:
null
,
source
:
null
,
target
:
null
,
}),
components
:
{
APageHeaderWrapper
:
PageHeaderWrapper
,
AAvatar
:
Avatar
,
ARow
:
Row
,
ACol
:
Col
,
ACard
:
Card
,
ATextarea
:
Input
.
TextArea
,
AModal
:
Modal
,
AAvatar
:
Avatar
,
ACardGrid
:
Card
.
Grid
,
ACardMeta
:
Card
.
Meta
,
AList
:
List
,
...
...
@@ -213,15 +104,30 @@ export default {
ARangePicker
:
DatePicker
.
RangePicker
,
},
methods
:
{
toggleForm
()
{
this
.
expandForm
=
!
this
.
expandForm
;
createFile
(
content
,
filename
)
{
const
a
=
document
.
createElement
(
"
a
"
);
const
blob
=
new
Blob
([
content
]);
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
a
.
href
=
url
;
a
.
download
=
filename
;
a
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
},
onSelectChange
(
selectedRowKeys
)
{
window
.
console
.
log
(
"
selectedRowKeys changed:
"
,
selectedRowKeys
);
this
.
selectedRowKeys
=
selectedRowKeys
;
downloadFile
()
{
this
.
visible
=
true
;
if
(
!
this
.
source
)
return
message
.
error
(
"
输入内容不能为空
"
);
this
.
createFile
(
this
.
target
,
this
.
filename
);
},
handleTableChange
(
pagination
,
filters
,
sorter
)
{
console
.
log
(
pagination
,
filters
,
sorter
)
getConvertString
()
{
getConvertString
({
string
:
this
.
source
})
.
then
((
res
)
=>
{
this
.
target
=
res
.
data
;
message
.
success
(
res
.
msg
);
})
.
catch
((
err
)
=>
{
message
.
error
(
err
.
msg
);
});
},
},
created
()
{},
...
...
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