|
|
|
@@ -65,18 +65,18 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { Toast } from "tdesign-mobile-vue";
|
|
|
|
|
import {
|
|
|
|
|
calculateManagementQrCodeGrid,
|
|
|
|
|
downloadManagementQrCodeImages,
|
|
|
|
|
printManagementQrCodeImages,
|
|
|
|
|
splitManagementQrCodePages
|
|
|
|
|
} from "@/utils/managementQrCode";
|
|
|
|
|
calculateQrCodeGrid,
|
|
|
|
|
downloadQrCodeImages,
|
|
|
|
|
printQrCodeImages,
|
|
|
|
|
splitQrCodePages
|
|
|
|
|
} from "@/utils/qrCode";
|
|
|
|
|
import { permissionCodes } from "@/utils/permission";
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: "ManagementQrCode"
|
|
|
|
|
name: "CustomerQrCode"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface ManagementQrCodeFormModel {
|
|
|
|
|
interface QrCodeFormModel {
|
|
|
|
|
prefix: string;
|
|
|
|
|
start: string;
|
|
|
|
|
digits: number;
|
|
|
|
@@ -88,7 +88,7 @@ const maxDigits = 16;
|
|
|
|
|
const defaultDigits = 3;
|
|
|
|
|
const storageKey = "management-qr-code-config";
|
|
|
|
|
|
|
|
|
|
const formModel = reactive<ManagementQrCodeFormModel>({
|
|
|
|
|
const formModel = reactive<QrCodeFormModel>({
|
|
|
|
|
prefix: "GAO",
|
|
|
|
|
start: "1",
|
|
|
|
|
digits: defaultDigits,
|
|
|
|
@@ -110,9 +110,9 @@ const codeList = computed(() => {
|
|
|
|
|
const startMinDigits = computed(() => Math.max(minDigits, Math.min(maxDigits, normalizeNumber(formModel.start).length || minDigits)));
|
|
|
|
|
const effectiveDigits = computed(() => Math.max(startMinDigits.value, Math.min(maxDigits, formModel.digits || defaultDigits)));
|
|
|
|
|
const maxCodeLength = computed(() => formModel.prefix.length + effectiveDigits.value);
|
|
|
|
|
const previewPages = computed(() => splitManagementQrCodePages(codeList.value, maxCodeLength.value));
|
|
|
|
|
const previewPages = computed(() => splitQrCodePages(codeList.value, maxCodeLength.value));
|
|
|
|
|
const visiblePreviewPages = computed(() => previewPages.value.slice(0, 1));
|
|
|
|
|
const paperGrid = computed(() => calculateManagementQrCodeGrid(maxCodeLength.value));
|
|
|
|
|
const paperGrid = computed(() => calculateQrCodeGrid(maxCodeLength.value));
|
|
|
|
|
const paperStyle = computed(() => ({
|
|
|
|
|
gridTemplateRows: `repeat(${paperGrid.value.rows}, minmax(0, 1fr))`,
|
|
|
|
|
gridTemplateColumns: `repeat(${paperGrid.value.columns}, minmax(0, 1fr))`
|
|
|
|
@@ -144,7 +144,7 @@ function loadLocalConfig(): void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const config = JSON.parse(cache) as Partial<ManagementQrCodeFormModel>;
|
|
|
|
|
const config = JSON.parse(cache) as Partial<QrCodeFormModel>;
|
|
|
|
|
const start = normalizeNumber(config.start);
|
|
|
|
|
const startDigits = Math.max(minDigits, Math.min(maxDigits, start.length || minDigits));
|
|
|
|
|
|
|
|
|
@@ -197,7 +197,7 @@ async function downloadImages(): Promise<void> {
|
|
|
|
|
downloading.value = true;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await downloadManagementQrCodeImages({
|
|
|
|
|
await downloadQrCodeImages({
|
|
|
|
|
codes: codeList.value,
|
|
|
|
|
filePrefix: `${finalStartCode.value}-${finalEndCode.value}`,
|
|
|
|
|
maxCodeLength: maxCodeLength.value
|
|
|
|
@@ -214,7 +214,7 @@ async function printQrCode(): Promise<void> {
|
|
|
|
|
|
|
|
|
|
printing.value = true;
|
|
|
|
|
try {
|
|
|
|
|
await printManagementQrCodeImages({
|
|
|
|
|
await printQrCodeImages({
|
|
|
|
|
codes: codeList.value,
|
|
|
|
|
maxCodeLength: maxCodeLength.value,
|
|
|
|
|
title: `${finalStartCode.value}-${finalEndCode.value}`
|