Jelajahi Sumber

活动后台开发

Administrator 8 bulan lalu
induk
melakukan
a8fcbcfe68

+ 7 - 0
src/api/activityTemplate.ts

@@ -3,6 +3,13 @@ import request from './request'
 
 export default {
 
+    all() {
+        return request({
+            url: '/activity/template/all',
+            method: 'get'
+        });
+    },
+
     add(data) {
         return request({
             url: '/activity/template/add',

+ 113 - 68
src/views/activity/rule/index.vue

@@ -16,6 +16,7 @@
         </div>
       </template>
       <template v-slot:type="scope">{{ getTypeLabel(scope.row.type) }}</template>
+      <template v-slot:actTemId="scope">{{ getActTemIdLabel(scope.row.actTemId) }}</template>
       <template v-slot:isOpen="scope">{{ getIsOpenLabel(scope.row.isOpen) }}</template>
       <template v-slot:tipsTime="scope">{{ dateUtils.getDate(scope.row.tipsTime) }}</template>
       <template v-slot:startTime="scope">{{ dateUtils.getDate(scope.row.startTime) }}</template>
@@ -39,21 +40,31 @@
           <el-input readonly v-model="ruleForm.id" />
         </el-form-item>
         <el-form-item label="活动类型" prop="type">
-          <el-radio-group v-model="ruleForm.type">
+          <el-radio-group v-model="ruleForm.type" :change="onTypeChange(ruleForm.type)">
             <el-radio :label="0">限时活动</el-radio>
             <el-radio :label="1">循环活动</el-radio>
             <el-radio :label="2">开服活动</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="活动模版" prop="actTem">
+        <el-form-item label="活动模版" prop="actTemId">
+        <el-select v-model="ruleForm.actTemId" placeholder="请选择活动模版" style="width: 300px">
+          <el-option
+            v-for="item in templateData"
+            :key="item.id"
+            :label="item.id + '-' + item.name"
+            :value="item.id"
+          />
+        </el-select>
+       </el-form-item>
+        <!--<el-form-item label="活动模版" prop="actTem">
           <el-radio-group v-model="ruleForm.actTem">
             <el-radio :label="0">1-模版一</el-radio>
             <el-radio :label="1">2-模版二</el-radio>
             <el-radio :label="2">3-模版三</el-radio>
           </el-radio-group>
-        </el-form-item>
+        </el-form-item> -->
         <el-form-item label="生效服务器" prop="gameIds">
-          <el-input v-model="ruleForm.gameIds" placeholder="默认不填为全服,支持数组,格式:1,2,3..."/>
+          <el-input v-model="ruleForm.gameIds" placeholder="0代表全服,支持数组,格式:1,2,3..."/>
         </el-form-item>
         <el-form-item label="排除服务器" prop="noGameIds">
           <el-input v-model="ruleForm.noGameIds" placeholder="支持数组,格式:1,2,3..."/>
@@ -81,7 +92,7 @@
             </el-form-item>
           </el-col>
         </el-form-item>
-        <el-form-item label="活动生效时间">
+        <el-form-item label="活动生效时间" required>
           <el-col :span="11">
             <el-form-item prop="startTime">
               <el-date-picker v-model="ruleForm.startTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
@@ -98,10 +109,10 @@
             </el-form-item>
           </el-col>
         </el-form-item>
-        <el-form-item label="循环模版列表" prop="lpActTemList">
+        <el-form-item label="循环模版列表" prop="lpActTemList" v-show="isLoopShow">
           <el-input v-model="ruleForm.lpActTemList" placeholder="循环活动列表,和循环间隔天数长度一致,格式:1,2..." />
         </el-form-item>
-        <el-form-item label="循环间隔天数" prop="lpActInterval">
+        <el-form-item label="循环间隔天数" prop="lpActInterval" v-show="isLoopShow">
           <el-input v-model="ruleForm.lpActInterval" placeholder="循环间隔天数,和循环模版列表长度一致,格式:7,7..." />
         </el-form-item>
       </el-form>
@@ -142,6 +153,7 @@ import { ref, reactive, onMounted, nextTick, onBeforeMount } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import type { FormInstance } from 'element-plus'
 import activityRuleApi from '@/api/activityRule'
+import activityTemplateApi from '@/api/activityTemplate'
 import dateUtils from '@/common/dateUtils'
 
 const loading = ref(true)
@@ -153,12 +165,13 @@ import PropTable from '@/components/Table/PropTable/index.vue'
 import ExcelJS from 'exceljs'
 import { UploadFilled } from '@element-plus/icons-vue'
 import type { UploadProps, UploadInstance } from 'element-plus'
+import { el } from 'element-plus/es/locale'
 // import { ElMessage } from 'element-plus'
 const tableData = ref([])
 const tableHeader = ref([])
 const upload = ref<UploadInstance>()
 
-const tableColumn = ["type","actTem","gameIds","noGameIds","isOpen",
+const tableColumn = ["type","actTemId","gameIds","noGameIds","isOpen",
   "tipsTime","startTime","endTime","stayTime","lpActTemList","lpActInterval"]
 const beforeUploadAction = (file, fileLi) => {
   return new Promise((resolve, reject) => {
@@ -222,11 +235,29 @@ const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
 }
 
 const data = ref([])
+const templateData = ref([])
+const templateOptionData = ref([{
+  "value":"number",
+  "label":"string"
+}])
 let currPageNum = 1;
 const pageSize = 1000;
 onBeforeMount(() => {
+  loadActivityTemplateInfo()
   loadActivityRuleInfo()
-})
+}) 
+
+const loadActivityTemplateInfo = () => {
+  activityTemplateApi.all().then(res => {
+    templateData.value = res.data.result;
+    for (var i=0; i < templateData.value.length; i++) {
+      templateOptionData.value[i].value = templateData.value[i].id;
+      templateOptionData.value[i].label = templateData.value[i].id +"-"+templateData.value[i].name;
+    }
+    console.log(templateData)
+    console.log(templateOptionData)
+  })
+}
 
 const loadActivityRuleInfo = () => {
   let queryParams = reactive({
@@ -242,8 +273,23 @@ const loadActivityRuleInfo = () => {
 const column = [
   { type: 'selection', width: 60, fixed: 'left' },
   { name: 'id', label: 'ID', width: 80 },
-  { name: 'type', label: '活动类型', slot: true, inSearch: true, valueType: 'input' },
-  { name: 'actTem', label: '活动模版', inSearch: true, valueType: 'input' },
+  { name: 'type', label: '活动类型', slot: true, inSearch: true,   
+    options: [
+      {
+        value: 0,
+        label: '限时活动',
+      },
+      {
+        value: 1,
+        label: '循环活动',
+      },
+      {
+        value: 2,
+        label: '开服活动',
+      }
+    ],
+    valueType: 'select', },
+  { name: 'actTemId', label: '活动模版',slot: true, inSearch: true, options:templateOptionData, valueType: 'select' },
   { name: 'gameIds', label: '生效服务器', inSearch: true, valueType: 'input' },
   { name: 'noGameIds', label: '排除服务器'},
   { name: 'isOpen', label: '是否开启', slot: true},
@@ -251,8 +297,8 @@ const column = [
   { name: 'startTime', label: '开始时间', slot: true, valueType: 'datetime' },
   { name: 'endTime', label: '结束时间', slot: true, valueType: 'datetime' },
   { name: 'stayTime', label: '停留时间', slot: true, valueType: 'datetime' },
-  { name: 'lpActTemList', label: '循环模版列表', slot: true },
-  { name: 'lpActInterval', label: '循环间隔天数', slot: true },
+  { name: 'lpActTemList', label: '循环模版列表' },
+  { name: 'lpActInterval', label: '循环间隔天数' },
   { name: 'state', label: '活动状态', slot: true },
   { name: 'operation', slot: true, fixed: 'right', width: 200, label: '操作' },
 ]
@@ -267,6 +313,15 @@ const getTypeLabel = (val) => {
   }
 }
 
+const getActTemIdLabel = (val) => {
+  for (var i=0; i < templateData.value.length; i++) {
+    if (templateData.value[i].id == val) {
+      return templateData.value[i].id + "-" + templateData.value[i].name
+    }
+  }
+  return val
+}
+
 const getIsOpenLabel = (val) => {
   if (val == 0) {
     return '否'
@@ -291,17 +346,11 @@ const getStateLabel = (val) => {
   }
 }
 
-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 onTypeChange = (val) => {
+  if (val == 1) {
+    isLoopShow.value = true
+  } else {
+    isLoopShow.value = false
   }
 }
 
@@ -313,7 +362,7 @@ const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
   id: null,
   type: 0,
-  actTem: 0,
+  actTemId: null,
   gameIds: null,
   noGameIds: null,
   isOpen: 0,
@@ -326,6 +375,13 @@ const ruleForm = reactive({
 })
 
 const rules = reactive({
+  actTemId: [
+    {
+      required: true,
+      message: '请选择活动类型',
+      trigger: 'change',
+    },
+  ],
   startTime: [
     {
       required: true,
@@ -341,6 +397,20 @@ const rules = reactive({
       message: '请选择活动结束时间',
       trigger: 'change',
     },
+  ],
+  lpActTemList: [
+    {
+      required: true,
+      message: '请输入循环模版列表',
+      trigger: 'change',
+    },
+  ],
+  lpActInterval: [
+    {
+      required: true,
+      message: '请输入循环间隔天数',
+      trigger: 'change',
+    },
   ]
 })
 
@@ -374,7 +444,7 @@ const add = () => {
   dialogVisible.value = true
   ruleForm.id = null
   ruleForm.type = 0
-  ruleForm.actTem = 0
+  ruleForm.actTemId = null
   ruleForm.gameIds = null
   ruleForm.noGameIds = null
   ruleForm.isOpen = 0
@@ -386,31 +456,6 @@ const add = () => {
   ruleForm.lpActInterval = null
 }
 
-const valid7Day = () => {
-  let now = new Date();
-  ruleForm.validTime = dateUtils.getDate(now);
-  let invalidDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 7, 
-    now.getHours(), now.getMinutes(), now.getSeconds())
-  ruleForm.invalidTime = dateUtils.getDate(invalidDate)
-}
-
-
-const valid15Day = () => {
-  let now = new Date();
-  ruleForm.validTime = dateUtils.getDate(now);
-  let invalidDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 15, 
-    now.getHours(), now.getMinutes(), now.getSeconds())
-  ruleForm.invalidTime = dateUtils.getDate(invalidDate)
-}
-
-const valid30Day = () => {
-  let now = new Date();
-  ruleForm.validTime = dateUtils.getDate(now);
-  let invalidDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 30, 
-    now.getHours(), now.getMinutes(), now.getSeconds())
-  ruleForm.invalidTime = dateUtils.getDate(invalidDate)
-}
-
 const handleConfirm = () => {
   // 验证table数据
   let isValid = true
@@ -466,17 +511,17 @@ const handleClose = async (done: () => void) => {
         //   id: rowObj.value.id,
         //   updateValue: ruleForm
         // })
-        // activityRuleApi.update(updateParams).then(res => {
-        //   if (res.data.code = 200) {
-        //     // item.state = ruleForm.state
-        //     loadactivityRuleInfo()
-        //     dialogVisible.value = false
-        //     return ElMessage.success('修改成功')
-        //   } else {
-        //     return ElMessage.error('修改失败')
-        //   }
-        // })
-        // console.log('update submit!')
+        activityRuleApi.update(ruleForm).then(res => {
+          if (res.data.code = 200) {
+            // item.state = ruleForm.state
+            loadActivityRuleInfo()
+            dialogVisible.value = false
+            return ElMessage.success('修改成功')
+          } else {
+            return ElMessage.error('修改失败')
+          }
+        })
+        console.log('update submit!')
       }
       console.log('submit!', ruleForm)
     } else {
@@ -525,16 +570,16 @@ const edit = (row) => {
   dialogVisible.value = true
   ruleForm.id = row.id
   ruleForm.type = row.type
-  ruleForm.actTem = row.actTem
-  ruleForm.gameIds = row.gameIds
-  ruleForm.noGameIds = row.noGameIds
+  ruleForm.actTemId = row.actTemId
+  ruleForm.gameIds = row.gameIds.toString()
+  ruleForm.noGameIds = row.noGameIds == null ? row.noGameIds : row.noGameIds.toString()
   ruleForm.isOpen = row.isOpen
   ruleForm.tipsTime = dateUtils.getDate(row.tipsTime)
   ruleForm.startTime = dateUtils.getDate(row.startTime)
   ruleForm.endTime = dateUtils.getDate(row.endTime)
   ruleForm.stayTime = dateUtils.getDate(row.stayTime)
-  ruleForm.lpActTemList = row.lpActTemList
-  ruleForm.lpActInterval = row.lpActInterval
+  ruleForm.lpActTemList = row.lpActTemList == null ? row.lpActTemList : row.lpActTemList.toString()
+  ruleForm.lpActInterval = row.lpActInterval == null ? row.lpActInterval : row.lpActInterval.toString()
   console.log(ruleForm)
 }
 
@@ -572,7 +617,7 @@ const reset = () => {
 }
 
 const onSubmit = (val) => {
-  if (val.title == null || val.title == "") {
+  if (val.type == null && val.actTemId == null && (val.gameIds == null || val.gameIds == "")) {
     ElMessage.warning('请输入查询条件')
     return
   }

+ 1 - 1
src/views/activity/template/index.vue

@@ -379,7 +379,7 @@ const edit = (row) => {
   ruleForm.reward = row.reward
   ruleForm.remark = row.remark
   ruleForm.keepDay = row.keepDay.toString()
-  ruleForm.stayDay = row.stayDay.toString()
+  ruleForm.stayDay = row.stayDay == null ? row.stayDay : row.stayDay.toString()
   ruleForm.isOpenSvr = row.isOpenSvr
 }
 

+ 9 - 3
src/views/operation/gmmail/index.vue

@@ -37,8 +37,8 @@
         <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">
-          <el-input v-model="ruleForm.toServerIds" placeholder="默认不填为全服,支持数组,格式:1,2,3..."/>
+        <el-form-item label="收件人服务器" prop="toServerIds">
+          <el-input v-model="ruleForm.toServerIds" placeholder="0代表全服,支持数组,格式:1,2,3..."/>
         </el-form-item>
         <el-form-item label="收件人角色ID" prop="toPlayerIds">
           <el-input v-model="ruleForm.toPlayerIds" placeholder="指定具体角色发送,支持数组,格式:10000001,10000002..." />
@@ -333,6 +333,13 @@ const ruleForm = reactive({
 })
 
 const rules = reactive({
+  toServerIds: [
+    {
+      required: true,
+      message: '请输入服务器ID',
+      trigger: 'change',
+    },
+  ],
   type: [
     {
       required: true,
@@ -569,7 +576,6 @@ const more = (row) => {
   ruleForm.id = row.id
   ruleForm.type = row.type
   ruleForm.toServerIds = row.toServerIds
-  ruleForm.toPlayerIds = row.toPlayerIds
   ruleForm.levelCondition = row.levelCondition
   ruleForm.itemCondition = getItemsLabel(row.itemCondition)
   ruleForm.heroCondition = row.heroCondition