<template>
  <div class="game-maintenance-container">
    <el-card shadow="hover">
      <div class="game-order-search mb15" >
        <el-form    label-position="right"
                    :model="formLabelAlign"
                    >

          <el-form-item label="内容：">
            <el-input  v-model="tableData.param.content" placeholder="" type="textarea" class="w-50 m-2"  rows="5" clearable/>
          </el-form-item>
          <el-form-item>
            <el-button size="large" type="primary" class="ml10" @click="noticeMaintenance">
              登录公告发送
            </el-button>
          </el-form-item>
        </el-form>

      </div>

    </el-card>
  </div>


</template>

<script lang="ts">
import {toRefs, reactive, onMounted,  defineComponent, } from 'vue';
//import { ElMessageBox, ElMessage } from 'element-plus';
import {gameGetNoticeLogin, gameNoticeLogin} from "/@/api/game";

import {ElMessage} from "element-plus/es";


interface TableDataState {
  tableData: {
    param: {
      content:string
      status:number
      noticeType:number
      channel:number
      id:number
    };

  };

}

export default defineComponent({
  name: 'apiV1GameOrderOrderList',
  setup() {
    // const {proxy} = getCurrentInstance() as any;

    const state = reactive<TableDataState>({
      tableData: {
        param: {
          status: 0,
          content: "",
          noticeType:2,
          channel:0,
          id:0,
        },
      }

    });
    const noticeMaintenance=()=>{
      gameNoticeLogin(state.tableData.param).then(()=>{
        ElMessage.success('发送成功');
      }).finally(()=>{
        // state.loading = false;
      })
    }

    // 初始化表格数据
    const initTableData = () => {
      getNotice()
    };
    const getNotice=()=>{
      gameGetNoticeLogin(state.tableData.param).then((res:any)=>{
        state.tableData.param.content = res.data.content;
        state.tableData.param.id = res.data.id;

      });
    };


    // function GetStateStr(s:number){
    //   if (s==2){
    //     return "成功"
    //   }
    //   return "失败(错误id="+s+")"
    // }

    // // 分页改变
    // const onHandleSizeChange = (val: number) => {
    // 	state.tableData.param.pageSize = val;
    // };
    // // 分页改变
    // const onHandleCurrentChange = (val: number) => {
    // 	state.tableData.param.pageNum = val;
    // };
    // 页面加载时
    onMounted(() => {
      initTableData();
    });
    return {
      noticeMaintenance,
      ...toRefs(state),
    };
  },
});
</script>
