dev
曾超新 5 years ago
parent 0cc576ffd9
commit 0ecea49471
  1. 1
      common/models/SysIpT.php
  2. 44
      frontend/controllers/SystemController.php
  3. 2
      frontend/views/insurer-type/index.php
  4. 2
      frontend/views/pay-type/edit.php
  5. 48
      frontend/views/system/edit.php
  6. 68
      frontend/views/system/ip-edit.php
  7. 154
      frontend/views/system/ip.php

@ -57,7 +57,6 @@ class SysIpT extends \common\models\Base
static public function getIpArray(){
$list = self::find()
->where('status = 1')
->orderBy('id ASC')
->all();

@ -19,7 +19,8 @@ class SystemController extends \yii\web\Controller
{
public $my = null;
public $web = null;
private $_STATE = 1;
public $enableCsrfValidation = false;
public $layout = 'blue-main';
public function init()
{
@ -94,21 +95,27 @@ class SystemController extends \yii\web\Controller
* @author liukangle
*
*/
public function actionIp(){
public function actionIp() {
return $this->render('ip');
}
public function actionIpJson(){
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
$name = $request->get('name');
$ips = SysIpT::find();
if($name != ''){
$ips = $ips->andWhere(['like','city_name',$name]);
$ips = SysIpT::find()->orderBy('id ASC');
$total = $ips->count();
$items = $ips->all();
$data = [];
$data['total'] = $total;
$data['rows'] = [];
foreach($items as $item) {
$row = $item->toArray();
$data['rows'][] = $row;
}
$ips = $ips->andWhere('status ='.$this->_STATE);
$data = $ips->orderBy('id ASC')->all();
return $this->render('ip',[
'info' => $data,
'name' => $name,
]);
return $data;
}
/**
@ -119,7 +126,7 @@ class SystemController extends \yii\web\Controller
* @author liukangle
*
*/
public function actionEdit()
public function actionIpEdit()
{
$request = Yii::$app->request;
@ -129,7 +136,7 @@ class SystemController extends \yii\web\Controller
} else {
$info = new SysIpT();
}
return $this->render('edit',[
return $this->render('ip-edit',[
'info' => $info,
]);
}
@ -181,7 +188,7 @@ class SystemController extends \yii\web\Controller
* @author liukangle
*
*/
public function actionDel()
public function actionIpDelete()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$request = Yii::$app->request;
@ -194,11 +201,12 @@ class SystemController extends \yii\web\Controller
$id = $request->post('id');
if($id > 0){
$row = SysIpT::findOne(['id'=>$id]);
$row->status = 0;
$row->save();
if($row) {
$row->delete();
}
$result['success'] = true;
$result['msg'] = '保存成功';
$result['msg'] = '删除成功';
}
return $result;

@ -47,12 +47,14 @@ use \common\libs\MyLib;
<script>
function opFormatter(value, row, index) {
var opStr = [];
if(row.id > 12) {
opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">');
opStr.push('<i class="fa fa-edit" title="编辑"></i>');
opStr.push('</a>');
opStr.push('<a href="javascript:void(0);" onclick="del(' + row.id + ')">');
opStr.push('<i class="fa fa-trash" title="删除"></i>');
opStr.push('</a>');
}
return opStr.join(' ');
}

@ -50,7 +50,7 @@ use \common\libs\MyLib;
parent.refreshList();
layer_close();
} else {
parent.layer.msg(data.msg);
parent.layer.msg(obj.msg);
}
},'json');
}, function(){

@ -1,48 +0,0 @@
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="theFrm">
<input type="hidden" name="id" value="<?=$info->id?>">
<tr>
<td width="100" height="25" class="td_bg">城市</td>
<td height="25" class="td_bg">
<input name="city_name" type="text" id="city_name" value="<?= $info->city_name ?>" style="width:400px;"/>
</td>
</tr>
<tr>
<td width="100" height="25" class="td_bg">IP</td>
<td height="25" class="td_bg">
<input name="ip" type="text" id="ip" value="<?= $info->ip ?>" style="width:400px;"/>
</td>
</tr>
</form>
<tr>
<td height="22" colspan="2" align="center" class="td_bg">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/>
&nbsp;&nbsp;
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 ">
</td>
</tr>
</table>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
$(function () {
//提交按钮
$("#submit-btn").click(function(){
if(confirm('是否确认提交?')) {
var params = $("#theFrm").serialize();
$.post('/system/ip-save',params,function(obj){
alert(obj.msg);
if(obj.success) {
$('#back-btn').click();
}
},'json');
}
});
//返回按钮
$('#back-btn').click(function(){
window.location.href='/system/ip';
});
})
</script>

@ -0,0 +1,68 @@
<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/iCheck/custom.css" rel="stylesheet">
<?php $this->endBlock(); ?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="row">
<div class="col-sm-12">
<form role="form" class="form-horizontal data-from" id="theFrm">
<input type="hidden" name="id" value="<?=intval($info->id)?>">
<div class="form-group">
<label class="col-sm-1 control-label">城市</label>
<div class="col-sm-6">
<input type="text" name="city_name" value="<?=$info->city_name?>" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">IP</label>
<div class="col-sm-6">
<input type="text" name="ip" value="<?=$info->ip?>" class="form-control">
</div>
</div>
<div>
<div class="row">
<div class="col-sm-5 col-sm-offset-5">
<button class="btn btn-primary btn-save" type="button">
<strong><?=$info ? '保 存':'添 加'?></strong>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript">
$(function () {
//提交按钮
$(".btn-save").click(function(){
parent.layer.confirm('是否确认提交?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
var params = $("#theFrm").serialize();
$.post('/system/ip-save',params,function(obj){
if(obj.success) {
parent.layer.msg('保存成功');
parent.refreshList();
layer_close();
} else {
parent.layer.msg(obj.msg);
}
},'json');
}, function(){
//
});
});
})
</script>
<?php $this->endBlock('footer_js'); ?>

@ -1,76 +1,98 @@
<?php
use \common\libs\MyLib;
?>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
$('#add-btn').click(function(){
edit(0);
});
$("#search-btn").click(function(){
var params = $('#searchForm').serialize();
window.location.href = "/system/ip?" + params;
});
});
//编辑
<?php $this->beginBlock('header_css'); ?>
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<?php $this->endBlock(); ?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>外网IP管理</h5>
<div class="ibox-tools">
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="create(0)">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');">
<i class="fa fa-refresh"></i> 刷新
</a>
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-md-12">
<table id="listTable">
<thead>
<tr>
<th width="50" data-field="id">ID</th>
<th data-field="city_name">城市</th>
<th data-field="ip">IP</th>
<th data-formatter="opFormatter">操作</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
function opFormatter(value, row, index) {
var opStr = [];
opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">');
opStr.push('<i class="fa fa-edit" title="编辑"></i>');
opStr.push('</a>');
opStr.push('<a href="javascript:void(0);" onclick="del(' + row.id + ')">');
opStr.push('<i class="fa fa-trash" title="删除"></i>');
opStr.push('</a>');
return opStr.join(' ');
}
function create() {
title = '新增IP';
layer_show(title, '/system/ip-edit?id=0');
}
function edit(id) {
window.location.href = '/system/edit?id=' + id;
var title = '编辑IP';
layer_show(title, '/system/ip-edit?id=' + id);
}
//删除
function del(id) {
if(confirm('是否确认删除?')) {
$.post('/system/del',{id:id},function(obj){
alert(obj.msg);
if(obj.success) {
window.location.reload();
}
},'json');
parent.layer.confirm('是否确认删除?', {
btn: ['删除','取消'], //按钮
shade: false //不显示遮罩
}, function(){
$.post('/system/ip-delete',{id:id},function(data) {
parent.layer.msg(data.msg);
refreshList();
}, 'json');
}, function(){
//
});
}
function refreshList() {
$('#listTable').bootstrapTable('refresh');
}
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<tr>
<td class="td_bg">
名称:<input name="name" type="text" value="<?= $name ?>">
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索">
<input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加">
</td>
</tr>
</form>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
<?php
if($info){
?>
<tr>
<td width="10%" align="center" align="center" class="bg_tr" nowrap>序列号</td>
<td width="30%" align="center" align="center" class="bg_tr">城市</td>
<td width="20%" align="center" align="center" class="bg_tr">IP</td>
<td width="40%" align="center" class="bg_tr">操作</td>
</tr>
<?php
foreach($info as $index => $item){
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td align="center" class="td_bg" nowrap ><?= $index+1 ?></td>
<td align="left" class="td_bg" nowrap ><?= $item->city_name ?></td>
<td align="left" class="td_bg" nowrap ><?= $item->ip ?></td>
<td align="center" class="td_bg" nowrap>
[<a href="javascript:void(0);" onclick="edit(<?= $item->id ?>)">修改</a>]
[<a href="javascript:void(0);" onclick="del(<?= $item->id ?>)">删除</a>]
</td>
</tr>
<?php
function search() {
$('#listTable').bootstrapTable('destroy');
$('#listTable').bootstrapTable({
url: "/system/ip-json",
pagination: false,
sidePagination: 'server',
queryParams: function(params) {
return params;
}
?>
<?php
}else{
?>
<tr>没有查到数据</tr>
<?php
});
}
?>
</table>
$(function() {
search();
});
</script>
<?php $this->endBlock(); ?>

Loading…
Cancel
Save