增加一個新的報名牌位編輯功能
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -0,0 +1,835 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link href="../../../js/bootstrap5/bootstrap.min.css" />
|
||||
<link href="../../item/jquery-ui/jquery-ui.min.css" />
|
||||
<link href="../../../js/vuetify.css" rel="stylesheet" />
|
||||
<link href="../../../js/mdi-font/css/materialdesignicons.min.css" rel="stylesheet" />
|
||||
<script src="../../../js/vue.min.js"></script>
|
||||
<script src="../../../js/vuetify.min.js"></script>
|
||||
<script src="../../../js/axios.min.js"></script>
|
||||
<script src="../../../js/bootstrap5/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="../../../js/jquery-4.0.0.min.js"></script>
|
||||
<script src="../../item/jquery-ui/jquery-ui.min.js"></script>
|
||||
<style>
|
||||
.div_border{
|
||||
border:1px solid black;
|
||||
}
|
||||
.work_space{
|
||||
min-height:90vh;
|
||||
min-width:90vw;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="d-flex full-home no-print" style="height: 100%;width:100%;">
|
||||
<div id="designArea" class="designArea" style="width: auto; height: auto">
|
||||
<div class="row mt-2">
|
||||
<div class="col-3">版型設定:
|
||||
<select id="styleSel" onchange="designer.changeStyle()">
|
||||
<option value="">請選擇版型</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row work_space">
|
||||
<div class="col-8 div_border printArea"></div>
|
||||
<div class="col-4 div_border"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const designer = {
|
||||
code: {
|
||||
style: []
|
||||
},
|
||||
selected: {
|
||||
style: ""
|
||||
},
|
||||
actitem: "",
|
||||
pageSize: "",
|
||||
defaultStyle: "",
|
||||
isAllSelected: false,
|
||||
dialog: false,
|
||||
addDialog: false, // 新增項目對話框
|
||||
addDialogType: '', // 'Y' 或 'N'
|
||||
newItemText: '', // 新增項目的文字
|
||||
noSpace: true, // 不加空格 checkbox(預設勾選)
|
||||
deleteDialog: false, // 確認刪除對話框
|
||||
deleteIndex: -1, // 要刪除的 index
|
||||
deleteType: '', // 'Y' 或 'N'
|
||||
deleteMemberName: '', // 要刪除的名稱(顯示用)
|
||||
phrases: [], // 常用片語
|
||||
familyMembers: [], // 親友名單
|
||||
tabletItem: {}, // 傳入的資料(信眾/牌位資訊)
|
||||
item: {},
|
||||
family_deceased_Y_selected: [], // 超渡/超薦/超冤名單
|
||||
family_deceased_N_selected: [], // 消災/陽上名單
|
||||
allStyle: [],
|
||||
allStyleDetails: [],
|
||||
allSize: [],
|
||||
tabletElement: [],
|
||||
http_host: "",
|
||||
printData: [],
|
||||
selectedElement: {},
|
||||
selectStyle: {},
|
||||
properTitle: [],//正名
|
||||
leftProperTitle: [],//左正名
|
||||
rightProperTitle: [],//右正名
|
||||
address: "",//地址
|
||||
alive:[],//陽上
|
||||
bg: [
|
||||
{ name: "黃1", path: "../../../admin/print/html/tablet-1_new.svg" },
|
||||
{ name: "黃2", path: "../../../admin/print/html/tablet-1B_new.svg" },
|
||||
{ name: "紅1", path: "../../../admin/print/html/tablet-2.svg" },
|
||||
{ name: "紅2", path: "../../../admin/print/html/tablet-2B.svg" }
|
||||
],
|
||||
async init() {
|
||||
// 載入常用片語
|
||||
fetch('phrases.json')
|
||||
.then(res => res.json())
|
||||
.then(data => { this.phrases = data; })
|
||||
.catch(err => console.error('載入 phrases.json 失敗:', err));
|
||||
|
||||
//// 監聽來自父頁面的消息
|
||||
//window.addEventListener('message', (event) => {
|
||||
// this.isAllSelected = false;
|
||||
// //console.log('editor.html - received message event');
|
||||
// //console.log('editor.html - event origin:', event.origin);
|
||||
// //console.log('editor.html - parent origin:', window.parent.location.origin);
|
||||
|
||||
// if (event.origin === window.parent.location.origin) {
|
||||
// //console.log('editor.html - origin check passed');
|
||||
// //console.log('editor.html - received data:', event.data);
|
||||
// const receivedData = event.data;
|
||||
// this.family_deceased_Y_selected = [];
|
||||
// this.family_deceased_N_selected = [];
|
||||
|
||||
// if (receivedData.tabletItem) {
|
||||
// //console.log('editor.html - updating tabletItem:', receivedData.tabletItem);
|
||||
// this.tabletItem = receivedData.tabletItem;
|
||||
// if (receivedData.familyMembers) {
|
||||
// this.familyMembers = receivedData.familyMembers; // 更新 familyMembers
|
||||
// //console.log("app mounted, window message: ", this.familyMembers, receivedData);
|
||||
// }
|
||||
// if (receivedData.tabletItem) {
|
||||
// this.tabletItem = receivedData.tabletItem;
|
||||
// }
|
||||
// //console.log("actitem:", receivedData.tabletItem.actitem_num_selected.val);
|
||||
// console.log("receivedData::", receivedData);
|
||||
// if (receivedData.tabletItem.style) {
|
||||
// this.selected.style = receivedData.tabletItem.style;
|
||||
// } else {
|
||||
// this.selected.style = "";
|
||||
// }
|
||||
// console.log("actitem:", receivedData.tabletItem.actitem_num_selected.val);
|
||||
// this.actitem = receivedData.tabletItem.actitem_num_selected.val;
|
||||
// //console.log("actitem:",receivedData.tabletItem.actitem_num_selected.val);
|
||||
// // 處理 f_num_tablet 資料
|
||||
// if (this.tabletItem.f_num_tablet) {
|
||||
// try {
|
||||
// const data = JSON.parse(this.tabletItem.f_num_tablet);
|
||||
|
||||
// if (this.item_type === 'B') {
|
||||
// // B類型:超渡、超薦等
|
||||
// this.family_deceased_Y_selected = data.mid_items || [];
|
||||
// this.family_deceased_N_selected = data.left_items || [];
|
||||
|
||||
// this.family_deceased_Y_selected.forEach(item => {
|
||||
// if (item.IsShuWen === undefined) {
|
||||
// //Vue.set(item, 'IsShuWen', false);
|
||||
// }
|
||||
// });
|
||||
// if (this.family_deceased_Y_selected.length > 0) {
|
||||
// this.isAllSelected = this.family_deceased_Y_selected.every(member => member.IsShuWen === true);
|
||||
// } else {
|
||||
// this.isAllSelected = false;
|
||||
// }
|
||||
|
||||
// } else {
|
||||
// // A類型:消災、陽上等
|
||||
// this.family_deceased_Y_selected = [];
|
||||
// this.family_deceased_N_selected = data.mid_items || [];
|
||||
|
||||
// this.family_deceased_N_selected.forEach(item => {
|
||||
// if (item.IsShuWen === undefined) {
|
||||
// //Vue.set(item, 'IsShuWen', false);
|
||||
// }
|
||||
// });
|
||||
// if (this.family_deceased_Y_selected.length > 0) {
|
||||
// this.isAllSelected = this.family_deceased_N_selected.every(member => member.IsShuWen === true);
|
||||
|
||||
// } else {
|
||||
// this.isAllSelected = false;
|
||||
// }
|
||||
// //console.log(this.family_deceased_N_selected)
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error('解析牌位資料時發生錯誤:', e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
//let HTTP_HOST = "<%=UrlHost()%>";
|
||||
//this.http_host = HTTP_HOST;
|
||||
|
||||
|
||||
},
|
||||
async getActItem() {
|
||||
axios
|
||||
.post('/api/tablet/GetActItem', { itemNum: this.actitem })
|
||||
.then(response => {
|
||||
|
||||
if (response.data.result == "Y" && response.data.data) {
|
||||
this.pageSize = response.data.data.pageSize;
|
||||
this.defaultStyle = response.data.data.defaultStyle;
|
||||
this.selected.style = response.data.data.defaultStyle;
|
||||
$("#styleSel").val(this.defaultStyle);
|
||||
|
||||
//this.getStyle();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
async getAllStyleDetails() {
|
||||
await axios
|
||||
.post( '/api/tablet/GetStyleDetailData', {})
|
||||
.then(response => {
|
||||
if (response.status == "200") {
|
||||
let data = response.data;
|
||||
if (data.result == "Y") {
|
||||
let details = data.data;
|
||||
this.allStyleDetails = details;
|
||||
//console.log(data.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
async getPaperSize() {
|
||||
let self = this
|
||||
await axios
|
||||
.post('/api/tablet/GetPaperSize', {})
|
||||
.then(response => {
|
||||
//if (response.result=="Y") {
|
||||
if (response.status == "200") {
|
||||
let data = response.data;
|
||||
this.allSize = data.data;
|
||||
//console.log(this.allSize);
|
||||
//if (this.allSize) {
|
||||
// this.allSize.forEach(x => {
|
||||
// $("#paperSizeSel").append(`<option value="${x.paperID}">${x.paperName}</option>`);
|
||||
// })
|
||||
|
||||
//}
|
||||
}
|
||||
//$("#paperSizeSel").val("0003");
|
||||
}
|
||||
)
|
||||
},
|
||||
async getTabletElement() {
|
||||
await axios
|
||||
.post('/api/tablet/GetTabletElement', {})
|
||||
.then(response => {
|
||||
//if (response.result=="Y") {
|
||||
if (response.status == "200") {
|
||||
let data = response.data;
|
||||
this.tabletElement = data.data;
|
||||
}
|
||||
});
|
||||
},
|
||||
async getTabletStyles() {
|
||||
await axios
|
||||
.post('/api/tablet/GetStyleData', {})
|
||||
.then(response => {
|
||||
if (response.status == "200") {
|
||||
let data = response.data;
|
||||
if (data.data) {
|
||||
data.data.forEach(x => {
|
||||
if (x.styleID !== "00001") {
|
||||
this.allStyle.push(x);
|
||||
$("#styleSel").append(`<option value="${x.styleID}">${x.name}</option`);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
async getData() {
|
||||
console.log("getData:", this.tabletItem)
|
||||
this.printData.length = 0;
|
||||
this.properTitle.length = 0
|
||||
this.alive.length = 0;
|
||||
//let list = localStorage.getItem("list")
|
||||
let param = [];
|
||||
let self = this;
|
||||
param.push({ order_no: this.tabletItem.order_no, num: this.tabletItem.num })
|
||||
await axios
|
||||
.post('/api/orderdetail/GetDetailToPrint', { param: param })
|
||||
.then(response => {
|
||||
|
||||
if (response.status == 200) {
|
||||
self.printData = response.data;
|
||||
self.printData.forEach(x => {
|
||||
self.selectStyle = x;
|
||||
let tablet = JSON.parse(x.f_num_tablet);
|
||||
|
||||
let mid_items = tablet.mid_items;
|
||||
let left_items = tablet.left_items;
|
||||
//let mid = [];
|
||||
mid_items.forEach(y => {
|
||||
self.properTitle.push(y.fam_name);
|
||||
});
|
||||
//let left = []
|
||||
if (left_items) {
|
||||
left_items.forEach(y => {
|
||||
self.alive.push(y.fam_name);
|
||||
});
|
||||
}
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
async render() {
|
||||
$("#printArea").empty();
|
||||
let self = this;
|
||||
let canvas = $(` <div class="canvas-area flex-grow-1 overflow-auto d-flex flex-row align-items-center position-relative" ></div>`)
|
||||
let nowPageWidth = 0;
|
||||
let tabletpaper;
|
||||
//列印紙張的尺寸
|
||||
|
||||
console.log("printData:", this.printData);
|
||||
let mid = [];
|
||||
Object.assign(mid, self.properTitle);
|
||||
let left = []
|
||||
Object.assign(left, self.alive);
|
||||
//this.printData.forEach(x => {
|
||||
let x = self.selectStyle;
|
||||
let style = self.allStyle.find(y => y.styleID == x.style);
|
||||
//用來印內容的尺寸
|
||||
let size = self.allSize.find(y => y.paperID == style.paperSize);
|
||||
let pageSize = self.allSize.find(y => y.paperID == style.printSize);
|
||||
//包含空白用來折的尺寸
|
||||
let printSize = self.allSize.find(y => y.paperID == style.printSize);
|
||||
|
||||
tabletpaper = $(` <div class="tablet-paper"></div>`)
|
||||
let img = self.bg.find(y => y.name == style.backendImg);
|
||||
let details = this.allStyleDetails.filter(y => y.styleID == x.style);
|
||||
console.log("details:", details);
|
||||
let ancestorFontSize = 16;
|
||||
details.forEach(d => {
|
||||
if (d.isActive != "hidden") {
|
||||
let element = self.tabletElement.find(y => y.elementID == d.elementID);
|
||||
//let newFontSize = self.scaleFontSize(d.sampleContent, d.fontSize, d.width);
|
||||
let newFontSize = 16;
|
||||
let html = "";
|
||||
let alive = "";
|
||||
let yang = "";
|
||||
let bi = "";
|
||||
|
||||
if (d.elementID === 'title1') {
|
||||
let $namelist = $(`<div class='nameList'></div>`).css({
|
||||
"writing-mode": "vertical rl",
|
||||
display: "flex",
|
||||
"flex-direction": "row",
|
||||
"flex-wrap": "wrap",
|
||||
margin: "auto",
|
||||
width: `${d.width}px`,
|
||||
height: `${d.height}px`,
|
||||
border: "0px solid #ccc",
|
||||
padding: "1px",
|
||||
"font-family": style.fontFamily,
|
||||
"letter-spacing": "0.1em",
|
||||
"column-gap": "1px",
|
||||
"row-gap": "1px",
|
||||
"align-items": "center",
|
||||
"justify-content": "space-between",
|
||||
});
|
||||
|
||||
mid.forEach(z => {
|
||||
let info = self.getTextInfo(z, newFontSize);
|
||||
let spanWidth = mid.length > 1 ? newFontSize : d.width
|
||||
let height = d.textHeight;
|
||||
if (info.width >= d.textHeight) {
|
||||
height = d.height;
|
||||
}
|
||||
let $span = $(`<span class="nameSpan">${z}</span>`).css({
|
||||
display: "block",
|
||||
"min-height": `${height}px`,
|
||||
"max-height": `${d.height}px`,
|
||||
"max-width": `${spanWidth}px`,
|
||||
//width: `${newFontSize}px`,
|
||||
"text-align": "justify",
|
||||
"text-align-last": "justify",
|
||||
"margin-bottom": "20px",
|
||||
"margin-left": "5px",
|
||||
"text-justify": "inter-character",
|
||||
"white-space": "pre-line",
|
||||
//"justify-content":"center"
|
||||
});
|
||||
$namelist.append($span);
|
||||
});
|
||||
|
||||
html = $namelist;
|
||||
} else if (d.elementID === "alive") {
|
||||
html = self.renderLiveList(left, d);
|
||||
|
||||
newFontSize = d.fontSize;
|
||||
} else if (d.elementID === "titletriangle") {
|
||||
html = self.renderRoster(mid, d)
|
||||
} else if (d.elementID === "combined") {
|
||||
ancestorFontSize = d.fontSize;
|
||||
newFontSize = 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;
|
||||
}
|
||||
let content = $(`<div class="tablet-element vertical-text ">${element.sampleContent}</div>`)
|
||||
.css({
|
||||
position: "absolute", left: d.startX + "mm", top: d.startY + "mm", fontSize: newFontSize + 'px',
|
||||
fontFamily: d.fontFamily, "font-weight": "bold", "z-index": 9999, visibility: d.isActive,
|
||||
"align-items": "center"
|
||||
|
||||
})
|
||||
.html(html);
|
||||
tabletpaper.append(content);
|
||||
html = "";
|
||||
alive = "";
|
||||
yang = "";
|
||||
bi = "";
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
self.pageStyle = `<style id="pageStyle">
|
||||
{
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
color-adjust: exact !important;
|
||||
}
|
||||
.vertical-text {
|
||||
writing-mode: vertical-rl !important;
|
||||
-webkit-writing-mode: vertical-rl !important;
|
||||
text-orientation: mixed !important;
|
||||
}
|
||||
body{
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
@media print{
|
||||
:host {
|
||||
width:auto !important;
|
||||
height:auto !important;
|
||||
}
|
||||
@page {
|
||||
size:${pageSize.width}mm ${pageSize.height}mm !important;
|
||||
margin:0;
|
||||
}
|
||||
html, body, form, .full-home, #printArea, .canvas-area {
|
||||
height: auto !important;
|
||||
width: auto !important;
|
||||
overflow: visible !important; /*必須為 visible */
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
display: block !important;
|
||||
}
|
||||
.no-print, #customMenu {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
.canvas-area{
|
||||
display:flex !important;
|
||||
|
||||
flex-direction: row !important;
|
||||
justify-content:center !important;
|
||||
align-items:center !important;
|
||||
|
||||
}
|
||||
|
||||
.tablet-paper {
|
||||
position: relative !important;
|
||||
display: block !important;
|
||||
break-inline:avoid;
|
||||
page-break-inline:avoid;
|
||||
break-after: page !important;
|
||||
page-break-after: always !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.tablet-element {
|
||||
position: absolute !important;
|
||||
white-space: normal;
|
||||
color: black !important; /* 確保文字是黑色的 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* 名單金字塔佈局容器 */
|
||||
.roster-container {
|
||||
width: 100%; height: 100%;
|
||||
writing-mode: vertical-rl; /* 直書 */
|
||||
display: flex;
|
||||
/*flex-direction: column;*/ /* 雖然是直書,但物理上我們是將「上層區」和「下層區」垂直堆疊 */
|
||||
flex-direction: row; /* 上下分層 (Top / Bottom) */
|
||||
align-items: center; /* 左右置中對齊 */
|
||||
justify-content: center;
|
||||
gap: 20px; /* 這是「上層」跟「下層」之間的距離,可以設大一點 */
|
||||
}
|
||||
|
||||
.roster-row {
|
||||
display: flex;
|
||||
flex-direction: row-reverse; /* 直書由右至左,所以 Row 要反向或依需求調整 */
|
||||
justify-content: center;
|
||||
gap: 8px; /* 名字之間的間距 */
|
||||
margin-left: 10px; /* 上下排之間的間距 (因為是直書,margin-left 是物理上的左邊/下方) */
|
||||
}
|
||||
|
||||
.name-group {
|
||||
display: flex;
|
||||
flex-direction: column; /* ★★★ 關鍵:這讓名字左右並排 ★★★ */
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
/* gap 由 HTML 動態綁定 */
|
||||
}
|
||||
|
||||
.roster-name {
|
||||
text-orientation: upright;
|
||||
/*font-weight: bold;*/
|
||||
white-space: normal;
|
||||
line-height: 1.2;
|
||||
font-family: DFKai-sb;
|
||||
/* 確保名字本身不會佔據過多寬度導致間距看起來很大 */
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
/* 【修復底圖沒出現】強制印出背景設定 */
|
||||
* {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
color-adjust: exact !important;
|
||||
}
|
||||
.ancestor-wrapper {
|
||||
/* 重置為橫向流,這樣 column 才會是真正的上下堆疊 */
|
||||
writing-mode: horizontal-tb;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center; /* 水平置中 */
|
||||
justify-content: felx-start;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.main-name {
|
||||
line-height: 1.2;
|
||||
/* 保持大字 */
|
||||
}
|
||||
|
||||
.sub-text {
|
||||
font-size: ${ancestorFontSize}px ;/*0.8em;*/ /* 縮小字體 */
|
||||
line-height: 1.2;
|
||||
margin-top: 4px; /* 與上方林張的間距 */
|
||||
white-space: normal; /* 避免自動換行 */
|
||||
writing-mode:vertical-rl
|
||||
}
|
||||
|
||||
.canvas-area{
|
||||
width: ${pageSize.width}mm;
|
||||
height: ${pageSize.height}mm;
|
||||
break-after: page;
|
||||
page-break-after: always;
|
||||
display:flex !important;
|
||||
justify-content:center;
|
||||
|
||||
}
|
||||
|
||||
.tablet-paper{
|
||||
background-color: white;
|
||||
display: inline-block;
|
||||
width: ${size.width}mm !important;
|
||||
height: ${size.height}mm !important;
|
||||
position: relative;
|
||||
margin-bottom: 0;
|
||||
background-image: url(${img.path});
|
||||
background-size: 100% 100%;
|
||||
break-inline:avoid;
|
||||
page-break-inline:avoid;
|
||||
}
|
||||
.tablet-element {
|
||||
cursor: move;
|
||||
padding: 4px;
|
||||
color: black !important; /* 強制墨水為黑色 */
|
||||
border: 1px solid transparent;
|
||||
transition: writing-mode 0.3s, transform 0.2s;
|
||||
}
|
||||
.tablet-element:hover { border-color: rgba(13, 110, 253, 0.3); }
|
||||
.tablet-paper:last-child { page-break-after: auto; }
|
||||
|
||||
.tablet-element span{
|
||||
z-index: 999;
|
||||
}
|
||||
</style>
|
||||
`
|
||||
$("#pageStyle").remove();
|
||||
$("head").append(self.pageStyle);
|
||||
$(canvas).append(tabletpaper);
|
||||
$(".printArea").append(canvas);
|
||||
//});
|
||||
|
||||
$(".tablet-element").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
self.selectedElement = $(this);
|
||||
let element = $(this).children().first();
|
||||
if (element.hasClass("liveList")) {//陽上
|
||||
//抓往生的人出來
|
||||
//self.familyMembers;
|
||||
} else if (element.hasClass("address")) {//地址
|
||||
|
||||
} else {//其他都是正名
|
||||
//抓未往生的人出來
|
||||
|
||||
}
|
||||
//console.log(this);
|
||||
});
|
||||
},
|
||||
//async getFamily() {
|
||||
// let param = {};
|
||||
// await axios
|
||||
// .post('/api/familymembers/follower', { param: param })
|
||||
// .then(response => { });
|
||||
|
||||
//},
|
||||
changeStyle() {
|
||||
|
||||
},
|
||||
fix2(val) {
|
||||
return Number.parseFloat(val).toFixed(2);
|
||||
},
|
||||
renderLiveList(names, el) {
|
||||
let $namelist = $(`<div class='liveList'></div>`).css({
|
||||
"writing-mode": "vertical rl",
|
||||
display: "flex",
|
||||
"flex-direction": "row",
|
||||
"flex-wrap": "wrap",
|
||||
margin: "auto",
|
||||
width: `${el.width}px`,
|
||||
height: `${el.height}px`,
|
||||
border: "0px solid #ccc",
|
||||
padding: "1px",
|
||||
"font-family": el.fontFamily,
|
||||
"letter-spacing": "0.1em",
|
||||
"column-gap": "1px",
|
||||
"row-gap": "1px",
|
||||
"align-items": "center",
|
||||
});
|
||||
let self = this;
|
||||
names.forEach(n => {
|
||||
$namelist.append(self.renderLiveSpan(n, el))
|
||||
})
|
||||
return $namelist;
|
||||
},
|
||||
renderLiveSpan(name, el) {
|
||||
return $(`<span class="liveSpan">${name}</span>`).css({
|
||||
display: "block",
|
||||
"min-height": `${el.textHeight}px`,
|
||||
"max-height": `${el.height}px`,
|
||||
width: `${el.textWidth}px`,
|
||||
height: `${el.textHeight}px`,
|
||||
"text-align": "justify",
|
||||
"text-align-last": "justify",
|
||||
"margin-bottom": "10px",
|
||||
"text-justify": "inter-character",
|
||||
"white-space": "pre-line"
|
||||
});
|
||||
},
|
||||
// 品字佈局邏輯:一上二下
|
||||
renderRoster(names, el) {
|
||||
if (!names.length) return '';
|
||||
const mid = names.length === 1 ? 1 : Math.floor(names.length / 2);
|
||||
const top = names.slice(0, mid);
|
||||
const bot = names.slice(mid);
|
||||
const size = this.autoScale(names, el.fontSize);
|
||||
|
||||
let h = $(`<div class="rosterList"></div>`).css(
|
||||
{
|
||||
width: el.width, height: el.height,
|
||||
"writing-mode": "vertical-rl", /* 直書 */
|
||||
display: "flex",
|
||||
"flex-direction": "row", /* 上下分層 (Top / Bottom) */
|
||||
"align-items": "center", /* 左右置中對齊 */
|
||||
"justify-content": "start",
|
||||
gap: "20px",
|
||||
});
|
||||
h.append(this.renderNameGroups(top, el));
|
||||
if (bot.length) h.append(this.renderNameGroups(bot, el));
|
||||
return h
|
||||
},
|
||||
renderNameGroups(items, el) {
|
||||
let g = $(`<div class="rosterspan"></div>`).css({
|
||||
"display": "flex",
|
||||
"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>`))
|
||||
})
|
||||
return g;
|
||||
},
|
||||
async autoScale(names, base) {
|
||||
const max = Math.max(...names.map(n => n.length), 0);
|
||||
return max > 5 ? Math.max(base * (5 / max), base * 0.6) : base;
|
||||
},
|
||||
scaleFontSize(txtContent, fontSize, elementWidth) {
|
||||
|
||||
let font = this.getTextSize("講", parseInt(fontSize));
|
||||
//自動判斷縮小字型的規則,要同時縮小間距
|
||||
|
||||
//if (dStyle.elementID === 'title1') {//表示是一般正名,也就是牌位正中間的一般格式,排法是上下上下
|
||||
if ((Math.ceil(txtContent.length / 2) * font.width) * 2 > parseFloat(elementWidth)) {
|
||||
let newfontSize = parseInt(fontSize) - 1;
|
||||
if (newfontSize <= 8) {
|
||||
return newfontSize;
|
||||
}
|
||||
//console.log("newfontSize:",newfontSize)
|
||||
return this.scaleFontSize(txtContent, newfontSize, elementWidth);
|
||||
}
|
||||
return fontSize;
|
||||
},
|
||||
getTextInfo(text, font) {
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
context.font = font;
|
||||
const metrics = context.measureText(text);
|
||||
return metrics
|
||||
},
|
||||
getTextWidth(text, font) {
|
||||
const canvas = document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
context.font = font;
|
||||
const metrics = context.measureText(text);
|
||||
|
||||
return metrics;
|
||||
},
|
||||
getTextSize(txt, fontsize) {
|
||||
let span = document.createElement("span");
|
||||
span.style.visibility = "hidden";
|
||||
span.style.position = "absolute";
|
||||
span.style.fontSize = fontsize + "px";
|
||||
span.style.fontFamily = "";
|
||||
span.innerText = txt;
|
||||
document.body.appendChild(span);
|
||||
let result = {
|
||||
width: span.offsetWidth,
|
||||
height: span.offsetHeight
|
||||
}
|
||||
document.body.removeChild(span);
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
$(() => $(window).on("message", function (event) {
|
||||
let e = event.originalEvent;
|
||||
if (e.origin === window.parent.location.origin) {
|
||||
//console.log('editor.html - origin check passed');
|
||||
//console.log('editor.html - received data:', event.data);
|
||||
const receivedData = e.data;
|
||||
designer.family_deceased_Y_selected = [];
|
||||
designer.family_deceased_N_selected = [];
|
||||
|
||||
if (receivedData.tabletItem) {
|
||||
//console.log('editor.html - updating tabletItem:', receivedData.tabletItem);
|
||||
designer.tabletItem = receivedData.tabletItem;
|
||||
if (receivedData.familyMembers) {
|
||||
designer.familyMembers = receivedData.familyMembers; // 更新 familyMembers
|
||||
//console.log("app mounted, window message: ", this.familyMembers, receivedData);
|
||||
}
|
||||
if (receivedData.tabletItem) {
|
||||
designer.tabletItem = receivedData.tabletItem;
|
||||
}
|
||||
//console.log("actitem:", receivedData.tabletItem.actitem_num_selected.val);
|
||||
console.log("receivedData::", receivedData);
|
||||
if (receivedData.tabletItem.style) {
|
||||
designer.selected.style = receivedData.tabletItem.style;
|
||||
} else {
|
||||
designer.selected.style = "";
|
||||
}
|
||||
console.log("actitem:", receivedData.tabletItem.actitem_num_selected.val);
|
||||
designer.actitem = receivedData.tabletItem.actitem_num_selected.val;
|
||||
//console.log("actitem:",receivedData.tabletItem.actitem_num_selected.val);
|
||||
// 處理 f_num_tablet 資料
|
||||
if (designer.tabletItem.f_num_tablet) {
|
||||
try {
|
||||
const data = JSON.parse(designer.tabletItem.f_num_tablet);
|
||||
|
||||
if (designer.item_type === 'B') {
|
||||
// B類型:超渡、超薦等
|
||||
designer.family_deceased_Y_selected = data.mid_items || [];
|
||||
designer.family_deceased_N_selected = data.left_items || [];
|
||||
|
||||
designer.family_deceased_Y_selected.forEach(item => {
|
||||
if (item.IsShuWen === undefined) {
|
||||
//Vue.set(item, 'IsShuWen', false);
|
||||
}
|
||||
});
|
||||
if (designer.family_deceased_Y_selected.length > 0) {
|
||||
designer.isAllSelected = this.family_deceased_Y_selected.every(member => member.IsShuWen === true);
|
||||
} else {
|
||||
designer.isAllSelected = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
// A類型:消災、陽上等
|
||||
designer.family_deceased_Y_selected = [];
|
||||
designer.family_deceased_N_selected = data.mid_items || [];
|
||||
|
||||
designer.family_deceased_N_selected.forEach(item => {
|
||||
if (item.IsShuWen === undefined) {
|
||||
//Vue.set(item, 'IsShuWen', false);
|
||||
}
|
||||
});
|
||||
if (designer.family_deceased_Y_selected.length > 0) {
|
||||
designer.isAllSelected = designer.family_deceased_N_selected.every(member => member.IsShuWen === true);
|
||||
|
||||
} else {
|
||||
designer.isAllSelected = false;
|
||||
}
|
||||
//console.log(this.family_deceased_N_selected)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析牌位資料時發生錯誤:', e);
|
||||
}
|
||||
}
|
||||
|
||||
designer.getActItem();
|
||||
designer.getData();
|
||||
}
|
||||
}
|
||||
console.log(e.origin, window.parent.location.origin)
|
||||
})
|
||||
)
|
||||
|
||||
$(() => designer.init().then(() => designer.getTabletElement().
|
||||
then(() => designer.getPaperSize().
|
||||
then(() => designer.getTabletStyles().
|
||||
then(designer.getAllStyleDetails())))));
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user