Compare commits
1 Commits
d8bcc4f4c4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b039b7abe |
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller\game;
|
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
use app\common\controller\Backend;
|
|
||||||
use support\Response;
|
|
||||||
use Webman\Http\Request as WebmanRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渠道管理
|
|
||||||
*/
|
|
||||||
class Channel extends Backend
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* GameChannel模型对象
|
|
||||||
* @var object|null
|
|
||||||
* @phpstan-var \app\common\model\GameChannel|null
|
|
||||||
*/
|
|
||||||
protected ?object $model = null;
|
|
||||||
|
|
||||||
protected array|string $preExcludeFields = ['id', 'user_count', 'profit_amount', 'create_time', 'update_time'];
|
|
||||||
|
|
||||||
protected array $withJoinTable = ['adminGroup', 'admin'];
|
|
||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
|
||||||
|
|
||||||
protected function initController(WebmanRequest $request): ?Response
|
|
||||||
{
|
|
||||||
$this->model = new \app\common\model\GameChannel();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
protected function _index(): Response
|
|
||||||
{
|
|
||||||
// 如果是 select 则转发到 select 方法,若未重写该方法,其实还是继续执行 index
|
|
||||||
if ($this->request && $this->request->get('select')) {
|
|
||||||
return $this->select($this->request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. withJoin 不可使用 alias 方法设置表别名,别名将自动使用关联模型名称(小写下划线命名规则)
|
|
||||||
* 2. 以下的别名设置了主表别名,同时便于拼接查询参数等
|
|
||||||
* 3. paginate 数据集可使用链式操作 each(function($item, $key) {}) 遍历处理
|
|
||||||
*/
|
|
||||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
|
||||||
$res = $this->model
|
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
|
||||||
->with($this->withJoinTable)
|
|
||||||
->visible(['adminGroup' => ['name'], 'admin' => ['username']])
|
|
||||||
->alias($alias)
|
|
||||||
->where($where)
|
|
||||||
->order($order)
|
|
||||||
->paginate($limit);
|
|
||||||
|
|
||||||
return $this->success('', [
|
|
||||||
'list' => $res->items(),
|
|
||||||
'total' => $res->total(),
|
|
||||||
'remark' => get_route_remark(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,211 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller\game;
|
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
use app\common\controller\Backend;
|
|
||||||
use support\Response;
|
|
||||||
use Webman\Http\Request as WebmanRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户管理
|
|
||||||
*/
|
|
||||||
class User extends Backend
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* GameUser模型对象
|
|
||||||
* @var object|null
|
|
||||||
* @phpstan-var \app\common\model\GameUser|null
|
|
||||||
*/
|
|
||||||
protected ?object $model = null;
|
|
||||||
|
|
||||||
protected array|string $preExcludeFields = ['id', 'uuid', 'create_time', 'update_time'];
|
|
||||||
|
|
||||||
protected array $withJoinTable = ['gameChannel', 'admin'];
|
|
||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'username', 'phone'];
|
|
||||||
|
|
||||||
protected function initController(WebmanRequest $request): ?Response
|
|
||||||
{
|
|
||||||
$this->model = new \app\common\model\GameUser();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加(重写:password 使用 Admin 同款加密;uuid 由 username+channel_id 生成)
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
protected function _add(): Response
|
|
||||||
{
|
|
||||||
if ($this->request && $this->request->method() === 'POST') {
|
|
||||||
$data = $this->request->post();
|
|
||||||
if (!$data) {
|
|
||||||
return $this->error(__('Parameter %s can not be empty', ['']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->applyInputFilter($data);
|
|
||||||
$data = $this->excludeFields($data);
|
|
||||||
|
|
||||||
$password = $data['password'] ?? null;
|
|
||||||
if (!is_string($password) || trim($password) === '') {
|
|
||||||
return $this->error(__('Parameter %s can not be empty', ['password']));
|
|
||||||
}
|
|
||||||
$data['password'] = hash_password($password);
|
|
||||||
|
|
||||||
$username = $data['username'] ?? '';
|
|
||||||
$channelId = $data['channel_id'] ?? ($data['game_channel_id'] ?? null);
|
|
||||||
if (!is_string($username) || trim($username) === '' || $channelId === null || $channelId === '') {
|
|
||||||
return $this->error(__('Parameter %s can not be empty', ['username/channel_id']));
|
|
||||||
}
|
|
||||||
$data['uuid'] = md5(trim($username) . '|' . $channelId);
|
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
||||||
$data[$this->dataLimitField] = $this->auth->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = false;
|
|
||||||
$this->model->startTrans();
|
|
||||||
try {
|
|
||||||
if ($this->modelValidate) {
|
|
||||||
$validate = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
||||||
if (class_exists($validate)) {
|
|
||||||
$validate = new $validate();
|
|
||||||
if ($this->modelSceneValidate) {
|
|
||||||
$validate->scene('add');
|
|
||||||
}
|
|
||||||
$validate->check($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$result = $this->model->save($data);
|
|
||||||
$this->model->commit();
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$this->model->rollback();
|
|
||||||
return $this->error($e->getMessage());
|
|
||||||
}
|
|
||||||
if ($result !== false) {
|
|
||||||
return $this->success(__('Added successfully'));
|
|
||||||
}
|
|
||||||
return $this->error(__('No rows were added'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->error(__('Parameter error'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑(重写:password 使用 Admin 同款加密;uuid 由 username+channel_id 生成)
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
protected function _edit(): Response
|
|
||||||
{
|
|
||||||
$pk = $this->model->getPk();
|
|
||||||
$id = $this->request ? ($this->request->post($pk) ?? $this->request->get($pk)) : null;
|
|
||||||
$row = $this->model->find($id);
|
|
||||||
if (!$row) {
|
|
||||||
return $this->error(__('Record not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$dataLimitAdminIds = $this->getDataLimitAdminIds();
|
|
||||||
if ($dataLimitAdminIds && !in_array($row[$this->dataLimitField], $dataLimitAdminIds)) {
|
|
||||||
return $this->error(__('You have no permission'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request && $this->request->method() === 'POST') {
|
|
||||||
$data = $this->request->post();
|
|
||||||
if (!$data) {
|
|
||||||
return $this->error(__('Parameter %s can not be empty', ['']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->applyInputFilter($data);
|
|
||||||
$data = $this->excludeFields($data);
|
|
||||||
|
|
||||||
if (array_key_exists('password', $data)) {
|
|
||||||
$password = $data['password'];
|
|
||||||
if (!is_string($password) || trim($password) === '') {
|
|
||||||
unset($data['password']);
|
|
||||||
} else {
|
|
||||||
$data['password'] = hash_password($password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$nextUsername = array_key_exists('username', $data) ? $data['username'] : $row['username'];
|
|
||||||
$nextChannelId = null;
|
|
||||||
if (array_key_exists('channel_id', $data)) {
|
|
||||||
$nextChannelId = $data['channel_id'];
|
|
||||||
} elseif (array_key_exists('game_channel_id', $data)) {
|
|
||||||
$nextChannelId = $data['game_channel_id'];
|
|
||||||
} else {
|
|
||||||
$nextChannelId = $row['channel_id'] ?? $row['game_channel_id'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($nextUsername) && trim($nextUsername) !== '' && $nextChannelId !== null && $nextChannelId !== '') {
|
|
||||||
$data['uuid'] = md5(trim($nextUsername) . '|' . $nextChannelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = false;
|
|
||||||
$this->model->startTrans();
|
|
||||||
try {
|
|
||||||
if ($this->modelValidate) {
|
|
||||||
$validate = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
||||||
if (class_exists($validate)) {
|
|
||||||
$validate = new $validate();
|
|
||||||
if ($this->modelSceneValidate) {
|
|
||||||
$validate->scene('edit');
|
|
||||||
}
|
|
||||||
$data[$pk] = $row[$pk];
|
|
||||||
$validate->check($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$result = $row->save($data);
|
|
||||||
$this->model->commit();
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$this->model->rollback();
|
|
||||||
return $this->error($e->getMessage());
|
|
||||||
}
|
|
||||||
if ($result !== false) {
|
|
||||||
return $this->success(__('Update successful'));
|
|
||||||
}
|
|
||||||
return $this->error(__('No rows updated'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->success('', [
|
|
||||||
'row' => $row
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
|
||||||
protected function _index(): Response
|
|
||||||
{
|
|
||||||
// 如果是 select 则转发到 select 方法,若未重写该方法,其实还是继续执行 index
|
|
||||||
if ($this->request && $this->request->get('select')) {
|
|
||||||
return $this->select($this->request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. withJoin 不可使用 alias 方法设置表别名,别名将自动使用关联模型名称(小写下划线命名规则)
|
|
||||||
* 2. 以下的别名设置了主表别名,同时便于拼接查询参数等
|
|
||||||
* 3. paginate 数据集可使用链式操作 each(function($item, $key) {}) 遍历处理
|
|
||||||
*/
|
|
||||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
|
||||||
$res = $this->model
|
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
|
||||||
->with($this->withJoinTable)
|
|
||||||
->visible(['gameChannel' => ['name'], 'admin' => ['username']])
|
|
||||||
->alias($alias)
|
|
||||||
->where($where)
|
|
||||||
->order($order)
|
|
||||||
->paginate($limit);
|
|
||||||
|
|
||||||
return $this->success('', [
|
|
||||||
'list' => $res->items(),
|
|
||||||
'total' => $res->total(),
|
|
||||||
'remark' => get_route_remark(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\common\model;
|
|
||||||
|
|
||||||
use support\think\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameChannel
|
|
||||||
*/
|
|
||||||
class GameChannel extends Model
|
|
||||||
{
|
|
||||||
// 表名
|
|
||||||
protected $name = 'game_channel';
|
|
||||||
|
|
||||||
// 自动写入时间戳字段
|
|
||||||
protected $autoWriteTimestamp = true;
|
|
||||||
|
|
||||||
// 字段类型转换
|
|
||||||
protected $type = [
|
|
||||||
'create_time' => 'integer',
|
|
||||||
'update_time' => 'integer',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
public function getprofitAmountAttr($value): ?float
|
|
||||||
{
|
|
||||||
return is_null($value) ? null : (float)$value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function adminGroup(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\admin\model\AdminGroup::class, 'admin_group_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function admin(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\admin\model\Admin::class, 'admin_id', 'id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\common\model;
|
|
||||||
|
|
||||||
use support\think\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GameUser
|
|
||||||
*/
|
|
||||||
class GameUser extends Model
|
|
||||||
{
|
|
||||||
// 表名
|
|
||||||
protected $name = 'game_user';
|
|
||||||
|
|
||||||
// 自动写入时间戳字段
|
|
||||||
protected $autoWriteTimestamp = true;
|
|
||||||
|
|
||||||
// 字段类型转换
|
|
||||||
protected $type = [
|
|
||||||
'create_time' => 'integer',
|
|
||||||
'update_time' => 'integer',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
public function getcoinAttr($value): ?float
|
|
||||||
{
|
|
||||||
return is_null($value) ? null : (float)$value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function gameChannel(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\common\model\GameChannel::class, 'game_channel_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function admin(): \think\model\relation\BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\app\admin\model\Admin::class, 'admin_id', 'id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\common\validate;
|
|
||||||
|
|
||||||
use think\Validate;
|
|
||||||
|
|
||||||
class GameChannel extends Validate
|
|
||||||
{
|
|
||||||
protected $failException = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证规则
|
|
||||||
*/
|
|
||||||
protected $rule = [
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提示消息
|
|
||||||
*/
|
|
||||||
protected $message = [
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证场景
|
|
||||||
*/
|
|
||||||
protected $scene = [
|
|
||||||
'add' => [],
|
|
||||||
'edit' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\common\validate;
|
|
||||||
|
|
||||||
use think\Validate;
|
|
||||||
|
|
||||||
class GameUser extends Validate
|
|
||||||
{
|
|
||||||
protected $failException = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证规则
|
|
||||||
*/
|
|
||||||
protected $rule = [
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提示消息
|
|
||||||
*/
|
|
||||||
protected $message = [
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证场景
|
|
||||||
*/
|
|
||||||
protected $scene = [
|
|
||||||
'add' => [],
|
|
||||||
'edit' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -204,7 +204,24 @@ if (!function_exists('get_controller_path')) {
|
|||||||
if (count($parts) < 2) {
|
if (count($parts) < 2) {
|
||||||
return $parts[0] ?? null;
|
return $parts[0] ?? null;
|
||||||
}
|
}
|
||||||
return implode('/', array_slice($parts, 1, -1)) ?: $parts[1];
|
$segments = array_slice($parts, 1, -1);
|
||||||
|
if ($segments === []) {
|
||||||
|
return $parts[1] ?? null;
|
||||||
|
}
|
||||||
|
// ThinkPHP 风格段 game.Config -> game/config,与 $request->controller 解析结果一致(否则权限节点对不上)
|
||||||
|
$normalized = [];
|
||||||
|
foreach ($segments as $seg) {
|
||||||
|
if (str_contains($seg, '.')) {
|
||||||
|
$dotPos = strpos($seg, '.');
|
||||||
|
$mod = substr($seg, 0, $dotPos);
|
||||||
|
$ctrl = substr($seg, $dotPos + 1);
|
||||||
|
$normalized[] = strtolower($mod);
|
||||||
|
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $ctrl));
|
||||||
|
} else {
|
||||||
|
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $seg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return implode('/', $normalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
export default {
|
|
||||||
id: 'id',
|
|
||||||
code: 'code',
|
|
||||||
name: 'name',
|
|
||||||
user_count: 'user_count',
|
|
||||||
profit_amount: 'profit_amount',
|
|
||||||
status: 'status',
|
|
||||||
'status 0': 'status 0',
|
|
||||||
'status 1': 'status 1',
|
|
||||||
remark: 'remark',
|
|
||||||
admin_group_id: 'admin_group_id',
|
|
||||||
admingroup__name: 'name',
|
|
||||||
admin_id: 'admin_id',
|
|
||||||
admin__username: 'username',
|
|
||||||
create_time: 'create_time',
|
|
||||||
update_time: 'update_time',
|
|
||||||
'quick Search Fields': 'id,code,name',
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
export default {
|
|
||||||
id: 'id',
|
|
||||||
username: 'username',
|
|
||||||
password: 'password',
|
|
||||||
uuid: 'uuid',
|
|
||||||
phone: 'phone',
|
|
||||||
remark: 'remark',
|
|
||||||
coin: 'coin',
|
|
||||||
status: 'status',
|
|
||||||
'status 0': 'status 0',
|
|
||||||
'status 1': 'status 1',
|
|
||||||
game_channel_id: 'game_channel_id',
|
|
||||||
gamechannel__name: 'name',
|
|
||||||
admin_id: 'admin_id',
|
|
||||||
admin__username: 'username',
|
|
||||||
create_time: 'create_time',
|
|
||||||
update_time: 'update_time',
|
|
||||||
'quick Search Fields': 'id,username,phone',
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
export default {
|
|
||||||
id: 'ID',
|
|
||||||
code: '渠道标识',
|
|
||||||
name: '渠道名',
|
|
||||||
user_count: '用户数',
|
|
||||||
profit_amount: '利润',
|
|
||||||
status: '状态',
|
|
||||||
'status 0': '禁用',
|
|
||||||
'status 1': '启用',
|
|
||||||
remark: '备注',
|
|
||||||
admin_group_id: '管理角色组',
|
|
||||||
admingroup__name: '组名',
|
|
||||||
admin_id: '管理员',
|
|
||||||
admin__username: '用户名',
|
|
||||||
create_time: '创建时间',
|
|
||||||
update_time: '修改时间',
|
|
||||||
'quick Search Fields': 'ID、渠道标识、渠道名',
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
export default {
|
|
||||||
id: 'ID',
|
|
||||||
username: '用户名',
|
|
||||||
password: '密码',
|
|
||||||
uuid: '用户唯一标识',
|
|
||||||
phone: '手机号',
|
|
||||||
remark: '备注',
|
|
||||||
coin: '平台币',
|
|
||||||
status: '状态',
|
|
||||||
'status 0': '禁用',
|
|
||||||
'status 1': '启用',
|
|
||||||
game_channel_id: '所属渠道',
|
|
||||||
gamechannel__name: '渠道名',
|
|
||||||
admin_id: '所属管理员',
|
|
||||||
admin__username: '用户名',
|
|
||||||
create_time: '创建时间',
|
|
||||||
update_time: '修改时间',
|
|
||||||
'quick Search Fields': 'ID、用户名、手机号',
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="default-main ba-table-box">
|
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
|
||||||
|
|
||||||
<!-- 表格顶部菜单 -->
|
|
||||||
<!-- 自定义按钮请使用插槽,甚至公共搜索也可以使用具名插槽渲染,参见文档 -->
|
|
||||||
<TableHeader
|
|
||||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('game.channel.quick Search Fields') })"
|
|
||||||
></TableHeader>
|
|
||||||
|
|
||||||
<!-- 表格 -->
|
|
||||||
<!-- 表格列有多种自定义渲染方式,比如自定义组件、具名插槽等,参见文档 -->
|
|
||||||
<!-- 要使用 el-table 组件原有的属性,直接加在 Table 标签上即可 -->
|
|
||||||
<Table ref="tableRef"></Table>
|
|
||||||
|
|
||||||
<!-- 表单 -->
|
|
||||||
<PopupForm />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { onMounted, provide, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import PopupForm from './popupForm.vue'
|
|
||||||
import { baTableApi } from '/@/api/common'
|
|
||||||
import { defaultOptButtons } from '/@/components/table'
|
|
||||||
import TableHeader from '/@/components/table/header/index.vue'
|
|
||||||
import Table from '/@/components/table/index.vue'
|
|
||||||
import baTableClass from '/@/utils/baTable'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: 'game/channel',
|
|
||||||
})
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const tableRef = useTemplateRef('tableRef')
|
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
|
||||||
|
|
||||||
/**
|
|
||||||
* baTable 内包含了表格的所有数据且数据具备响应性,然后通过 provide 注入给了后代组件
|
|
||||||
*/
|
|
||||||
const baTable = new baTableClass(
|
|
||||||
new baTableApi('/admin/game.Channel/'),
|
|
||||||
{
|
|
||||||
pk: 'id',
|
|
||||||
column: [
|
|
||||||
{ type: 'selection', align: 'center', operator: false },
|
|
||||||
{ label: t('game.channel.id'), prop: 'id', align: 'center', width: 70, operator: 'RANGE', sortable: 'custom' },
|
|
||||||
{
|
|
||||||
label: t('game.channel.code'),
|
|
||||||
prop: 'code',
|
|
||||||
align: 'center',
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
sortable: false,
|
|
||||||
operator: 'LIKE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.channel.name'),
|
|
||||||
prop: 'name',
|
|
||||||
align: 'center',
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
sortable: false,
|
|
||||||
operator: 'LIKE',
|
|
||||||
},
|
|
||||||
{ label: t('game.channel.user_count'), prop: 'user_count', align: 'center', sortable: false, operator: 'RANGE' },
|
|
||||||
{ label: t('game.channel.profit_amount'), prop: 'profit_amount', align: 'center', sortable: false, operator: 'RANGE' },
|
|
||||||
{
|
|
||||||
label: t('game.channel.status'),
|
|
||||||
prop: 'status',
|
|
||||||
align: 'center',
|
|
||||||
operator: 'eq',
|
|
||||||
sortable: false,
|
|
||||||
render: 'switch',
|
|
||||||
replaceValue: { '0': t('game.channel.status 0'), '1': t('game.channel.status 1') },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.channel.admingroup__name'),
|
|
||||||
prop: 'adminGroup.name',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 110,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.channel.admin__username'),
|
|
||||||
prop: 'admin.username',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 90,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.channel.create_time'),
|
|
||||||
prop: 'create_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 160,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.channel.update_time'),
|
|
||||||
prop: 'update_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 160,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{ label: t('Operate'), align: 'center', width: 80, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
|
||||||
],
|
|
||||||
dblClickNotEditColumn: [undefined, 'status'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
defaultItems: { status: '1' },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
provide('baTable', baTable)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
baTable.table.ref = tableRef.value
|
|
||||||
baTable.mount()
|
|
||||||
baTable.getData()?.then(() => {
|
|
||||||
baTable.initSort()
|
|
||||||
baTable.dragSort()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
<template>
|
|
||||||
<!-- 对话框表单 -->
|
|
||||||
<!-- 建议使用 Prettier 格式化代码 -->
|
|
||||||
<!-- el-form 内可以混用 el-form-item、FormItem、ba-input 等输入组件 -->
|
|
||||||
<el-dialog
|
|
||||||
class="ba-operate-dialog"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
|
||||||
@close="baTable.toggleForm"
|
|
||||||
>
|
|
||||||
<template #header>
|
|
||||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
|
||||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
|
||||||
<div
|
|
||||||
class="ba-operate-form"
|
|
||||||
:class="'ba-' + baTable.form.operate + '-form'"
|
|
||||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
v-if="!baTable.form.loading"
|
|
||||||
ref="formRef"
|
|
||||||
@submit.prevent=""
|
|
||||||
@keyup.enter="baTable.onSubmit(formRef)"
|
|
||||||
:model="baTable.form.items"
|
|
||||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
|
||||||
:label-width="baTable.form.labelWidth + 'px'"
|
|
||||||
:rules="rules"
|
|
||||||
>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.code')"
|
|
||||||
type="string"
|
|
||||||
v-model="baTable.form.items!.code"
|
|
||||||
prop="code"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.channel.code') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.name')"
|
|
||||||
type="string"
|
|
||||||
v-model="baTable.form.items!.name"
|
|
||||||
prop="name"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.channel.name') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.status')"
|
|
||||||
type="switch"
|
|
||||||
v-model="baTable.form.items!.status"
|
|
||||||
prop="status"
|
|
||||||
:input-attr="{ content: { '0': t('game.channel.status 0'), '1': t('game.channel.status 1') } }"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.remark')"
|
|
||||||
type="textarea"
|
|
||||||
v-model="baTable.form.items!.remark"
|
|
||||||
prop="remark"
|
|
||||||
:input-attr="{ rows: 3 }"
|
|
||||||
@keyup.enter.stop=""
|
|
||||||
@keyup.ctrl.enter="baTable.onSubmit(formRef)"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.channel.remark') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.admin_group_id')"
|
|
||||||
type="remoteSelect"
|
|
||||||
v-model="baTable.form.items!.admin_group_id"
|
|
||||||
prop="admin_group_id"
|
|
||||||
:input-attr="{ pk: 'admin_group.id', field: 'name', remoteUrl: '/admin/auth.Group/index' }"
|
|
||||||
:placeholder="t('Please select field', { field: t('game.channel.admin_group_id') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.channel.admin_id')"
|
|
||||||
type="remoteSelect"
|
|
||||||
v-model="baTable.form.items!.admin_id"
|
|
||||||
prop="admin_id"
|
|
||||||
:input-attr="{ pk: 'admin.id', field: 'username', remoteUrl: '/admin/auth.Admin/index' }"
|
|
||||||
:placeholder="t('Please select field', { field: t('game.channel.admin_id') })"
|
|
||||||
/>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
<template #footer>
|
|
||||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
|
||||||
<el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
|
|
||||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
|
||||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { FormItemRule } from 'element-plus'
|
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
|
||||||
import { useConfig } from '/@/stores/config'
|
|
||||||
import type baTableClass from '/@/utils/baTable'
|
|
||||||
import { buildValidatorData } from '/@/utils/validate'
|
|
||||||
|
|
||||||
const config = useConfig()
|
|
||||||
const formRef = useTemplateRef('formRef')
|
|
||||||
const baTable = inject('baTable') as baTableClass
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|
||||||
code: [buildValidatorData({ name: 'required', title: t('game.channel.code') })],
|
|
||||||
name: [buildValidatorData({ name: 'required', title: t('game.channel.name') })],
|
|
||||||
user_count: [buildValidatorData({ name: 'integer', title: t('game.channel.user_count') })],
|
|
||||||
profit_amount: [buildValidatorData({ name: 'float', title: t('game.channel.profit_amount') })],
|
|
||||||
admin_group_id: [buildValidatorData({ name: 'required', title: t('game.channel.admin_group_id') })],
|
|
||||||
admin_id: [buildValidatorData({ name: 'required', title: t('game.channel.admin_id') })],
|
|
||||||
create_time: [buildValidatorData({ name: 'date', title: t('game.channel.create_time') })],
|
|
||||||
update_time: [buildValidatorData({ name: 'date', title: t('game.channel.update_time') })],
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="default-main ba-table-box">
|
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
|
||||||
|
|
||||||
<!-- 表格顶部菜单 -->
|
|
||||||
<!-- 自定义按钮请使用插槽,甚至公共搜索也可以使用具名插槽渲染,参见文档 -->
|
|
||||||
<TableHeader
|
|
||||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
|
||||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('game.user.quick Search Fields') })"
|
|
||||||
></TableHeader>
|
|
||||||
|
|
||||||
<!-- 表格 -->
|
|
||||||
<!-- 表格列有多种自定义渲染方式,比如自定义组件、具名插槽等,参见文档 -->
|
|
||||||
<!-- 要使用 el-table 组件原有的属性,直接加在 Table 标签上即可 -->
|
|
||||||
<Table ref="tableRef"></Table>
|
|
||||||
|
|
||||||
<!-- 表单 -->
|
|
||||||
<PopupForm />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { onMounted, provide, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import PopupForm from './popupForm.vue'
|
|
||||||
import { baTableApi } from '/@/api/common'
|
|
||||||
import { defaultOptButtons } from '/@/components/table'
|
|
||||||
import TableHeader from '/@/components/table/header/index.vue'
|
|
||||||
import Table from '/@/components/table/index.vue'
|
|
||||||
import baTableClass from '/@/utils/baTable'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: 'game/user',
|
|
||||||
})
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const tableRef = useTemplateRef('tableRef')
|
|
||||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
|
||||||
|
|
||||||
/**
|
|
||||||
* baTable 内包含了表格的所有数据且数据具备响应性,然后通过 provide 注入给了后代组件
|
|
||||||
*/
|
|
||||||
const baTable = new baTableClass(
|
|
||||||
new baTableApi('/admin/game.User/'),
|
|
||||||
{
|
|
||||||
pk: 'id',
|
|
||||||
column: [
|
|
||||||
{ type: 'selection', align: 'center', operator: false },
|
|
||||||
{ label: t('game.user.id'), prop: 'id', align: 'center', width: 70, operator: 'RANGE', sortable: 'custom' },
|
|
||||||
{
|
|
||||||
label: t('game.user.username'),
|
|
||||||
prop: 'username',
|
|
||||||
align: 'center',
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
sortable: false,
|
|
||||||
operator: 'LIKE',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.uuid'),
|
|
||||||
prop: 'uuid',
|
|
||||||
align: 'center',
|
|
||||||
showOverflowTooltip: true,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
sortable: false,
|
|
||||||
operator: 'LIKE',
|
|
||||||
},
|
|
||||||
{ label: t('game.user.phone'), prop: 'phone', align: 'center', operatorPlaceholder: t('Fuzzy query'), sortable: false, operator: 'LIKE' },
|
|
||||||
{ label: t('game.user.coin'), prop: 'coin', align: 'center', sortable: false, operator: 'RANGE' },
|
|
||||||
{
|
|
||||||
label: t('game.user.status'),
|
|
||||||
prop: 'status',
|
|
||||||
align: 'center',
|
|
||||||
operator: 'eq',
|
|
||||||
sortable: false,
|
|
||||||
render: 'switch',
|
|
||||||
replaceValue: { '0': t('game.user.status 0'), '1': t('game.user.status 1') },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.gamechannel__name'),
|
|
||||||
prop: 'gameChannel.name',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 100,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.admin__username'),
|
|
||||||
prop: 'admin.username',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 90,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
render: 'tags',
|
|
||||||
operator: 'LIKE',
|
|
||||||
comSearchRender: 'string',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.remark'),
|
|
||||||
prop: 'remark',
|
|
||||||
align: 'center',
|
|
||||||
minWidth: 100,
|
|
||||||
showOverflowTooltip: true,
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.create_time'),
|
|
||||||
prop: 'create_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 160,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('game.user.update_time'),
|
|
||||||
prop: 'update_time',
|
|
||||||
align: 'center',
|
|
||||||
render: 'datetime',
|
|
||||||
operator: 'RANGE',
|
|
||||||
comSearchRender: 'datetime',
|
|
||||||
sortable: 'custom',
|
|
||||||
width: 160,
|
|
||||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
|
||||||
},
|
|
||||||
{ label: t('Operate'), align: 'center', width: 80, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
|
||||||
],
|
|
||||||
dblClickNotEditColumn: [undefined, 'status'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
defaultItems: { status: '1' },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
provide('baTable', baTable)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
baTable.table.ref = tableRef.value
|
|
||||||
baTable.mount()
|
|
||||||
baTable.getData()?.then(() => {
|
|
||||||
baTable.initSort()
|
|
||||||
baTable.dragSort()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
<template>
|
|
||||||
<!-- 对话框表单 -->
|
|
||||||
<!-- 建议使用 Prettier 格式化代码 -->
|
|
||||||
<!-- el-form 内可以混用 el-form-item、FormItem、ba-input 等输入组件 -->
|
|
||||||
<el-dialog
|
|
||||||
class="ba-operate-dialog"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
|
||||||
@close="baTable.toggleForm"
|
|
||||||
>
|
|
||||||
<template #header>
|
|
||||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
|
||||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
|
||||||
<div
|
|
||||||
class="ba-operate-form"
|
|
||||||
:class="'ba-' + baTable.form.operate + '-form'"
|
|
||||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
v-if="!baTable.form.loading"
|
|
||||||
ref="formRef"
|
|
||||||
@submit.prevent=""
|
|
||||||
@keyup.enter="baTable.onSubmit(formRef)"
|
|
||||||
:model="baTable.form.items"
|
|
||||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
|
||||||
:label-width="baTable.form.labelWidth + 'px'"
|
|
||||||
:rules="rules"
|
|
||||||
>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.username')"
|
|
||||||
type="string"
|
|
||||||
v-model="baTable.form.items!.username"
|
|
||||||
prop="username"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.user.username') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.password')"
|
|
||||||
type="password"
|
|
||||||
v-model="baTable.form.items!.password"
|
|
||||||
prop="password"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.user.password') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.phone')"
|
|
||||||
type="string"
|
|
||||||
v-model="baTable.form.items!.phone"
|
|
||||||
prop="phone"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.user.phone') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.remark')"
|
|
||||||
type="textarea"
|
|
||||||
v-model="baTable.form.items!.remark"
|
|
||||||
prop="remark"
|
|
||||||
:input-attr="{ rows: 3 }"
|
|
||||||
@keyup.enter.stop=""
|
|
||||||
@keyup.ctrl.enter="baTable.onSubmit(formRef)"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.user.remark') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.coin')"
|
|
||||||
type="number"
|
|
||||||
v-model="baTable.form.items!.coin"
|
|
||||||
prop="coin"
|
|
||||||
:input-attr="{ step: 1 }"
|
|
||||||
:placeholder="t('Please input field', { field: t('game.user.coin') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.status')"
|
|
||||||
type="switch"
|
|
||||||
v-model="baTable.form.items!.status"
|
|
||||||
prop="status"
|
|
||||||
:input-attr="{ content: { '0': t('game.user.status 0'), '1': t('game.user.status 1') } }"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.game_channel_id')"
|
|
||||||
type="remoteSelect"
|
|
||||||
v-model="baTable.form.items!.game_channel_id"
|
|
||||||
prop="game_channel_id"
|
|
||||||
:input-attr="{ pk: 'game_channel.id', field: 'name', remoteUrl: '/admin/game.Channel/index' }"
|
|
||||||
:placeholder="t('Please select field', { field: t('game.user.game_channel_id') })"
|
|
||||||
/>
|
|
||||||
<FormItem
|
|
||||||
:label="t('game.user.admin_id')"
|
|
||||||
type="remoteSelect"
|
|
||||||
v-model="baTable.form.items!.admin_id"
|
|
||||||
prop="admin_id"
|
|
||||||
:input-attr="{ pk: 'admin.id', field: 'username', remoteUrl: '/admin/auth.Admin/index' }"
|
|
||||||
:placeholder="t('Please select field', { field: t('game.user.admin_id') })"
|
|
||||||
/>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
<template #footer>
|
|
||||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
|
||||||
<el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
|
|
||||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
|
||||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { FormItemRule } from 'element-plus'
|
|
||||||
import { inject, reactive, useTemplateRef } from 'vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import FormItem from '/@/components/formItem/index.vue'
|
|
||||||
import { useConfig } from '/@/stores/config'
|
|
||||||
import type baTableClass from '/@/utils/baTable'
|
|
||||||
import { buildValidatorData } from '/@/utils/validate'
|
|
||||||
|
|
||||||
const config = useConfig()
|
|
||||||
const formRef = useTemplateRef('formRef')
|
|
||||||
const baTable = inject('baTable') as baTableClass
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
|
||||||
username: [buildValidatorData({ name: 'required', title: t('game.user.username') })],
|
|
||||||
password: [
|
|
||||||
buildValidatorData({ name: 'password', title: t('game.user.password') }),
|
|
||||||
buildValidatorData({ name: 'required', title: t('game.user.password') }),
|
|
||||||
],
|
|
||||||
phone: [buildValidatorData({ name: 'required', title: t('game.user.phone') })],
|
|
||||||
coin: [buildValidatorData({ name: 'number', title: t('game.user.coin') })],
|
|
||||||
game_channel_id: [buildValidatorData({ name: 'required', title: t('game.user.game_channel_id') })],
|
|
||||||
admin_id: [buildValidatorData({ name: 'required', title: t('game.user.admin_id') })],
|
|
||||||
create_time: [buildValidatorData({ name: 'date', title: t('game.user.create_time') })],
|
|
||||||
update_time: [buildValidatorData({ name: 'date', title: t('game.user.update_time') })],
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
|
||||||
Reference in New Issue
Block a user