[游戏管理]游戏配置
This commit is contained in:
14
web/src/lang/backend/en/game/config.ts
Normal file
14
web/src/lang/backend/en/game/config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
'quick Search Fields': 'ID / Key / Remark',
|
||||
id: 'ID',
|
||||
config_key: 'Config key',
|
||||
config_value: 'Value',
|
||||
value_type: 'Value type',
|
||||
'value_type string': 'String',
|
||||
'value_type int': 'Integer',
|
||||
'value_type decimal': 'Decimal',
|
||||
'value_type json': 'JSON',
|
||||
remark: 'Remark',
|
||||
create_time: 'Created',
|
||||
update_time: 'Updated',
|
||||
}
|
||||
14
web/src/lang/backend/zh-cn/game/config.ts
Normal file
14
web/src/lang/backend/zh-cn/game/config.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
'quick Search Fields': 'ID/参数键/说明',
|
||||
id: 'ID',
|
||||
config_key: '参数键',
|
||||
config_value: '参数值',
|
||||
value_type: '值类型',
|
||||
'value_type string': '字符串',
|
||||
'value_type int': '整数',
|
||||
'value_type decimal': '小数',
|
||||
'value_type json': 'JSON',
|
||||
remark: '说明',
|
||||
create_time: '创建时间',
|
||||
update_time: '更新时间',
|
||||
}
|
||||
125
web/src/views/backend/game/config/index.vue
Normal file
125
web/src/views/backend/game/config/index.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<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.config.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: 'game/config',
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
const tableRef = useTemplateRef('tableRef')
|
||||
const optButtons: OptButton[] = defaultOptButtons(['edit', 'delete'])
|
||||
|
||||
const baTable = new baTableClass(
|
||||
new baTableApi('/admin/game.Config/'),
|
||||
{
|
||||
pk: 'id',
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', operator: false },
|
||||
{ label: t('game.config.id'), prop: 'id', align: 'center', width: 80, operator: 'RANGE', sortable: 'custom' },
|
||||
{
|
||||
label: t('game.config.config_key'),
|
||||
prop: 'config_key',
|
||||
align: 'center',
|
||||
minWidth: 200,
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
operator: 'LIKE',
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{
|
||||
label: t('game.config.config_value'),
|
||||
prop: 'config_value',
|
||||
align: 'center',
|
||||
minWidth: 160,
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
operator: 'LIKE',
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{
|
||||
label: t('game.config.value_type'),
|
||||
prop: 'value_type',
|
||||
align: 'center',
|
||||
width: 110,
|
||||
operator: 'eq',
|
||||
render: 'tag',
|
||||
replaceValue: {
|
||||
string: t('game.config.value_type string'),
|
||||
int: t('game.config.value_type int'),
|
||||
decimal: t('game.config.value_type decimal'),
|
||||
json: t('game.config.value_type json'),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('game.config.remark'),
|
||||
prop: 'remark',
|
||||
align: 'center',
|
||||
minWidth: 200,
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
operator: 'LIKE',
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{
|
||||
label: t('game.config.create_time'),
|
||||
prop: 'create_time',
|
||||
align: 'center',
|
||||
render: 'datetime',
|
||||
operator: 'RANGE',
|
||||
comSearchRender: 'datetime',
|
||||
sortable: 'custom',
|
||||
width: 170,
|
||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||
},
|
||||
{
|
||||
label: t('game.config.update_time'),
|
||||
prop: 'update_time',
|
||||
align: 'center',
|
||||
render: 'datetime',
|
||||
operator: 'RANGE',
|
||||
comSearchRender: 'datetime',
|
||||
sortable: 'custom',
|
||||
width: 170,
|
||||
timeFormat: 'yyyy-mm-dd hh:MM:ss',
|
||||
},
|
||||
{ label: t('Operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false, fixed: 'right' },
|
||||
],
|
||||
dblClickNotEditColumn: [undefined],
|
||||
},
|
||||
{
|
||||
defaultItems: { value_type: 'string', remark: '' },
|
||||
}
|
||||
)
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.table.ref = tableRef.value
|
||||
baTable.mount()
|
||||
baTable.getData()?.then(() => {
|
||||
baTable.initSort()
|
||||
baTable.dragSort()
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
106
web/src/views/backend/game/config/popupForm.vue
Normal file
106
web/src/views/backend/game/config/popupForm.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<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('game.config.config_key')"
|
||||
type="string"
|
||||
v-model="baTable.form.items!.config_key"
|
||||
prop="config_key"
|
||||
:placeholder="t('Please input field', { field: t('game.config.config_key') })"
|
||||
:input-attr="{ disabled: baTable.form.operate === 'Edit' }"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('game.config.config_value')"
|
||||
type="textarea"
|
||||
v-model="baTable.form.items!.config_value"
|
||||
prop="config_value"
|
||||
:input-attr="{ rows: 5 }"
|
||||
:placeholder="t('Please input field', { field: t('game.config.config_value') })"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('game.config.value_type')"
|
||||
type="radio"
|
||||
v-model="baTable.form.items!.value_type"
|
||||
prop="value_type"
|
||||
:input-attr="{
|
||||
content: {
|
||||
string: t('game.config.value_type string'),
|
||||
int: t('game.config.value_type int'),
|
||||
decimal: t('game.config.value_type decimal'),
|
||||
json: t('game.config.value_type json'),
|
||||
},
|
||||
}"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('game.config.remark')"
|
||||
type="textarea"
|
||||
v-model="baTable.form.items!.remark"
|
||||
prop="remark"
|
||||
:input-attr="{ rows: 2 }"
|
||||
/>
|
||||
</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'
|
||||
|
||||
const config = useConfig()
|
||||
const formRef = useTemplateRef('formRef')
|
||||
const baTable = inject('baTable') as baTableClass
|
||||
const { t } = useI18n()
|
||||
|
||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||
config_key: [buildRequired('game.config.config_key')],
|
||||
value_type: [buildRequired('game.config.value_type')],
|
||||
})
|
||||
|
||||
function buildRequired(langKey: string): FormItemRule {
|
||||
return {
|
||||
required: true,
|
||||
message: t('Please input field', { field: t(langKey) }),
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
Reference in New Issue
Block a user