
<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="服务器ID" prop="toServerIds">
          <el-input v-model="ruleForm.toServerIds" placeholder="可填列表，逗号间隔" />
        </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-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>
        <el-form-item>
          <el-button type="primary" @click="submitForm(ruleFormRef)">发送</el-button>
          <el-button @click="resetForm(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({
  toServerIds: '',
  toPlayerIds: '',
  command: null,
  params: null,
  result:'',
})

const rules = reactive({
  toServerIds: [
    {
      required: true,
      message: '请输入服务器ID',
      trigger: 'change',
    },
  ],
  toPlayerIds: [
    {
      required: true,
      message: '请输入角色ID',
      trigger: 'change',
    },
  ],
  command: [
    {
      required: true,
      message: '请输入命令',
      trigger: 'change',
    },
  ],
  params: [
    {
      required: true,
      message: '请输入命令参数',
      trigger: 'change',
    },
  ],
})

const submitForm = async (formEl: FormInstance | undefined) => {
  console.log('--FORM---', ruleForm)
  if (!formEl) return

}

const resetForm = (formEl: FormInstance | undefined) => {
  if (!formEl) return
  formEl.resetFields()
}
</script>
