Commit b72bad8d authored by rlgy's avatar rlgy

update

parent 80cf90a6
......@@ -163,19 +163,28 @@ class CoinController extends BaseController
public function actionDelete()
{
Yii::$app->response->format = 'json';
$id = Yii::$app->request->get('id', 0);
if ($id) {
$model = Coin::findOne(['id' => $id]);
if ($model) {
try {
$model->delete();
$this->success('删除成功', '/admin/coin/index', true);
} catch (\Throwable $t) {
} catch (\Exception $e) {
$role = Yii::$app->user->identity->group;
if ('administrator' != $role) {
$coin = Coin::find()->select(['group'])->where(['id' => $id])->one();
if ($role == $coin->group) {
try {
$model->delete();
return ['code' => 0, 'msg' => 'succeed'];
} catch (\Throwable $t) {
} catch (\Exception $e) {
}
}else{
return ['code' => -1, 'msg' => '没有权限修改'];
}
}
}
}
$this->error('删除失败', Yii::$app->request->getReferrer(), true);
return ['code' => -1, 'msg' => '删除失败'];
}
public function actionGetExchangeListById()
......
......@@ -56,11 +56,13 @@ table.on('tool(table1)', function (obj) {
});
} else if (obj.event == 'delete') {
layer.confirm('真的要删除' + data.name + '吗?', {icon: 3, title: '删除'}, function (index) {
obj.del(); //删除对应行(tr)的DOM结构
layer.close(index);
//向服务端发送删除指令
$.get('/admin/coin/delete?id=' + obj.data.id, function (data, status) {
layer.msg(data.info);
if (data.code == 0) {
obj.del(); //删除对应行(tr)的DOM结构
}
layer.msg(data.msg);
});
});
} else if (obj.event == 'edit') {
......
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