Commit 7e653cc9 authored by shajiaiming's avatar shajiaiming

通过地址查看设备唯一码

parent 9a329d34
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace backend\assets\platformCoins;
use yii\web\AssetBundle;
use yii\web\View;
class IndexAsset extends AssetBundle
{
public $sourcePath = '@backend/web/js/platform-coins';
public $js = [
'index.js',
];
public $jsOptions = [
'position' => View::POS_END,
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/12/17
* Time: 10:13
*/
namespace backend\controllers;
use backend\models\coin\CoinPlatformForm;
use common\models\psources\CoinPlatform;
use common\models\psources\CoinPlatformCoins;
use Yii;
class PlatformCoinsController extends BaseController
{
public function actionList()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$coins_address = $request->get('coins_address', '**');
$where = [];
if ($coins_address) {
$where[] = ['coins_address' => $coins_address];
}
$data = CoinPlatformCoins::getList($page, $limit, $where);
foreach ($data['data'] as &$val){
unset($val['id']);
unset($val['coins_name']);
unset($val['type']);
unset($val['platform_id']);
unset($val['update_time']);
}
$data['code'] = 0;
Yii::$app->response->format = 'json';
return $data;
}
return $this->render('index');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use backend\assets\platformCoins\IndexAsset;
IndexAsset::register($this);
?>
<style>
.layui-table-tips-c {
padding: 0px;
}
</style>
<div class="layui-row">
<div class="layui-col-md8">
<form class="layui-form" method="get" action="">
<div class="layui-inline">
<label class="layui-form-label" style="margin-bottom: 0; width: 100px;">按地址搜索</label>
<div class="layui-input-inline">
<input class="layui-input" name="coins_address" style="width: 400px;">
</div>
</div>
<div class="layui-inline">
<button class="layui-btn" lay-submit lay-filter="form1">搜索</button>
</div>
</form>
</div>
</div>
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
<script type="text/html" id="operationTpl">
<a lay-event="edit">
<button class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe642;</i></button>
</a>
<a lay-event="delete">
<button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>
</a>
</script>
/**
* @author rlgyzhcn@qq.com
*/
var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var tableIns = table.render({
elem: "#table1",
url: '/admin/platform-coins/list',
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'coins_address', title: '地址'},
{field: 'deviceCode', title: '设备唯一码'},
{field: 'create_time', title: '添加时间'},
]],
});
form.on('submit(form1)', function (data) {
table.reload("table1", {
where: data.field,
page: {curr: 1},
});
return false;
});
//监听单元格事件
table.on('tool(table1)', function (obj) {
var data = obj.data;
if (obj.event == 'delete') {
layer.confirm('真的要删除' + data.name + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/wallet/delete?id=' + obj.data.id, function (data, status) {
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
} else if (obj.event == 'edit') {
$.get('/admin/wallet/edit', {id: data.id}, function (str) {
var editIndex = layer.open({
type: 1,
title: '编辑: ' + data.name,
area: '625px',
content: str,
btn: ['保存', '取消'],
btn1: function () {
// console.log();
$.post('/admin/wallet/edit', $("#walletEdit").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
table.reload("table1", {
where: data.field,
});
layer.close(editIndex);
}
});
}
});
});
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment