[渠道管理]
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\admin\controller\game;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
@@ -14,9 +14,9 @@ use Webman\Http\Request as WebmanRequest;
|
|||||||
class Channel extends Backend
|
class Channel extends Backend
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* GameChannel模型对象
|
* Channel模型对象
|
||||||
* @var object|null
|
* @var object|null
|
||||||
* @phpstan-var \app\common\model\GameChannel|null
|
* @phpstan-var \app\common\model\Channel|null
|
||||||
*/
|
*/
|
||||||
protected ?object $model = null;
|
protected ?object $model = null;
|
||||||
|
|
||||||
@@ -26,9 +26,12 @@ class Channel extends Backend
|
|||||||
|
|
||||||
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
protected string|array $quickSearchField = ['id', 'code', 'name'];
|
||||||
|
|
||||||
|
private array $currentChannelIds = [];
|
||||||
|
|
||||||
protected function initController(WebmanRequest $request): ?Response
|
protected function initController(WebmanRequest $request): ?Response
|
||||||
{
|
{
|
||||||
$this->model = new \app\common\model\GameChannel();
|
$this->model = new \app\common\model\Channel();
|
||||||
|
$this->currentChannelIds = $this->getCurrentChannelIds();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,11 +43,13 @@ class Channel extends Backend
|
|||||||
$response = $this->initializeBackend($request);
|
$response = $this->initializeBackend($request);
|
||||||
if ($response !== null) return $response;
|
if ($response !== null) return $response;
|
||||||
|
|
||||||
$channels = Db::name('game_channel')
|
$query = Db::name('channel')
|
||||||
->field(['id', 'name', 'admin_group_id'])
|
->field(['id', 'name', 'admin_group_id'])
|
||||||
->order('id', 'asc')
|
->order('id', 'asc');
|
||||||
->select()
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
->toArray();
|
$query = $query->where('id', 'in', $this->currentChannelIds ?: [0]);
|
||||||
|
}
|
||||||
|
$channels = $query->select()->toArray();
|
||||||
|
|
||||||
$groupChildrenCache = [];
|
$groupChildrenCache = [];
|
||||||
$getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
|
$getGroupChildren = function ($groupId) use (&$getGroupChildren, &$groupChildrenCache) {
|
||||||
@@ -131,13 +136,14 @@ class Channel extends Backend
|
|||||||
|
|
||||||
$data = $this->applyInputFilter($data);
|
$data = $this->applyInputFilter($data);
|
||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
|
$data = $this->normalizeAgentModeFields($data);
|
||||||
|
unset($data['invite_code']);
|
||||||
|
|
||||||
$adminId = $data['admin_id'] ?? null;
|
$adminId = $data['admin_id'] ?? null;
|
||||||
if ($adminId === null || $adminId === '') {
|
if ($adminId === null || $adminId === '') {
|
||||||
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
return $this->error(__('Parameter %s can not be empty', ['admin_id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不允许前端填写,统一后端根据管理员所属“顶级角色组(pid=0)”自动回填
|
|
||||||
if (array_key_exists('admin_group_id', $data)) {
|
if (array_key_exists('admin_group_id', $data)) {
|
||||||
unset($data['admin_group_id']);
|
unset($data['admin_group_id']);
|
||||||
}
|
}
|
||||||
@@ -153,6 +159,10 @@ class Channel extends Backend
|
|||||||
return $this->error(__('Record not found'));
|
return $this->error(__('Record not found'));
|
||||||
}
|
}
|
||||||
$data['admin_group_id'] = $topGroupId;
|
$data['admin_group_id'] = $topGroupId;
|
||||||
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
$data['top_admin_id'] = $this->auth->id;
|
||||||
|
$data['admin_id'] = $this->auth->id;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||||
$data[$this->dataLimitField] = $this->auth->id;
|
$data[$this->dataLimitField] = $this->auth->id;
|
||||||
@@ -198,6 +208,9 @@ class Channel extends Backend
|
|||||||
if (!$row) {
|
if (!$row) {
|
||||||
return $this->error(__('Record not found'));
|
return $this->error(__('Record not found'));
|
||||||
}
|
}
|
||||||
|
if (!$this->auth->isSuperAdmin() && !in_array($row['id'], $this->currentChannelIds, true)) {
|
||||||
|
return $this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
|
||||||
$dataLimitAdminIds = $this->getDataLimitAdminIds();
|
$dataLimitAdminIds = $this->getDataLimitAdminIds();
|
||||||
if ($dataLimitAdminIds && !in_array($row[$this->dataLimitField], $dataLimitAdminIds)) {
|
if ($dataLimitAdminIds && !in_array($row[$this->dataLimitField], $dataLimitAdminIds)) {
|
||||||
@@ -212,8 +225,9 @@ class Channel extends Backend
|
|||||||
|
|
||||||
$data = $this->applyInputFilter($data);
|
$data = $this->applyInputFilter($data);
|
||||||
$data = $this->excludeFields($data);
|
$data = $this->excludeFields($data);
|
||||||
|
$data = $this->normalizeAgentModeFields($data);
|
||||||
|
unset($data['invite_code']);
|
||||||
|
|
||||||
// 不允许前端填写,统一后端根据管理员所属“顶级角色组(pid=0)”自动回填
|
|
||||||
if (array_key_exists('admin_group_id', $data)) {
|
if (array_key_exists('admin_group_id', $data)) {
|
||||||
unset($data['admin_group_id']);
|
unset($data['admin_group_id']);
|
||||||
}
|
}
|
||||||
@@ -232,6 +246,10 @@ class Channel extends Backend
|
|||||||
}
|
}
|
||||||
$data['admin_group_id'] = $topGroupId;
|
$data['admin_group_id'] = $topGroupId;
|
||||||
}
|
}
|
||||||
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
$data['top_admin_id'] = $this->auth->id;
|
||||||
|
$data['admin_id'] = $this->auth->id;
|
||||||
|
}
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
$this->model->startTrans();
|
$this->model->startTrans();
|
||||||
@@ -270,17 +288,14 @@ class Channel extends Backend
|
|||||||
*/
|
*/
|
||||||
protected function _index(): Response
|
protected function _index(): Response
|
||||||
{
|
{
|
||||||
// 如果是 select 则转发到 select 方法,若未重写该方法,其实还是继续执行 index
|
|
||||||
if ($this->request && $this->request->get('select')) {
|
if ($this->request && $this->request->get('select')) {
|
||||||
return $this->select($this->request);
|
return $this->select($this->request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. withJoin 不可使用 alias 方法设置表别名,别名将自动使用关联模型名称(小写下划线命名规则)
|
|
||||||
* 2. 以下的别名设置了主表别名,同时便于拼接查询参数等
|
|
||||||
* 3. paginate 数据集可使用链式操作 each(function($item, $key) {}) 遍历处理
|
|
||||||
*/
|
|
||||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||||
|
if (!$this->auth->isSuperAdmin()) {
|
||||||
|
$where[] = [$alias['channel'] . '.id', 'in', $this->currentChannelIds ?: [0]];
|
||||||
|
}
|
||||||
$res = $this->model
|
$res = $this->model
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
->with($this->withJoinTable)
|
->with($this->withJoinTable)
|
||||||
@@ -297,7 +312,36 @@ class Channel extends Backend
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getCurrentChannelIds(): array
|
||||||
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
{
|
||||||
*/
|
if ($this->auth->isSuperAdmin()) {
|
||||||
}
|
return Db::name('channel')->column('id');
|
||||||
|
}
|
||||||
|
$admin = Db::name('admin')
|
||||||
|
->field(['id', 'channel_id'])
|
||||||
|
->where('id', $this->auth->id)
|
||||||
|
->find();
|
||||||
|
$ids = [];
|
||||||
|
if ($admin && !empty($admin['channel_id'])) {
|
||||||
|
$ids[] = $admin['channel_id'];
|
||||||
|
}
|
||||||
|
$owned = Db::name('channel')->where('top_admin_id', $this->auth->id)->column('id');
|
||||||
|
$created = Db::name('channel')->where('admin_id', $this->auth->id)->column('id');
|
||||||
|
return array_values(array_unique(array_merge($ids, $owned, $created)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeAgentModeFields(array $data): array
|
||||||
|
{
|
||||||
|
$mode = $data['agent_mode'] ?? null;
|
||||||
|
if ($mode === 'turnover') {
|
||||||
|
$data['affiliate_share_rate'] = null;
|
||||||
|
$data['affiliate_fee_rate'] = null;
|
||||||
|
$data['carryover_balance'] = 0;
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
if ($mode === 'affiliate') {
|
||||||
|
$data['turnover_share_rate'] = null;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,12 +5,12 @@ namespace app\common\model;
|
|||||||
use support\think\Model;
|
use support\think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GameChannel
|
* Channel
|
||||||
*/
|
*/
|
||||||
class GameChannel extends Model
|
class Channel extends Model
|
||||||
{
|
{
|
||||||
// 表名
|
// 表名
|
||||||
protected $name = 'game_channel';
|
protected $name = 'channel';
|
||||||
|
|
||||||
// 自动写入时间戳字段
|
// 自动写入时间戳字段
|
||||||
protected $autoWriteTimestamp = true;
|
protected $autoWriteTimestamp = true;
|
||||||
@@ -21,7 +21,6 @@ class GameChannel extends Model
|
|||||||
'update_time' => 'integer',
|
'update_time' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function getprofitAmountAttr($value): ?float
|
public function getprofitAmountAttr($value): ?float
|
||||||
{
|
{
|
||||||
return is_null($value) ? null : (float)$value;
|
return is_null($value) ? null : (float)$value;
|
||||||
@@ -36,4 +35,4 @@ class GameChannel extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(\app\admin\model\Admin::class, 'admin_id', 'id');
|
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' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
37
web/src/lang/backend/en/channel.ts
Normal file
37
web/src/lang/backend/en/channel.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
id: 'id',
|
||||||
|
code: 'code',
|
||||||
|
invite_code: 'invite_code',
|
||||||
|
name: 'name',
|
||||||
|
top_admin_id: 'top_admin_id',
|
||||||
|
agent_mode: 'agent_mode',
|
||||||
|
'agent_mode turnover': 'turnover',
|
||||||
|
'agent_mode affiliate': 'affiliate',
|
||||||
|
agent_mode_title_turnover: 'Turnover Agent Mode',
|
||||||
|
agent_mode_desc_turnover_1: 'Settlement: commissions apply only when platform-wide PnL is positive.',
|
||||||
|
agent_mode_desc_turnover_2: 'Formula: bucket base by turnover × turnover share rate.',
|
||||||
|
agent_mode_desc_turnover_3: 'Fields: fill turnover share rate only; affiliate fields are cleared automatically.',
|
||||||
|
agent_mode_title_affiliate: 'Affiliate Agent Mode',
|
||||||
|
agent_mode_desc_affiliate_1: 'Settlement: based on net player loss within this affiliate line.',
|
||||||
|
agent_mode_desc_affiliate_2: 'Formula: net loss after costs × affiliate share rate.',
|
||||||
|
agent_mode_desc_affiliate_3: 'Fields: supports fee deduction rate and carryover balance; turnover rate is cleared automatically.',
|
||||||
|
turnover_share_rate: 'turnover_share_rate',
|
||||||
|
affiliate_share_rate: 'affiliate_share_rate',
|
||||||
|
affiliate_fee_rate: 'affiliate_fee_rate',
|
||||||
|
carryover_balance: 'carryover_balance',
|
||||||
|
user_count: 'user_count',
|
||||||
|
profit_amount: 'profit_amount',
|
||||||
|
total_profit_amount: 'total_profit_amount',
|
||||||
|
commission_pool_amount: 'commission_pool_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,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',
|
|
||||||
}
|
|
||||||
37
web/src/lang/backend/zh-cn/channel.ts
Normal file
37
web/src/lang/backend/zh-cn/channel.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export default {
|
||||||
|
id: 'ID',
|
||||||
|
code: '渠道标识',
|
||||||
|
invite_code: '渠道邀请码',
|
||||||
|
name: '渠道名',
|
||||||
|
top_admin_id: '顶级代理',
|
||||||
|
agent_mode: '代理模式',
|
||||||
|
'agent_mode turnover': '普通返水代理',
|
||||||
|
'agent_mode affiliate': '联营代理',
|
||||||
|
agent_mode_title_turnover: '普通返水代理(按流水分桶)',
|
||||||
|
agent_mode_desc_turnover_1: '结算口径:仅在平台大盘盈利时参与分红;大盘亏损或持平时当期分红为0。',
|
||||||
|
agent_mode_desc_turnover_2: '计算方式:渠道分桶基数 × 返水分红比例(turnover_share_rate)。',
|
||||||
|
agent_mode_desc_turnover_3: '字段说明:仅需填写返水分红比例;切换到该模式会自动清空联营相关字段。',
|
||||||
|
agent_mode_title_affiliate: '联营代理(客损占成)',
|
||||||
|
agent_mode_desc_affiliate_1: '结算口径:按该渠道辖区净客损结算,支持联营占成分账。',
|
||||||
|
agent_mode_desc_affiliate_2: '计算方式:净客损扣除成本后 × 联营占成比例(affiliate_share_rate)。',
|
||||||
|
agent_mode_desc_affiliate_3: '字段说明:可配置联营成本扣除比例与负结转余额;切换到该模式会自动清空返水比例。',
|
||||||
|
turnover_share_rate: '返水分红比例',
|
||||||
|
affiliate_share_rate: '联营占成比例',
|
||||||
|
affiliate_fee_rate: '联营成本扣除比例',
|
||||||
|
carryover_balance: '联营负结转余额',
|
||||||
|
user_count: '用户数',
|
||||||
|
profit_amount: '当期利润',
|
||||||
|
total_profit_amount: '累计总利润',
|
||||||
|
commission_pool_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,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、渠道标识、渠道名',
|
|
||||||
}
|
|
||||||
224
web/src/views/backend/channel/index.vue
Normal file
224
web/src/views/backend/channel/index.vue
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<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('channel.quick Search Fields') })"
|
||||||
|
></TableHeader>
|
||||||
|
|
||||||
|
<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: 'channel',
|
||||||
|
})
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const tableRef = useTemplateRef('tableRef')
|
||||||
|
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
||||||
|
const formatRatePercent = (_row: any, _column: any, cellValue: number | string | null) => {
|
||||||
|
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
||||||
|
const num = Number(cellValue)
|
||||||
|
if (Number.isNaN(num)) return '-'
|
||||||
|
return `${num.toFixed(2)}%`
|
||||||
|
}
|
||||||
|
const formatAmountInt = (_row: any, _column: any, cellValue: number | string | null) => {
|
||||||
|
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
||||||
|
const num = Number(cellValue)
|
||||||
|
if (Number.isNaN(num)) return '-'
|
||||||
|
return `${num}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const baTable = new baTableClass(
|
||||||
|
new baTableApi('/admin/channel/'),
|
||||||
|
{
|
||||||
|
pk: 'id',
|
||||||
|
column: [
|
||||||
|
{ type: 'selection', align: 'center', operator: false },
|
||||||
|
{ label: t('channel.id'), prop: 'id', align: 'center', width: 70, operator: 'RANGE', sortable: 'custom' },
|
||||||
|
{
|
||||||
|
label: t('channel.code'),
|
||||||
|
prop: 'code',
|
||||||
|
align: 'center',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
sortable: false,
|
||||||
|
operator: 'LIKE',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.name'),
|
||||||
|
prop: 'name',
|
||||||
|
align: 'center',
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
sortable: false,
|
||||||
|
operator: 'LIKE',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.agent_mode'),
|
||||||
|
prop: 'agent_mode',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120,
|
||||||
|
operator: 'eq',
|
||||||
|
sortable: false,
|
||||||
|
render: 'tag',
|
||||||
|
replaceValue: {
|
||||||
|
turnover: t('channel.agent_mode turnover'),
|
||||||
|
affiliate: t('channel.agent_mode affiliate'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.turnover_share_rate'),
|
||||||
|
prop: 'turnover_share_rate',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatRatePercent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.affiliate_share_rate'),
|
||||||
|
prop: 'affiliate_share_rate',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatRatePercent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.affiliate_fee_rate'),
|
||||||
|
prop: 'affiliate_fee_rate',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 140,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatRatePercent,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.carryover_balance'),
|
||||||
|
prop: 'carryover_balance',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 130,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmountInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.user_count'),
|
||||||
|
prop: 'user_count',
|
||||||
|
align: 'center',
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.profit_amount'),
|
||||||
|
prop: 'profit_amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmountInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.total_profit_amount'),
|
||||||
|
prop: 'total_profit_amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmountInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.commission_pool_amount'),
|
||||||
|
prop: 'commission_pool_amount',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
sortable: false,
|
||||||
|
operator: 'RANGE',
|
||||||
|
formatter: formatAmountInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.status'),
|
||||||
|
prop: 'status',
|
||||||
|
align: 'center',
|
||||||
|
operator: 'eq',
|
||||||
|
sortable: false,
|
||||||
|
render: 'switch',
|
||||||
|
replaceValue: { '0': t('channel.status 0'), '1': t('channel.status 1') },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.admingroup__name'),
|
||||||
|
prop: 'adminGroup.name',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 110,
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
render: 'tags',
|
||||||
|
operator: 'LIKE',
|
||||||
|
comSearchRender: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('channel.admin__username'),
|
||||||
|
prop: 'admin.username',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 90,
|
||||||
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
|
render: 'tags',
|
||||||
|
operator: 'LIKE',
|
||||||
|
comSearchRender: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('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('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', agent_mode: 'turnover' },
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
provide('baTable', baTable)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
baTable.table.ref = tableRef.value
|
||||||
|
baTable.mount()
|
||||||
|
baTable.getData()?.then(() => {
|
||||||
|
baTable.initSort()
|
||||||
|
baTable.dragSort()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
||||||
229
web/src/views/backend/channel/popupForm.vue
Normal file
229
web/src/views/backend/channel/popupForm.vue
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
<template>
|
||||||
|
<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('channel.code')"
|
||||||
|
type="string"
|
||||||
|
v-model="baTable.form.items!.code"
|
||||||
|
prop="code"
|
||||||
|
:placeholder="t('Please input field', { field: t('channel.code') })"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('channel.name')"
|
||||||
|
type="string"
|
||||||
|
v-model="baTable.form.items!.name"
|
||||||
|
prop="name"
|
||||||
|
:placeholder="t('Please input field', { field: t('channel.name') })"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('channel.agent_mode')"
|
||||||
|
type="radio"
|
||||||
|
v-model="baTable.form.items!.agent_mode"
|
||||||
|
prop="agent_mode"
|
||||||
|
:input-attr="{ content: { turnover: t('channel.agent_mode turnover'), affiliate: t('channel.agent_mode affiliate') } }"
|
||||||
|
/>
|
||||||
|
<el-alert
|
||||||
|
:title="currentAgentMode === 'turnover' ? t('channel.agent_mode_title_turnover') : t('channel.agent_mode_title_affiliate')"
|
||||||
|
type="info"
|
||||||
|
show-icon
|
||||||
|
:closable="false"
|
||||||
|
class="agent-mode-alert"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<ul class="agent-mode-desc-list">
|
||||||
|
<li v-for="item in currentAgentModeDescList" :key="item">{{ item }}</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
<FormItem
|
||||||
|
v-if="currentAgentMode === 'turnover'"
|
||||||
|
:label="t('channel.turnover_share_rate')"
|
||||||
|
type="number"
|
||||||
|
v-model="baTable.form.items!.turnover_share_rate"
|
||||||
|
prop="turnover_share_rate"
|
||||||
|
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100 }"
|
||||||
|
:placeholder="`${t('Please input field', { field: t('channel.turnover_share_rate') })} (例如 30.5)`"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
v-if="currentAgentMode === 'affiliate'"
|
||||||
|
:label="t('channel.affiliate_share_rate')"
|
||||||
|
type="number"
|
||||||
|
v-model="baTable.form.items!.affiliate_share_rate"
|
||||||
|
prop="affiliate_share_rate"
|
||||||
|
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100 }"
|
||||||
|
:placeholder="`${t('Please input field', { field: t('channel.affiliate_share_rate') })} (例如 55.5)`"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
v-if="currentAgentMode === 'affiliate'"
|
||||||
|
:label="t('channel.affiliate_fee_rate')"
|
||||||
|
type="number"
|
||||||
|
v-model="baTable.form.items!.affiliate_fee_rate"
|
||||||
|
prop="affiliate_fee_rate"
|
||||||
|
:input-attr="{ step: 0.01, precision: 2, min: 0, max: 100 }"
|
||||||
|
:placeholder="`${t('Please input field', { field: t('channel.affiliate_fee_rate') })} (例如 15.0)`"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
v-if="currentAgentMode === 'affiliate'"
|
||||||
|
:label="t('channel.carryover_balance')"
|
||||||
|
type="number"
|
||||||
|
v-model="baTable.form.items!.carryover_balance"
|
||||||
|
prop="carryover_balance"
|
||||||
|
:input-attr="{ step: 0.0001, precision: 4 }"
|
||||||
|
:placeholder="t('Please input field', { field: t('channel.carryover_balance') })"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('channel.status')"
|
||||||
|
type="switch"
|
||||||
|
v-model="baTable.form.items!.status"
|
||||||
|
prop="status"
|
||||||
|
:input-attr="{ content: { '0': t('channel.status 0'), '1': t('channel.status 1') } }"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('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('channel.remark') })"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('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', params: { top_group: '1' } }"
|
||||||
|
:placeholder="t('Please select field', { field: t('channel.admin_id') })"
|
||||||
|
/>
|
||||||
|
<FormItem
|
||||||
|
:label="t('channel.top_admin_id')"
|
||||||
|
type="remoteSelect"
|
||||||
|
v-model="baTable.form.items!.top_admin_id"
|
||||||
|
prop="top_admin_id"
|
||||||
|
:input-attr="{ pk: 'admin.id', field: 'username', remoteUrl: '/admin/auth.Admin/index', params: { top_group: '1' } }"
|
||||||
|
:placeholder="t('Please select field', { field: t('channel.top_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 { computed, inject, reactive, useTemplateRef, watch } 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 currentAgentMode = computed(() => baTable.form.items?.agent_mode ?? 'turnover')
|
||||||
|
const currentAgentModeDescList = computed(() => {
|
||||||
|
if (currentAgentMode.value === 'turnover') {
|
||||||
|
return [t('channel.agent_mode_desc_turnover_1'), t('channel.agent_mode_desc_turnover_2'), t('channel.agent_mode_desc_turnover_3')]
|
||||||
|
}
|
||||||
|
return [t('channel.agent_mode_desc_affiliate_1'), t('channel.agent_mode_desc_affiliate_2'), t('channel.agent_mode_desc_affiliate_3')]
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => baTable.form.items?.agent_mode,
|
||||||
|
(mode) => {
|
||||||
|
if (!baTable.form.items) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (mode === 'turnover') {
|
||||||
|
baTable.form.items.affiliate_share_rate = null
|
||||||
|
baTable.form.items.affiliate_fee_rate = null
|
||||||
|
baTable.form.items.carryover_balance = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (mode === 'affiliate') {
|
||||||
|
baTable.form.items.turnover_share_rate = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const percentValidator = (label: string) => {
|
||||||
|
return (_rule: any, value: string | number | null, callback: (error?: Error) => void) => {
|
||||||
|
if (value === null || value === undefined || value === '') {
|
||||||
|
callback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const str = String(value).trim()
|
||||||
|
if (!/^\d+(\.\d{1,2})?$/.test(str)) {
|
||||||
|
callback(new Error(`${label}仅支持最多两位小数`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const num = Number(str)
|
||||||
|
if (Number.isNaN(num) || num < 0 || num > 100) {
|
||||||
|
callback(new Error(`${label}必须在0到100之间`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||||
|
code: [buildValidatorData({ name: 'required', title: t('channel.code') })],
|
||||||
|
name: [buildValidatorData({ name: 'required', title: t('channel.name') })],
|
||||||
|
agent_mode: [buildValidatorData({ name: 'required', title: t('channel.agent_mode') })],
|
||||||
|
turnover_share_rate: [{ validator: percentValidator(t('channel.turnover_share_rate')), trigger: 'blur' }],
|
||||||
|
affiliate_share_rate: [{ validator: percentValidator(t('channel.affiliate_share_rate')), trigger: 'blur' }],
|
||||||
|
affiliate_fee_rate: [{ validator: percentValidator(t('channel.affiliate_fee_rate')), trigger: 'blur' }],
|
||||||
|
carryover_balance: [buildValidatorData({ name: 'number', title: t('channel.carryover_balance') })],
|
||||||
|
admin_id: [buildValidatorData({ name: 'required', title: t('channel.admin_id') })],
|
||||||
|
top_admin_id: [buildValidatorData({ name: 'required', title: t('channel.top_admin_id') })],
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.agent-mode-alert {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent-mode-desc-list {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
padding-left: 18px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -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,111 +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_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', params: { top_group: '1' } }"
|
|
||||||
: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_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>
|
|
||||||
Reference in New Issue
Block a user