<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogFormVisible"
    width="600px"
    :close-on-click-modal="false"
    @close="close"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="商品分类" prop="name">
        <el-input v-model.trim="form.name" autocomplete="off" type="name" size="small" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="close">取 消</el-button>
      <el-button type="primary" size="small" @click="save('form')">确定保存</el-button>
    </div>
  </el-dialog>
</template>
<script>
// import { doEdit } from "@/api/userManagement";
export default {
  name: '',
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
      form: {
        name: ''
      },
      rules: {
        name: [
          { required: true, trigger: 'blur', message: '请输入商品分类' }
        ]
      },
      title: '',
      dialogFormVisible: false,
      // 记录省市县
      provinceList: [],
      dataprovinceList: [],
      provinceCode: ''
    }
  },
  created() {},
  methods: {
    showEdit(row) {
      if (!row) {
        this.title = '添加'
      } else {
        this.title = '编辑'
        this.form = Object.assign({}, row)
      }
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].resetFields()
      this.form = this.$options.data().form
      this.dialogFormVisible = false
    },
    save(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('fetchData')
          this.close()
        } else {
          return false
        }
      })
    }
  }
}
</script>
