增加一個新的報名牌位編輯功能

This commit is contained in:
2026-04-07 18:04:08 +08:00
parent 36174834a8
commit 83a7c67439
7 changed files with 1085 additions and 47 deletions
+42 -14
View File
@@ -260,7 +260,6 @@
let pageSize = self.allSize.find(y => y.paperID == $("#paperSizeSel").val());
this.printData.forEach(x => {
console.log("x:", x)
let style = self.allStyle.find(y => y.styleID == x.style);
//用來印內容的尺寸
let size = self.allSize.find(y => y.paperID == style.paperSize);
@@ -271,7 +270,6 @@
let xCount = parseFloat(pageSize.width) / parseFloat(printSize.width);
let yCount = parseFloat(pageSize.height) / parseFloat(printSize.height);
let total = Math.floor(xCount) * Math.floor(yCount);
console.log(xCount, yCount, total);
//if ((nowPageWidth + parseFloat(printSize.width)) > pageSize.width) {
if (nowPageWidth >= total) {
//$(canvas).css("width", printSize.width + "mm");
@@ -305,7 +303,6 @@
let left_items = tablet.left_items;
let details = this.allStyleDetails.filter(y => y.styleID == x.style);
console.log("details:", details);
let mid = [];
mid_items.forEach(y => {
mid.push(y.fam_name);
@@ -316,7 +313,7 @@
left.push(y.fam_name);
});
}
let ancestorFontSize = 16;
details.forEach(d => {
if (d.isActive != "hidden") {
let newFontSize = self.scaleFontSize(mid, d.fontSize, d.width);
@@ -347,7 +344,6 @@
mid.forEach(z => {
let info = self.getTextInfo(z, newFontSize);
let spanWidth = mid.length > 1 ? newFontSize : d.width
console.log("spanWidth:", spanWidth);
let height = d.textHeight;
if (info.width >= d.textHeight) {
height = d.height;
@@ -363,6 +359,7 @@
"margin-bottom": "20px",
"margin-left": "5px",
"text-justify": "inter-character",
"white-space": "pre-line",
//"justify-content":"center"
});
$namelist.append($span);
@@ -375,6 +372,13 @@
newFontSize = d.fontSize;
} else if (d.elementID === "titletriangle") {
html = self.renderRoster(mid, d)
} else if (d.elementID === "combined") {
ancestorFontSize = d.fontSize;
const parts =mid.join("\n").split('\n');
html = `<div class="ancestor-wrapper" style="width:${d.width}px !important;height:${d.height}px !important;" >
<span class="main-name" >${parts[0] || ''}</span>
<span class="sub-text">${parts[1] || ''}</span>
</div>`;
}
if (newFontSize < 10) {
newFontSize = 10;
@@ -520,7 +524,7 @@
display: flex;
flex-direction: column;
align-items: center; /* 水平置中 */
justify-content: center;
justify-content: felx-start;
width: fit-content;
}
@@ -530,7 +534,7 @@
}
.sub-text {
font-size: 0.6em; /* 縮小字體 */
font-size: ${ancestorFontSize}px ;/*0.8em;*/ /* 縮小字體 */
line-height: 1.2;
margin-top: 4px; /* 與上方林張的間距 */
white-space: normal; /* 避免自動換行 */
@@ -613,16 +617,18 @@
let textWidth;//= $(this).css("width");//find("span").first().css("width");
let textHeight; //= $(this).css("height");
if ($(this).find(".nameList").first()) {
if ($(this).find(".nameList").first().hasClass("nameList")) {
textWidth = $(this).find(".nameList").first().css("width");
textHeight = $(this).find(".nameList").first().css("height");
} else if ($(this).find(".liveList").first()) {
} else if ($(this).find(".liveList").first().hasClass("liveList")) {
textWidth = $(this).find(".liveList").first().css("width");
textHeight = $(this).find(".liveList").first().css("height");
} else if ($(this).find(".rosterList").first()) {
} else if ($(this).find(".rosterList").first().hasClass("rosterList")) {
textWidth = $(this).find(".rosterList").first().css("width");
textHeight = $(this).find(".rosterList").first().css("height");
} else if ($(this).find(".ancestor-wrapper").first().hasClass("ancestor-wrapper")) {
textWidth = $(this).find(".ancestor-wrapper").first().css("width");
textHeight = $(this).find(".ancestor-wrapper").first().css("height");
}
let left = $(this).css("left");
@@ -638,6 +644,10 @@
$("#textX").prop("readonly", false);
$("#textY").prop("readonly", false);
$("#fontSize").prop("readonly", false);
$("#textWidth").prop("readonly", false);
$("#textHeight").prop("readonly", false);
$("#textBreakCount").prop("readonly", true);
$("#textBreakWord").prop("readonly", true);
});
$(".tablet-element span").on("click", function (e) {
@@ -647,6 +657,13 @@
let fontFamily = $(this).css("font-family");
let textWidth = $(this).css("max-width");
let textHeight = $(this).css("min-height");
if ($(this).hasClass("liveSpan")) {
textWidth = $(this).css("width");
} else if ($(this).hasClass("main-name") || $(this).hasClass("sub-text")) {
textWidth = "";
textHeight = "";
}
let left = $(this).css("left");
let top = $(this).css("top");
left = left.replace("px", "");
@@ -661,6 +678,16 @@
$("#textX").prop("readonly", true);
$("#textY").prop("readonly", true);
$("#fontSize").prop("readonly", true);
$("#textBreakCount").prop("readonly", false);
$("#textBreakWord").prop("readonly", false);
} else if ($(this).hasClass("main-name") || $(this).hasClass("sub-text")) {
$("#textX").prop("readonly", true);
$("#textY").prop("readonly", true);
$("#fontSize").prop("readonly", true);
$("#textBreakCount").prop("readonly", true);
$("#textBreakWord").prop("readonly", true);
$("#textWidth").prop("readonly", true);
$("#textHeight").prop("readonly", true);
}
});
@@ -704,6 +731,7 @@
"text-align-last": "justify",
"margin-bottom": "10px",
"text-justify": "inter-character",
"white-space": "pre-line"
});
},
// 品字佈局邏輯:一上二下
@@ -734,6 +762,7 @@
"flex-direction": "column",
"justify-content": "center",
"height": el.textHeight,
"white-space": "pre-line"
})
items.forEach(x => {
g.append($(`<div class="" style="font-size:${el.fontSize}pt;letter-spacing: 10px;">${x}</div>`))
@@ -782,7 +811,6 @@
//if (dStyle.elementID === 'title1') {//表示是一般正名,也就是牌位正中間的一般格式,排法是上下上下
if ((Math.ceil(txtContent.length / 2) * font.width) * 2 > parseFloat(elementWidth)) {
let newfontSize = parseInt(fontSize) - 1;
console.log("newfontSize:", newfontSize);
if (newfontSize <= 8) {
return newfontSize;
}
@@ -836,7 +864,7 @@
} else if (this.selected.hasClass("liveSpan")) {
let spans = $(this.selected.parent().first()).find(".liveSpan");
spans.each(function (index, x) {
$(x).css("max-width", $("#textWidth").val());
$(x).css("width", $("#textWidth").val());
});
} else if (this.selected.hasClass("rosterSpan")) {
let spans = $(this.selected.parent().first()).find(".rosterSpan");
@@ -860,13 +888,13 @@
} else if (this.selected.hasClass("nameSpan")) {
let spans = $(this.selected.parent().first()).find(".nameSpan");
spans.each(function (index, x) {
console.log($(x))
$(x).css("min-height", $("#textHeight").val());
});
} else if (this.selected.hasClass("liveSpan")) {
let spans = $(this.selected.parent().first()).find(".liveSpan");
spans.each(function (index, x) {
$(x).css("min-height", $("#textHeight").val());
$(x).css("height", $("#textHeight").val());
});
} else if (this.selected.hasClass("rosterSpan")) {
let spans = $(this.selected.parent().first()).find(".rosterSpan");