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

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

	this.createRoute = function () {
		utils.popup("/ns/routes/createPopup", {
			width: "50em",
			height: "40em",
			callback: function () {
				utils.success("保存成功", function () {
					utils.reload()
				})
			}
		})
	}

	this.updateRoute = function (routeId) {
		utils.popup("/ns/routes/updatePopup?routeId=" + routeId, {
			width: "50em",
			height: "40em",
			callback: function () {
				utils.success("保存成功", function () {
					utils.reload()
				})
			}
		})
	}

	this.deleteRoute = function (routeId) {
		let that = this
		utils.confirm("确定要删除此线路吗？", function () {
			that.$post(".delete")
				.params({
					routeId: routeId
				})
				.success(function () {
					utils.reload()
				})
		})
	}

	this.sortTable = function (ids) {
		this.$post(".sort")
			.params({
				routeIds: ids
			})
			.success(function () {
				utils.successToast("排序保存成功")
			})
	}
}