<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('CustomWwwcForm:form:label:ww')">
        <el-input-number v-model="form.ww" controls-position="right" :min="1" :precision="0" :step="1" />
      </el-form-item>
      <el-form-item :label="$t('CustomWwwcForm:form:label:wl')">
        <el-input-number v-model="form.wc" controls-position="right" :precision="0" :step="1" />
      </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: null,
        wc: null
      },
      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>
