[色子游戏]奖池配置
This commit is contained in:
@@ -110,9 +110,13 @@
|
|||||||
columnsFactory: () => [
|
columnsFactory: () => [
|
||||||
{ type: 'selection' },
|
{ type: 'selection' },
|
||||||
{ prop: 'name', label: '名称' },
|
{ prop: 'name', label: '名称' },
|
||||||
{ prop: 'weight', label: '权重' },
|
|
||||||
{ prop: 'type', label: '奖池类型' },
|
{ prop: 'type', label: '奖池类型' },
|
||||||
{ prop: 'safety_line', label: '安全线' },
|
{ prop: 'safety_line', label: '安全线' },
|
||||||
|
{ prop: 't1_wight', label: 'T1池权重' },
|
||||||
|
{ prop: 't2_wight', label: 'T2池权重' },
|
||||||
|
{ prop: 't3_wight', label: 'T3池权重' },
|
||||||
|
{ prop: 't4_wight', label: 'T4池权重' },
|
||||||
|
{ prop: 't5_wight', label: 'T5池权重' },
|
||||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="visible"
|
v-model="visible"
|
||||||
:title="dialogType === 'add' ? '新增色子奖池配置' : '编辑色子奖池配置'"
|
:title="dialogType === 'add' ? '新增色子奖池配置' : '编辑色子奖池配置'"
|
||||||
width="500px"
|
width="600px"
|
||||||
align-center
|
align-center
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
@@ -11,17 +11,58 @@
|
|||||||
<el-form-item label="名称" prop="name">
|
<el-form-item label="名称" prop="name">
|
||||||
<el-input v-model="formData.name" placeholder="请输入名称" />
|
<el-input v-model="formData.name" placeholder="请输入名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="权重" prop="weight">
|
|
||||||
<el-slider v-model="formData.weight" placeholder="请输入权重" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
maxlength="500"
|
||||||
|
show-word-limit
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="奖池类型" prop="type">
|
<el-form-item label="奖池类型" prop="type">
|
||||||
<el-select v-model="formData.type" :options="[]" placeholder="请选择奖池类型" clearable />
|
<el-select
|
||||||
|
v-model="formData.type"
|
||||||
|
placeholder="请选择奖池类型"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option label="正常" :value="0" />
|
||||||
|
<el-option label="强制杀猪" :value="1" />
|
||||||
|
<el-option label="T1高倍率" :value="2" />
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="安全线" prop="safety_line">
|
<el-form-item label="安全线" prop="safety_line">
|
||||||
<el-input v-model="formData.safety_line" placeholder="请输入安全线" />
|
<el-input-number
|
||||||
|
v-model="formData.safety_line"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="T1池权重(%)" prop="t1_wight">
|
||||||
|
<el-slider v-model="formData.t1_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="T2池权重(%)" prop="t2_wight">
|
||||||
|
<el-slider v-model="formData.t2_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="T3池权重(%)" prop="t3_wight">
|
||||||
|
<el-slider v-model="formData.t3_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="T4池权重(%)" prop="t4_wight">
|
||||||
|
<el-slider v-model="formData.t4_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="T5池权重(%)" prop="t5_wight">
|
||||||
|
<el-slider v-model="formData.t5_wight" :min="0" :max="100" :step="0.01" show-input />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<div class="text-gray-500 text-sm">
|
||||||
|
五个池权重总和:<span :class="weightsSum > 100 ? 'text-red-500' : ''">{{
|
||||||
|
weightsSum
|
||||||
|
}}</span
|
||||||
|
>% / 100%(不可超过100%)
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -65,26 +106,41 @@
|
|||||||
set: (value) => emit('update:modelValue', value)
|
set: (value) => emit('update:modelValue', value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 五个权重字段名,用于总和校验 */
|
||||||
|
const WEIGHT_KEYS = ['t1_wight', 't2_wight', 't3_wight', 't4_wight', 't5_wight'] as const
|
||||||
|
|
||||||
|
/** 五个池权重总和(用于展示与校验) */
|
||||||
|
const weightsSum = computed(() => {
|
||||||
|
return WEIGHT_KEYS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单验证规则
|
* 表单验证规则
|
||||||
*/
|
*/
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
name: [{ required: true, message: '名称必需填写', trigger: 'blur' }],
|
name: [{ required: true, message: '名称必需填写', trigger: 'blur' }],
|
||||||
weight: [{ required: true, message: '权重必需填写', trigger: 'blur' }],
|
type: [{ required: true, message: '请选择奖池类型', trigger: 'change' }],
|
||||||
remark: [{ required: true, message: '备注必需填写', trigger: 'blur' }],
|
t1_wight: [{ required: true, message: 'T1池权重必需填写', trigger: 'blur' }],
|
||||||
type: [{ required: true, message: '奖池类型必需填写', trigger: 'blur' }],
|
t2_wight: [{ required: true, message: 'T2池权重必需填写', trigger: 'blur' }],
|
||||||
|
t3_wight: [{ required: true, message: 'T3池权重必需填写', trigger: 'blur' }],
|
||||||
|
t4_wight: [{ required: true, message: 'T4池权重必需填写', trigger: 'blur' }],
|
||||||
|
t5_wight: [{ required: true, message: 'T5池权重必需填写', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始数据
|
* 初始数据(权重为数字便于输入与校验)
|
||||||
*/
|
*/
|
||||||
const initialFormData = {
|
const initialFormData = {
|
||||||
id: null,
|
id: null as number | null,
|
||||||
name: '',
|
name: '',
|
||||||
weight: '0.00',
|
|
||||||
remark: '',
|
remark: '',
|
||||||
type: null,
|
type: null as number | null,
|
||||||
safety_line: '0.00',
|
safety_line: 0 as number,
|
||||||
|
t1_wight: 0 as number,
|
||||||
|
t2_wight: 0 as number,
|
||||||
|
t3_wight: 0 as number,
|
||||||
|
t4_wight: 0 as number,
|
||||||
|
t5_wight: 0 as number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,14 +174,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化表单数据
|
* 初始化表单数据(数值字段转为 number 便于输入框与校验)
|
||||||
*/
|
*/
|
||||||
const initForm = () => {
|
const initForm = () => {
|
||||||
if (props.data) {
|
if (!props.data) return
|
||||||
for (const key in formData) {
|
const numKeys = [
|
||||||
if (props.data[key] != null && props.data[key] != undefined) {
|
'type',
|
||||||
;(formData as any)[key] = props.data[key]
|
'safety_line',
|
||||||
}
|
't1_wight',
|
||||||
|
't2_wight',
|
||||||
|
't3_wight',
|
||||||
|
't4_wight',
|
||||||
|
't5_wight'
|
||||||
|
]
|
||||||
|
for (const key in formData) {
|
||||||
|
if (props.data[key] != null && props.data[key] !== undefined) {
|
||||||
|
const val = props.data[key]
|
||||||
|
;(formData as any)[key] = numKeys.includes(key) ? Number(val) : val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +210,10 @@
|
|||||||
if (!formRef.value) return
|
if (!formRef.value) return
|
||||||
try {
|
try {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
|
if (weightsSum.value > 100) {
|
||||||
|
ElMessage.warning('五个池权重总和不能超过100%')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (props.dialogType === 'add') {
|
if (props.dialogType === 'add') {
|
||||||
await api.save(formData)
|
await api.save(formData)
|
||||||
ElMessage.success('新增成功')
|
ElMessage.success('新增成功')
|
||||||
|
|||||||
@@ -15,7 +15,12 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col v-bind="setSpan(6)">
|
<el-col v-bind="setSpan(6)">
|
||||||
<el-form-item label="奖池类型" prop="type">
|
<el-form-item label="奖池类型" prop="type">
|
||||||
<el-select v-model="formData.type" :options="[]" placeholder="请选择奖池类型" clearable />
|
<el-select
|
||||||
|
v-model="formData.type"
|
||||||
|
:options="typeOptions"
|
||||||
|
placeholder="请选择奖池类型"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</sa-search-bar>
|
</sa-search-bar>
|
||||||
@@ -35,6 +40,11 @@
|
|||||||
// 展开/收起
|
// 展开/收起
|
||||||
const isExpanded = ref<boolean>(false)
|
const isExpanded = ref<boolean>(false)
|
||||||
|
|
||||||
|
const typeOptions = [
|
||||||
|
{ name: '0', value: '正常' },
|
||||||
|
{ name: '1', value: '强制杀猪' },
|
||||||
|
{ name: '2', value: 'T1高倍率' }
|
||||||
|
]
|
||||||
// 表单数据双向绑定
|
// 表单数据双向绑定
|
||||||
const searchBarRef = ref()
|
const searchBarRef = ref()
|
||||||
const formData = computed({
|
const formData = computed({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\dice\logic\lottery_config;
|
namespace app\dice\logic\lottery_config;
|
||||||
|
|
||||||
use plugin\saiadmin\basic\eloquent\BaseLogic;
|
use plugin\saiadmin\basic\think\BaseLogic;
|
||||||
use plugin\saiadmin\exception\ApiException;
|
use plugin\saiadmin\exception\ApiException;
|
||||||
use plugin\saiadmin\utils\Helper;
|
use plugin\saiadmin\utils\Helper;
|
||||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\dice\model\lottery_config;
|
namespace app\dice\model\lottery_config;
|
||||||
|
|
||||||
use plugin\saiadmin\basic\eloquent\BaseModel;
|
use plugin\saiadmin\basic\think\BaseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 色子奖池配置模型
|
* 色子奖池配置模型
|
||||||
@@ -15,10 +15,16 @@ use plugin\saiadmin\basic\eloquent\BaseModel;
|
|||||||
*
|
*
|
||||||
* @property $id ID
|
* @property $id ID
|
||||||
* @property $name 名称
|
* @property $name 名称
|
||||||
* @property $weight 权重
|
|
||||||
* @property $remark 备注
|
* @property $remark 备注
|
||||||
* @property $type 奖池类型
|
* @property $type 奖池类型
|
||||||
* @property $safety_line 安全线
|
* @property $safety_line 安全线
|
||||||
|
* @property $create_time 创建时间
|
||||||
|
* @property $update_time 修改时间
|
||||||
|
* @property $t1_wight T1池权重
|
||||||
|
* @property $t2_wight T2池权重
|
||||||
|
* @property $t3_wight T3池权重
|
||||||
|
* @property $t4_wight T4池权重
|
||||||
|
* @property $t5_wight T5池权重
|
||||||
*/
|
*/
|
||||||
class DiceLotteryConfig extends BaseModel
|
class DiceLotteryConfig extends BaseModel
|
||||||
{
|
{
|
||||||
@@ -26,7 +32,7 @@ class DiceLotteryConfig extends BaseModel
|
|||||||
* 数据表主键
|
* 数据表主键
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $primaryKey = 'id';
|
protected $pk = 'id';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库表名称
|
* 数据库表名称
|
||||||
@@ -34,14 +40,6 @@ class DiceLotteryConfig extends BaseModel
|
|||||||
*/
|
*/
|
||||||
protected $table = 'dice_lottery_config';
|
protected $table = 'dice_lottery_config';
|
||||||
|
|
||||||
/**
|
|
||||||
* 属性转换
|
|
||||||
*/
|
|
||||||
protected function casts(): array
|
|
||||||
{
|
|
||||||
return array_merge(parent::casts(), [
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 名称 搜索
|
* 名称 搜索
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,9 +18,12 @@ class DiceLotteryConfigValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'name' => 'require',
|
'name' => 'require',
|
||||||
'weight' => 'require',
|
|
||||||
'remark' => 'require',
|
|
||||||
'type' => 'require',
|
'type' => 'require',
|
||||||
|
't1_wight' => 'require',
|
||||||
|
't2_wight' => 'require',
|
||||||
|
't3_wight' => 'require',
|
||||||
|
't4_wight' => 'require',
|
||||||
|
't5_wight' => 'require',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,9 +31,12 @@ class DiceLotteryConfigValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $message = [
|
protected $message = [
|
||||||
'name' => '名称必须填写',
|
'name' => '名称必须填写',
|
||||||
'weight' => '权重必须填写',
|
|
||||||
'remark' => '备注必须填写',
|
|
||||||
'type' => '奖池类型必须填写',
|
'type' => '奖池类型必须填写',
|
||||||
|
't1_wight' => 'T1池权重必须填写',
|
||||||
|
't2_wight' => 'T2池权重必须填写',
|
||||||
|
't3_wight' => 'T3池权重必须填写',
|
||||||
|
't4_wight' => 'T4池权重必须填写',
|
||||||
|
't5_wight' => 'T5池权重必须填写',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,15 +45,21 @@ class DiceLotteryConfigValidate extends BaseValidate
|
|||||||
protected $scene = [
|
protected $scene = [
|
||||||
'save' => [
|
'save' => [
|
||||||
'name',
|
'name',
|
||||||
'weight',
|
|
||||||
'remark',
|
|
||||||
'type',
|
'type',
|
||||||
|
't1_wight',
|
||||||
|
't2_wight',
|
||||||
|
't3_wight',
|
||||||
|
't4_wight',
|
||||||
|
't5_wight',
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
'name',
|
'name',
|
||||||
'weight',
|
|
||||||
'remark',
|
|
||||||
'type',
|
'type',
|
||||||
|
't1_wight',
|
||||||
|
't2_wight',
|
||||||
|
't3_wight',
|
||||||
|
't4_wight',
|
||||||
|
't5_wight',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,15 @@
|
|||||||
/**
|
/**
|
||||||
* Here is your custom functions.
|
* Here is your custom functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mb_split 兼容:当 PHP 未启用 mbstring 或 mb_split 不可用时,用 preg_split 模拟
|
||||||
|
* 解决 Illuminate\Support\Str::studly() 在 Windows 等环境下报 Call to undefined function mb_split() 的问题
|
||||||
|
*/
|
||||||
|
if (!function_exists('mb_split')) {
|
||||||
|
function mb_split(string $pattern, string $string, int $limit = -1): array
|
||||||
|
{
|
||||||
|
$regex = '/' . str_replace('/', '\\/', $pattern) . '/u';
|
||||||
|
return preg_split($regex, $string, $limit === -1 ? -1 : $limit) ?: [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user