Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
devManagerSys
Project
Project
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
李远洪
devManagerSys
Commits
3146f085
Commit
3146f085
authored
Apr 01, 2021
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit
parent
1e501cdb
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
630 additions
and
6 deletions
+630
-6
README.md
README.md
+2
-0
app/Config/App.php
app/Config/App.php
+2
-2
app/Config/Routes.php
app/Config/Routes.php
+1
-1
app/Controllers/DevManageCtr.php
app/Controllers/DevManageCtr.php
+12
-0
app/Controllers/SysManage.php
app/Controllers/SysManage.php
+44
-0
app/Controllers/SysManageCtr.php
app/Controllers/SysManageCtr.php
+72
-0
app/Models/SysLogModel.php
app/Models/SysLogModel.php
+42
-0
app/Models/SysMsgModel.php
app/Models/SysMsgModel.php
+64
-0
app/Views/devManage/borrow_check.php
app/Views/devManage/borrow_check.php
+2
-0
app/Views/home/show_dev_detail.php
app/Views/home/show_dev_detail.php
+3
-1
app/Views/sysManage/aside.php
app/Views/sysManage/aside.php
+8
-2
app/Views/sysManage/msg_manage.php
app/Views/sysManage/msg_manage.php
+113
-0
pic1.png
pic1.png
+0
-0
sys_man.sql
sys_man.sql
+265
-0
No files found.
README.md
View file @
3146f085
# 设备管理系统

\ No newline at end of file
app/Config/App.php
View file @
3146f085
...
...
@@ -21,8 +21,8 @@ class App extends BaseConfig
| environments.
|
*/
// public $baseURL = 'http://localhost:8080
/';
public
$baseURL
=
'http://10.16.9.166:8080/'
;
public
$baseURL
=
'http://localhost:8082
/'
;
//
public $baseURL = 'http://10.16.9.166:8080/';
// public $baseURL = 'http://localhost/ci4/public/';
...
...
app/Config/Routes.php
View file @
3146f085
...
...
@@ -35,7 +35,7 @@ $routes->get('/devManage', 'DevManage::devManagePage');
$routes
->
get
(
'/sign'
,
'Sign::loginPage'
);
$routes
->
get
(
'/orgManage'
,
'OrgManage::orgManagePage'
);
$routes
->
get
(
'/userManage'
,
'UserManage::userManagePage'
);
$routes
->
get
(
'/sysManage'
,
'SysManage::
lo
gManagePage'
);
$routes
->
get
(
'/sysManage'
,
'SysManage::
ms
gManagePage'
);
/**
* --------------------------------------------------------------------
...
...
app/Controllers/DevManageCtr.php
View file @
3146f085
...
...
@@ -535,11 +535,22 @@ class DevManageCtr extends BaseController
$devManageModel
=
new
\App\Models\DevManageModel
();
$borrowInfo1
=
$devManageModel
->
searchBorrowerInfoByDevid
(
$item
);
$borrowInfo2
=
$devManageModel
->
searchBorrowInfoByBorrowerAndDevid
(
$item
);
$sysMsgModel
=
new
\App\Models\SysMsgModel
();
$theDevInfo
=
$devManageModel
->
getDeviceInfoById
(
$param
->
devId
)[
0
];
$sys_msg
=
$param
->
borrower
.
"签借了设备:"
.
$theDevInfo
[
"dev_name"
]
.
";设备id="
.
$param
->
devId
;
$msgInfo
=
array
();
$msgInfo
[
"msg_type"
]
=
1
;
$msgInfo
[
"msg_status"
]
=
0
;
$msgInfo
[
"msg_content"
]
=
$sys_msg
;
$msgInfo
[
"create_time"
]
=
$curTime
;
if
(
count
(
$borrowInfo1
)
==
0
||
count
(
$borrowInfo1
)
>
1
){
if
(
count
(
$borrowInfo2
)
==
0
){
$devManageModel
->
insertBorrowInfo
(
$item
);
$result
[
"status"
]
=
SUCESS
;
$result
[
"message"
]
=
"设备申请成功!"
;
$sysMsgModel
->
addMsg
(
$msgInfo
);
}
else
{
$result
[
"status"
]
=
COMMON_FAIL
;
$result
[
"message"
]
=
"你已经申请该设备!"
;
...
...
@@ -553,6 +564,7 @@ class DevManageCtr extends BaseController
$devManageModel
->
insertBorrowInfo
(
$item
);
$result
[
"status"
]
=
SUCESS
;
$result
[
"message"
]
=
"设备申请成功!"
;
$sysMsgModel
->
addMsg
(
$msgInfo
);
}
else
{
$result
[
"status"
]
=
COMMON_FAIL
;
$result
[
"message"
]
=
"你已经申请该设备!"
;
...
...
app/Controllers/SysManage.php
View file @
3146f085
...
...
@@ -41,4 +41,48 @@ class SysManage extends BaseController
return
view
(
'sysManage/log_manage'
,
$data
);
}
/****************************************************
* 消息管理页面
/****************************************************/
public
function
msgManagePage
(){
$data
=
array
();
$username
=
$this
->
request
->
getGet
(
"username"
);
$token
=
$this
->
request
->
getGet
(
"token"
);
$page
=
(
int
)
$this
->
request
->
getGet
(
"page"
);
if
(
$page
==
0
){
$page
=
1
;
}
$perPage
=
(
int
)
$this
->
request
->
getGet
(
"perPage"
);
if
(
$perPage
==
0
){
$perPage
=
20
;
}
$pageInfo
=
array
();
$pageInfo
[
"page"
]
=
$page
;
$pageInfo
[
"perPage"
]
=
$perPage
;
if
(
$username
==
""
||
$token
==
""
){
$data
[
"userInfo"
]
=
[];
}
else
{
$signModel
=
new
\App\Models\SignModel
();
$userInfo
=
$signModel
->
getItemByUsername
(
$username
);
$sysMsgModel
=
new
\App\Models\SysMsgModel
();
$totalNums
=
$sysMsgModel
->
getTatalMsgNum
()[
0
][
"total"
];
$pageInfo
[
"total"
]
=
$totalNums
;
$msgs
=
$sysMsgModel
->
getAllMsg
();
if
(
$userInfo
[
0
][
"token"
]
==
$token
){
$data
[
"userInfo"
]
=
$userInfo
[
0
];
$data
[
"notification"
]
=
[];
//TODO 小红点的逻辑需要加上
}
else
{
$data
[
"userInfo"
]
=
[];
}
$data
[
"msgs"
]
=
$msgs
;
$data
[
"pageInfo"
]
=
$pageInfo
;
}
$data
[
"uri"
]
=
getUriInfo
(
$this
->
request
);
return
view
(
'sysManage/msg_manage'
,
$data
);
}
}
\ No newline at end of file
app/Controllers/SysManageCtr.php
View file @
3146f085
<?php
namespace
App\Controllers
;
helper
(
'statusCode'
);
helper
(
'const'
);
class
SysManageCtr
extends
BaseController
{
/****************************************************
* 拒绝签借
/****************************************************/
function
refuseBorrow
(){
$result
=
array
();
$param
=
$this
->
request
->
getJSON
();
$borrowId
=
$param
->
msgId
;
try
{
$devManageModel
=
new
\App\Models\DevManageModel
();
$devManageModel
->
deleteBorrowMsgById
(
$borrowId
);
$devManageModel
->
deleteBorrowMsgById
(
$borrowId
);
$result
[
"status"
]
=
SUCESS
;
$result
[
"message"
]
=
"拒绝签借成功!"
;
}
catch
(
Exception
$e
){
$result
[
"status"
]
=
COMMON_FAIL
;
$message
=
$e
->
getMessage
();
$result
[
"message"
]
=
$message
;
}
$this
->
response
->
setHeader
(
'Content-Type'
,
'application/json'
)
->
setHeader
(
'charset'
,
'utf-8'
);
$result
=
json_encode
(
$result
);
echo
$result
;
}
/****************************************************
* 通过签借
/****************************************************/
function
acceptBorrow
(){
$result
=
array
();
$param
=
$this
->
request
->
getJSON
();
$timest
=
time
();
$curTime
=
date
(
"Y-m-d H:i:s"
,
$timest
);
$item
=
array
();
$item
[
"id"
]
=
$param
->
borrowId
;
$item
[
"borrow_status"
]
=
2
;
$item
[
"borrow_time"
]
=
$curTime
;
$item1
=
array
();
#用于更新设备的签借ID
$item1
[
"id"
]
=
$param
->
devId
;
$item1
[
"borrow_id"
]
=
$param
->
borrowId
;
$item2
=
array
();
#用于审核后删除非借出的相同设备id的设备签借信息
$item2
[
"dev_id"
]
=
$param
->
devId
;
$item2
[
"borrow_id"
]
=
$param
->
borrowId
;
try
{
$devManageModel
=
new
\App\Models\DevManageModel
();
$devManageModel
->
updateTheDeviceInfo
(
$item1
);
$devManageModel
->
modifyBorrowStatus
(
$item
);
$devManageModel
->
deleteBorrowMsgBydevidButId
(
$item2
);
$result
[
"status"
]
=
SUCESS
;
$result
[
"message"
]
=
"通过签借成功!"
;
}
catch
(
Exception
$e
){
$result
[
"status"
]
=
COMMON_FAIL
;
$message
=
$e
->
getMessage
();
$result
[
"message"
]
=
$message
;
}
$this
->
response
->
setHeader
(
'Content-Type'
,
'application/json'
)
->
setHeader
(
'charset'
,
'utf-8'
);
$result
=
json_encode
(
$result
);
echo
$result
;
}
}
\ No newline at end of file
app/Models/SysLogModel.php
0 → 100644
View file @
3146f085
<?php
namespace
App\Models
;
use
CodeIgniter\Model
;
class
SysLogModel
extends
Model
{
protected
$DBGroup
=
'default'
;
//默认连接的数据库
protected
$table
=
'sys_msg'
;
//指定模型要使用的数据库表
protected
$returnType
=
'array'
;
protected
$allowedFields
=
[
//允许更改,写入数据库的字段
"id"
,
"msg_type"
,
"msg_status"
,
"msg_content"
,
"create_time"
];
/****************************************************
* 添加系统消息
/****************************************************/
public
function
addMsg
(
$data
){
$sql
=
'insert into sys_msg (msg_type,msg_status,msg_content,create_time) values ('
.
$data
[
"msg_type"
]
.
','
.
$data
[
"msg_status"
]
.
',"'
.
$data
[
"msg_content"
]
.
'","'
.
$data
[
"create_time"
]
.
'")'
;
$this
->
db
->
query
(
$sql
);
}
/****************************************************
* 获取所有系统消息
/****************************************************/
public
function
getAllSysMsg
(){
$sql
=
'select * from sys_msg'
;
}
}
app/Models/SysMsgModel.php
0 → 100644
View file @
3146f085
<?php
namespace
App\Models
;
use
CodeIgniter\Model
;
class
SysMsgModel
extends
Model
{
protected
$DBGroup
=
'default'
;
//默认连接的数据库
protected
$table
=
'sys_msg'
;
//指定模型要使用的数据库表
protected
$returnType
=
'array'
;
protected
$allowedFields
=
[
//允许更改,写入数据库的字段
"id"
,
"msg_type"
,
"msg_status"
,
"msg_content"
,
"create_time"
];
/****************************************************
* 添加系统消息
/****************************************************/
public
function
addMsg
(
$data
){
$sql
=
'insert into sys_msg (msg_type,msg_status,msg_content,create_time) values ('
.
$data
[
"msg_type"
]
.
','
.
$data
[
"msg_status"
]
.
',"'
.
$data
[
"msg_content"
]
.
'","'
.
$data
[
"create_time"
]
.
'")'
;
$this
->
db
->
query
(
$sql
);
}
/****************************************************
* 获取所有系统消息
/****************************************************/
public
function
getAllMsg
(){
$sql
=
'select * from sys_msg ORDER BY create_time DESC'
;
$obj
=
$this
->
db
->
query
(
$sql
);
$result
=
$obj
->
getResultArray
();
return
$result
;
}
/****************************************************
* 获取所有消息数量
/****************************************************/
public
function
getTatalMsgNum
(){
$sql
=
'select count(*) as total from sys_msg'
;
$obj
=
$this
->
db
->
query
(
$sql
);
$result
=
$obj
->
getResultArray
();
return
$result
;
}
/****************************************************
* 修改消息签借状态
/****************************************************/
public
function
modifyMsgStatus
(
$data
){
$sql
=
'update sys_msg set msg_status='
.
$data
[
"msg_status"
]
.
' where id='
.
$data
[
"id"
];
$this
->
db
->
query
(
$sql
);
}
}
app/Views/devManage/borrow_check.php
View file @
3146f085
...
...
@@ -18,6 +18,7 @@
<th>
#
</th>
<th>
设备名
</th>
<th>
设备编号
</th>
<th>
设备id
</th>
<th>
借阅者
</th>
<th>
借阅原因
</th>
<th>
操作
</th>
...
...
@@ -29,6 +30,7 @@
<td>
<?=
$i
+
1
?>
</td>
<td>
<?=
$data
[
"borrowInfo"
][
$i
][
"dev_name"
]
?>
</td>
<td>
<?=
$data
[
"borrowInfo"
][
$i
][
"dev_code"
]
?>
</td>
<td>
<?=
$data
[
"borrowInfo"
][
$i
][
"dev_id"
]
?>
</td>
<td>
<?=
$data
[
"borrowInfo"
][
$i
][
"borrower"
]
?>
</td>
<td>
<?=
$data
[
"borrowInfo"
][
$i
][
"comment"
]
?>
</td>
<td>
...
...
app/Views/home/show_dev_detail.php
View file @
3146f085
...
...
@@ -8,7 +8,9 @@
<input
class=
"input-xlarge focused"
id=
"dev_id"
type=
"text"
value=
"
<?php
if
(
count
(
$data
[
"devInfo"
])
!=
0
){
echo
$data
[
"devInfo"
][
"id"
];}
?>
"
placeholder=
"输入设备id"
style=
"display:inline;margin: 0px;width:200px;"
>
<button
class=
"btn btn-primary"
onclick=
"showDevById()"
>
查 看
</button>
<?php
if
(
count
(
$data
[
"devInfo"
])
!=
0
){
?>
<button
class=
"btn btn-primary"
href=
"#showBorrowWindow"
data-toggle=
"modal"
userId=
'
<?php
if
(
$data
[
"userInfo"
]
!=
[]){
echo
$data
[
"userInfo"
][
"id"
];}
else
{
echo
"0"
;}
?>
'
onclick=
"showBorrowWindow(this)"
>
签 借
</button>
<?php
if
(
$data
[
"devInfo"
][
"borrow_status"
]
!=
2
)
{
?>
<button
class=
"btn btn-primary"
href=
"#showBorrowWindow"
data-toggle=
"modal"
userId=
'
<?php
if
(
$data
[
"userInfo"
]
!=
[]){
echo
$data
[
"userInfo"
][
"id"
];}
else
{
echo
"0"
;}
?>
'
onclick=
"showBorrowWindow(this)"
>
签 借
</button>
<?php
}
?>
<?php
}
?>
</div>
...
...
app/Views/sysManage/aside.php
View file @
3146f085
...
...
@@ -3,9 +3,13 @@
<div
class=
"row-fluid"
>
<div
class=
"span3"
id=
"sidebar"
style=
"width:250px;position:fixed;z-index:100;display:none;"
>
<ul
class=
"nav nav-list bs-docs-sidenav nav-collapse collapse"
>
<li
<?php
if
(
$data
[
"uri"
][
"seg"
][
2
]
==
"/"
||
$data
[
"uri"
][
"seg"
][
1
]
==
"logManagePage"
){
echo
"class='active'"
;}
?>
onclick=
"leftSwich(this)"
id=
"left_org_manage"
>
<li
<?php
if
(
$data
[
"uri"
][
"seg"
][
1
]
==
"/"
||
$data
[
"uri"
][
"seg"
][
1
]
==
"msgManagePage"
){
echo
"class='active'"
;}
?>
onclick=
"leftSwich(this)"
id=
"left_msg_manage"
>
<a><i
class=
"icon-chevron-right"
></i>
消息管理
</a>
</li>
<li
<?php
if
(
$data
[
"uri"
][
"seg"
][
1
]
==
"logManagePage"
){
echo
"class='active'"
;}
?>
onclick=
"leftSwich(this)"
id=
"left_log_manage"
>
<a><i
class=
"icon-chevron-right"
></i>
日志管理
</a>
</li>
</ul>
</div>
</div>
...
...
@@ -27,8 +31,10 @@
token
=
""
;
}
if
(
id
==
"
left_
or
g_manage
"
){
if
(
id
==
"
left_
lo
g_manage
"
){
window
.
location
.
href
=
"
http://
"
+
host
+
"
/sysManage/logManagePage?username=
"
+
username
+
"
&token=
"
+
token
;
}
else
if
(
id
==
"
left_msg_manage
"
){
window
.
location
.
href
=
"
http://
"
+
host
+
"
/sysManage/msgManagePage?username=
"
+
username
+
"
&token=
"
+
token
;
}
}
...
...
app/Views/sysManage/msg_manage.php
0 → 100644
View file @
3146f085
<?php
$data
=
$this
->
data
;
?>
<?php
$pager
=
\Config\Services
::
pager
();
?>
<?=
view
(
"header.php"
,
$data
);
?>
<?=
view
(
"sysManage/aside.php"
,
$data
);
?>
<div
class=
"span9"
id=
"content"
style=
"width:100%;"
>
<div
style=
"width:100%;min-height:700px;"
>
<div
style=
"width:100%;height:200px;_background:pink;margin:auto;"
>
<div
style=
"margin:0px 10px;margin-top:10px;padding:0px 10px;_background:pink;min-height:50px;"
>
<select
id=
"selectError"
style=
"display:inline;margin: 0px;width:150px;"
value=
"所有消息"
>
<option>
所有消息
</option>
<option>
未读消息
</option>
</select>
<button
class=
"btn btn-primary"
>
查询
</button>
</div>
<div
class=
"row-fluid"
style=
"width:auto;margin:0px 10px;"
>
<!-- block -->
<div
class=
"block"
>
<div
class=
"block-content collapse in"
>
<div
class=
"span12"
>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
#
</th>
<th>
消息内容
</th>
<th>
状态
</th>
<th>
时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<?php
for
(
$i
=
0
;
$i
<
count
(
$data
[
"msgs"
]);
$i
++
){
?>
<tr
msgId=
"
<?=
$data
[
"msgs"
][
$i
][
"id"
]
?>
"
>
<td>
<?=
$i
+
1
?>
</td>
<td>
<?=
$data
[
"msgs"
][
$i
][
"msg_content"
]
?>
</td>
<td>
<?php
if
(
$data
[
"msgs"
][
$i
][
"msg_status"
]
==
0
){
echo
"<p style='color:red;'>未读</p>"
;}
else
{
echo
"<p>已读</p>"
;}
?>
</td>
<td>
<?=
$data
[
"msgs"
][
$i
][
"create_time"
]
?>
</td>
<td>
<?php
if
(
$data
[
"msgs"
][
$i
][
"msg_status"
]
==
0
){
?>
<a
href=
"#"
onclick=
"goDetailPage()"
>
详情
</a>
<a
href=
"#"
onclick=
"allowBorrow(this)"
>
同意
</a>
<a
href=
"#"
onclick=
"refuseBorrow(this)"
>
拒绝
</a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div
class=
"pagination"
style=
"text-align:right;padding-right:30px;height:50px;"
>
<div>
<div
style=
"display:inline;"
>
<select
id=
"per_page"
size=
"1"
style=
"width:100px;margin:0px;float:right;height:30px;margin-left:5px;"
onchange=
"perPageChange()"
>
<option
value=
"10"
<?php
if
(
$data
[
"pageInfo"
][
"perPage"
]
==
15
){
echo
'selected="selected"'
;}
?>
>
10 条/页
</option>
<option
value=
"20"
<?php
if
(
$data
[
"pageInfo"
][
"perPage"
]
==
20
){
echo
'selected="selected"'
;}
?>
>
20 条/页
</option>
<option
value=
"50"
<?php
if
(
$data
[
"pageInfo"
][
"perPage"
]
==
50
){
echo
'selected="selected"'
;}
?>
>
50 条/页
</option>
<option
value=
"100"
<?php
if
(
$data
[
"pageInfo"
][
"perPage"
]
==
100
){
echo
'selected="selected"'
;}
?>
>
100 条/页
</option>
</select>
</div>
<?=
$pager
->
makeLinks
(
$data
[
"pageInfo"
][
"page"
],
$data
[
"pageInfo"
][
"perPage"
],
$data
[
"pageInfo"
][
"total"
])
?>
</div>
</div>
</div>
<!-- /block -->
</div>
</div>
</div>
</div>
<?=
view
(
"footer.php"
,
$data
);
?>
<style>
.pagination
{
margin
:
0px
0px
;
}
</style>
<script>
/*****************************************************
* 点击进入消息详情
*****************************************************/
function
goDetailPage
(){
var
host
=
window
.
location
.
host
;
var
username
=
$
.
cookie
(
'
username
'
);
var
token
=
$
.
cookie
(
'
token
'
);
if
(
username
==
undefined
){
username
=
""
;
}
if
(
token
==
undefined
){
token
=
""
;
}
window
.
location
.
href
=
"
http://
"
+
host
+
"
/devManage/borrowCheckPage
"
+
"
?username=
"
+
username
+
"
&token=
"
+
token
;
}
/*****************************************************
* 同意签借
*****************************************************/
function
allowBorrow
(
e
){
var
content
=
$
(
$
(
e
).
parent
().
prevAll
()[
2
]).
text
();
devId
=
content
.
split
(
"
=
"
)[
1
]
console
.
log
(
devId
)
}
/*****************************************************
* 拒绝签借
*****************************************************/
function
refuseBorrow
(
e
){
var
content
=
$
(
$
(
e
).
parent
().
prevAll
()[
2
]).
text
();
devId
=
content
.
split
(
"
=
"
)[
1
]
console
.
log
(
devId
)
}
</script>
pic1.png
0 → 100644
View file @
3146f085
186 KB
sys_man.sql
0 → 100644
View file @
3146f085
This diff is collapsed.
Click to expand it.
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