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

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

	this.createUser = function () {
		utils.popup(Tea.url(".createPopup"), {
			width: "44em",
			callback: function () {
				utils.success("创建成功", function () {
					utils.reload()
				})
			}
		})
	}

	this.updateUser = function (userId) {
		utils.popup("/servers/certs/acme/users/updatePopup?userId=" + userId, {
			width: "44em",
			callback: function () {
				utils.success("保存成功", function () {
					utils.reload()
				})
			}
		})
	}

	this.deleteUser = function (userId) {
		let that = this
		utils.confirm("确定要删除此用户吗？", function () {
			that.$post(".delete")
				.params({
					userId: userId
				})
				.refresh()
		})
	}
}