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

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

	this.createGroup = function () {
		utils.popup("/servers/groups/createPopup", {
			callback: function () {
				utils.success("保存成功", function () {
					utils.reload()
				})
			}
		})
	}

	this.deleteGroup = function (groupId) {
		let that = this
		utils.confirm("确定要删除这个分组吗？", function () {
			that.$post("/servers/groups/group/delete")
				.params({
					groupId: groupId
				})
				.success(function () {
					utils.success("删除成功", function () {
						utils.reload()
					})
				})
		})
	}

	this.sortTable = function (groupIds) {
		this.$post("/servers/groups/sort")
			.params({
				groupIds: groupIds
			})
			.success(function () {
				utils.successToast("保存成功")
			})
	}
}