<template>
  <div class="servicePage">
    <div class="configuration">
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="180px" class="demo-ruleForm">
        <el-form-item label="服务ID" prop="serviceId">
          <el-input v-model="ruleForm.serviceId" maxlength="20" />
        </el-form-item>
        <el-form-item label="Secret" prop="serviceSecret">
          <el-input v-model="ruleForm.serviceSecret" maxlength="20" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        serviceId: '',
        serviceSecret: ''
      },
      rules: {
        serviceId: [
          { required: true, message: '请输入服务ID', trigger: 'blur' }
        ],
        serviceSecret: [
          { required: true, message: '请输入Secret', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style lang="scss" scpoed>
.servicePage {
	padding: 5rem 20px;

	.configuration {
		width: 600px;
	}
}
</style>
