import notice from '@/utils/notice/index';
import order from "../../../utils/controls/order";
import toast from "../../../utils/tool/toast";
export default {

    methods:{
      changeStatus(item) {

          let target = this.updateStatus[item.name] || {};

          if (item.reload || target.reload) {
              this.useUpdateLoading = true;
              return this.$refs.header && this.$refs.header.reload(2,true);
          }  else if (item.delete) {
              return this.$router.navigateBack();
          } else {
              this.setTargetStatus(item.toStatus);
          }
      }
    },

    onShow(){
        if (this.storageMsg) {
            toast.success(this.storageMsg);
            this.storageMsg = null;
        }
    },

    created(){

        this.updateStatus = {
          'comment':{
              reload:true
          }
        };

        notice.on('order-detail',(item)=>{
            if(item.page === 'order-detail' && item.msg) {
                this.storageMsg = item.msg;
            }
            this.changeStatus(item);
        },'order')
    },

    beforeDestroy(){
        notice.off('order-detail','order');
    }

}