import request from '@/utils/request'
import {upcloud_base_strategy} from "@/config/serviceSettings";

export let getExpiredDaysModual = {

    methods: {

        getExpiredDays(id) {
            getExpiredDaysAlertNoIntercept(id).then(res => {
                if (!res.success) {
                    this.$exception(res)
                    return
                }
                if (!res.data) return;
                this.expiredDays.alert = +res.data.regValue
            })
            getExpiredDaysAlertAndIntercept(id).then(res => {
                if (!res.success) {
                    this.$exception(res)
                    return
                }
                if (!res.data) return;
                this.expiredDays.intercept = +res.data.regValue
            })
        }

    }

}

// 180Day
function getExpiredDaysAlertNoIntercept(id) {
    return request({
        method: 'get',
        url: upcloud_base_strategy+'/registry/by-code?regCode=expiredDaysAlertNoIntercept&warehouseId=' + id,
    })
}

// 90Day
function getExpiredDaysAlertAndIntercept(id) {
    return request({
        method: 'get',
        url: upcloud_base_strategy+'/registry/by-code?regCode=expiredDaysAlertAndIntercept&warehouseId=' + id,
    })
}