<template>
  <el-dialog title="修改礼品名称" :visible.sync="dialogVisible" width="600px" @close="cancelSubmit('editInfoModal')">
    <el-form :model="editInfoModal" ref="editInfoModal" :rules="modalRules" :label-position="labelPosition" v-loading="loading">
      <el-form-item label="礼品名称" label-width="80px" prop="goodsName" style="width:560px">
        <dm-input type="text" v-model="editInfoModal.goodsName" :byte-type="1" :maxlength="30"> </dm-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelSubmit('editInfoModal')">取消</el-button>
      <el-button type="primary" @click="submitProNanme('editInfoModal')">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
// import request from '../service/request.js';
export default {
  props: {
    updateNameForm: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      dialogVisible: false,
      editInfoModal: {
        goodsName: '',
        goodsId: ''
      },
      labelPosition: 'top',
      modalRules: {
        goodsName: [ { required: true, message: '名称不能为空', trigger: 'blur' } ]
      },
      title: '',
      label: '',
      loading: false
    };
  },
  mounted() {
    this.dialogVisible = true;
    // this.editInfoModal.goodsName = this.updateNameForm.name;
    // this.editInfoModal.goodsId = this.updateNameForm.id;
  },
  methods: {
    submitProNanme(formName) {
      console('修改礼品名称');
      // if(this.loading) return;
      // this.$refs[formName].validate(valid => {
      //   if (valid) {
      //     let params = {
      //       goodsId: this.editInfoModal.goodsId,
      //       goodsName: this.editInfoModal.goodsName
      //     };
      //     this.loading = true;
      //     // request.post('/api-integral-mall/update-integral-gift-info', params).then(res => {
      //     //   if (res.data.code === '0000') {
      //     //     this.dialogVisible = false;
      //     //     setInterval(() => {
      //     //       this.$emit('closeUpdateName');
      //     //     }, 10);
      //     //     this.$message.success('修改成功');
      //     //     this.$emit('getList');
      //     //   } else {
      //     //     this.$message.error(res.data.message);
      //     //   }
      //     // }).finally(() => this.loading = false);
      //   } else {
      //     return false;
      //   }
      // });
    },
    // 取消修改
    cancelSubmit(formName) {
      this.$refs[formName].resetFields();
      // this.editInfoModal.goodsName = '';
      // this.editInfoModal.goodsId = '';
      this.dialogVisible = false;
      setInterval(() => {
        this.$emit('closeUpdateName');
      }, 10);
    }
  }
};
</script>
<style scoped></style>
