<template>
  <div>
    <el-dialog v-bind="$attrs" :title="'formItem.menu.edit'| i18nFilter" v-on="$listeners" @open="onOpen" @close="onClose">
      <el-form ref="" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-form-item :label="$t('menuManage.menuCode')" prop="code">
          <el-input v-model="formData.code" :placeholder="['placeholder.input', $t('menuManage.menuCode')] | i18nFilterForm" clearable :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item :label="$t('menuManage.icon')" prop="icon">
          <el-select v-model="formData.icon" :placeholder="['placeholder.select', $t('menuManage.icon')] | i18nFilterForm" clearable :style="{width: '100%'}">
            <el-option
              v-for="(item, index) in iconOptions"
              :key="index"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('menuManage.href')" prop="href">
          <el-input v-model="formData.href" :placeholder="['placeholder.input', $t('menuManage.href')] | i18nFilterForm" clearable :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item :label="$t('menuManage.menuName')" prop="name">
          <el-input v-model="formData.name" :placeholder="['placeholder.input', $t('menuManage.menuName')] | i18nFilterForm" clearable :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item :label="$t('menuManage.remark')" prop="remark">
          <el-input v-model="formData.remark" :placeholder="['placeholder.input', $t('menuManage.remark')] | i18nFilterForm" clearable :style="{width: '100%'}" />
        </el-form-item>
        <el-form-item :label="$t('menuManage.menustartstop')" prop="enabled">
          <el-switch v-model="formData.enabled" />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
        <el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  components: {},
  inheritAttrs: false,
  props: [],
  data() {
    return {
      formData: {
        code: undefined,
        icon: undefined,
        href: undefined,
        name: undefined,
        remark: undefined,
        enabled: true
      },
      rules: {
        code: [{
          required: true,
          message: this.$i18nForm(['placeholder.input', this.$t('menuManage.menuCode')]),
          trigger: 'blur'
        }],
        icon: [{
          required: true,
          message: this.$i18nForm(['placeholder.select', this.$t('menuManage.icon')]),
          trigger: 'change'
        }],
        href: [],
        name: [{
          required: true,
          message: this.$i18nForm(['placeholder.input', this.$t('menuManage.menuName')]),
          trigger: 'blur'
        }],
        remark: []
      },
      iconOptions: [{
        'label': '选项一',
        'value': 1
      }, {
        'label': '选项二',
        'value': 2
      }]
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs[''].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handelConfirm() {
      this.$refs[''].validate(valid => {
        if (!valid) return
        this.close()
      })
    }
  }
}

</script>
<style>
</style>
