<template>
  <el-form
    ref="subjectForm"
    v-loading="loading"
    :model="form"
    :rules="rules"
    size="small"
    label-width="80px"
  >
    <div class="base-dialog-body">
      <!-- 窗宽 -->
      <el-form-item :label="$t('trials:reading:label:wlTplWW')">
        <el-input-number v-model="form.ww" controls-position="right" />
      </el-form-item>
      <!-- 窗位 -->
      <el-form-item :label="$t('trials:reading:label:wlTplWL')">
        <el-input-number v-model="form.wc" controls-position="right" />
      </el-form-item>
    </div>
    <div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
      <el-form-item>
        <!-- 取消 -->
        <el-button
          size="small"
          type="primary"
          @click="handleCancel"
        >
          {{ $t('common:button:cancel') }}
        </el-button>
        <!-- 保存 -->
        <el-button size="small" type="primary" @click="handleSave">
          {{ $t('common:button:save') }}
        </el-button>
      </el-form-item>
    </div>

  </el-form>

</template>
<script>
export default {
  name: 'CustomWwwcForm',

  data() {
    return {
      form: {
        ww: '',
        wc: ''
      },
      rules: {
        ww: [
          { required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
        ],
        wc: [
          { required: true, message: this.$t('common:ruleMessage:specify'), trigger: 'blur' }
        ]
      },
      loading: false
    }
  },
  methods: {
    handleSave() {
      this.$refs.subjectForm.validate(valid => {
        if (!valid) return
        this.$emit('setWwwc', this.form)
      })
    },
    handleCancel() {
      this.$emit('close')
    }
  }
}
</script>
