import { defineComponent, computed, ref, reactive, mergeProps, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderClass, 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 { 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: "device", __ssrInlineRender: true, setup(__props) { useApi(); useToast(); const auth = useAuthStore(); const isSuperAdmin = computed(() => auth.identity === 1); const canCreate = computed(() => auth.identity > 0 && auth.identity <= 2); const tab = ref("codes"); const brands = ref([]); const products = ref([]); const allProducts = ref([]); const notes = ref([]); const devices = ref([]); const devTotal = ref(0); const devPage = ref(0); const devPageSize = ref(200); const filterBrand = ref(0); const filterProduct = ref(0); const filterStart = ref(""); const filterEnd = ref(""); const statBatch = ref("-"); const statDevices = ref("-"); const statLast = ref("-"); const notesCountText = ref(""); const notesLoading = ref(false); const notesError = ref(""); const codeStatus = ref("0"); const codeSort = ref("createtime"); const codeBatch = ref(""); const codeCode = ref(""); const codeMac = ref(""); const codeUid = ref(""); const codePageSizeSel = ref("200"); const codePageSizeCustom = ref(null); const devicesError = ref(""); const selectAll = ref(false); const selectedCodes = ref([]); const selectedCount = computed(() => selectedCodes.value.length); ref(null); ref(null); ref(null); const createMode = ref("production"); const cBrand = ref(0); const cProduct = ref(0); const cBindmac = ref(false); const cNumber = ref(null); const cMacaddresses = ref(""); const cRemark = ref(""); const submitting = ref(false); const previewLoading = ref(false); const preview = ref(null); ref(null); const csvFileName = ref(""); ref(null); const emailSending = ref(false); const email = reactive({ to: "", cc: "", subject: "", content: "" }); ref(null); const revokeCtx = ref(null); const revokeConfirmInput = ref(""); const revokeError = ref(""); const revokeSubmitting = ref(false); const revokeConfirmTarget = computed(() => revokeCtx.value ? revokeCtx.value.batchno : ""); const revokeConfirmOk = computed(() => !!revokeCtx.value && revokeConfirmInput.value.trim() === revokeConfirmTarget.value); const totalPages = computed(() => Math.max(1, Math.ceil(devTotal.value / devPageSize.value))); const pgInfoText = computed(() => filterProduct.value ? "第 " + (devPage.value + 1) + " / " + totalPages.value + " 页" : "-"); const filterProductOptions = computed(() => { return filterBrand.value ? products.value.filter((p) => p.brandid === filterBrand.value) : products.value; }); const createProductOptions = computed(() => { return cBrand.value ? products.value.filter((p) => p.brandid === cBrand.value) : []; }); const createProductInfo = computed(() => { const p = allProducts.value.find((x) => x.id === cProduct.value); const codeCount = p?.devicecodecount && p.devicecodecount > 0 ? p.devicecodecount : 1; return { isClassicBT: p?.devicetype === 1, codeCount }; }); const createFinalTotal = computed(() => (Number(cNumber.value) || 0) * createProductInfo.value.codeCount); const importMacCount = computed(() => cMacaddresses.value.split(",").map((s) => s.trim()).filter(Boolean).length); const previewCid = computed(() => { if (!preview.value) return "N/A"; const b = brands.value.find((x) => x.id === preview.value.brandid); return b && b.providerid != null ? Number(b.providerid).toString(16).padStart(4, "0").toUpperCase() : "N/A"; }); function fmtTime(ts) { if (!ts) return "-"; const d = new Date(ts * 1e3); return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0") + " " + String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0"); } function nameOfBrand(id) { const b = brands.value.find((x) => x.id === id); return b ? b.brand : String(id || ""); } function nameOfProduct(id) { const p = allProducts.value.find((x) => x.id === id); return p ? p.devicename : String(id || ""); } function hexId(id) { return id ? Number(id).toString(16).toUpperCase() : ""; } function serialRange(n) { const a = n.serialstart != null && n.serialstart !== "" ? String(n.serialstart) : ""; const b = n.serialend != null && n.serialend !== "" ? String(n.serialend) : ""; if (!a && !b) return "-"; return a + " - " + b; } function codeState(d) { if (d.disabled !== 0) return { label: "已禁用", dot: "bg-red-500", text: "text-red-600" }; if (d.status === 1) return { label: "已激活", dot: "bg-emerald-500", text: "text-emerald-600" }; if (d.status === 2) return { label: "已过期", dot: "bg-amber-500", text: "text-amber-600" }; return { label: "未使用", dot: "bg-slate-300", text: "text-slate-500" }; } return (_ctx, _push, _parent, _attrs) => { _push(`
| 授权码 | 批次 | MAC地址 | 用户UID | 激活时间 | 状态 | 操作 | |
|---|---|---|---|---|---|---|---|
| 请先选择产品 | |||||||
| 查询失败: ${ssrInterpolate(devicesError.value)} | |||||||
| 暂无数据 | |||||||
| ${ssrInterpolate(d.code || "")} | ${ssrInterpolate(d.batchno || "")} | ${ssrInterpolate(d.devicemac || "-")} | ${ssrInterpolate(d.uid || "-")} | ${ssrInterpolate(d.usedtime ? fmtTime(d.usedtime) : "-")} | ${ssrInterpolate(codeState(d).label)} | `);
if (d.disabled !== 0) {
_push(``);
} else {
_push(``);
}
if (d.status !== 0) {
_push(``);
} else {
_push(``);
}
_push(` | |
| 生产时间 | 品牌商 | 产品 | 批次号 | 序号区间 | 起始MAC | 结束MAC | 数量 | 操作 |
|---|---|---|---|---|---|---|---|---|
| 加载中… | ||||||||
| 查询失败: ${ssrInterpolate(notesError.value)} | ||||||||
| 暂无数据 | ||||||||
| ${ssrInterpolate(fmtTime(n.ts))} | ${ssrInterpolate(nameOfBrand(n.brandid))} | ${ssrInterpolate(nameOfProduct(n.productid))} | ${ssrInterpolate(n.batchno || "")} | ${ssrInterpolate(serialRange(n))} | ${ssrInterpolate(n.startmac || "")} | ${ssrInterpolate(n.endmac || "")} | ${ssrInterpolate(n.devicenum || 0)} | `);
if (isSuperAdmin.value) {
_push(``);
} else {
_push(``);
}
_push(` |
生产流程:填写生产表单 → 系统按产品类型计算最终授权码数量并预分配批次号 → 二次确认生产方案(品牌商 / 产品ID / 批次号 / 数量 / MAC区间)→ 提交服务端生产 → 发送生产通知邮件。