<template>
  <el-form
    ref="customWWWC"
    v-loading="loading"
    :model="form"
    :rules="rules"
    size="small"
    label-width="80px"
  >
    <div class="base-dialog-body" style="border:none">

      <el-form-item :label="$t('CustomWwwcForm:form:label:ww')">
        <el-input-number v-model="form.ww" controls-position="right" :min="1" :max="100000" :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" :min="-100000" :max="100000" :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',
  props: {
    ww: {
      type: Number,
      default: null
    },
    wc: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      form: {
        ww: this.ww,
        wc: this.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: {
    async handleSave() {
      const valid = await this.$refs.customWWWC.validate()
      if (!valid) return
      this.$emit('setWwwc', this.form)
    },
    handleCancel() {
      this.$emit('close')
    }
  }
}
</script>
