<template>
  <div>
    <el-form
      ref="dataForm"
      :rules="rules"
      :model="configForm"
      label-well-code="right"
      label-width="140px"
    >
      <div class="titleStyle">
        报警推送方式
      </div>
      <el-row>
        <el-col :span="12">
          <el-form-item label="推送方式" prop="pushRule">
            <el-select v-model="configForm.pushRule" size="small" placeholder="无" :disabled="!editMode" clearable>
              <el-option
                v-for="item in pushRuleList"
                :key="item.value"
                :label="item.name"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <div class="titleStyle">
        WEB端推送配置
      </div>
      <el-row>
        <el-col :span="12">
          <el-form-item label="服务地址" prop="websocketUrl">
            <el-input
              v-model.trim="configForm.websocketUrl"
              clearable
              size="small"
              :disabled="!editMode"
              type="text"
              placeholder="无"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <div class="titleStyle">
        APP端推送配置
      </div>
      <el-row>
        <el-col :span="12">
          <el-form-item label="个推平台appId" prop="appId">
            <el-input
              v-model.trim="configForm.appId"
              clearable
              size="small"
              :disabled="!editMode"
              type="text"
              placeholder="无"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="个推平台appKey" prop="appKey">
            <el-input
              v-model.trim="configForm.appKey"
              clearable
              size="small"
              :disabled="!editMode"
              type="text"
              placeholder="无"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="个推平台appSecret" prop="appSecret">
            <el-input
              v-model.trim="configForm.appSecret"
              clearable
              size="small"
              :disabled="!editMode"
              type="text"
              placeholder="无"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="margin: 20px 220px;">
      <el-button @click="updata">
        修改
      </el-button>
      <el-button type="primary" @click="saveData">
        保存
      </el-button>
      <el-button @click="editMode = false">
        取消
      </el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AlarmPushConfig',
  data() {
    return {
      editMode: false,
      pushRuleList: [
        { name: '权属单位及其上级所有用户', value: '1' },
        { name: '权属单位所有用户', value: '2' },
        { name: '权属单位负责人', value: '3' },
        { name: '指定人员', value: '4' }
      ],
      // 表单内容
      configForm: {
        pushRule: '权属单位及以其上级所有用户', // 报警推送规则
        websocketUrl: 'ws://111.198.10.15:11309/websocket', // websocket地址
        appId: 'qQqFtTBrUa7SGLjntUlpT4', // 个推appId
        appKey: 'GNjHLiqJkD6OoeZbtbdfi5', // 个推appKey
        appSecret: '7IuYlRuqWtAaZzVmJHunh7' // 个推appSecret
      },
      // 表单校验规则
      rules: {
        devcode: [{ required: true, message: '设备编号无', trigger: ['blur', 'change'] }],
        imei: [{ required: true, message: 'IMEI号无', trigger: ['blur', 'change'] }],
        iccid: [{ required: true, message: 'SIM卡号无', trigger: ['blur', 'change'] }]
      }
    }
  },
  methods: {
    updata() {
      this.editMode = true
    },
    saveData() {}
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.titleStyle{
    margin: 20px;
}
</style>
