Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
17d844b6
Commit
17d844b6
authored
Apr 12, 2020
by
季圣华
Browse files
增加插件模块
parent
b55e6401
Changes
2
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/plugin.html
0 → 100644
View file @
17d844b6
<!DOCTYPE html>
<html>
<head>
<title>
插件管理
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<!-- 指定以IE8的方式来渲染 -->
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=EmulateIE8"
/>
<link
rel=
"shortcut icon"
href=
"/images/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"stylesheet"
href=
"/js/bootstrap/css/bootstrap.min.css"
>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"/css/jsherp.css"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/js/easyui/themes/default/easyui.css"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/js/easyui/themes/icon.css"
/>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"/css/common.css"
/>
<script
type=
"text/javascript"
src=
"/js/jquery-1.8.0.min.js"
></script>
<script
type=
"text/javascript"
src=
"/js/easyui/jquery.easyui.min.js"
></script>
<script
type=
"text/javascript"
src=
"/js/easyui/locale/easyui-lang-zh_CN.js"
></script>
<script
type=
"text/javascript"
src=
"/js/common/common.js"
></script>
</head>
<body>
<!-- 数据显示table -->
<div
id=
"tablePanel"
class=
"easyui-panel"
data-options=
"fit:true"
style=
"padding:1px;top:300px;"
title=
"插件管理"
iconCls=
"icon-list"
>
<div
class=
"box-body form-inline"
>
<div
class=
"form-group"
>
<label
class=
"control-label"
>
车牌号码:
</label>
<div
class=
"control-inline"
>
<input
type=
"text"
id=
"searchPluginNumber"
name=
"searchPluginNumber"
value=
""
maxlength=
"100"
class=
"easyui-textbox width-90"
/>
</div>
</div>
<div
class=
"form-group"
>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-search"
id=
"searchBtn"
>
查询
</a>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-redo"
id=
"searchResetBtn"
>
重置
</a>
</div>
</div>
<table
id=
"tableData"
style=
"height:340px;top:300px;border-bottom-color:#FFFFFF"
></table>
</div>
<div
id=
"pluginDlg"
class=
"easyui-dialog"
style=
"width:380px;padding:10px 20px"
closed=
"true"
buttons=
"#dlg-buttons"
modal=
"true"
cache=
"false"
collapsible=
"false"
closable=
"true"
>
<form
id=
"pluginFM"
method=
"post"
novalidate
>
<table>
<tr>
<td
style=
"width:60px;"
>
车牌号码
</td>
<td
style=
"padding:5px"
>
<input
name=
"pluginNumber"
id=
"pluginNumber"
class=
"easyui-textbox"
data-options=
"required:true,validType:'length[2,30]'"
style=
"width: 230px;"
/>
</td>
</tr>
<tr>
<td>
驾驶员
</td>
<td
style=
"padding:5px"
>
<input
name=
"pluginDriver"
id=
"pluginDriver"
class=
"easyui-textbox"
data-options=
"validType:'length[2,30]'"
style=
"width: 230px;"
/>
</td>
</tr>
<tr>
<td>
车辆状态
</td>
<td
style=
"padding:5px"
>
<select
name=
"pluginStatus"
id=
"pluginStatus"
class=
"easyui-combobox"
data-options=
"panelHeight:'auto'"
style=
"width:230px;"
>
<option
value=
"1"
>
正常
</option>
<option
value=
"2"
>
在租
</option>
<option
value=
"3"
>
在售
</option>
</select>
</td>
</tr>
<tr>
<td>
车辆归属
</td>
<td
style=
"padding:5px"
>
<select
name=
"pluginBelong"
id=
"pluginBelong"
class=
"easyui-combobox"
data-options=
"panelHeight:'auto'"
style=
"width:230px;"
>
<option
value=
"1"
>
公司车
</option>
<option
value=
"2"
>
外请车
</option>
<option
value=
"3"
>
租用车
</option>
</select>
</td>
</tr>
</table>
</form>
</div>
<div
id=
"dlg-buttons"
>
<a
href=
"javascript:void(0)"
id=
"savePlugin"
class=
"easyui-linkbutton"
iconCls=
"icon-ok"
>
保存
</a>
<a
href=
"javascript:void(0)"
id=
"cancelPlugin"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
onclick=
"javascript:$('#pluginDlg').dialog('close')"
>
取消
</a>
</div>
<script
type=
"text/javascript"
>
//初始化界面
$
(
function
()
{
initTableData
();
ininPager
();
});
//初始化表格数据
function
initTableData
()
{
$
(
'
#tableData
'
).
datagrid
({
height
:
heightInfo
,
nowrap
:
false
,
rownumbers
:
true
,
//动画效果
animate
:
false
,
//选中单行
singleSelect
:
true
,
collapsible
:
false
,
selectOnCheck
:
false
,
//单击行是否选中
checkOnSelect
:
false
,
//交替出现背景
striped
:
true
,
pagination
:
true
,
pageSize
:
initPageSize
,
pageList
:
initPageNum
,
columns
:
[[
{
field
:
'
id
'
,
width
:
35
,
align
:
"
center
"
,
checkbox
:
true
},
{
title
:
'
操作
'
,
field
:
'
op
'
,
align
:
"
center
"
,
width
:
60
,
formatter
:
function
(
value
,
rec
,
index
)
{
var
str
=
''
;
str
+=
'
<img title="开启" src="/js/easyui/themes/icons/ok.png" style="cursor: pointer;" onclick="startPlugin(
\'
'
+
rec
.
pluginDescriptor
.
pluginId
+
'
\'
);"/>
'
;
str
+=
'
<img title="停止" src="/js/easyui/themes/icons/no.png" style="cursor: pointer;" onclick="stopPlugin(
\'
'
+
rec
.
pluginDescriptor
.
pluginId
+
'
\'
);"/>
'
;
return
str
;
}
},
{
title
:
'
插件Id
'
,
field
:
'
pluginId
'
,
width
:
150
,
formatter
:
function
(
value
,
rec
)
{
if
(
rec
)
{
return
rec
.
pluginDescriptor
.
pluginId
;
}
}
},
{
title
:
'
插件描述
'
,
field
:
'
pluginDescription
'
,
width
:
150
,
formatter
:
function
(
value
,
rec
)
{
if
(
rec
)
{
return
rec
.
pluginDescriptor
.
pluginDescription
;
}
}
},
{
title
:
'
版本
'
,
field
:
'
pluginVersion
'
,
width
:
150
,
formatter
:
function
(
value
,
rec
)
{
if
(
rec
)
{
return
rec
.
pluginDescriptor
.
version
;
}
}
},
{
title
:
'
作者
'
,
field
:
'
provider
'
,
width
:
100
,
formatter
:
function
(
value
,
rec
)
{
if
(
rec
)
{
return
rec
.
pluginDescriptor
.
provider
;
}
}
},
{
title
:
'
插件路径
'
,
field
:
'
path
'
,
width
:
400
},
{
title
:
'
插件状态
'
,
field
:
'
pluginState
'
,
width
:
100
,
formatter
:
function
(
value
,
rec
)
{
if
(
rec
)
{
if
(
rec
.
pluginState
==
"
STARTED
"
)
{
return
"
<span style='color:green'>开启</span>
"
;
}
else
if
(
rec
.
pluginState
==
"
STOPPED
"
)
{
return
"
<span style='color:red'>关闭</span>
"
;
}
}
}
}
]],
toolbar
:
[
{
id
:
'
addPlugin
'
,
text
:
'
增加
'
,
iconCls
:
'
icon-add
'
,
handler
:
function
()
{
addPlugin
();
}
},
'
-
'
,
{
id
:
'
deletePlugin
'
,
text
:
'
删除
'
,
iconCls
:
'
icon-remove
'
,
handler
:
function
()
{
batDeletePlugin
();
}
}
],
onLoadError
:
function
()
{
$
.
messager
.
alert
(
'
页面加载提示
'
,
'
页面加载异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
dgResize
();
showPluginDetails
(
1
,
initPageSize
);
}
//分页信息处理
function
ininPager
()
{
try
{
var
opts
=
$
(
"
#tableData
"
).
datagrid
(
'
options
'
);
var
pager
=
$
(
"
#tableData
"
).
datagrid
(
'
getPager
'
);
pager
.
pagination
({
onSelectPage
:
function
(
pageNum
,
pageSize
)
{
opts
.
pageNumber
=
pageNum
;
opts
.
pageSize
=
pageSize
;
pager
.
pagination
(
'
refresh
'
,
{
pageNumber
:
pageNum
,
pageSize
:
pageSize
});
showPluginDetails
(
pageNum
,
pageSize
);
}
});
}
catch
(
e
)
{
$
.
messager
.
alert
(
'
异常处理提示
'
,
"
分页信息异常 :
"
+
e
.
name
+
"
:
"
+
e
.
message
,
'
error
'
);
}
}
//停止插件
function
stopPlugin
(
pluginId
)
{
$
.
messager
.
confirm
(
'
停止确认
'
,
'
确定要停止该插件吗?
'
,
function
(
r
)
{
if
(
r
)
{
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/plugin/stop/
"
+
pluginId
,
dataType
:
"
json
"
,
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
==
200
)
{
$
(
"
#searchBtn
"
).
click
();
}
else
{
$
.
messager
.
alert
(
'
停止提示
'
,
'
停止插件失败,请稍后再试!
'
,
'
error
'
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
停止提示
'
,
'
停止插件异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
});
}
//增加
var
url
;
var
pluginId
=
0
;
//保存编辑前的名称
var
oldPluginNumber
=
""
;
function
addPlugin
()
{
$
(
'
#pluginDlg
'
).
dialog
(
'
open
'
).
dialog
(
'
setTitle
'
,
'
<img src="/js/easyui/themes/icons/edit_add.png"/> 增加车辆信息
'
);
$
(
"
.window-mask
"
).
css
({
width
:
webW
,
height
:
webH
});
$
(
'
#pluginFM
'
).
form
(
'
clear
'
);
oldPluginNumber
=
""
;
pluginId
=
0
;
url
=
'
/api/plugin/plugin-plugin/plugin/insert
'
;
}
//开启插件
function
startPlugin
(
pluginId
)
{
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/plugin/start/
"
+
pluginId
,
dataType
:
"
json
"
,
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
==
200
)
{
$
(
"
#searchBtn
"
).
click
();
}
else
{
$
.
messager
.
alert
(
'
开启提示
'
,
'
开启插件失败,请稍后再试!
'
,
'
error
'
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
开启提示
'
,
'
开启插件异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
//搜索处理
$
(
"
#searchBtn
"
).
unbind
().
bind
({
click
:
function
()
{
showPluginDetails
(
1
,
initPageSize
);
var
opts
=
$
(
"
#tableData
"
).
datagrid
(
'
options
'
);
var
pager
=
$
(
"
#tableData
"
).
datagrid
(
'
getPager
'
);
opts
.
pageNumber
=
1
;
opts
.
pageSize
=
initPageSize
;
pager
.
pagination
(
'
refresh
'
,
{
pageNumber
:
1
,
pageSize
:
initPageSize
});
}
});
function
showPluginDetails
(
pageNo
,
pageSize
)
{
$
.
ajax
({
type
:
"
get
"
,
url
:
"
/plugin/list
"
,
dataType
:
"
json
"
,
data
:
({
currentPage
:
pageNo
,
pageSize
:
pageSize
}),
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
){
$
(
"
#tableData
"
).
datagrid
(
'
loadData
'
,
res
.
data
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
查询提示
'
,
'
查询数据后台异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
//重置按钮
$
(
"
#searchResetBtn
"
).
unbind
().
bind
({
click
:
function
()
{
$
(
"
#searchPluginNumber
"
).
textbox
(
"
setValue
"
,
""
);
//加载完以后重新初始化
$
(
"
#searchBtn
"
).
click
();
}
});
</script>
</body>
</html>
\ No newline at end of file
src/main/java/com/jsh/erp/controller/PluginController.java
View file @
17d844b6
...
...
@@ -3,12 +3,16 @@ package com.jsh.erp.controller;
import
com.gitee.starblues.integration.application.PluginApplication
;
import
com.gitee.starblues.integration.operator.PluginOperator
;
import
com.gitee.starblues.integration.operator.module.PluginInfo
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.nio.file.Paths
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
...
...
@@ -31,9 +35,24 @@ public class PluginController {
* 获取插件信息
* @return 返回插件信息
*/
@GetMapping
public
List
<
PluginInfo
>
getPluginInfo
(){
return
pluginOperator
.
getPluginInfo
();
@GetMapping
(
value
=
"/list"
)
public
BaseResponseInfo
getPluginInfo
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
List
<
PluginInfo
>
list
=
pluginOperator
.
getPluginInfo
();
map
.
put
(
"rows"
,
list
);
map
.
put
(
"total"
,
list
.
size
());
res
.
code
=
200
;
res
.
data
=
map
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"获取数据失败"
;
}
return
res
;
}
/**
...
...
@@ -57,17 +76,26 @@ public class PluginController {
* @return 返回操作结果
*/
@PostMapping
(
"/stop/{id}"
)
public
String
stop
(
@PathVariable
(
"id"
)
String
id
){
public
BaseResponseInfo
stop
(
@PathVariable
(
"id"
)
String
id
){
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
""
;
try
{
if
(
pluginOperator
.
stop
(
id
)){
return
"plugin '"
+
id
+
"' stop success"
;
message
=
"plugin '"
+
id
+
"' stop success"
;
}
else
{
return
"plugin '"
+
id
+
"' stop failure"
;
message
=
"plugin '"
+
id
+
"' stop failure"
;
}
map
.
put
(
"message"
,
message
);
res
.
code
=
200
;
res
.
data
=
map
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
"plugin '"
+
id
+
"' stop failure. "
+
e
.
getMessage
();
map
.
put
(
"message"
,
"plugin '"
+
id
+
"' stop failure. "
+
e
.
getMessage
());
res
.
code
=
500
;
res
.
data
=
map
;
}
return
res
;
}
/**
...
...
@@ -76,17 +104,26 @@ public class PluginController {
* @return 返回操作结果
*/
@PostMapping
(
"/start/{id}"
)
public
String
start
(
@PathVariable
(
"id"
)
String
id
){
public
BaseResponseInfo
start
(
@PathVariable
(
"id"
)
String
id
){
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
""
;
try
{
if
(
pluginOperator
.
start
(
id
)){
return
"plugin '"
+
id
+
"' start success"
;
message
=
"plugin '"
+
id
+
"' start success"
;
}
else
{
return
"plugin '"
+
id
+
"' start failure"
;
message
=
"plugin '"
+
id
+
"' start failure"
;
}
map
.
put
(
"message"
,
message
);
res
.
code
=
200
;
res
.
data
=
map
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
"plugin '"
+
id
+
"' start failure. "
+
e
.
getMessage
();
map
.
put
(
"message"
,
"plugin '"
+
id
+
"' start failure. "
+
e
.
getMessage
());
res
.
code
=
500
;
res
.
data
=
map
;
}
return
res
;
}
...
...
Write
Preview
Supports
Markdown
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