|
@@ -4,7 +4,7 @@ import Table from '@/components/Table.vue'
|
|
|
import Dialog from '@/components/common/Dialog.vue'
|
|
|
import type { ReqConfig } from '@/types/dataAnalysis'
|
|
|
import { type FormField, FormFieldType } from '@/types/form'
|
|
|
-import type { FormRules } from 'element-plus'
|
|
|
+import { ElMessageBox, type FormRules } from 'element-plus'
|
|
|
import type { FormConfig } from '@/types/form'
|
|
|
import {
|
|
|
type TablePaginationSetting,
|
|
@@ -15,9 +15,24 @@ import type { DialogConfig } from '@/types/dialog'
|
|
|
import { reactive, onMounted, ref } from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
import { useRequest } from '@/hooks/useRequest'
|
|
|
+import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
|
|
|
-const { AllApi } = useRequest()
|
|
|
+const { AllApi, analysisResCode } = useRequest()
|
|
|
|
|
|
+// 事件表单对象
|
|
|
+const eventFormRef = ref()
|
|
|
+
|
|
|
+// 参数表格ref对象
|
|
|
+const optionTableRef = ref()
|
|
|
+
|
|
|
+// 是否是新增触发
|
|
|
+const isAdd = ref(true)
|
|
|
+
|
|
|
+// 事件ID,这里的actionID,在获取事件详情的时候传入的字段是id字段,但是在获取
|
|
|
+// 参数列表的时候,传入的是actionid字段。。。。。。
|
|
|
+const actionId = ref()
|
|
|
+
|
|
|
+// 编辑状态
|
|
|
const eventEditState = ref(false)
|
|
|
|
|
|
// 属性对话框
|
|
@@ -25,15 +40,15 @@ const attrDialog = ref()
|
|
|
|
|
|
// 表单规则字段
|
|
|
const ruleForm = reactive({
|
|
|
- eventID: '',
|
|
|
- eventDisplayName: '',
|
|
|
- useageStatus: '',
|
|
|
- triggerTimingDesc: ''
|
|
|
+ actionId: '',
|
|
|
+ actionName: '',
|
|
|
+ status: 1,
|
|
|
+ remark: ''
|
|
|
})
|
|
|
|
|
|
// 表单规则
|
|
|
const rules = reactive<FormRules<typeof ruleForm>>({
|
|
|
- eventID: [
|
|
|
+ actionId: [
|
|
|
{ required: true, message: '事件ID是必填项', trigger: 'blur' },
|
|
|
{
|
|
|
min: 1,
|
|
@@ -42,8 +57,8 @@ const rules = reactive<FormRules<typeof ruleForm>>({
|
|
|
trigger: 'blur'
|
|
|
}
|
|
|
],
|
|
|
- eventDisplayName: [
|
|
|
- { required: true, message: '事件显示名是必填项', trigger: 'blur' },
|
|
|
+ actionName: [
|
|
|
+ { required: true, message: '事件名是必填项', trigger: 'blur' },
|
|
|
{
|
|
|
min: 5,
|
|
|
max: 10,
|
|
@@ -51,12 +66,12 @@ const rules = reactive<FormRules<typeof ruleForm>>({
|
|
|
trigger: 'blur'
|
|
|
}
|
|
|
],
|
|
|
- useageStatus: [{ required: true, message: '使用状态是必填项', trigger: 'change' }],
|
|
|
- triggerTimingDesc: [
|
|
|
+ status: [{ required: true, message: '使用状态是必填项', trigger: 'change' }],
|
|
|
+ remark: [
|
|
|
{
|
|
|
min: 1,
|
|
|
max: 255,
|
|
|
- message: '描述长度必须在1到255个字符之间',
|
|
|
+ message: '备注长度必须在1到255个字符之间',
|
|
|
trigger: 'blur'
|
|
|
}
|
|
|
]
|
|
@@ -65,17 +80,17 @@ const rules = reactive<FormRules<typeof ruleForm>>({
|
|
|
// 表单字段信息
|
|
|
const FormFields: Array<FormField> = [
|
|
|
{
|
|
|
- name: 'eventID',
|
|
|
+ name: 'actionId',
|
|
|
cnName: '事件ID',
|
|
|
type: FormFieldType.INPUT
|
|
|
},
|
|
|
{
|
|
|
- name: 'eventDisplayName',
|
|
|
- cnName: '事件显示',
|
|
|
+ name: 'actionName',
|
|
|
+ cnName: '事件名',
|
|
|
type: FormFieldType.INPUT
|
|
|
},
|
|
|
{
|
|
|
- name: 'useageStatus',
|
|
|
+ name: 'status',
|
|
|
cnName: '使用状态',
|
|
|
type: FormFieldType.SELECT,
|
|
|
otherOptions: {
|
|
@@ -83,30 +98,30 @@ const FormFields: Array<FormField> = [
|
|
|
options: [
|
|
|
{
|
|
|
name: 'disabled',
|
|
|
- label: '已禁用',
|
|
|
- value: false
|
|
|
+ label: '禁用',
|
|
|
+ value: 0
|
|
|
},
|
|
|
{
|
|
|
name: 'abled',
|
|
|
- label: '已启用',
|
|
|
- value: true
|
|
|
+ label: '启用',
|
|
|
+ value: 1
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
- name: 'triggerTimingDesc',
|
|
|
- cnName: '触发时机描述',
|
|
|
+ name: 'remark',
|
|
|
+ cnName: '备注',
|
|
|
type: FormFieldType.RICHTEXT,
|
|
|
otherOptions: {
|
|
|
- placeholder: '请输入描述'
|
|
|
+ placeholder: '请输入备注'
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
|
|
|
// 表单请求参数
|
|
|
const formReq = reactive<ReqConfig>({
|
|
|
- url: AllApi.mockEvent,
|
|
|
+ url: AllApi.updateGameAction,
|
|
|
otherOptions: {}
|
|
|
})
|
|
|
|
|
@@ -128,67 +143,122 @@ const pageConfig = reactive<TablePaginationSetting>({
|
|
|
// 表格字段信息
|
|
|
const tableFieldConfig = reactive<Array<TableFieldInfo>>([
|
|
|
{
|
|
|
- name: 'attrID',
|
|
|
- cnName: '参数ID',
|
|
|
- isShow: true
|
|
|
+ name: 'actionId',
|
|
|
+ cnName: '事件ID',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true
|
|
|
},
|
|
|
{
|
|
|
- name: 'useStatus',
|
|
|
- cnName: '使用状态',
|
|
|
+ name: 'createdAt',
|
|
|
+ cnName: '创建时间',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'id',
|
|
|
+ cnName: 'ID',
|
|
|
isShow: true,
|
|
|
+ needSort: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'optionId',
|
|
|
+ cnName: '选项ID',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'optionName',
|
|
|
+ cnName: '选项名称',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'optionType',
|
|
|
+ cnName: '选项类型',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true,
|
|
|
specialEffect: {
|
|
|
+ type: FieldSpecialEffectType.TRANSLATE,
|
|
|
othnerInfo: {
|
|
|
- text: ['已使用', '已弃用']
|
|
|
+ translateText: {
|
|
|
+ string: '字符串',
|
|
|
+ int: '数字',
|
|
|
+ array: '数组'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'status',
|
|
|
+ cnName: '使用状态状态',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true,
|
|
|
+ specialEffect: {
|
|
|
+ othnerInfo: {
|
|
|
+ text: ['启用', '禁用']
|
|
|
},
|
|
|
- type: FieldSpecialEffectType.DROPDOWN
|
|
|
+ type: FieldSpecialEffectType.STATE
|
|
|
}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'updatedAt',
|
|
|
+ cnName: '更新时间',
|
|
|
+ isShow: true,
|
|
|
+ needSort: true
|
|
|
}
|
|
|
])
|
|
|
|
|
|
// 表格请求配置
|
|
|
const tableReqConfig = reactive<ReqConfig>({
|
|
|
- url: AllApi.mockEvent,
|
|
|
- otherOptions: {
|
|
|
- eventID: ''
|
|
|
- }
|
|
|
+ url: AllApi.gameActionOptionList,
|
|
|
+ otherOptions: {}
|
|
|
})
|
|
|
|
|
|
// 对话框请求参数
|
|
|
const dialogReqConfig = reactive<ReqConfig>({
|
|
|
- url: AllApi.mockEvent,
|
|
|
- otherOptions: {}
|
|
|
+ url: AllApi.addGameActionOption,
|
|
|
+ otherOptions: {
|
|
|
+ formData: {}
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
// 对话框表单规则字段
|
|
|
const dilogRuleForm = reactive({
|
|
|
- attrID: '',
|
|
|
- useStatus: false
|
|
|
+ optionName: '',
|
|
|
+ optionId: '',
|
|
|
+ status: 1,
|
|
|
+ optionType: ''
|
|
|
})
|
|
|
|
|
|
// 表单规则
|
|
|
const dialogRules = reactive<FormRules<typeof dilogRuleForm>>({
|
|
|
- attrID: [
|
|
|
- { required: true, message: '属性ID是必填项', trigger: 'blur' },
|
|
|
+ optionName: [{ required: true, message: '选项名称是必填项', trigger: 'change', type: 'string' }],
|
|
|
+ optionId: [{ required: true, message: '选项ID是必填项', trigger: 'change', type: 'string' }],
|
|
|
+ status: [{ required: true, message: '选项状态是必填项', trigger: 'change', type: 'number' }],
|
|
|
+ optionType: [
|
|
|
{
|
|
|
- min: 1,
|
|
|
- max: 20,
|
|
|
- message: '属性ID长度必须在1到20个字符之间',
|
|
|
- trigger: 'blur'
|
|
|
+ required: true,
|
|
|
+ message: '选项类型是必填项',
|
|
|
+ trigger: 'change'
|
|
|
}
|
|
|
- ],
|
|
|
- useStatus: [{ required: true, message: '使用状态是必填项', trigger: 'change' }]
|
|
|
+ ]
|
|
|
})
|
|
|
|
|
|
// 表单字段信息
|
|
|
const dialogFormFields: Array<FormField> = [
|
|
|
{
|
|
|
- name: 'attrID',
|
|
|
- cnName: '属性ID',
|
|
|
+ name: 'optionName',
|
|
|
+ cnName: '选项名称',
|
|
|
type: FormFieldType.INPUT
|
|
|
},
|
|
|
{
|
|
|
- name: 'useStatus',
|
|
|
- cnName: '使用状态',
|
|
|
+ name: 'optionId',
|
|
|
+ cnName: '选项ID',
|
|
|
+ type: FormFieldType.INPUT
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'status',
|
|
|
+ cnName: '选项状态',
|
|
|
type: FormFieldType.SELECT,
|
|
|
otherOptions: {
|
|
|
placeholder: '请选择状态',
|
|
@@ -196,12 +266,37 @@ const dialogFormFields: Array<FormField> = [
|
|
|
{
|
|
|
name: 'disabled',
|
|
|
label: '已禁用',
|
|
|
- value: false
|
|
|
+ value: 0 // 对应int型状态
|
|
|
},
|
|
|
{
|
|
|
name: 'abled',
|
|
|
label: '已启用',
|
|
|
- value: true
|
|
|
+ value: 1 // 对应int型状态
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'optionType',
|
|
|
+ cnName: '选项类型',
|
|
|
+ type: FormFieldType.SELECT,
|
|
|
+ otherOptions: {
|
|
|
+ placeholder: '请选择类型',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ name: 'string',
|
|
|
+ label: '字符串',
|
|
|
+ value: 'string'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'int',
|
|
|
+ label: '整数',
|
|
|
+ value: 'int'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'array',
|
|
|
+ label: '数组',
|
|
|
+ value: 'array'
|
|
|
}
|
|
|
]
|
|
|
}
|
|
@@ -216,9 +311,35 @@ const dialogConfig = reactive<DialogConfig>({
|
|
|
fieldsInfo: dialogFormFields
|
|
|
})
|
|
|
|
|
|
+/**
|
|
|
+ * @description: 获取事件详情
|
|
|
+ * @param {*} id 这个id还是路由参数中query传过来的id
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const getEventInfo = (id: number) => {
|
|
|
+ axiosInstance
|
|
|
+ .post(AllApi.gameActionDetail, { id })
|
|
|
+ .then((data) => {
|
|
|
+ analysisResCode(data).then((info) => {
|
|
|
+ let result = info.data
|
|
|
+ let updateEventField = {
|
|
|
+ gid: '',
|
|
|
+ actionId: '',
|
|
|
+ actionName: '',
|
|
|
+ remark: '',
|
|
|
+ status: 1
|
|
|
+ }
|
|
|
+ eventFormRef.value.fillForm(Object.assign(updateEventField, { ...result }))
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
// 新增属性
|
|
|
const addNewAttr = () => {
|
|
|
- attrDialog.value.changeVisable()
|
|
|
+ attrDialog.value.addForm()
|
|
|
}
|
|
|
|
|
|
// 改变编辑状态
|
|
@@ -227,35 +348,91 @@ const changeEditState = (state: boolean) => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 取消编辑
|
|
|
+ * @description: 取消编辑,同时把数据恢复
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const cancelEdit = () => {
|
|
|
changeEditState(false)
|
|
|
+ eventFormRef.value.resumeFormData()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 保存编辑
|
|
|
+ * @description: 保存编辑,提交表单
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const saveEdit = () => {
|
|
|
changeEditState(false)
|
|
|
+ eventFormRef.value.submitFormData()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 开始编辑
|
|
|
+ * @description: 开始编辑,备份一份现有的表单数据
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const startEdit = () => {
|
|
|
changeEditState(true)
|
|
|
+ eventFormRef.value.backupFormData()
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+/**
|
|
|
+ * @description: 接受到表单提交事件后,需要去重新请求一下表格的数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const formSub = () => {
|
|
|
+ optionTableRef.value.getData()
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 修改选项
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const editOption = (row: any) => {
|
|
|
+ console.log(row)
|
|
|
+ attrDialog.value.editForm(row, AllApi.updateGameActionOption)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 删除选项
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const delOption = (row: any) => {
|
|
|
+ ElMessageBox.confirm('确认删除该配置吗', '警告', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ optionTableRef.value.deleteRow(AllApi.deleteGameActionOption, { id: row.id })
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 初始化一些参数
|
|
|
+ * 加载时如果有actionid,则代表是修改页面,需要去请求数据,没有则是新增页面
|
|
|
+ * 这里的actionid,是返回参数中id、actionID中的前者,在这个页面会被用于请求事件详情和相关的参数列表
|
|
|
+ * 在请求的时候,他们的名字不同,但传入的都是这个id
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const initParams = () => {
|
|
|
const routes = useRoute()
|
|
|
- let query = routes.query
|
|
|
+ let query_actionId = routes.query.id as string
|
|
|
+ if (query_actionId) {
|
|
|
+ isAdd.value = false
|
|
|
+ actionId.value = parseInt(query_actionId)
|
|
|
+ getEventInfo(parseInt(actionId.value))
|
|
|
+ tableReqConfig.otherOptions.actionId = actionId.value
|
|
|
+ dialogReqConfig.otherOptions.formData.actionId = actionId.value
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- console.log(query)
|
|
|
-})
|
|
|
+initParams()
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description:
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+onMounted(() => {})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -275,7 +452,12 @@ onMounted(() => {
|
|
|
</div>
|
|
|
<div class="eventForm">
|
|
|
<div class="formBox">
|
|
|
- <Form :inline="true" :config="formConfig"></Form>
|
|
|
+ <Form
|
|
|
+ :disabled="eventEditState"
|
|
|
+ ref="eventFormRef"
|
|
|
+ :inline="true"
|
|
|
+ :config="formConfig"
|
|
|
+ ></Form>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="attrList">
|
|
@@ -285,15 +467,40 @@ onMounted(() => {
|
|
|
<div class="list">
|
|
|
<Table
|
|
|
:need-left-tools="true"
|
|
|
+ :open-page-query="true"
|
|
|
:pagination-config="pageConfig"
|
|
|
:table-fields-info="tableFieldConfig"
|
|
|
:request-config="tableReqConfig"
|
|
|
@add-new-item="addNewAttr"
|
|
|
- ></Table>
|
|
|
+ ref="optionTableRef"
|
|
|
+ >
|
|
|
+ <template #tableOperation>
|
|
|
+ <el-table-column label="操作" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="editOption(scope.row)"
|
|
|
+ class="operationBtn"
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="danger"
|
|
|
+ @click="delOption(scope.row)"
|
|
|
+ class="operationBtn"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </Table>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="addAttrDialo">
|
|
|
- <Dialog ref="attrDialog" :config="dialogConfig"></Dialog>
|
|
|
+ <Dialog ref="attrDialog" :config="dialogConfig" @form-submit="formSub"></Dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|