|
@@ -1,30 +1,36 @@
|
|
|
<template>
|
|
|
<div class="app-container" ref="appContainer">
|
|
|
- <ServerPropTable :loading="loading" @selection-change="selectionChange" :columns="column" :data="list" @reset="reset"
|
|
|
+ <PropTable :loading="loading" @selection-change="selectionChange" :columns="column" :data="list" @reset="reset"
|
|
|
@onSubmit="onSubmit">
|
|
|
<template v-slot:btn>
|
|
|
<div style="display: flex; justify-content: flex-end">
|
|
|
- <el-button type="primary" @click="add"
|
|
|
- ><el-icon><plus /></el-icon> 添加</el-button>
|
|
|
+ <el-button type="primary" @click="add"><el-icon>
|
|
|
+ <plus />
|
|
|
+ </el-icon> 添加</el-button>
|
|
|
<el-button type="danger" @click="batchDelete"><el-icon>
|
|
|
<delete />
|
|
|
</el-icon>删除</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
+ <template v-slot:validTime="scope">{{ dateUtils.getDate(scope.row.validTime) }}</template>
|
|
|
+ <template v-slot:invalidTime="scope">{{ dateUtils.getDate(scope.row.invalidTime) }}</template>
|
|
|
+ <template v-slot:state="scope">{{ getStateLabel(scope.row) }}</template>
|
|
|
+ <template v-slot:createTime="scope">{{ dateUtils.getDate(scope.row.createTime) }}</template>
|
|
|
+ <template v-slot:items="scope">{{ getItemsLabel(scope.row.items) }}</template>
|
|
|
<template v-slot:operation="scope">
|
|
|
- <el-button type="primary" size="small" icon="Edit" @click="edit(scope.row)">
|
|
|
- 编辑
|
|
|
+ <el-button type="primary" size="small" icon="More" @click="more(scope.row)">
|
|
|
+ 详情
|
|
|
</el-button>
|
|
|
<el-button @click="del(scope.row)" type="danger" size="small" icon="Delete">
|
|
|
删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
- </ServerPropTable>
|
|
|
+ </PropTable>
|
|
|
|
|
|
<el-dialog v-model="dialogVisible" :title='title' width="50%">
|
|
|
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm"
|
|
|
:size="formSize">
|
|
|
- <el-form-item label="ID" prop="id">
|
|
|
+ <el-form-item label="ID" prop="id" v-show="isIdShow">
|
|
|
<el-input readonly v-model="ruleForm.id" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="收件人服务器ID" prop="toServerIds">
|
|
@@ -46,12 +52,8 @@
|
|
|
<el-form-item label="收件人角色创建">
|
|
|
<el-col :span="11">
|
|
|
<el-form-item prop="roleCreateTimeStart">
|
|
|
- <el-date-picker
|
|
|
- v-model="ruleForm.roleCreateTimeStart"
|
|
|
- type="datetime"
|
|
|
- placeholder="选择起始时间"
|
|
|
- style="width: 100%"
|
|
|
- />
|
|
|
+ <el-date-picker v-model="ruleForm.roleCreateTimeStart" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="选择起始时间" style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col class="text-center" :span="2" style="text-align: center">
|
|
@@ -59,7 +61,8 @@
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item prop="roleCreateTimeEnd">
|
|
|
- <el-date-picker v-model="ruleForm.roleCreateTimeEnd" type="datetime" placeholder="选择截止时间" style="width: 100%" />
|
|
|
+ <el-date-picker v-model="ruleForm.roleCreateTimeEnd" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="选择截止时间" style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
@@ -69,18 +72,14 @@
|
|
|
<el-form-item label="发送者名称" prop="sendName">
|
|
|
<el-input v-model="ruleForm.sendName" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="邮件道具" prop="itemInfo">
|
|
|
- <el-input v-model="ruleForm.itemInfo" />
|
|
|
+ <el-form-item label="邮件道具" prop="items">
|
|
|
+ <el-input v-model="ruleForm.items" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="邮件生效时间" required>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item prop="validTime">
|
|
|
- <el-date-picker
|
|
|
- v-model="ruleForm.validTime"
|
|
|
- type="datetime"
|
|
|
- placeholder="选择开始时间"
|
|
|
- style="width: 100%"
|
|
|
- />
|
|
|
+ <el-date-picker v-model="ruleForm.validTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="选择起始时间" style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col class="text-center" :span="2" style="text-align: center">
|
|
@@ -88,7 +87,8 @@
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-form-item prop="invalidTime">
|
|
|
- <el-date-picker v-model="ruleForm.invalidTime" type="datetime" placeholder="选择结束时间" style="width: 100%" />
|
|
|
+ <el-date-picker v-model="ruleForm.invalidTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ placeholder="选择截止时间" style="width: 100%" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
@@ -106,28 +106,15 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup name="comprehensive">
|
|
|
-import { ref, reactive, onMounted, nextTick, onBeforeMount} from 'vue'
|
|
|
+import { ref, reactive, onMounted, nextTick, onBeforeMount } from 'vue'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
import gmMailApi from '@/api/gmMail'
|
|
|
+import dateUtils from '@/common/dateUtils'
|
|
|
|
|
|
const loading = ref(true)
|
|
|
const appContainer = ref(null)
|
|
|
-import ServerPropTable from '@/components/Table/ServerPropTable/index.vue'
|
|
|
-import { el } from 'element-plus/es/locale'
|
|
|
-// const data = []
|
|
|
-// for (let i = 0; i < 100; i++) {
|
|
|
-// data.push({
|
|
|
-// id: i + 1,
|
|
|
-// title: 'GM邮件' + (i+1),
|
|
|
-// validTime: '2023-08-21 10:00:00',
|
|
|
-// invalidTime: '2023-09-21 10:00:00',
|
|
|
-// itemInfo: '1002-100,1001-200',
|
|
|
-// sendName: '深渊联盟',
|
|
|
-// toServerIds: '1,2,3,4,5',
|
|
|
-// toPlayerIds: '10000001, 10000001',
|
|
|
-// })
|
|
|
-// }
|
|
|
+import PropTable from '@/components/Table/PropTable/index.vue'
|
|
|
|
|
|
const data = ref([])
|
|
|
let currPageNum = 1;
|
|
@@ -147,86 +134,68 @@ const loadGmMailInfo = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
const column = [
|
|
|
{ type: 'selection', width: 60, fixed: 'left' },
|
|
|
{ name: 'id', label: 'ID', width: 80 },
|
|
|
{ name: 'title', label: '邮件标题', inSearch: true, valueType: 'input' },
|
|
|
- { name: 'validTime', label: '邮件生效时间'},
|
|
|
- { name: 'invalidTime', label: '邮件失效时间'},
|
|
|
- { name: 'itemInfo', label: '邮件道具'},
|
|
|
- { name: 'sendName', label: '发送者名称'},
|
|
|
- { name: 'toServerIds', label: '收件人服务器ID'},
|
|
|
- { name: 'toPlayerIds', label: '收件人玩家ID'},
|
|
|
+ { name: 'validTime', label: '邮件生效时间', slot: true, valueType: 'datetime' },
|
|
|
+ { name: 'invalidTime', label: '邮件失效时间', slot: true, valueType: 'datetime' },
|
|
|
+ { name: 'state', label: '邮件状态', slot: true },
|
|
|
+ { name: 'items', label: '邮件道具', slot: true },
|
|
|
+ { name: 'createTime', label: '邮件创建时间', slot: true },
|
|
|
{ name: 'operation', slot: true, fixed: 'right', width: 200, label: '操作' },
|
|
|
]
|
|
|
|
|
|
+const getStateLabel = (val) => {
|
|
|
+ // 取得当前时间,单位:秒
|
|
|
+ const timestamp: number = Date.parse(new Date().toString());
|
|
|
+ if (timestamp < val.validTime) {
|
|
|
+ return '未发送'
|
|
|
+ } else if (timestamp >= val.validTime && timestamp <= val.invalidTime) {
|
|
|
+ return '发送中'
|
|
|
+ } else {
|
|
|
+ return '已送达'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getItemsLabel = (val) => {
|
|
|
+ console.log("val:", val)
|
|
|
+ if (val != null) {
|
|
|
+ let label = ""
|
|
|
+ val.forEach((v, i) => {
|
|
|
+ label += v["itId"] + '-' + v["itCnt"]
|
|
|
+ if (i < val.length - 1) {
|
|
|
+ label += ","
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const list = ref(data)
|
|
|
|
|
|
const formSize = ref('default')
|
|
|
const ruleFormRef = ref<FormInstance>()
|
|
|
+
|
|
|
const ruleForm = reactive({
|
|
|
- id: null,
|
|
|
- title: null,
|
|
|
- validTime: null,
|
|
|
- invalidTime: null,
|
|
|
- itemInfo: null,
|
|
|
- sendName: '深渊联盟',
|
|
|
- toServerIds: null,
|
|
|
- toPlayerIds: null,
|
|
|
- levelCondition: null,
|
|
|
- itemCondition: null,
|
|
|
- heroCondition: null,
|
|
|
- roleCreateTimeStart: null,
|
|
|
- roleCreateTimeEnd: null,
|
|
|
- content: null,
|
|
|
+ id: null,
|
|
|
+ title: null,
|
|
|
+ validTime: null,
|
|
|
+ invalidTime: null,
|
|
|
+ items: null,
|
|
|
+ sendName: '深渊联盟',
|
|
|
+ toServerIds: null,
|
|
|
+ toPlayerIds: null,
|
|
|
+ levelCondition: null,
|
|
|
+ itemCondition: null,
|
|
|
+ heroCondition: null,
|
|
|
+ roleCreateTimeStart: null,
|
|
|
+ roleCreateTimeEnd: null,
|
|
|
+ content: null,
|
|
|
+ createTime: null
|
|
|
})
|
|
|
|
|
|
const rules = reactive({
|
|
|
- toServerIds: [
|
|
|
- {
|
|
|
- message: '请输入收件人服务器ID',
|
|
|
- trigger: 'change',
|
|
|
- }
|
|
|
- ],
|
|
|
- toPlayerIds: [
|
|
|
- {
|
|
|
- message: '请输入收件人角色ID',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
- levelCondition: [
|
|
|
- {
|
|
|
- message: '请输入收件人等级条件',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
- itemCondition: [
|
|
|
- {
|
|
|
- message: '请输入收件人道具条件',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
- heroCondition: [
|
|
|
- {
|
|
|
- message: '请输入收件人英雄条件',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
- roleCreateTimeStart: [
|
|
|
- {
|
|
|
- type: 'date',
|
|
|
- message: '请输入收件人角色创建起始时间',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
- roleCreateTimeEnd: [
|
|
|
- {
|
|
|
- type: 'date',
|
|
|
- message: '请输入收件人角色创建截至时间',
|
|
|
- trigger: 'change',
|
|
|
- },
|
|
|
- ],
|
|
|
title: [
|
|
|
{
|
|
|
required: true,
|
|
@@ -241,14 +210,14 @@ const rules = reactive({
|
|
|
trigger: 'change',
|
|
|
},
|
|
|
],
|
|
|
- itemInfo: [
|
|
|
+ items: [
|
|
|
{
|
|
|
required: true,
|
|
|
message: '请输入邮件道具',
|
|
|
trigger: 'change',
|
|
|
},
|
|
|
],
|
|
|
- validTime : [
|
|
|
+ validTime: [
|
|
|
{
|
|
|
required: true,
|
|
|
type: 'date',
|
|
@@ -277,67 +246,61 @@ const rules = reactive({
|
|
|
const dialogVisible = ref(false)
|
|
|
const rowObj = ref({})
|
|
|
const selectObj = ref([])
|
|
|
-const title = ref('编辑')
|
|
|
+const title = ref('详情')
|
|
|
+const isIdShow = ref(true)
|
|
|
|
|
|
const add = () => {
|
|
|
title.value = '新增'
|
|
|
+ isIdShow.value = false
|
|
|
dialogVisible.value = true
|
|
|
+ ruleForm.id = null
|
|
|
+ ruleForm.toServerIds = null
|
|
|
+ ruleForm.toPlayerIds = null
|
|
|
+ ruleForm.levelCondition = null
|
|
|
+ ruleForm.itemCondition = null
|
|
|
+ ruleForm.heroCondition = null
|
|
|
+ ruleForm.roleCreateTimeStart = null
|
|
|
+ ruleForm.roleCreateTimeEnd = null
|
|
|
+ ruleForm.title = null
|
|
|
+ ruleForm.sendName = '深渊联盟'
|
|
|
+ ruleForm.items = null
|
|
|
+ ruleForm.validTime = null
|
|
|
+ ruleForm.invalidTime = null
|
|
|
+ ruleForm.content = null
|
|
|
}
|
|
|
|
|
|
const handleClose = async (done: () => void) => {
|
|
|
await ruleFormRef.value.validate((valid, fields) => {
|
|
|
if (valid) {
|
|
|
- // list.value.forEach((item) => {
|
|
|
- if (title.value == '新增') {
|
|
|
- // let addParams = reactive({
|
|
|
- // pageNum: currPageNum,
|
|
|
- // pageSize: pageSize,
|
|
|
- // updateValue: ruleForm
|
|
|
- // })
|
|
|
- gmMailApi.send(ruleForm).then(res => {
|
|
|
- if (res.data.code = 200) {
|
|
|
- // item.state = ruleForm.state
|
|
|
- loadGmMailInfo()
|
|
|
- return ElMessage.success('新增成功')
|
|
|
- } else {
|
|
|
- return ElMessage.error('新增失败')
|
|
|
- }
|
|
|
- })
|
|
|
- console.log('add submit!')
|
|
|
- } else{
|
|
|
- // if (item.id === rowObj.value.id) {
|
|
|
- // item.toServerIds = ruleForm.toServerIds
|
|
|
- // item.toPlayerIds = ruleForm.toPlayerIds
|
|
|
- // item.levelCondition = ruleForm.levelCondition
|
|
|
- // item.itemCondition = ruleForm.itemCondition
|
|
|
- // item.heroCondition = ruleForm.heroCondition
|
|
|
- // item.roleCreateTimeStart = ruleForm.roleCreateTimeStart
|
|
|
- // item.roleCreateTimeEnd = ruleForm.roleCreateTimeEnd
|
|
|
- // item.title = ruleForm.title
|
|
|
- // item.sendName = ruleForm.sendName
|
|
|
- // item.itemInfo = ruleForm.itemInfo
|
|
|
- // item.validTime = ruleForm.validTime
|
|
|
- // item.invalidTime = ruleForm.invalidTime
|
|
|
- // item.content = ruleForm.content
|
|
|
- let updateParams = reactive({
|
|
|
- id: rowObj.value.id,
|
|
|
- updateValue: ruleForm
|
|
|
- })
|
|
|
- gmMailApi.update(updateParams).then(res => {
|
|
|
- if (res.data.code = 200) {
|
|
|
- // item.state = ruleForm.state
|
|
|
- loadGmMailInfo()
|
|
|
- return ElMessage.success('修改成功')
|
|
|
- } else {
|
|
|
- return ElMessage.error('修改失败')
|
|
|
- }
|
|
|
- })
|
|
|
- console.log('update submit!')
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
- // })
|
|
|
- dialogVisible.value = false
|
|
|
+ if (title.value == '新增') {
|
|
|
+ gmMailApi.send(ruleForm).then(res => {
|
|
|
+ console.log('result', res)
|
|
|
+ if (res.data.code = 200) {
|
|
|
+ loadGmMailInfo()
|
|
|
+ dialogVisible.value = false
|
|
|
+ return ElMessage.success(res.data.msg)
|
|
|
+ } else {
|
|
|
+ return ElMessage.error(res.data.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('add submit!')
|
|
|
+ } else {
|
|
|
+ // let updateParams = reactive({
|
|
|
+ // id: rowObj.value.id,
|
|
|
+ // updateValue: ruleForm
|
|
|
+ // })
|
|
|
+ // gmMailApi.update(updateParams).then(res => {
|
|
|
+ // if (res.data.code = 200) {
|
|
|
+ // // item.state = ruleForm.state
|
|
|
+ // loadGmMailInfo()
|
|
|
+ // dialogVisible.value = false
|
|
|
+ // return ElMessage.success('修改成功')
|
|
|
+ // } else {
|
|
|
+ // return ElMessage.error('修改失败')
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // console.log('update submit!')
|
|
|
+ }
|
|
|
console.log('submit!', ruleForm)
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
@@ -358,7 +321,7 @@ const batchDelete = () => {
|
|
|
.then(() => {
|
|
|
let selectGmMaliIds = reactive([])
|
|
|
for (let value of selectObj.value) {
|
|
|
- selectGmMaliIds.push(value._id)
|
|
|
+ selectGmMaliIds.push(value.id)
|
|
|
}
|
|
|
let deleteParams = reactive({
|
|
|
gmMaliIds: selectGmMaliIds
|
|
@@ -378,8 +341,11 @@ const selectionChange = (val) => {
|
|
|
selectObj.value = val
|
|
|
}
|
|
|
|
|
|
-const edit = (row) => {
|
|
|
+const more = (row) => {
|
|
|
+ title.value = '详情'
|
|
|
+ isIdShow.value = true
|
|
|
rowObj.value = row
|
|
|
+ console.log(row)
|
|
|
dialogVisible.value = true
|
|
|
ruleForm.id = row.id
|
|
|
ruleForm.toServerIds = row.toServerIds
|
|
@@ -387,14 +353,15 @@ const edit = (row) => {
|
|
|
ruleForm.levelCondition = row.levelCondition
|
|
|
ruleForm.itemCondition = row.itemCondition
|
|
|
ruleForm.heroCondition = row.heroCondition
|
|
|
- ruleForm.roleCreateTimeStart = row.roleCreateTimeStart
|
|
|
- ruleForm.roleCreateTimeEnd = row.roleCreateTimeEnd
|
|
|
+ ruleForm.roleCreateTimeStart = dateUtils.getDate(row.roleCreateTimeStart)
|
|
|
+ ruleForm.roleCreateTimeEnd = dateUtils.getDate(row.roleCreateTimeEnd)
|
|
|
ruleForm.title = row.title
|
|
|
ruleForm.sendName = row.sendName
|
|
|
- ruleForm.itemInfo = row.itemInfo
|
|
|
- ruleForm.validTime = row.validTime
|
|
|
- ruleForm.invalidTime = row.invalidTime
|
|
|
+ ruleForm.items = getItemsLabel(row.items)
|
|
|
+ ruleForm.validTime = dateUtils.getDate(row.validTime)
|
|
|
+ ruleForm.invalidTime = dateUtils.getDate(row.invalidTime)
|
|
|
ruleForm.content = row.content
|
|
|
+ console.log(ruleForm)
|
|
|
}
|
|
|
|
|
|
const del = (row) => {
|
|
@@ -405,10 +372,9 @@ const del = (row) => {
|
|
|
type: 'warning',
|
|
|
draggable: true,
|
|
|
})
|
|
|
- .then(() => {
|
|
|
- // list.value = list.value.filter((item) => item._id !== row._id)
|
|
|
+ .then(() => {
|
|
|
let deleteParams = reactive({
|
|
|
- id: row._id
|
|
|
+ id: row.id
|
|
|
})
|
|
|
gmMailApi.delete(deleteParams).then(res => {
|
|
|
loadGmMailInfo()
|
|
@@ -423,6 +389,7 @@ const del = (row) => {
|
|
|
}
|
|
|
|
|
|
const reset = () => {
|
|
|
+ loadGmMailInfo()
|
|
|
loading.value = true
|
|
|
setTimeout(() => {
|
|
|
loading.value = false
|
|
@@ -431,17 +398,15 @@ const reset = () => {
|
|
|
}
|
|
|
|
|
|
const onSubmit = (val) => {
|
|
|
- if ( val.title == null || val.title == "") {
|
|
|
+ if (val.title == null || val.title == "") {
|
|
|
ElMessage.warning('请输入查询条件')
|
|
|
return
|
|
|
}
|
|
|
let queryParams = reactive({
|
|
|
pageNum: 1,
|
|
|
- pageSize: pageSize
|
|
|
+ pageSize: pageSize,
|
|
|
+ condition: val
|
|
|
})
|
|
|
- if (val.title != null) {
|
|
|
- queryParams.title = val.title
|
|
|
- }
|
|
|
gmMailApi.query(queryParams).then(res => {
|
|
|
data.value = res.data.result;
|
|
|
console.log(data.value)
|
|
@@ -452,15 +417,6 @@ const onSubmit = (val) => {
|
|
|
}, 500)
|
|
|
}
|
|
|
|
|
|
-// const onUpdate = (val) => {
|
|
|
-// console.log('val===', val)
|
|
|
-// ElMessage.success('触发修改方法')
|
|
|
-// loading.value = true
|
|
|
-// setTimeout(() => {
|
|
|
-// loading.value = false
|
|
|
-// }, 500)
|
|
|
-// }
|
|
|
-
|
|
|
const getHeight = () => {
|
|
|
|
|
|
}
|