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.
 
 
 
 
 
 

103 lines
10 KiB

import { defineComponent, ref, reactive, mergeProps, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderStyle, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrInterpolate } from 'vue/server-renderer';
import { u as useApi } from './useApi-B-E5eLsI.mjs';
import { u as useToast } from './useToast-CS21XT61.mjs';
import './server.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';
import './useLoading-D4zrSa2m.mjs';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "code",
__ssrInlineRender: true,
setup(__props) {
useApi();
useToast();
const view = ref("list");
const loading = ref(false);
const isEditing = ref(false);
const currentBrandId = ref(0);
const filterStatus = ref(-1);
const codes = ref([]);
const brands = ref([]);
const allProducts = ref([]);
const brandMap = reactive({});
const form = reactive({
code: "",
productid: 0,
remark: "",
bindrewardvpitime: 0,
bindrewardtranslate: 0,
bindrewardmeeting: 0,
maxuses: 0,
expire: "",
disabled: false
});
function formatTs(ts) {
if (!ts) return "永久";
return new Date(ts * 1e3).toLocaleString();
}
function facName(c) {
return brandMap[c.brandid] || (c.brandid ? "品牌商#" + c.brandid : "-");
}
function prodName(c) {
const prod = allProducts.value.find((p) => p.id === c.productid);
return prod ? prod.devicename || "#" + c.productid : c.productid ? "#" + c.productid : "-";
}
ref(null);
ref(null);
const currentQrCode = ref("");
return (_ctx, _push, _parent, _attrs) => {
_push(`<div${ssrRenderAttrs(mergeProps({ class: "space-y-6" }, _attrs))}><div class="bg-white rounded-xl shadow-sm border border-slate-100 p-4"><div class="flex items-end gap-3 flex-wrap"><div class="form-control"><label class="label py-1"><span class="label-text text-xs">品牌商</span></label><select class="select select-bordered select-sm" style="${ssrRenderStyle({ "min-width": "200px" })}"><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(currentBrandId.value) ? ssrLooseContain(currentBrandId.value, 0) : ssrLooseEqual(currentBrandId.value, 0)) ? " selected" : ""}>全部品牌商</option><!--[-->`);
ssrRenderList(brands.value, (b) => {
_push(`<option${ssrRenderAttr("value", b.id)}${ssrIncludeBooleanAttr(Array.isArray(currentBrandId.value) ? ssrLooseContain(currentBrandId.value, b.id) : ssrLooseEqual(currentBrandId.value, b.id)) ? " selected" : ""}>${ssrInterpolate(brandMap[b.id])}</option>`);
});
_push(`<!--]--></select></div><div class="form-control"><label class="label py-1"><span class="label-text text-xs">状态</span></label><select class="select select-bordered select-sm"><option${ssrRenderAttr("value", -1)}${ssrIncludeBooleanAttr(Array.isArray(filterStatus.value) ? ssrLooseContain(filterStatus.value, -1) : ssrLooseEqual(filterStatus.value, -1)) ? " selected" : ""}>全部</option><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(filterStatus.value) ? ssrLooseContain(filterStatus.value, 0) : ssrLooseEqual(filterStatus.value, 0)) ? " selected" : ""}>启用</option><option${ssrRenderAttr("value", 1)}${ssrIncludeBooleanAttr(Array.isArray(filterStatus.value) ? ssrLooseContain(filterStatus.value, 1) : ssrLooseEqual(filterStatus.value, 1)) ? " selected" : ""}>停用</option></select></div><button class="btn btn-primary btn-sm text-white" title="新增公码需先选择具体品牌商"${ssrIncludeBooleanAttr(currentBrandId.value === 0) ? " disabled" : ""}>+ 新增公码</button></div></div><div style="${ssrRenderStyle(view.value === "list" ? null : { display: "none" })}"><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>公码</th><th>品牌商</th><th>关联产品</th><th>备注</th><th>VIP天/翻译分/会议分</th><th>核销/上限</th><th>失效时间</th><th>状态</th><th>操作</th></tr></thead><tbody>`);
if (loading.value) {
_push(`<tr><td colspan="9" class="text-center text-slate-400 py-8">加载中…</td></tr>`);
} else if (!codes.value.length) {
_push(`<tr><td colspan="9" class="text-center text-slate-400 py-8">${ssrInterpolate(currentBrandId.value ? "暂无公码,点击右上角“新增公码”创建" : "暂无公码")}</td></tr>`);
} else {
_push(`<!---->`);
}
_push(`<!--[-->`);
ssrRenderList(codes.value, (c) => {
_push(`<tr><td class="font-mono text-base font-bold text-indigo-700">${ssrInterpolate(c.code || "")}</td><td class="text-sm">${ssrInterpolate(facName(c))}</td><td class="text-sm">${ssrInterpolate(prodName(c))}</td><td class="text-sm text-slate-500">${ssrInterpolate(c.remark || "-")}</td><td class="text-sm">${ssrInterpolate(c.bindrewardvpitime || 0)} / ${ssrInterpolate(c.bindrewardtranslate || 0)} / ${ssrInterpolate(c.bindrewardmeeting || 0)}</td><td class="text-sm">${ssrInterpolate(c.useduses || 0)} / ${ssrInterpolate(c.maxuses ? c.maxuses : "∞")}</td><td class="text-sm">${ssrInterpolate(formatTs(c.expiretime))}</td><td>`);
if (c.status === 0) {
_push(`<span class="badge badge-success badge-sm text-white">启用</span>`);
} else {
_push(`<span class="badge badge-ghost badge-sm">停用</span>`);
}
_push(`</td><td><div class="flex gap-1"><button class="btn btn-ghost btn-xs text-indigo-600">二维码</button><button class="btn btn-ghost btn-xs">编辑</button><button class="btn btn-ghost btn-xs text-amber-600">${ssrInterpolate(c.status === 0 ? "停用" : "启用")}</button><button class="btn btn-ghost btn-xs text-red-500">删除</button></div></td></tr>`);
});
_push(`<!--]--></tbody></table></div></div></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 ? `编辑公码 ${form.code}` : "新增公码")}</h2></div><div class="bg-white rounded-xl shadow-sm border border-slate-100 p-6 max-w-2xl"><form><div class="form-control mb-4"><label class="label"><span class="label-text font-medium">关联产品(选填,仅作分类)</span></label><select class="select select-bordered w-full"><option${ssrRenderAttr("value", 0)}${ssrIncludeBooleanAttr(Array.isArray(form.productid) ? ssrLooseContain(form.productid, 0) : ssrLooseEqual(form.productid, 0)) ? " selected" : ""}>不关联</option><!--[-->`);
ssrRenderList(allProducts.value, (p) => {
_push(`<option${ssrRenderAttr("value", p.id)}${ssrIncludeBooleanAttr(Array.isArray(form.productid) ? ssrLooseContain(form.productid, p.id) : ssrLooseEqual(form.productid, p.id)) ? " selected" : ""}>${ssrInterpolate(p.devicename || "#" + p.id)}</option>`);
});
_push(`<!--]--></select></div><div class="form-control mb-4"><label class="label"><span class="label-text font-medium">备注</span></label><input${ssrRenderAttr("value", form.remark)} type="text" class="input input-bordered w-full" placeholder="例如:包装海报-2026春季"></div><div class="grid grid-cols-3 gap-3 mb-4"><div class="form-control"><label class="label"><span class="label-text font-medium">奖励VIP天数</span></label><input${ssrRenderAttr("value", form.bindrewardvpitime)} type="number" min="0" class="input input-bordered"></div><div class="form-control"><label class="label"><span class="label-text font-medium">奖励翻译分钟</span></label><input${ssrRenderAttr("value", form.bindrewardtranslate)} type="number" min="0" class="input input-bordered"></div><div class="form-control"><label class="label"><span class="label-text font-medium">奖励会议分钟</span></label><input${ssrRenderAttr("value", form.bindrewardmeeting)} type="number" min="0" class="input input-bordered"></div></div><div class="grid grid-cols-2 gap-3 mb-4"><div class="form-control"><label class="label"><span class="label-text font-medium">最大核销人数(0=不限)</span></label><input${ssrRenderAttr("value", form.maxuses)} type="number" min="0" class="input input-bordered"></div><div class="form-control"><label class="label"><span class="label-text font-medium">失效时间(留空=永久)</span></label><input${ssrRenderAttr("value", form.expire)} type="datetime-local" class="input input-bordered"></div></div><div class="form-control mb-6" style="${ssrRenderStyle(isEditing.value ? null : { display: "none" })}"><label class="label cursor-pointer justify-start gap-3"><input${ssrIncludeBooleanAttr(Array.isArray(form.disabled) ? ssrLooseContain(form.disabled, null) : form.disabled) ? " checked" : ""} type="checkbox" class="checkbox"><span class="label-text font-medium">停用</span></label></div><div class="flex gap-3"><button type="button" class="btn btn-ghost">取消</button><button type="submit" class="btn btn-primary text-white">保存</button></div></form></div></div><dialog class="modal"><div class="modal-box max-w-md"><h3 class="font-bold text-lg mb-4 text-slate-800">公码二维码</h3><div class="flex flex-col items-center gap-4"><div class="p-3 bg-white border border-slate-200 rounded-lg"></div><div class="text-center"><div class="text-xs text-slate-500 mb-1">公码</div><div class="font-mono text-2xl font-bold text-indigo-700 tracking-widest">${ssrInterpolate(currentQrCode.value)}</div></div><div class="text-xs text-slate-400 text-center"> 新用户使用 App 扫描即可领取奖励,每人仅可领取 1 次 </div></div><div class="modal-action"><button type="button" class="btn btn-outline btn-sm">下载图片</button><button type="button" class="btn btn-outline btn-sm">打印</button><form method="dialog"><button class="btn btn-sm">关闭</button></form></div></div><form method="dialog" class="modal-backdrop"><button>close</button></form></dialog></div>`);
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/code.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export { _sfc_main as default };
//# sourceMappingURL=code-BZlgiQix.mjs.map