<!--
 * @Author: zwq
 * @Date: 2020-12-29 16:37:56
 * @LastEditors: zwq
 * @LastEditTime: 2022-10-20 13:38:57
 * @Description:
-->
<template>
  <el-dialog :visible.sync="visible" :title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter" width="40%" class="dialog" @close="close">
    <!-- <small-title slot="title">
      {{ !dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter }}
    </small-title> -->

    <el-form
      ref="dataForm"
      :model="dataForm"
      :rules="dataRule"
      label-width="100px"
      @keyup.enter.native="dataFormSubmit()"
    >
      <el-form-item label="所属仓库名称" prop="name1">
        <el-input
          v-model="dataForm.name1"
          placeholder="请输入所属仓库名称"
          clearable
        />
      </el-form-item>
      <el-form-item label="区域名称" prop="name2">
        <el-input
          v-model="dataForm.name2"
          placeholder="请输入区域名称"
          clearable
        />
      </el-form-item>
      <el-form-item label="区域属性" prop="name3">
        <el-input
          v-model="dataForm.name3"
          placeholder="请输入区域属性"
          clearable
        />
      </el-form-item>
      <el-form-item label="ERP代码" prop="name4">
        <el-input
          v-model="dataForm.name4"
          placeholder="请输入ERP代码"
          clearable
        />
      </el-form-item>
    </el-form>

    <el-row style="text-align: right">
      <el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
      <el-button type="primary" @click="dataFormSubmit()">{{ 'btn.save' | i18nFilter }}</el-button>
    </el-row>
  </el-dialog>
</template>

<script>
// import SmallTitle from '@/components/BaseDrawer/components/SmallTitle.vue'

export default {
  // components: { SmallTitle },
  data() {
    return {
      visible: false,
      dataForm: {
        id: '',
        name1: '',
        name2: '',
        name3: '',
        name4: ''
      },
      dataRule: {
        name1: [
          {
            required: true,
            message: '请输入所属仓库名称',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  methods: {
    init(row) {
      this.dataForm = row || ''
      console.log(row)
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
      })
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          this.$message({
            message: this.$t('module.basicData.visual.success'),
            type: 'success',
            duration: 1500,
            onClose: () => {
              this.visible = false
              this.$emit('refreshDataList')
            }
          })
        }
      })
    },
    close() {
      this.visible = false
      this.$emit('refreshDataList')
    }
  }
}
</script>

<style scoped>
.dialog >>> .el-dialog__body {
  padding: 30px 24px;
}
</style>
