Commit 04404eee authored by shajiaiming's avatar shajiaiming

fix

parent 3030c9c5
......@@ -11,7 +11,7 @@ class CoinSupportedSymbolController extends BaseController
{
public function actionList()
{
$platform_withhold_id = Yii::$app->request->get('id');
$platform_id = Yii::$app->request->get('id');
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
......@@ -20,7 +20,7 @@ class CoinSupportedSymbolController extends BaseController
$id = $request->get('id', '');
$where = [];
if ($id) {
$where[] = ['platform_withhold_id' => $id];
$where[] = ['platform_id' => $id];
}
$data = CoinSupportedSymbol::getList($page, $limit, $where);
$data['code'] = 0;
......@@ -28,7 +28,7 @@ class CoinSupportedSymbolController extends BaseController
return $data;
}
return $this->render('index', ['platform_withhold_id' => $platform_withhold_id]);
return $this->render('index', ['platform_id' => $platform_id]);
}
public function actionAdd()
......@@ -40,11 +40,12 @@ class CoinSupportedSymbolController extends BaseController
if ($model->load($data, '') && $model->validate()) {
$coinSupportedSymbol = new CoinSupportedSymbol();
$coinSupportedSymbol->platform_withhold_id = $data['platform_withhold_id'];
$coinSupportedSymbol->symbol = $data['symbol'];
$coinSupportedSymbol->platform_id = $data['platform_id'];
$coinSupportedSymbol->currency = $data['currency'];
$coinSupportedSymbol->base_currency = $data['base_currency'];
$result = $coinSupportedSymbol->save();
if ($result === true) {
$this->success('添加成功', '/admin/coin-supported-symbol/list?id=' . $data['platform_withhold_id']);
$this->success('添加成功', '/admin/coin-supported-symbol/list?id=' . $data['platform_id']);
}
}
//表单验证失败
......@@ -59,8 +60,8 @@ class CoinSupportedSymbolController extends BaseController
}
$this->error($errors, Yii::$app->request->getReferrer());
}
$platform_withhold_id = Yii::$app->request->get('platform_withhold_id');
return $this->render('add', ['model' => $model, 'platform_withhold_id' => $platform_withhold_id]);
$platform_id = Yii::$app->request->get('platform_id');
return $this->render('add', ['model' => $model, 'platform_id' => $platform_id]);
}
public function actionDelete()
......
<h4>添加货币对</h4>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md6">
<form class="layui-form" method="post" action="">
<div style="padding: 5px 20px;">
<br>
<form id="addData">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-inline">
<label class="layui-form-label">货币对</label>
<div class="layui-input-block">
<input class="layui-input" name="symbol" lay-verify="required">
<div class="input-group my-group">
<span class="input-group-addon">币种名称</span>
<input name="coin_name" type="text" class="form-control" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn">提交</button>
</div>
<input class="layui-input" name="platform_withhold_id" type="hidden" value="<?= $platform_withhold_id ?>"
<input class="layui-input" name="platform_id" type="hidden" value="<?= $platform_id ?>"
lay-verify="required">
</form>
</div>
</div>
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<style>
.layui-form-label {
width: 100px;
}
</style>
<div class="layui-row" style="padding: 5px;">
<div class="layui-col-md12">
<form class="layui-form" method="post" action="" id="walletEdit">
<input name="_csrf" type="hidden" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input name="id" type="hidden" value="<?= $model->id ?>">
<div class="layui-inline">
<label class="layui-form-label">简称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="<?= $model->name ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">下载地址</label>
<div class="layui-input-block">
<input class="layui-input" name="download_url" value="<?= $model->download_url ?>">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">介绍</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="introduce"><?= $model->introduce?></textarea>
</div>
</div>
</form>
</div>
</div>
<script>
var laydate = layui.laydate;
laydate.render({
elem: "#time1"
});
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/coin/upload',
data: {_csrf: $_csrf},
done: function (res) {
console.log(res.data.src);
$("input[name='icon']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
},
error: function (res) {
}
});
//form render
var form = layui.form;
form.render();
</script>
......@@ -16,15 +16,13 @@ IndexAsset::register($this);
padding: 0px;
}
</style>
<h4>货币列表</h4>
<h4>货币列表</h4>
<div class="layui-row">
<div class="layui-col-md1">
<a href="/admin/coin-supported-symbol/add?platform_withhold_id=<?= $platform_withhold_id ?>"">
<button class="layui-btn layui-btn-default" id="add">添加货币对</button>
</a>
<button class="layui-btn layui-btn-sm" lay-event="add" id="add">单笔添加</button>
</div>
</div>
<input id="platform_withhold_id" type="hidden" value="<?= $platform_withhold_id ?>">
<input id="platform_id" type="hidden" value="<?= $platform_id ?>">
<div class="layui-row">
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
......
......@@ -48,4 +48,5 @@ IndexAsset::register($this);
<a lay-event="delete">
<button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe640;</i></button>
</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" href="/admin/coin-supported-symbol/list?id={{d.id}}" >支持发行货币对</a>
</script>
......@@ -5,16 +5,17 @@ var table = layui.table;
var form = layui.form;
var layer = layui.layer;
form.render();
var platform_withhold_id = $("#platform_withhold_id").val();
var platform_id = $("#platform_id").val();
var tableIns = table.render({
elem: "#table1",
url: '/admin/coin-supported-symbol/list?id=' + platform_withhold_id,
url: '/admin/coin-supported-symbol/list?id=' + platform_id,
limit: 10,
page: 1,
loading: true,
cols: [[
{field: 'id', title: 'ID'},
{field: 'symbol', title: '货币对'},
{field: 'currency', title: '交易货币'},
{field: 'base_currency', title: '基础货币'},
{field: 'create_time', title: '创建时间'},
{field: 'id', title: '操作', templet: '#operationTpl'}
]],
......@@ -30,7 +31,7 @@ form.on('submit(form1)', function (data) {
table.on('tool(table1)', function (obj) {
var data = obj.data;
if (obj.event == 'delete') {
layer.confirm('真的要删除' + data.symbol + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.confirm('真的要删除' + data.coin_name + '吗?', {icon: 3, title: '删除'}, function (index) {
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin-supported-symbol/delete?id=' + obj.data.id, function (data, status) {
......@@ -42,3 +43,30 @@ table.on('tool(table1)', function (obj) {
});
}
});
$('#add').click(function () {
//打开弹窗
$.get('/admin/coin-supported-symbol/add?platform_id=' + platform_id, {}, function (str) {
var index = layer.open({
type: 1,
title: '添加数据',
id: 'add-one',
skin: 'layui-layer-lan',
area: ['320px', 'auto'],
content: str,
btn: ['确认', '取消'],
btn1: function () {
$.post('/admin/coin-supported-symbol/add', $("#addData").serialize(), function (rev) {
layer.msg(rev.msg);
if (rev.code == 0) {
layer.close(index);
table.reload("table1", {});
}
});
}
});
layui.form.render();
});
return false;
});
\ 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