ui pre #40
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import type { Id } from "../../src/eid/typ.ts"
|
||||
import type { Pas, PasCode, PreUsr } from "../../src/pra/pos.ts"
|
||||
import type { DocU } from "../../src/db.ts"
|
||||
import type { DocC, DocU } from "../../src/db.ts"
|
||||
import type * as Q from "../../src/pra/que.ts"
|
||||
import { nav, navhash, navpas } from "./nav.ts"
|
||||
import { bind, main, pas_a, pos, que } from "./template.ts"
|
||||
import { is_actid, is_nbr, lim_re, req_re } from "../../src/eid/is.ts"
|
||||
import { utc_medium } from "../../src/ont/utc.ts"
|
||||
import { btn, ida, idnam, label, meta, pro, rolref, seladm, txt } from "./section.ts"
|
||||
import { is_pro_usr, is_sec } from "../../src/pra/con.ts"
|
||||
import { is_pre_agd, is_pre_soc, is_pre_usr, is_pro_usr, is_sec } from "../../src/pra/con.ts"
|
||||
|
||||
export function pas(
|
||||
) {
|
||||
@@ -104,13 +104,19 @@ export async function usr(
|
||||
pas_a.innerText = u.nam
|
||||
t.put.addEventListener("click", () => put("用户", u))
|
||||
t.pas.addEventListener("click", pas)
|
||||
if (nav.pas.aut || is_sec(nav.pas)) {
|
||||
t.preusr.addEventListener("click", () => pre("用户"))
|
||||
} else t.preusr.remove()
|
||||
if (nav.pas.aut) {
|
||||
t.presoc.addEventListener("click", () => pre("社团"))
|
||||
t.preagd.addEventListener("click", () => pre("活动"))
|
||||
} else[t.presoc, t.preagd].forEach(p => p.remove())
|
||||
if (is_pre_usr(nav.pas)) t.preusr.addEventListener("click", () => pre("用户"))
|
||||
else t.preusr.remove()
|
||||
if (is_pre_soc(nav.pas)) t.presoc.addEventListener("click", () => pre("社团"))
|
||||
else t.presoc.remove()
|
||||
if (is_pre_agd(nav.pas)) t.preagd.addEventListener("click", () => pre("活动"))
|
||||
else t.preagd.remove()
|
||||
btn(t.prefund, t.prefund.innerText, {
|
||||
prompt1: "输入订单号",
|
||||
confirm: "订单号只能激活或绑定一位用户。确认使用?",
|
||||
alert: "无效订单号,或订单号已被使用",
|
||||
pos: (actid) => actid ? pos("pre", { actid }) : null,
|
||||
refresh: () => usr(u._id),
|
||||
})
|
||||
t.pro.remove()
|
||||
} else {
|
||||
t.pos.remove()
|
||||
@@ -145,9 +151,45 @@ export function lit(
|
||||
|
||||
}
|
||||
function pre(
|
||||
t: "用户" | "社团" | "活动",
|
||||
nam: "用户" | "社团" | "活动",
|
||||
) {
|
||||
if (!nav.pas) return
|
||||
main.innerHTML = ""
|
||||
const t = bind("pre")
|
||||
|
||||
idnam(t, `${nav.pas.uid}`, `添加${nam}`)
|
||||
seladm(t)
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
let p: () => any
|
||||
let r: (id: Id["_id"]) => void
|
||||
switch (nam) {
|
||||
case "用户": {
|
||||
t.pnam.parentElement?.remove()
|
||||
p = () => ({ nbr: t.nbr.value, adm1: t.adm1.value, adm2: t.adm2.value })
|
||||
r = usr
|
||||
break
|
||||
} case "社团": {
|
||||
t.nbr.parentElement?.remove()
|
||||
p = () => ({ snam: t.pnam.value, adm1: t.adm1.value, adm2: t.adm2.value })
|
||||
r = soc
|
||||
break
|
||||
} case "活动": {
|
||||
t.nbr.parentElement?.remove()
|
||||
p = () => ({ anam: t.pnam.value, adm1: t.adm1.value, adm2: t.adm2.value })
|
||||
r = agd
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
btn(t.pre, t.pre.innerText, {
|
||||
pos: () => pos<DocC<Id["_id"]>>("pre", p()),
|
||||
alert: `无效输入\n或${nam === "用户" ? "手机号" : "名称"}已被占用`,
|
||||
refresh: r,
|
||||
})
|
||||
t.cancel.addEventListener("click", () => usr(nav.pas!.uid))
|
||||
|
||||
main.append(t.bind)
|
||||
}
|
||||
|
||||
function put(
|
||||
@@ -169,8 +211,7 @@ function put(
|
||||
const pagd = () => ({
|
||||
account: t.account.value.trim(), budget: parseInt(t.budget.value),
|
||||
fund: parseInt(t.fund.value), expense: parseInt(t.expense.value)
|
||||
})
|
||||
// deno-lint-ignore no-explicit-any
|
||||
}) // deno-lint-ignore no-explicit-any
|
||||
let p: () => any[]
|
||||
let r
|
||||
switch (nam) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import type { DocU } from "../../src/db.ts"
|
||||
import { adm } from "../../src/ont/adm.ts"
|
||||
import { adm, adm1_def, adm2_def } from "../../src/ont/adm.ts"
|
||||
import { utc_medium } from "../../src/ont/utc.ts"
|
||||
import { Usr } from "./article.ts"
|
||||
import { nav } from "./nav.ts"
|
||||
@@ -129,8 +129,8 @@ export function rolref(
|
||||
|
||||
export function seladm(
|
||||
t: Section["seladm"],
|
||||
adm1 = "江苏",
|
||||
adm2 = "苏州"
|
||||
adm1 = adm1_def,
|
||||
adm2 = adm2_def,
|
||||
) {
|
||||
selopt(t.adm1, adm.keys())
|
||||
t.adm1.value = adm1
|
||||
@@ -149,5 +149,5 @@ export function pro(
|
||||
const [rej, ref] = [d.rej.includes(nav.pas.uid), d.ref.includes(nav.pas.uid)]
|
||||
const p = (re: "rej" | "ref", add: boolean) => pos<DocU>("pro", { re, [id]: d._id, add })
|
||||
btn(t.prorej, rej ? "取消反对" : "反对", refresh ? { pos: () => p("rej", !rej), refresh } : undefined)
|
||||
btn(t.proref, rej ? "取消推荐" : "推荐", refresh ? { pos: () => p("ref", !ref), refresh } : undefined)
|
||||
btn(t.proref, ref ? "取消推荐" : "推荐", refresh ? { pos: () => p("ref", !ref), refresh } : undefined)
|
||||
}
|
||||
|
@@ -69,6 +69,14 @@ const template = {
|
||||
...section.pro,
|
||||
},
|
||||
|
||||
pre: {
|
||||
tid: "pre" as const,
|
||||
...section.idnam,
|
||||
nbr: t("input"), pnam: t("input"),
|
||||
...section.seladm,
|
||||
pre: t("button"), cancel: t("button"),
|
||||
},
|
||||
|
||||
put: {
|
||||
tid: "put" as const,
|
||||
...section.idnam,
|
||||
|
@@ -97,6 +97,37 @@
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<template id="pre">
|
||||
<article>
|
||||
<section>
|
||||
<a class="idnam"><code class="id active"></code> <span class="nam"></span></a>
|
||||
</section>
|
||||
<hr>
|
||||
<section class="flex">
|
||||
<label>手机号:</label>
|
||||
<input class="nbr" type="text" inputmode="numeric" pattern="\d{11}" placeholder="十一位手机号(中国大陆)"
|
||||
minlength="11" maxlength="11" required />
|
||||
</section>
|
||||
<hr>
|
||||
<section class="flex">
|
||||
<label>名称:(2-16个中文字符)</label>
|
||||
<input class="pnam" type="text" maxlength="16" required />
|
||||
</section>
|
||||
<hr>
|
||||
<section class="flex adm">
|
||||
<label>地区:</label>
|
||||
<select class="adm1"></select>
|
||||
<select class="adm2"></select>
|
||||
</section>
|
||||
<hr>
|
||||
<section class="flex">
|
||||
<button class="pre">确认</button>
|
||||
<button class="cancel">取消</button>
|
||||
</section>
|
||||
<hr>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<template id="put">
|
||||
<article>
|
||||
<section>
|
||||
|
Reference in New Issue
Block a user