import initCtx from "@/utils/ctx.js";

export default function () {
	const {utils, Tea} = initCtx(this)

	var that = this;

	this.success = this.$NotifyPopup

	this.selectedType = this.scheduling.code;
	this.schedulingTypeDescription = null;

	this.changeSchedulingType = function () {
		this.schedulingTypeDescription = this.schedulingTypes.$find(function (k, v) {
			return v.code == that.selectedType;
		}).description;
	};
	this.changeSchedulingType();

	// hash
	this.hashKey = "";
	this.hashVar = "";
	if (this.scheduling.code == "hash") {
		this.hashKey = this.scheduling.options.key;
	} else {
		this.hashKey = "${remoteAddr}";
	}

	this.changeHashVar = function () {
		if (this.hashVar.length > 0) {
			this.hashKey = this.hashVar;
		}
	};

	// sticky
	if (this.scheduling.code == "sticky") {
		this.stickyType = this.scheduling.options.type;
		this.stickyParam = this.scheduling.options.param;
	} else {
		this.stickyType = "cookie";
		this.stickyParam = "Origin";
	}
}