import {OrderPayStatus, OrderPayUseStatus} from "$utils/control/order/const/order";
import {OrderUpdateOperation} from "$utils/control/order/const/operation";

import orderControl from '$utils/control/order';

export default {

    provide(){
      return {
          updateOrderStatus:(item:Record<string, any>,status:OrderPayStatus)=> this.updateOrderStatus(item,status),
      }
    },

    methods:{

        updateOrderStatus(item:Record<string, any>,status:OrderPayStatus){

            if (this.updateConfig[status]) {

                for (let key in this.updateConfig[status]) {

                    if (this.updateConfig[status].hasOwnProperty(key)) {
                        this.$refs[key] && this.$refs[key].updateOrder && this.$refs[key].updateOrder({
                            type:this.updateConfig[status][key],
                            item,
                            status,
                            id: item.oid
                        });
                    }
                }

            }

        }

    },

    created() {

        // 执行配置
        this.updateConfig = orderControl.getUpdateConfig(this.orderStatus);

    }

}