<!--
 * @Author: zwq
 * @Date: 2020-12-29 16:37:56
 * @LastEditors: zwq
 * @LastEditTime: 2022-01-17 10:19:45
 * @Description:
-->
<template>
  <el-dialog
    :title="!dataForm.id ? 'btn.add' : 'btn.edit' | i18nFilter"
    :visible.sync="visible"
  >
    <el-form ref="dataForm" :model="dataForm" label-width="120px">
      <el-form-item :label="$t('module.basicData.factory.FactoryName')" prop="name">
        <el-input v-model="dataForm.name" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.factory.FactoryName')])" clearable />
      </el-form-item>
      <el-form-item :label="$t('module.basicData.factory.FactoryCode')" prop="code">
        <el-input v-model="dataForm.code" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.factory.FactoryCode')])" clearable />
      </el-form-item>
      <el-form-item :label="$t('module.basicData.factory.Address')" prop="address">
        <el-input v-model="dataForm.address" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.factory.Address')])" clearable />
      </el-form-item>
      <el-form-item :label="$t('module.basicData.visual.Remarks')" prop="description">
        <el-input v-model="dataForm.description" :placeholder="$i18nForm(['placeholder.input', $t('module.basicData.visual.Remarks')])" clearable />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { StorageBoxInfoDetail } from '@/api/basicData/Warehouse/StorageBoxInfo'

export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        name: '',
        code: '',
        address: '',
        description: ''
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || ''
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        StorageBoxInfoDetail(this.dataForm.id).then(res => {
          this.dataForm.name = res.data.name
          this.dataForm.code = res.data.code
          this.dataForm.address = res.data.address
          this.dataForm.description = res.data.description
        })
      })
    }
  }
}
</script>
