1.新增游戏管理接口和菜单
2.创建对接第三方文档
This commit is contained in:
40
saiadmin-artd/src/views/plugin/dice/api/game/index.ts
Normal file
40
saiadmin-artd/src/views/plugin/dice/api/game/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 游戏管理 API
|
||||
*/
|
||||
export default {
|
||||
list(params: Record<string, unknown>) {
|
||||
return request.get<Api.Common.ApiPage>({
|
||||
url: '/core/dice/game/DiceGame/index',
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
read(id: number | string) {
|
||||
return request.get<Api.Common.ApiData>({
|
||||
url: '/core/dice/game/DiceGame/read?id=' + id
|
||||
})
|
||||
},
|
||||
|
||||
save(params: Record<string, unknown>) {
|
||||
return request.post({
|
||||
url: '/core/dice/game/DiceGame/save',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
update(params: Record<string, unknown>) {
|
||||
return request.put({
|
||||
url: '/core/dice/game/DiceGame/update',
|
||||
data: params
|
||||
})
|
||||
},
|
||||
|
||||
delete(params: Record<string, unknown>) {
|
||||
return request.del({
|
||||
url: '/core/dice/game/DiceGame/destroy',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
}
|
||||
141
saiadmin-artd/src/views/plugin/dice/game/index/index.vue
Normal file
141
saiadmin-artd/src/views/plugin/dice/game/index/index.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div class="art-full-height">
|
||||
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
|
||||
|
||||
<ElCard class="art-table-card" shadow="never">
|
||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||
<template #left>
|
||||
<ElSpace wrap>
|
||||
<ElButton v-permission="'dice:game:index:save'" @click="showDialog('add')" v-ripple>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:add-fill" />
|
||||
</template>
|
||||
新增
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-permission="'dice:game:index:destroy'"
|
||||
:disabled="selectedRows.length === 0"
|
||||
@click="deleteSelectedRows(api.delete, refreshData)"
|
||||
v-ripple
|
||||
>
|
||||
<template #icon>
|
||||
<ArtSvgIcon icon="ri:delete-bin-5-line" />
|
||||
</template>
|
||||
删除
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
@pagination:size-change="handleSizeChange"
|
||||
@pagination:current-change="handleCurrentChange"
|
||||
>
|
||||
<template #status="{ row }">
|
||||
<ElTag :type="row.status === 1 ? 'success' : 'info'">{{ row.status === 1 ? '启用' : '禁用' }}</ElTag>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<SaButton
|
||||
v-permission="'dice:game:index:update'"
|
||||
type="secondary"
|
||||
@click="showDialog('edit', row)"
|
||||
/>
|
||||
<SaButton
|
||||
v-permission="'dice:game:index:destroy'"
|
||||
type="error"
|
||||
@click="deleteRow(row, api.delete, refreshData)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<EditDialog
|
||||
v-model="dialogVisible"
|
||||
:dialog-type="dialogType"
|
||||
:data="dialogData"
|
||||
@success="refreshData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useTable } from '@/hooks/core/useTable'
|
||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||
import api from '../../api/game/index'
|
||||
import TableSearch from './modules/table-search.vue'
|
||||
import EditDialog from './modules/edit-dialog.vue'
|
||||
|
||||
const searchForm = ref({
|
||||
provider_code: undefined,
|
||||
game_code: undefined,
|
||||
game_type: undefined,
|
||||
status: undefined
|
||||
})
|
||||
|
||||
const handleSearch = (params: Record<string, unknown>) => {
|
||||
Object.assign(searchParams, params)
|
||||
getData()
|
||||
}
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
loading,
|
||||
getData,
|
||||
searchParams,
|
||||
pagination,
|
||||
resetSearchParams,
|
||||
handleSortChange,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
refreshData
|
||||
} = useTable({
|
||||
core: {
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ type: 'selection', align: 'center' },
|
||||
{ prop: 'id', label: 'ID', width: 80, align: 'center' },
|
||||
{ prop: 'provider', label: '供应商', minWidth: 120, align: 'center' },
|
||||
{ prop: 'provider_code', label: '供应商编码', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_code', label: '游戏编号', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_key', label: '游戏唯一值', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_name', label: '中文名', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_name_en', label: '英文名', minWidth: 120, align: 'center' },
|
||||
{ prop: 'game_type', label: '类型', minWidth: 90, align: 'center' },
|
||||
{ prop: 'sort', label: '排序', width: 80, align: 'center' },
|
||||
{ prop: 'status', label: '状态', width: 90, align: 'center', useSlot: true },
|
||||
{ prop: 'update_time', label: '更新时间', minWidth: 160, align: 'center' },
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
useSlot: true
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
dialogType,
|
||||
dialogVisible,
|
||||
dialogData,
|
||||
showDialog,
|
||||
deleteRow,
|
||||
deleteSelectedRows,
|
||||
handleSelectionChange,
|
||||
selectedRows
|
||||
} = useSaiAdmin()
|
||||
</script>
|
||||
@@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="dialogType === 'add' ? '新增游戏' : '编辑游戏'"
|
||||
width="680px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="供应商" prop="provider">
|
||||
<el-input v-model="formData.provider" placeholder="请输入供应商名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="供应商编码" prop="provider_code">
|
||||
<el-input v-model="formData.provider_code" placeholder="请输入供应商编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏编号" prop="game_code">
|
||||
<el-input v-model="formData.game_code" placeholder="请输入游戏编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏唯一值" prop="game_key">
|
||||
<el-input v-model="formData.game_key" placeholder="请输入游戏唯一值" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="中文名称" prop="game_name">
|
||||
<el-input v-model="formData.game_name" placeholder="请输入中文名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="英文名称" prop="game_name_en">
|
||||
<el-input v-model="formData.game_name_en" placeholder="请输入英文名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="游戏类型" prop="game_type">
|
||||
<el-input v-model="formData.game_type" placeholder="请输入游戏类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="Logo地址" prop="logo">
|
||||
<el-tabs v-model="logoInputMode" class="w-full">
|
||||
<el-tab-pane label="图片选择" name="picker">
|
||||
<sa-image-picker
|
||||
v-model="formData.logo"
|
||||
:multiple="false"
|
||||
:limit="1"
|
||||
width="120px"
|
||||
height="120px"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="图片上传" name="upload">
|
||||
<sa-image-upload
|
||||
v-model="formData.logo"
|
||||
:multiple="false"
|
||||
:limit="1"
|
||||
:max-size="5"
|
||||
:show-tips="true"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-form-item>
|
||||
<el-form-item label="游戏地址" prop="game_url">
|
||||
<el-input v-model="formData.game_url" placeholder="请输入游戏地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="大厅地址" prop="hall_url">
|
||||
<el-input v-model="formData.hall_url" placeholder="请输入大厅地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio :value="1">启用</el-radio>
|
||||
<el-radio :value="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/game/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: false,
|
||||
dialogType: 'add',
|
||||
data: undefined
|
||||
})
|
||||
const emit = defineEmits<Emits>()
|
||||
const formRef = ref<FormInstance>()
|
||||
const logoInputMode = ref<'picker' | 'upload'>('picker')
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
type GameFormData = {
|
||||
id: number | null
|
||||
provider: string
|
||||
provider_code: string
|
||||
game_code: string
|
||||
game_key: string
|
||||
game_name: string
|
||||
game_name_en: string
|
||||
game_type: string
|
||||
logo: string
|
||||
game_url: string
|
||||
hall_url: string
|
||||
status: number
|
||||
sort: number
|
||||
remark: string
|
||||
}
|
||||
|
||||
const initialFormData: GameFormData = {
|
||||
id: null,
|
||||
provider: 'Dicey Fun',
|
||||
provider_code: 'DF',
|
||||
game_code: '',
|
||||
game_key: '',
|
||||
game_name: '',
|
||||
game_name_en: '',
|
||||
game_type: 'slot',
|
||||
logo: '',
|
||||
game_url: '',
|
||||
hall_url: '',
|
||||
status: 1,
|
||||
sort: 100,
|
||||
remark: ''
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
const rules = computed<FormRules>(() => ({
|
||||
provider: [{ required: true, message: '请输入供应商', trigger: 'blur' }],
|
||||
provider_code: [{ required: true, message: '请输入供应商编码', trigger: 'blur' }],
|
||||
game_code: [{ required: true, message: '请输入游戏编号', trigger: 'blur' }],
|
||||
game_key: [{ required: true, message: '请输入游戏唯一值', trigger: 'blur' }],
|
||||
game_name: [{ required: true, message: '请输入中文名称', trigger: 'blur' }],
|
||||
game_type: [{ required: true, message: '请输入游戏类型', trigger: 'blur' }]
|
||||
}))
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
async (newVal) => {
|
||||
if (!newVal) return
|
||||
Object.assign(formData, initialFormData)
|
||||
if (!props.data) return
|
||||
await nextTick()
|
||||
if (typeof props.data.id === 'number') formData.id = props.data.id
|
||||
if (typeof props.data.provider === 'string') formData.provider = props.data.provider
|
||||
if (typeof props.data.provider_code === 'string') formData.provider_code = props.data.provider_code
|
||||
if (typeof props.data.game_code === 'string') formData.game_code = props.data.game_code
|
||||
if (typeof props.data.game_key === 'string') formData.game_key = props.data.game_key
|
||||
if (typeof props.data.game_name === 'string') formData.game_name = props.data.game_name
|
||||
if (typeof props.data.game_name_en === 'string') formData.game_name_en = props.data.game_name_en
|
||||
if (typeof props.data.game_type === 'string') formData.game_type = props.data.game_type
|
||||
if (typeof props.data.logo === 'string') formData.logo = props.data.logo
|
||||
if (typeof props.data.game_url === 'string') formData.game_url = props.data.game_url
|
||||
if (typeof props.data.hall_url === 'string') formData.hall_url = props.data.hall_url
|
||||
formData.status = Number(props.data.status ?? 1) === 1 ? 1 : 0
|
||||
const sortValue = Number(props.data.sort ?? 100)
|
||||
formData.sort = Number.isFinite(sortValue) ? sortValue : 100
|
||||
if (typeof props.data.remark === 'string') formData.remark = props.data.remark
|
||||
}
|
||||
)
|
||||
|
||||
function handleClose() {
|
||||
visible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (props.dialogType === 'add') {
|
||||
await api.save(formData)
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
await api.update(formData)
|
||||
ElMessage.success('更新成功')
|
||||
}
|
||||
emit('success')
|
||||
handleClose()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<sa-search-bar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
label-width="100px"
|
||||
:showExpand="false"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="供应商编码" prop="provider_code">
|
||||
<el-input v-model="formData.provider_code" placeholder="请输入供应商编码" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="游戏编号" prop="game_code">
|
||||
<el-input v-model="formData.game_code" placeholder="请输入游戏编号" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="游戏类型" prop="game_type">
|
||||
<el-input v-model="formData.game_type" placeholder="请输入游戏类型" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态" clearable>
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type GameSearchForm = {
|
||||
provider_code?: string
|
||||
game_code?: string
|
||||
game_type?: string
|
||||
status?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: GameSearchForm
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: GameSearchForm): void
|
||||
(e: 'search', params: GameSearchForm): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const searchBarRef = ref()
|
||||
const formData = computed<GameSearchForm>({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val)
|
||||
})
|
||||
|
||||
function handleReset() {
|
||||
searchBarRef.value?.ref.resetFields()
|
||||
emit('reset')
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
emit('search', formData.value)
|
||||
}
|
||||
|
||||
const setSpan = (span: number) => {
|
||||
return {
|
||||
span,
|
||||
xs: 24,
|
||||
sm: span >= 12 ? span : 12,
|
||||
md: span >= 8 ? span : 8,
|
||||
lg: span,
|
||||
xl: span
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user