<template>
  <div>
    <Modal v-model="draftModal" title="草稿名称">
      <Input
        v-model="value"
        placeholder="请输入草稿名称"
        style="width: 250px"
      />
      <div slot="footer">
        <Button type="primary"  @click="asyncOK">确定</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
export default {
  name: "draftName",
  props: {
    context: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      data: null,
      draftModal: false,
      value: "",
      billDefineName: null,
    };
  },
  mounted() {},
  methods: {
    asyncOK() {
      if(!this.value){
        this.$Message.info('请输入草稿名称');
        return 
      }
      //掉接口保存当前json  和value
      let obj = {
        billDefineName: this.billDefineName,
        title: this.value,
        billdata: JSON.stringify(this.data),
      };
      GAMS.Util.invokeServer({
        path: "rbcfunc/billdraft/add",
        type: "POST",
        data: JSON.stringify(obj),
        contentType: "application/json",
      })
        .then(
          function (data, textStatus, response) {
            if(data.code == 0){
             this.$Message.info("保存成功");
             this.draftModal = false;
            }else{
               data.msg && this.$Message.error(data.msg);
            }
          }.bind(this)
        )
        .catch((XMLHttpRequest, textStatus, errorThrown) => {
        });
    },
  },
};
</script>

<style lang="less" scoped>
.drawer-footer {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  border-top: 1px solid #e8e8e8;
  padding: 10px 16px;
  text-align: right;
  background: #fff;
}
</style>


