Browse Source

礼包码、GM命令,客户端配置

Administrator 3 tháng trước cách đây
mục cha
commit
4c4e7109b3

+ 4 - 4
src/api/giftCode.ts

@@ -3,17 +3,17 @@ import request from './request'
 
 export default {
 
-    fixGenerate(data) {
+    fixedGenerate(data) {
         return request({
-            url: '/gift_code/fix_generate',
+            url: '/gift_code/fixed_generate',
             method: 'post',
             data
         });
     },
 
-    batchGenerate(data) {
+    randomGenerate(data) {
         return request({
-            url: '/gift_code/batch_generate',
+            url: '/gift_code/random_generate',
             method: 'post',
             data
         });

+ 14 - 0
src/api/gmCmd.ts

@@ -0,0 +1,14 @@
+import request from './request'
+
+
+export default {
+
+    send(data) {
+        return request({
+            url: '/gm_cmd/send',
+            method: 'post',
+            data
+        });
+    }
+
+}

+ 13 - 13
src/routers/modules/operation.ts

@@ -21,24 +21,24 @@ const operationRouter = [{
             alwaysShow:true,
             redirect: '/views/operation/giftcode/fixedGeneration',
             children: [
-                // {
-                //   path: '/views/operation/giftcode/fixedGeneration',
-                //   component: () => import('@/views/operation/giftcode/fixedGeneration/index.vue'),
-                //   name: 'fixedGeneration',
-                //   meta: { title: '固定生成'}
-                // },
                 {
-                    path: '/views/operation/giftcode/batchGeneration',
-                    component: () => import('@/views/operation/giftcode/batchGeneration/index.vue'),
-                    name: 'batchGeneration',
-                    meta: { title: '批量生成', icon: 'CirclePlus'}
-                  },
-                  {
+                    path: '/views/operation/giftcode/fixedGeneration',
+                    component: () => import('@/views/operation/giftcode/fixedGeneration/index.vue'),
+                    name: 'fixedGeneration',
+                    meta: { title: '固定生成', icon: 'CirclePlus'}
+                },
+                {
+                    path: '/views/operation/giftcode/randomGeneration',
+                    component: () => import('@/views/operation/giftcode/randomGeneration/index.vue'),
+                    name: 'randomGeneration',
+                    meta: { title: '随机生成', icon: 'CirclePlus'}
+                },
+                {
                     path: '/views/operation/giftcode/listTable',
                     component: () => import('@/views/operation/giftcode/listTable/index.vue'),
                     name: 'listTable',
                     meta: { title: '礼包码列表', icon: 'List'}
-                  },
+                },
             ]
         },
         {

+ 30 - 17
src/views/operation/clientConfig/index.vue

@@ -32,24 +32,30 @@
         <el-form-item label="资源地址" prop="assetsUrl">
           <el-input v-model="ruleForm.assetsUrl" />
         </el-form-item>
-        <el-form-item label="资源版本" prop="assetsVer">
+        <el-form-item label="资源版本" prop="assetsVer">
           <el-input v-model="ruleForm.assetsVer" />
         </el-form-item>
-        <el-form-item label="资源加载类型" prop="loadType">
-          <el-radio-group v-model="ruleForm.loadType">
-            <el-radio :label="0">远程加载</el-radio>
-            <el-radio :label="1">本地加载</el-radio>
-          </el-radio-group>
+        <el-form-item label="资源强更版本" prop="forceAssetsVer">
+          <el-input v-model="ruleForm.forceAssetsVer" />
         </el-form-item>
-        <el-form-item label="安装包版本" prop="apkVer">
+        <el-form-item label="安装包版本" prop="apkVer">
           <el-input v-model="ruleForm.apkVer" />
         </el-form-item>
-        <el-form-item label="打包版本号" prop="buildVer">
+        <el-form-item label="安装包子版本" prop="apkSubVer">
+          <el-input v-model="ruleForm.apkSubVer" />
+        </el-form-item>
+        <el-form-item label="打包版本" prop="buildVer">
           <el-input v-model="ruleForm.buildVer" />
         </el-form-item>
-        <el-form-item label="协议版本号" prop="protocolVer">
+        <el-form-item label="协议版本" prop="protocolVer">
           <el-input v-model="ruleForm.protocolVer" />
         </el-form-item>
+        <el-form-item label="资源加载类型" prop="loadType">
+          <el-radio-group v-model="ruleForm.loadType">
+            <el-radio :label="0">远程加载</el-radio>
+            <el-radio :label="1">本地加载</el-radio>
+          </el-radio-group>
+        </el-form-item>
       </el-form>
       <template #footer>
         <span class="dialog-footer">
@@ -65,11 +71,10 @@ import { ref, reactive, onMounted, nextTick, onBeforeMount } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import type { FormInstance } from 'element-plus'
 import clientConfigApi from '@/api/clientConfig'
-import dateUtils from '@/common/dateUtils'
+import PropTable from '@/components/Table/PropTable/index.vue'
 
 const loading = ref(true)
 const appContainer = ref(null)
-import PropTable from '@/components/Table/PropTable/index.vue'
 
 // import { ref } from 'vue'
 
@@ -165,11 +170,13 @@ const column = [
   { type: 'selection', width: 60, fixed: 'left' },
   { name: 'id', label: 'ID', width: 80, inSearch: true, valueType: 'input' },
   { name: 'assetsUrl', label: '资源地址' },
-  { name: 'assetsVer', label: '资源版本号' },
+  { name: 'assetsVer', label: '资源版本' },
+  { name: 'forceAssetsVer', label: '强更资源版本' },
+  { name: 'apkVer', label: '安装包版本' },
+  { name: 'apkSubVer', label: '安装包子版本' },
+  { name: 'buildVer', label: '打包版本' },
+  { name: 'protocolVer', label: '协议版本' },
   { name: 'loadType', label: '资源加载类型', slot: true},
-  { name: 'apkVer', label: '安装包版本号' },
-  { name: 'buildVer', label: '打包版本号' },
-  { name: 'protocolVer', label: '协议版本号' },
   { name: 'operation', slot: true, fixed: 'right', width: 200, label: '操作' },
 ]
 
@@ -190,7 +197,9 @@ const ruleForm = reactive({
     id: null,
     assetsUrl: null,
     assetsVer: null,
+    forceAssetsVer: null,
     apkVer: null,
+    apkSubVer: null,
     buildVer: null,
     protocolVer: null,
     loadType:0
@@ -233,10 +242,12 @@ const add = () => {
   ruleForm.id = null
   ruleForm.assetsUrl = null
   ruleForm.assetsVer = null
-  ruleForm.loadType = 0
+  ruleForm.forceAssetsVer = null
   ruleForm.apkVer = null
+  ruleForm.apkSubVer = null
   ruleForm.buildVer = null
   ruleForm.protocolVer = null
+  ruleForm.loadType = 0
 }
 
 const handleConfirm = () => {
@@ -336,10 +347,12 @@ const edit = (row) => {
   ruleForm.id = row.id
   ruleForm.assetsUrl = row.assetsUrl
   ruleForm.assetsVer = row.assetsVer == null ? row.assetsVer : row.assetsVer.toString()
-  ruleForm.loadType = row.loadType
+  ruleForm.forceAssetsVer = row.forceAssetsVer == null ? row.forceAssetsVer : row.forceAssetsVer.toString()
   ruleForm.apkVer = row.apkVer == null ? row.apkVer : row.apkVer.toString()
+  ruleForm.apkSubVer = row.apkSubVer == null ? row.apkSubVer : row.apkSubVer.toString()
   ruleForm.buildVer = row.buildVer == null ? row.buildVer : row.buildVer.toString()
   ruleForm.protocolVer = row.protocolVer == null ? row.protocolVer : row.protocolVer.toString()
+  ruleForm.loadType = row.loadType
 }
 
 const del = (row) => {

+ 0 - 135
src/views/operation/giftcode/batchGeneration/index.vue

@@ -1,135 +0,0 @@
-
-<template>
-  <PageWrapLayout>
-    <div style="max-width: 800px">
-      <el-form
-          ref="ruleFormRef"
-          :model="ruleForm"
-          :rules="rules"
-          label-width="120px"
-          class="demo-ruleForm"
-          :size="formSize"
-      >
-        <el-form-item label="礼包类型" prop="codeType">
-          <el-select v-model="ruleForm.codeType" placeholder="礼包类型">
-            <el-option label="一次性" value="0" />
-            <el-option label="通用" value="1" />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="礼包道具" prop="itemInfo">
-          <el-input v-model="ruleForm.itemInfo" placeholder="可填列表,逗号间隔" />
-        </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-form-item>
-          </el-col>
-          <el-col class="text-center" :span="2" style="text-align: center">
-            <span class="text-gray-500">-</span>
-          </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-form-item>
-          </el-col>
-        </el-form-item>
-        <el-form-item label="随机生成个数" prop="randomCount">
-          <el-input v-model="ruleForm.randomCount" placeholder="随机生成个数"/>
-        </el-form-item>
-        <el-form-item label="生成的礼包码" prop="result">
-          <el-input readonly v-model="ruleForm.result" :rows="10" type="textarea" />
-        </el-form-item>
-        <el-form-item>
-          <el-button type="primary" @click="submitForm(ruleFormRef)">立即生成</el-button>
-          <el-button @click="resetForm(ruleFormRef)">重置</el-button>
-          <el-button type="warning" @click="copyResult(ruleFormRef)">复制礼包码</el-button>
-        </el-form-item>
-      </el-form>
-    </div>
-  </PageWrapLayout>
-</template>
-
-<script lang="ts" setup >
-import { reactive, ref } from 'vue'
-import type { FormInstance } from 'element-plus'
-// import Upload from './components/Upload.vue'
-
-const formSize = ref('default')
-const ruleFormRef = ref<FormInstance>()
-const ruleForm = reactive({
-  code: '',
-  codeType: '',
-  validTime: '',
-  invalidTime: '',
-  giftItems: '',
-  itemInfo:[],
-  randomCount: 0,
-  result:''
-})
-
-const rules = reactive({
-  codeType: [
-    {
-      required: true,
-      message: '请选择礼包类型',
-      trigger: 'change',
-    },
-  ],
-  validTime: [
-    {
-      type: 'date',
-      required: true,
-      message: '请选择时间',
-      trigger: 'change',
-    },
-  ],
-  invalidTime: [
-    {
-      type: 'date',
-      required: true,
-      message: '请选择时间',
-      trigger: 'change',
-    },
-  ],
-  itemInfo: [
-    {
-      type: 'array',
-      required: true,
-      message: '请输入礼包道具',
-      trigger: 'change',
-    },
-  ],
-  randomCount: [
-    {
-      type: 'number',
-      required: true,
-      message: '请输入随机生成个数',
-      trigger: 'change',
-    },
-    { pattern: /^(?!0)(?:[0-9]{1,4}|10000)$/, message: '范围在1-10000',trigger: 'blur'}
-  ],
-})
-
-const submitForm = async (formEl: FormInstance | undefined) => {
-  console.log('--FORM---', ruleForm)
-  if (!formEl) return
-
-}
-
-const copyResult = async (formEl: FormInstance | undefined) => {
-  console.log('--COPY---', ruleForm)
-  if (!formEl) return
-
-}
-
-const resetForm = (formEl: FormInstance | undefined) => {
-  if (!formEl) return
-  formEl.resetFields()
-}
-</script>

+ 63 - 32
src/views/operation/giftcode/fixedGeneration/index.vue

@@ -14,36 +14,38 @@
           <el-input v-model="ruleForm.code" placeholder="3 到 8 个字符"/>
         </el-form-item>
         <el-form-item label="礼包类型" prop="codeType">
-          <el-select v-model="ruleForm.codeType" placeholder="礼包类型">
-            <el-option label="一次性" value="0" />
-            <el-option label="通用" value="1" />
-          </el-select>
+          <el-radio-group v-model="ruleForm.codeType">
+            <el-radio :label="0">一次性(一个玩家只使用一次)</el-radio>
+            <el-radio :label="1">通用(每个玩家可使用一次)</el-radio>
+          </el-radio-group>
         </el-form-item>
-        <el-form-item label="礼包道具ID" prop="itemIds">
-          <el-input v-model="ruleForm.itemIds" placeholder="道具ID列表,逗号间隔" />
-        </el-form-item>
-        <el-form-item label="礼包道具数量" prop="itemCounts">
-          <el-input v-model="ruleForm.itemCounts" placeholder="道具数量列表,逗号间隔" />
+        <el-form-item label="礼包道具" prop="itemInfo">
+          <el-input v-model="ruleForm.itemInfo" placeholder="可填列表,逗号间隔,格式:1001-100,1002-200" />
         </el-form-item>
         <el-form-item label="礼包生效时间" required>
-          <el-col :span="11">
+          <el-col :span="7">
             <el-form-item prop="validTime">
               <el-date-picker
                   v-model="ruleForm.validTime"
+                  value-format="YYYY-MM-DD HH:mm:ss"
                   type="datetime"
                   placeholder="选择开始时间"
                   style="width: 100%"
               />
             </el-form-item>
           </el-col>
-          <el-col class="text-center" :span="2" style="text-align: center">
+          <el-col class="text-center" :span="1" style="text-align: center">
             <span class="text-gray-500">-</span>
           </el-col>
-          <el-col :span="11">
+          <el-col :span="7">
             <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" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择结束时间" style="width: 100%" />
             </el-form-item>
           </el-col>
+          <el-col class="text-enpty" :span="1"/>
+          <el-button type="primary" @click="valid7Day">7天</el-button>
+          <el-button type="primary" @click="valid15Day">15天</el-button>
+          <el-button type="primary" @click="valid30Day">30天</el-button>
         </el-form-item>
         <el-form-item>
           <el-button type="primary" @click="submitForm(ruleFormRef)">立即生成</el-button>
@@ -57,18 +59,20 @@
 <script lang="ts" setup >
 import { reactive, ref } from 'vue'
 import type { FormInstance } from 'element-plus'
+import { ElMessage } from 'element-plus'
 // import Upload from './components/Upload.vue'
+import giftCodeApi from '@/api/giftCode'
+import dateUtils from '@/common/dateUtils'
 
 const formSize = ref('default')
 const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
   code: '',
-  codeType: '',
+  codeType: 0,
   validTime: '',
   invalidTime: '',
   giftItems: '',
-  itemIds:[],
-  itemCounts:[],
+  itemInfo:[]
 })
 
 const rules = reactive({
@@ -103,32 +107,59 @@ const rules = reactive({
       trigger: 'change',
     },
   ],
-  itemIds: [
-    {
-      type: 'array',
-      required: true,
-      message: '请输入礼包道具ID',
-      trigger: 'change',
-    },
-  ],
-  itemCounts: [
+  itemInfo: [
     {
-      type: 'array',
       required: true,
-      message: '请输入礼包道具数量',
+      message: '请输入礼包道具',
       trigger: 'change',
     },
-  ],
+  ]
 })
 
-const submitForm = async (formEl: FormInstance | undefined) => {
-  console.log('--FORM---', ruleForm)
-  if (!formEl) return
-
+const submitForm = async (done: () => void) => {
+  await ruleFormRef.value.validate((valid, fields) => {
+    if (valid) {
+      giftCodeApi.fixedGenerate(ruleForm).then(res => {
+        if (res.data.code = 200) {
+            return ElMessage.success(res.data.msg)
+          } else {
+            return ElMessage.error(res.data.msg)
+          }
+      })
+      console.log('submit!', ruleForm)
+    } else {
+      console.log('error submit!', fields)
+    }
+  })
 }
 
 const resetForm = (formEl: FormInstance | undefined) => {
   if (!formEl) return
   formEl.resetFields()
 }
+
+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)
+}
+
 </script>

+ 4 - 3
src/views/operation/giftcode/listTable/index.vue

@@ -1,6 +1,6 @@
 <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">
@@ -20,7 +20,7 @@
           删除
         </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"
@@ -73,9 +73,10 @@ import { ref, reactive, onMounted, nextTick } from 'vue'
 import * as dayjs from 'dayjs'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import type { FormInstance } from 'element-plus'
+import PropTable from '@/components/Table/PropTable/index.vue'
+
 const loading = ref(true)
 const appContainer = ref(null)
-import ServerPropTable from '@/components/Table/ServerPropTable/index.vue'
 const data = []
 for (let i = 0; i < 100; i++) {
   data.push({

+ 178 - 0
src/views/operation/giftcode/randomGeneration/index.vue

@@ -0,0 +1,178 @@
+
+<template>
+  <PageWrapLayout>
+    <div style="max-width: 800px">
+      <el-form
+          ref="ruleFormRef"
+          :model="ruleForm"
+          :rules="rules"
+          label-width="120px"
+          class="demo-ruleForm"
+          :size="formSize"
+      >
+      <el-form-item label="礼包类型" prop="codeType">
+          <el-radio-group v-model="ruleForm.codeType">
+            <el-radio :label="0">一次性(一个玩家只使用一次)</el-radio>
+            <el-radio :label="1">通用(每个玩家可使用一次)</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item label="礼包道具" prop="itemInfo">
+          <el-input v-model="ruleForm.itemInfo" placeholder="可填列表,逗号间隔,格式:1001-100,1002-200" />
+        </el-form-item>
+        <el-form-item label="礼包生效时间" required>
+          <el-col :span="7">
+            <el-form-item prop="validTime">
+              <el-date-picker
+                  v-model="ruleForm.validTime"
+                  value-format="YYYY-MM-DD HH:mm:ss"
+                  type="datetime"
+                  placeholder="选择开始时间"
+                  style="width: 100%"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col class="text-center" :span="1" style="text-align: center">
+            <span class="text-gray-500">-</span>
+          </el-col>
+          <el-col :span="7">
+            <el-form-item prop="invalidTime">
+              <el-date-picker v-model="ruleForm.invalidTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetime" placeholder="选择结束时间" style="width: 100%" />
+            </el-form-item>
+          </el-col>
+          <el-col class="text-enpty" :span="1"/>
+          <el-button type="primary" @click="valid7Day">7天</el-button>
+          <el-button type="primary" @click="valid15Day">15天</el-button>
+          <el-button type="primary" @click="valid30Day">30天</el-button>
+        </el-form-item>
+        <el-form-item label="随机生成个数" prop="randomCount">
+          <el-input v-model="ruleForm.randomCount" type = "number" placeholder="随机生成个数,范围[1,10000]"/>
+        </el-form-item>
+        <el-form-item label="生成的礼包码" prop="result">
+          <el-input readonly v-model="ruleForm.result" :rows="10" type="textarea" />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="submitForm(ruleFormRef)">立即生成</el-button>
+          <el-button @click="resetForm(ruleFormRef)">重置</el-button>
+          <el-button type="warning" @click="copyResult(ruleFormRef)">复制礼包码</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </PageWrapLayout>
+</template>
+
+<script lang="ts" setup >
+import { reactive, ref } from 'vue'
+import type { FormInstance } from 'element-plus'
+import giftCodeApi from '@/api/giftCode'
+import dateUtils from '@/common/dateUtils'
+import { ElMessage } from 'element-plus'
+
+const formSize = ref('default')
+const ruleFormRef = ref<FormInstance>()
+const ruleForm = reactive({
+  code: '',
+  codeType: '',
+  validTime: '',
+  invalidTime: '',
+  giftItems: '',
+  itemInfo:[],
+  randomCount: null,
+  result:''
+})
+
+const rules = reactive({
+  codeType: [
+    {
+      required: true,
+      message: '请选择礼包类型',
+      trigger: 'change',
+    },
+  ],
+  validTime: [
+    {
+      type: 'date',
+      required: true,
+      message: '请选择时间',
+      trigger: 'change',
+    },
+  ],
+  invalidTime: [
+    {
+      type: 'date',
+      required: true,
+      message: '请选择时间',
+      trigger: 'change',
+    },
+  ],
+  itemInfo: [
+    {
+      required: true,
+      message: '请输入礼包道具',
+      trigger: 'change',
+    },
+  ],
+  randomCount: [
+    {
+      required: true,
+      message: '请输入随机生成个数',
+      trigger: 'change',
+    },
+  ],
+})
+
+const submitForm = async (done: () => void) => {
+  await ruleFormRef.value.validate((valid, fields) => {
+    if (valid) {
+      giftCodeApi.randomGenerate(ruleForm).then(res => {
+        console.log('result!', res)
+        ruleForm.result = res.data.result
+        if (res.data.code = 200) {
+            return ElMessage.success(res.data.msg)
+          } else {
+            return ElMessage.error(res.data.msg)
+          }
+      })
+      console.log('submit!', ruleForm)
+    } else {
+      console.log('error submit!', fields)
+    }
+  })
+}
+
+const copyResult = async (formEl: FormInstance | undefined) => {
+  navigator.clipboard.writeText(ruleForm.result).then(
+    () => ElMessage.success("复制成功"),
+    (error) => ElMessage.error("复制失败")
+  );
+}
+
+const resetForm = (formEl: FormInstance | undefined) => {
+  if (!formEl) return
+  formEl.resetFields()
+}
+
+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)
+}
+
+</script>

+ 16 - 30
src/views/operation/sendcmd/index.vue

@@ -11,17 +11,11 @@
           :size="formSize"
       >
         <el-form-item label="服务器ID" prop="toServerIds">
-          <el-input v-model="ruleForm.toServerIds" placeholder="可填列表,逗号间隔" />
+          <el-input v-model="ruleForm.toServerIds" placeholder="可填列表和服务器段(101-110),逗号间隔" />
         </el-form-item>
-        <el-form-item label="角色ID" prop="toPlayerIds">
-          <el-input v-model="ruleForm.toPlayerIds" placeholder="可填列表,逗号间隔" />
-        </el-form-item>
-        <el-form-item label="命令" prop="command">
+        <el-form-item label="GM命令" prop="command">
           <el-input v-model="ruleForm.command"/>
         </el-form-item>
-        <el-form-item label="命令参数" prop="params">
-          <el-input v-model="ruleForm.params"/>
-        </el-form-item>
         <el-form-item label="执行结果" prop="result">
           <el-input readonly v-model="ruleForm.result" :rows="10" type="textarea" />
         </el-form-item>
@@ -38,14 +32,13 @@
 import { reactive, ref } from 'vue'
 import type { FormInstance } from 'element-plus'
 // import Upload from './components/Upload.vue'
+import gmCmdApi from '@/api/gmCmd'
 
 const formSize = ref('default')
 const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
   toServerIds: '',
-  toPlayerIds: '',
   command: null,
-  params: null,
   result:'',
 })
 
@@ -57,33 +50,26 @@ const rules = reactive({
       trigger: 'change',
     },
   ],
-  toPlayerIds: [
-    {
-      required: true,
-      message: '请输入角色ID',
-      trigger: 'change',
-    },
-  ],
   command: [
     {
       required: true,
-      message: '请输入命令',
+      message: '请输入GM命令',
       trigger: 'change',
     },
-  ],
-  params: [
-    {
-      required: true,
-      message: '请输入命令参数',
-      trigger: 'change',
-    },
-  ],
+  ]
 })
 
-const submitForm = async (formEl: FormInstance | undefined) => {
-  console.log('--FORM---', ruleForm)
-  if (!formEl) return
-
+const submitForm = async (done: () => void) => {
+  await ruleFormRef.value.validate((valid, fields) => {
+    if (valid) {
+      gmCmdApi.send(ruleForm).then(res => {
+        ruleForm.result = res.data.msg
+      })
+      console.log('submit!', ruleForm)
+    } else {
+      console.log('error submit!', fields)
+    }
+  })
 }
 
 const resetForm = (formEl: FormInstance | undefined) => {

+ 6 - 0
src/views/server/chatTable/index.vue

@@ -32,6 +32,9 @@
             <el-radio :label="1">开启</el-radio>
           </el-radio-group>
         </el-form-item>
+        <el-form-item label="包含服务器" prop="gameIds">
+          <el-input v-model="ruleForm.gameIds" placeholder="0代表全服,支持数组,格式:1,2,3..."/>
+        </el-form-item>
       </el-form>
       <template #footer>
         <span class="dialog-footer">
@@ -109,7 +112,9 @@ const list = ref(data)
 const formSize = ref('default')
 const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
+  _id: null,
   state: null,
+  gameIds: null
 })
 
 const rules = reactive({
@@ -192,6 +197,7 @@ const edit = (row) => {
   dialogVisible.value = true
   ruleForm._id = row._id
   ruleForm.state = row.state
+  ruleForm.gameIds = row.gameIds.toString()
 }
 
 const del = (row) => {

+ 6 - 1
src/views/server/crossTable/index.vue

@@ -32,7 +32,9 @@
             <el-radio :label="1">开启</el-radio>
           </el-radio-group>
         </el-form-item>
-
+        <el-form-item label="包含服务器" prop="gameIds">
+          <el-input v-model="ruleForm.gameIds" placeholder="0代表全服,支持数组,格式:1,2,3..."/>
+        </el-form-item>
       </el-form>
       <template #footer>
         <span class="dialog-footer">
@@ -111,7 +113,9 @@ const list = ref(data)
 const formSize = ref('default')
 const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
+  _id: null,
   state: null,
+  gameIds: null,
 })
 
 const rules = reactive({
@@ -195,6 +199,7 @@ const edit = (row) => {
   dialogVisible.value = true
   ruleForm._id = row._id
   ruleForm.state = row.state
+  ruleForm.gameIds = row.gameIds.toString()
 }
 
 const del = (row) => {

+ 28 - 22
src/views/server/gameTable/index.vue

@@ -25,28 +25,27 @@
       <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm"
         :size="formSize">
         <el-form-item label="ID" prop="_id">
-          <el-input readonly :value="ruleForm._id" />
+          <el-input readonly :value="ruleForm._id" type = "number" />
         </el-form-item>
         <el-form-item label="推荐权重" prop="weight">
-          <el-input v-model="ruleForm.weight" />
+          <el-input  v-model="ruleForm.weight" type = "number"/>
         </el-form-item>
         <el-form-item label="状态" prop="state">
           <el-radio-group v-model="ruleForm.state">
             <el-radio :label="0">关闭</el-radio>
             <el-radio :label="1">开启</el-radio>
             <el-radio :label="2">开放</el-radio>
+            <el-radio :label="3">繁忙</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="开服时间" prop="openTime">
+        <!-- <el-form-item label="开服时间" prop="openTime">
           <el-date-picker
                     v-model="ruleForm.openTime"
                     type="datetime"
                     value-format="YYYY-MM-DD HH:mm:ss"
                     clearable
                 />
-
-          <!-- <el-input v-model="ruleForm.openTime" /> -->
-        </el-form-item>
+        </el-form-item> -->
 
       </el-form>
       <template #footer>
@@ -93,7 +92,7 @@ const getDate = (val) => {
     y = now.getFullYear(),
     m = now.getMonth() + 1,
     d = now.getDate()
-  return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
+  return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substring(0, 8);
 }
 
 onBeforeMount(() => {
@@ -131,11 +130,15 @@ const column = [
       {
         value: 2,
         label: '开放',
+      },
+      {
+        value: 3,
+        label: '繁忙',
       }
     ],
     valueType: 'select',
   },
-  { name: 'openTime', label: '开服时间', inSearch: true, valueType: 'datetime'},
+  { name: 'openTime', label: '开服时间', slot: true},
   { name: 'operation', slot: true, fixed: 'right', width: 200, label: '操作' },
 ]
 
@@ -146,6 +149,8 @@ const getStateLabel = (val) => {
     return '开启'
   } else if (val == 2) {
     return '开放'
+  } else if (val == 3) {
+    return '繁忙'
   }
 }
 
@@ -155,9 +160,8 @@ const formSize = ref('default')
 const ruleFormRef = ref<FormInstance>()
 const ruleForm = reactive({
   _id:null,
-  weight: 0,
-  state: null,
-  openTime: null
+  weight: null,
+  state: null
 })
 
 const rules = reactive({
@@ -179,6 +183,7 @@ const handleClose = async (done: () => void) => {
   await ruleFormRef.value.validate((valid, fields) => {
     if (valid) {
       list.value.forEach((item) => {
+          ruleForm.weight = parseInt(ruleForm.weight)
           let updateParams = reactive({
             serverName: serverName,
             _id: ruleForm._id,
@@ -194,7 +199,7 @@ const handleClose = async (done: () => void) => {
           })
       })
       dialogVisible.value = false
-      console.log('submit!', ruleForm.weight, ruleForm.state)
+      console.log('submit!', ruleForm)
     } else {
       console.log('error submit!', fields)
     }
@@ -238,7 +243,7 @@ const edit = (row) => {
   ruleForm._id = row._id
   ruleForm.weight = row.weight
   ruleForm.state = row.state
-  ruleForm.openTime = getDate(row.openTime)
+  // ruleForm.openTime = getDate(row.openTime)
 }
 
 const del = (row) => {
@@ -289,8 +294,8 @@ const onSubmit = (val) => {
   if (val.state != null) {
     queryParams.state = val.state
   }
-  if (!val.weight) {
-    queryParams.weight = val.weight
+  if (val.weight) {
+    queryParams.weight = parseInt(val.weight)
   }
   serverApi.query(queryParams).then(res => {
     data.value = res.data.result;
@@ -303,7 +308,7 @@ const onSubmit = (val) => {
 }
 
 const onUpdate = (val) => {
-  if (val.state == null && !val.weight && !val.openTime) {
+  if (!val._id && val.state == null && !val.weight ) {
     ElMessage.warning('请输入编辑内容')
     return
   }
@@ -311,18 +316,19 @@ const onUpdate = (val) => {
     serverName: serverName,
     updateValue: reactive({})
   })
+  console.log('onUpdate', val)
   if (val._id) {
     updateParams._id = parseInt(val._id)
   }
   if (val.state != null) {
-    updateParams.updateValue.state = val.stage
-  }
-  if (!val.weight) {
-    updateParams.updateValue.weight = val.weight
+    updateParams.updateValue.state = val.state
   }
-  if (!val.openTime) {
-    updateParams.updateValue.openTime = val.openTime.getTime()
+  if (val.weight) {
+    updateParams.updateValue.weight = parseInt(val.weight)
   }
+  // if (!val.openTime) {
+  //   updateParams.updateValue.openTime = val.openTime.getTime()
+  // }
   serverApi.updateBatch(updateParams).then(res => {
     if (res.data.code = 200) {
       loadServerInfo()

+ 5 - 0
src/views/server/gatewayTable/index.vue

@@ -30,6 +30,7 @@
           <el-radio-group v-model="ruleForm.state">
             <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>
@@ -87,6 +88,10 @@ const column = [
       {
         value: 1,
         label: '开启',
+      },
+      {
+        value: 2,
+        label: '开放',
       }
     ],
     valueType: 'select',

+ 1 - 2
src/views/server/loginTable/index.vue

@@ -80,8 +80,7 @@ const loadServerInfo = () => {
 const column = [
   { type: 'selection', width: 60, fixed: 'left' },
   { name: '_id', label: 'ID', inSearch: true, valueType: 'inputNumber', width: 80 },
-  { name: 'gatewayId', label: '连接网关服'},
-  { name: 'gameIds', label: '包含游戏服'},
+  { name: 'addr', label: '登录地址'},
   {
     name: 'state',
     label: '状态',