You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
13 KiB
190 lines
13 KiB
import { defineComponent, computed, ref, reactive, unref, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrRenderStyle, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrInterpolate, ssrRenderClass } from 'vue/server-renderer';
|
|
import { u as useApi } from './useApi-B-E5eLsI.mjs';
|
|
import { u as useToast } from './useToast-CS21XT61.mjs';
|
|
import { a as useAuthStore } from './server.mjs';
|
|
import './useLoading-D4zrSa2m.mjs';
|
|
import '../nitro/nitro.mjs';
|
|
import 'node:http';
|
|
import 'node:https';
|
|
import 'node:events';
|
|
import 'node:buffer';
|
|
import 'node:fs';
|
|
import 'node:path';
|
|
import 'node:crypto';
|
|
import 'node:url';
|
|
import '../routes/renderer.mjs';
|
|
import 'vue-bundle-renderer/runtime';
|
|
import 'unhead/server';
|
|
import 'devalue';
|
|
import 'unhead/utils';
|
|
import 'pinia';
|
|
import 'perfect-debounce';
|
|
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "dealers",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
useApi();
|
|
useToast();
|
|
const auth = useAuthStore();
|
|
const canAudit = computed(() => auth.isAdmin);
|
|
const view = ref("list");
|
|
const rows = ref([]);
|
|
const brands = ref([]);
|
|
const loading = ref(false);
|
|
const submitting = ref(false);
|
|
const isEditing = ref(false);
|
|
const filters = reactive({ brandid: 0, status: -1, keyword: "" });
|
|
const form = reactive({ id: "", name: "", brandid: 0, sharepct: 0, contact: "", contactmails: "", remark: "" });
|
|
const STATUS_LABELS = { 0: "待审核", 1: "启用", 2: "停用", 3: "驳回" };
|
|
const STATUS_CLASS = {
|
|
0: "badge-warning",
|
|
1: "badge-success",
|
|
2: "badge-ghost",
|
|
3: "badge-error"
|
|
};
|
|
function statusLabel(s) {
|
|
return STATUS_LABELS[s] ?? String(s);
|
|
}
|
|
function statusClass(s) {
|
|
return STATUS_CLASS[s] ?? "badge-ghost";
|
|
}
|
|
function ratePct(rate) {
|
|
return ((Number(rate) || 0) / 100).toFixed(2) + "%";
|
|
}
|
|
function brandName(id) {
|
|
const b = brands.value.find((x) => x.id === id);
|
|
return b ? b.brand : id ? "品牌商#" + Number(id).toString(16).toUpperCase() : "-";
|
|
}
|
|
function fmtTime(ts) {
|
|
if (!ts) return "-";
|
|
const d = new Date(ts * 1e3);
|
|
const p = (n) => ("0" + n).slice(-2);
|
|
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(_attrs)}><div style="${ssrRenderStyle(view.value === "list" ? null : { display: "none" })}"><div class="flex items-center justify-between mb-5"><h2 class="text-lg font-semibold text-slate-800">渠道商列表</h2>`);
|
|
if (!unref(auth).isDealer) {
|
|
_push(`<button class="btn btn-primary btn-sm text-white">+ 新增渠道商</button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div><div class="bg-white rounded-xl shadow-sm border border-slate-100 p-4 mb-4"><div class="flex flex-wrap items-end gap-3">`);
|
|
if (!unref(auth).isBrandAccount && !unref(auth).isDealer) {
|
|
_push(`<div class="form-control"><label class="label py-1"><span class="label-text text-xs text-slate-500">品牌商</span></label><select class="select select-bordered select-sm w-48"><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(filters.brandid) ? ssrLooseContain(filters.brandid, 0) : ssrLooseEqual(filters.brandid, 0)) ? " selected" : ""}>全部品牌商</option><!--[-->`);
|
|
ssrRenderList(brands.value, (b) => {
|
|
_push(`<option${ssrRenderAttr("value", b.id)}${ssrIncludeBooleanAttr(Array.isArray(filters.brandid) ? ssrLooseContain(filters.brandid, b.id) : ssrLooseEqual(filters.brandid, b.id)) ? " selected" : ""}>${ssrInterpolate(b.brand)}</option>`);
|
|
});
|
|
_push(`<!--]--></select></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="form-control"><label class="label py-1"><span class="label-text text-xs text-slate-500">状态</span></label><select class="select select-bordered select-sm w-36"><option${ssrRenderAttr("value", -1)}${ssrIncludeBooleanAttr(Array.isArray(filters.status) ? ssrLooseContain(filters.status, -1) : ssrLooseEqual(filters.status, -1)) ? " selected" : ""}>全部状态</option><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(filters.status) ? ssrLooseContain(filters.status, 0) : ssrLooseEqual(filters.status, 0)) ? " selected" : ""}>待审核</option><option${ssrRenderAttr("value", 1)}${ssrIncludeBooleanAttr(Array.isArray(filters.status) ? ssrLooseContain(filters.status, 1) : ssrLooseEqual(filters.status, 1)) ? " selected" : ""}>启用</option><option${ssrRenderAttr("value", 2)}${ssrIncludeBooleanAttr(Array.isArray(filters.status) ? ssrLooseContain(filters.status, 2) : ssrLooseEqual(filters.status, 2)) ? " selected" : ""}>停用</option><option${ssrRenderAttr("value", 3)}${ssrIncludeBooleanAttr(Array.isArray(filters.status) ? ssrLooseContain(filters.status, 3) : ssrLooseEqual(filters.status, 3)) ? " selected" : ""}>驳回</option></select></div><div class="form-control"><label class="label py-1"><span class="label-text text-xs text-slate-500">搜索</span></label><input${ssrRenderAttr("value", filters.keyword)} type="text" class="input input-bordered input-sm w-52" placeholder="名称 / 渠道商ID"></div><button class="btn btn-sm btn-primary text-white">查询</button><button class="btn btn-sm btn-ghost">重置</button></div></div><div class="bg-white rounded-xl shadow-sm border border-slate-100"><div class="overflow-x-auto"><table class="table table-zebra"><thead><tr><th>渠道商ID</th><th>名称</th><th>所属品牌商</th><th>分成比例</th><th>联系方式</th><th>状态</th><th>创建时间</th><th>操作</th></tr></thead><tbody>`);
|
|
if (loading.value) {
|
|
_push(`<tr><td colspan="8" class="text-center py-8"><span class="loading loading-spinner loading-sm"></span></td></tr>`);
|
|
} else if (!rows.value.length) {
|
|
_push(`<tr><td colspan="8" class="text-center text-slate-400 py-8">暂无数据</td></tr>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<!--[-->`);
|
|
ssrRenderList(rows.value, (ch) => {
|
|
_push(`<tr><td class="font-mono text-sm font-semibold">${ssrInterpolate(ch.id)}</td><td class="font-medium">${ssrInterpolate(ch.name)}</td><td><span class="badge badge-ghost badge-sm">${ssrInterpolate(brandName(ch.brandid))}</span></td><td class="text-sm">${ssrInterpolate(ratePct(ch.sharerate))}</td><td class="text-sm text-slate-500">`);
|
|
if (ch.contact) {
|
|
_push(`<div>${ssrInterpolate(ch.contact)}</div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (ch.contactmails) {
|
|
_push(`<div class="text-xs text-slate-400">${ssrInterpolate(ch.contactmails)}</div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (!ch.contact && !ch.contactmails) {
|
|
_push(`<span class="text-slate-300">-</span>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</td><td><span class="${ssrRenderClass([statusClass(ch.status), "badge badge-sm"])}">${ssrInterpolate(statusLabel(ch.status))}</span>`);
|
|
if (ch.status === 3 && ch.auditremark) {
|
|
_push(`<div class="text-xs text-slate-400 mt-1">${ssrInterpolate(ch.auditremark)}</div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</td><td class="text-sm text-slate-500">${ssrInterpolate(fmtTime(ch.createtime))}</td><td><div class="flex flex-wrap gap-1"><button class="btn btn-ghost btn-xs">编辑</button>`);
|
|
if (canAudit.value) {
|
|
_push(`<!--[-->`);
|
|
if (ch.status !== 1) {
|
|
_push(`<button class="btn btn-ghost btn-xs text-emerald-600">${ssrInterpolate(ch.status === 0 ? "通过" : "启用")}</button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (ch.status === 1) {
|
|
_push(`<button class="btn btn-ghost btn-xs text-amber-600">停用</button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (ch.status === 0) {
|
|
_push(`<button class="btn btn-ghost btn-xs text-red-500">驳回</button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
if (!unref(auth).isDealer) {
|
|
_push(`<button class="btn btn-ghost btn-xs text-red-500">删除</button>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div></td></tr>`);
|
|
});
|
|
_push(`<!--]--></tbody></table></div></div><p class="text-xs text-slate-400 mt-3">`);
|
|
if (unref(auth).isBrandAccount) {
|
|
_push(`<!--[--> 这里只显示贵品牌商名下的渠道商。新增后为「待审核」,需平台审核通过(状态=启用)才能用于生产授权码;分成比例由平台设置。 <!--]-->`);
|
|
} else {
|
|
_push(`<!--[--> 渠道商新增后需超管/管理员审核通过(状态=启用)才能用于生产授权码;已有生产批次的渠道商不能删除,只能停用。 <!--]-->`);
|
|
}
|
|
_push(`</p></div><div style="${ssrRenderStyle(view.value === "form" ? null : { display: "none" })}"><div class="flex items-center gap-3 mb-5"><button class="btn btn-ghost btn-sm">← 返回列表</button><h2 class="text-lg font-semibold text-slate-800">${ssrInterpolate(isEditing.value ? "编辑渠道商" : "新增渠道商")}</h2></div><div class="bg-white rounded-xl shadow-sm border border-slate-100 p-6 max-w-2xl"><form>`);
|
|
if (isEditing.value) {
|
|
_push(`<div class="form-control mb-4"><label class="label"><span class="label-text font-medium">渠道商ID</span></label><input${ssrRenderAttr("value", form.id)} type="text" class="input input-bordered w-full font-mono" disabled><span class="label-text-alt text-slate-400 mt-1">短码由系统生成,创建后不可修改</span></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="form-control mb-4"><label class="label"><span class="label-text font-medium">渠道商名称 *</span></label><input${ssrRenderAttr("value", form.name)} type="text" class="input input-bordered w-full" required></div>`);
|
|
if (!unref(auth).isBrandAccount) {
|
|
_push(`<div class="form-control mb-4"><label class="label"><span class="label-text font-medium">所属品牌商 *</span></label><select class="select select-bordered w-full"${ssrIncludeBooleanAttr(isEditing.value) ? " disabled" : ""} required><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(form.brandid) ? ssrLooseContain(form.brandid, 0) : ssrLooseEqual(form.brandid, 0)) ? " selected" : ""}>请选择品牌商</option><!--[-->`);
|
|
ssrRenderList(brands.value, (b) => {
|
|
_push(`<option${ssrRenderAttr("value", b.id)}${ssrIncludeBooleanAttr(Array.isArray(form.brandid) ? ssrLooseContain(form.brandid, b.id) : ssrLooseEqual(form.brandid, b.id)) ? " selected" : ""}>${ssrInterpolate(b.brand)}</option>`);
|
|
});
|
|
_push(`<!--]--></select>`);
|
|
if (isEditing.value) {
|
|
_push(`<span class="label-text-alt text-slate-400 mt-1">归属品牌商创建后不可修改</span>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<div class="form-control mb-4"><label class="label"><span class="label-text font-medium">分成比例(%)</span></label><input${ssrRenderAttr("value", form.sharepct)} type="number" step="0.01" min="0" max="100" class="input input-bordered w-full"${ssrIncludeBooleanAttr(!canAudit.value) ? " disabled" : ""}><span class="label-text-alt text-slate-400 mt-1"> 从所属品牌商的分成里再切;仅超管/管理员可设置。 </span></div><div class="form-control mb-4"><label class="label"><span class="label-text font-medium">联系人 / 电话</span></label><input${ssrRenderAttr("value", form.contact)} type="text" class="input input-bordered w-full"></div><div class="form-control mb-4"><label class="label"><span class="label-text font-medium">联系邮箱</span></label><input${ssrRenderAttr("value", form.contactmails)} type="text" class="input input-bordered w-full" placeholder="多个邮箱用逗号分隔"></div><div class="form-control mb-6"><label class="label"><span class="label-text font-medium">备注</span></label><textarea class="textarea textarea-bordered w-full" rows="3">${ssrInterpolate(form.remark)}</textarea></div><div class="flex gap-3"><button type="button" class="btn btn-ghost">取消</button><button type="submit" class="btn btn-primary text-white"${ssrIncludeBooleanAttr(submitting.value) ? " disabled" : ""}>保存</button></div>`);
|
|
if (!isEditing.value && !canAudit.value) {
|
|
_push(`<p class="text-xs text-amber-600 mt-3"> 提交后为「待审核」状态,须超管/管理员通过后才能用于生产。 </p>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</form></div></div></div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/dealers.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { _sfc_main as default };
|
|
//# sourceMappingURL=dealers-D0gf3N66.mjs.map
|
|
|