export default <LibMixins>{

    data(){
      return {
          buttonAsync:false
      }
    },

    watch:{
      title:function () {
          if (!this.title) {
              return this.triggerCancel();
          }
      }
    },

    methods:{

        triggerCancel(){

            if (this.value) {

                this.$attrs.cancel && this.$attrs.cancel();

                return this.close();
            }

        },

        triggerConfirm(callback){

            if (this.value) {

                let resultData = this.$attrs.confirm && this.$attrs.confirm();

                if (resultData instanceof Promise) {
                    this.storageResultData = resultData;
                    this.buttonAsync = true;
                    callback();
                } else {
                    return this.close();
                }
            }

        },

        triggerWaiting(obj){
            this.storageResultData.then((value)=>{

                if (value === false) {
                    obj.none();
                    return this.close();
                } else {
                    obj.success();
                    this.triggerWaitingTime = setTimeout(()=> this.close(),this.successAsyncTime);
                }

            }).catch(()=>{
                obj.none();
                this.buttonAsync = false;
            });
        }

    },

    beforeUnmount() {
        clearTimeout(this.triggerWaitingTime);
    }

}