From 36174834a8b00ed8bd23ea1d3626d486de0eb626 Mon Sep 17 00:00:00 2001 From: minom Date: Mon, 6 Apr 2026 19:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=8C=E4=BD=8D=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/admin/activity/item_reg.aspx | 221 +++++----- web/admin/activity/item_reg.aspx.cs | 51 ++- web/admin/item/TabletDesigner.aspx | 7 - web/admin/print/print_multi_new.aspx | 479 ++++++++++++++++----- web/admin/print/tablet_edit/editornew.html | 20 +- 5 files changed, 533 insertions(+), 245 deletions(-) diff --git a/web/admin/activity/item_reg.aspx b/web/admin/activity/item_reg.aspx index 842494e..5b58631 100644 --- a/web/admin/activity/item_reg.aspx +++ b/web/admin/activity/item_reg.aspx @@ -24,7 +24,7 @@ return { this_id: '<%= Request["num"] %>', paperlist: [], - stylelist:[], + stylelist: [], options: {}, optionsDetail: { multiSort: false, @@ -45,7 +45,7 @@ { id: 'kind', title: '分類名稱' }, ], selected: {}, - select(item,t) { + select(item, t) { console.log("select search1", t); } }, @@ -62,7 +62,7 @@ { id: 'subject', title: '文件名稱' }, ], selected: {}, - select(item,t) { + select(item, t) { console.log("select search2", t); item.files_num_selected.text = t.subject //=====? @@ -73,26 +73,26 @@ id: 'search3', title: '子項目', text_prop: 'subject', - value_prop: 'num', - keys: [ - { id: 'subject', title: '項目名稱', value: '' }, - { id: 'kindTxt', title: '項目分類' }, - ], - api_url: HTTP_HOST + 'api/activity/GetItemList', - columns: [ - { id: 'subject', title: '項目名稱', value: '' }, - { id: 'kindTxt', title: '項目分類' }, - ], - selected: {}, - select(item,t) { - console.log("select search3", item, t); - //debugger; - item.actItem.subject = t.subject - item.actItem.num = t.num - item.item_num_selected={ - text: t.subject, - val : t.num - } + value_prop: 'num', + keys: [ + { id: 'subject', title: '項目名稱', value: '' }, + { id: 'kindTxt', title: '項目分類' }, + ], + api_url: HTTP_HOST + 'api/activity/GetItemList', + columns: [ + { id: 'subject', title: '項目名稱', value: '' }, + { id: 'kindTxt', title: '項目分類' }, + ], + selected: {}, + select(item, t) { + console.log("select search3", item, t); + //debugger; + item.actItem.subject = t.subject + item.actItem.num = t.num + item.item_num_selected = { + text: t.subject, + val: t.num + } // item.bom_editedItem.actItem.subject = t.subject // item.bom_editedItem.actItem.num = t.num @@ -100,11 +100,11 @@ // text : t.subject, // val = t.num // } - } - ////新增/修改+關閉時, 會清空/還原 + } + ////新增/修改+關閉時, 會清空/還原 }, - }, + }, show: false, current: {}, list: [], @@ -144,7 +144,7 @@ editedItem: { id: 0, num: 0, - actItem_num: 0, + actItem_num: 0, files_num_selected: { text: '', val: 0 @@ -177,12 +177,12 @@ 'items-per-page-options': [] }, bom_list: [], - bom_count: 0, + bom_count: 0, bom_editedIndex: -1, bom_editedItem: { id: 0, num: 0, - package_num: 0, + package_num: 0, //item_num: 0, item_num_selected: { text: '', @@ -192,13 +192,13 @@ bom_defaultItem: { id: 0, num: 0, - package_num: 0, + package_num: 0, //item_num: 0, item_num_selected: { text: '', val: 0 }, - }, + }, } }, mounted() { @@ -245,8 +245,8 @@ }); //necessary parameter=== if (this.search_dialog.current.id == 'search1') { - if (this.this_id=="") - search['status'] = "Y";//啟用 + if (this.this_id == "") + search['status'] = "Y";//啟用 } console.log("search_get", api_url, search, params, this.options); this.search_dialog.loading = true @@ -294,7 +294,7 @@ target.children("input.search-text").val(curr.selected[curr.text_prop])//text target.children("input:hidden").val(curr.selected[curr.value_prop])//value if (curr.select instanceof Function) { - curr.select(editem,row); + curr.select(editem, row); } this.search_dialog.show = false; //console.log(row, row["u_name"], row["f_number"], curr.id, target); @@ -311,7 +311,7 @@ actItem_num: this.this_id, } axios - .post(HTTP_HOST + 'api/activity/GetItemFiles', + .post(HTTP_HOST + 'api/activity/GetItemFiles', searchItemDetail, { params: params }) .then(response => { this.desserts = response.data.list @@ -325,7 +325,7 @@ item_num: this.this_id, } axios - .post(HTTP_HOST + 'api/activity/GetItemBomList', + .post(HTTP_HOST + 'api/activity/GetItemBomList', searchItemBom, { params: params }) .then(response => { this.bom_list = response.data.list @@ -333,48 +333,53 @@ }) .catch( error => console.log(error) - ) - - axios - .post(HTTP_HOST + 'api/tablet/GetPaperSize', {}) - .then(response => { - console.log(response); - if (response.status == "200") { - let data = response.data; - if (data.result == "Y") { - data.data.forEach(x => { - this.paperlist.push({ name: x.paperName, id: x.paperID, width: x.width, height: x.height }) - $("#pageSize").append(``); - $("#printSize").append(``); - }); - } - } - }) - .catch( - error => console.log(error) - ) - - axios - .post(HTTP_HOST + 'api/tablet/GetStyleData', {}) - .then(response => { - console.log(response); - if (response.status == "200") { - let data = response.data; - if (data.result == "Y") { - data.data.forEach(x => { - if (x.styleID != "000001") { - this.stylelist.push({ styleID: x.styleID, name: x.name }) - $("#defaultStyle").append(``); - } - }); - } - } - }) - .catch( - error => console.log(error) ) } + axios + .post(HTTP_HOST + 'api/tablet/GetPaperSize', {}) + .then(response => { + console.log(response); + if (response.status == "200") { + let data = response.data; + if (data.result == "Y") { + data.data.forEach(x => { + this.paperlist.push({ name: x.paperName, id: x.paperID, width: x.width, height: x.height }) + $('#<%= ddlPageSize.ClientID %>').append(``); + $('#<%= ddlPrintSize.ClientID %>').append(``); + }); + + $('#<%= ddlPageSize.ClientID %>').val($("#<%= hidPageSize.ClientID %>").val()) + $('#<%= ddlPrintSize.ClientID %>').val($("#<%= hidPrintSize.ClientID %>").val()) + } + } + }) + .catch( + error => console.log(error) + ) + + axios + .post(HTTP_HOST + 'api/tablet/GetStyleData', {}) + .then(response => { + console.log(response); + if (response.status == "200") { + let data = response.data; + if (data.result == "Y") { + data.data.forEach(x => { + if (x.styleID != "000001") { + this.stylelist.push({ styleID: x.styleID, name: x.name }) + $('#<%= ddlDefaultStyle.ClientID %>').append(``); + //$("#defaultStyle").append(``); + } + }); + $('#<%= ddlDefaultStyle.ClientID %>').val($("#<%= hidDefaultStyle.ClientID %>").val()) + } + } + }) + .catch( + error => console.log(error) + ) + }, editItem(item) { this.editedIndex = this.desserts.indexOf(item); @@ -401,7 +406,7 @@ } }, cancel() { - + this.spliceNullData(); this.close(); }, @@ -424,7 +429,7 @@ }, 300) }, addNew() { - + this.spliceNullData(); //addObj.id = this.desserts.length + 1; @@ -440,12 +445,12 @@ addObj.id = (isFinite(_c) ? _c : 0) + 1; this.desserts.unshift(addObj); this.editItem(addObj); - }, + }, save() { if (this.editedIndex > -1) { if (this.this_id != '') { //chcck necessary params - if (this.editedItem.files_num_selected.val != 0 ) { + if (this.editedItem.files_num_selected.val != 0) { //insert or update data var pro_order_detail = { @@ -475,27 +480,27 @@ } } - }, - titleword() { - var e = document.getElementById("<%= category.ClientID%>"); + }, + titleword() { + var e = document.getElementById("<%= category.ClientID%>"); const strUser = e.options[e.selectedIndex].text; const _kind_txt = $('#<%= kind_txt.ClientID%>').val(); const _subject = $('#<%= subject.ClientID%>').val(); return "(" + strUser + ")" + " " + _kind_txt + " " + _subject; }, - bom_editItem(item){ + bom_editItem(item) { this.bom_editedIndex = this.bom_list.indexOf(item); this.bom_editedItem = $.extend(true, {}, item); console.log("bom_editItem:", this.bom_editedIndex, this.bom_editedItem); //debugger; }, - bom_deleteItem(item){ + bom_deleteItem(item) { confirm('確定要刪除此筆資料嗎?') && this.bom_list.splice(index, 1); }, - bom_cancel(){ + bom_cancel() { this.bom_spliceNullData(); - this.bom_close(); + this.bom_close(); }, bom_spliceNullData() { //if new data ,then splice it @@ -513,7 +518,7 @@ this.bom_editedItem = -1; }, 300) }, - bom_addNew(){ + bom_addNew() { this.spliceNullData(); //addObj.id = this.desserts.length + 1; @@ -532,13 +537,13 @@ if (!!this.bom_list) this.bom_list?.unshift(addObj); this.bom_editItem(addObj); }, - bom_save(){ + bom_save() { if (this.bom_editedIndex > -1) { if (this.this_id != '') { //chcck necessary params - if (this.bom_editedItem.item_num_selected.val != 0 ) { + if (this.bom_editedItem.item_num_selected.val != 0) { //insert or update data - var package_num = $(".packageNum input[type=hidden]").val(); + var package_num = $(".packageNum input[type=hidden]").val(); var bom_detail = { num: this.bom_editedItem.num, @@ -566,13 +571,13 @@ } } }, - selectChange(what) { - if (what == "pageSize") { - document.getElementById('<%= pageSizeSel.ClientID %>').value = $("#pageSize").val(); - } else if (what == "printSize") { - document.getElementById('<%= printSizeSel.ClientID %>').value = $("#printSize").val(); - } else if (what=="defaultStyle") { - document.getElementById('<%= defaultStyleSel.ClientID %>').value = $("#defaultStyle").val(); + changeSel(selType) { + if (selType=="ddlPageSize") { + $("#<%= hidPageSize.ClientID %>").val($("#<%= ddlPageSize.ClientID %>").val()) + } else if (selType == "ddlPrintSize") { + $("#<%= hidPrintSize.ClientID %>").val($("#<%=ddlPrintSize.ClientID %>").val()) + } else if (selType == "ddlDefaultStyle") { + $("#<%= hidDefaultStyle.ClientID %>").val($("#<%= ddlDefaultStyle.ClientID %>").val()) } } }, @@ -591,8 +596,8 @@ function setCss() { $(".cyclePanel input").addClass("form-check-input"); } - - + + @@ -678,28 +683,34 @@
- + + <%-- - + --%> <%-- --%>
- + + <%-- - + --%> <%-- --%>
- + + <%-- - + --%> <%-- --%>
diff --git a/web/admin/activity/item_reg.aspx.cs b/web/admin/activity/item_reg.aspx.cs index 9f25b85..a6c42f7 100644 --- a/web/admin/activity/item_reg.aspx.cs +++ b/web/admin/activity/item_reg.aspx.cs @@ -44,6 +44,21 @@ public partial class admin_activity_item_reg : MyWeb.config print_init.Text = prod.print_init; PARTNO.Text = prod.partno; //kind.SelectedValue = prod.kind.ToString(); + if (!isStrNull(prod.pageSize)) + { + ddlPageSize.Value = prod.pageSize.ToString(); + hidPageSize.Value = prod.pageSize.ToString(); + } + if (!isStrNull(prod.printSize)) + { + ddlPrintSize.Value = prod.printSize.ToString(); + hidPrintSize.Value = prod.printSize.ToString(); + } + if (!isStrNull(prod.defaultStyle)) + { + ddlDefaultStyle.Value = prod.defaultStyle.ToString(); + hidDefaultStyle.Value = prod.defaultStyle.ToString(); + } if (prod.kind.HasValue) { kind_txt.Value = prod.actItem_kind.kind; @@ -121,17 +136,17 @@ public partial class admin_activity_item_reg : MyWeb.config actItem.subject = subject.Text; actItem.print_init = print_init.Text; actItem.partno = PARTNO.Text; - if (!isStrNull(pageSizeSel.Value)) + if (!isStrNull(ddlPageSize.Value)) { - actItem.pageSize =(pageSizeSel.Value); + actItem.pageSize = ddlPageSize.Value; } - if (!isStrNull(printSizeSel.Value)) + if (!isStrNull(ddlPrintSize.Value)) { - actItem.printSize = (printSizeSel.Value); + actItem.printSize = ddlPrintSize.Value; } - if (!isStrNull(defaultStyleSel.Value)) + if (!isStrNull(ddlDefaultStyle.Value)) { - actItem.defaultStyle = (defaultStyleSel.Value); + actItem.defaultStyle = (ddlDefaultStyle.Value); } //if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; } if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; } @@ -180,17 +195,17 @@ public partial class admin_activity_item_reg : MyWeb.config actItem.subject = subject.Text; actItem.print_init = print_init.Text; actItem.partno = PARTNO.Text; - if (!isStrNull(pageSizeSel.Value)) + if (!isStrNull(hidPageSize.Value)) { - actItem.pageSize = (pageSizeSel.Value); + actItem.pageSize = hidPageSize.Value; } - if (!isStrNull(printSizeSel.Value)) + if (!isStrNull(hidPrintSize.Value)) { - actItem.printSize = (printSizeSel.Value); + actItem.printSize = hidPrintSize.Value; } - if (!isStrNull(defaultStyleSel.Value)) + if (!isStrNull(hidDefaultStyle.Value)) { - actItem.defaultStyle = (defaultStyleSel.Value); + actItem.defaultStyle = (hidDefaultStyle.Value); } //if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; } if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; } @@ -270,4 +285,16 @@ public partial class admin_activity_item_reg : MyWeb.config } } } + + //protected override void Render(HtmlTextWriter writer) + //{ + // ClientScript.RegisterForEventValidation( + // ddlDefaultStyle.UniqueID, "ddlDefaultStyle"); + // ClientScript.RegisterForEventValidation( + // ddlPageSize.UniqueID, "ddlPageSize"); + // ClientScript.RegisterForEventValidation( + // ddlPrintSize.UniqueID, "ddlPrintSize"); + + // base.Render(writer); + //} } \ No newline at end of file diff --git a/web/admin/item/TabletDesigner.aspx b/web/admin/item/TabletDesigner.aspx index d319601..44ce7c5 100644 --- a/web/admin/item/TabletDesigner.aspx +++ b/web/admin/item/TabletDesigner.aspx @@ -807,13 +807,6 @@ "justify-content": "start", gap: "20px", }); - //h.append( - // $(`
${top.map(n => `
${n}
`).join('')}
`) - //) - //if (bot.length) h.append(`
${bot.map(n => `
${n}
`).join('')}
`) - //h += `
${top.map(n => `
${n}
`).join('')}
`; - ///if (bot.length) h += `
${bot.map(n => `
${n}
`).join('')}
`; - //return h + `
`; h.append(this.renderNameGroups(top,el)); if (bot.length) h.append(this.renderNameGroups(bot,el)); return h diff --git a/web/admin/print/print_multi_new.aspx b/web/admin/print/print_multi_new.aspx index c5300ae..75281f3 100644 --- a/web/admin/print/print_multi_new.aspx +++ b/web/admin/print/print_multi_new.aspx @@ -18,6 +18,62 @@ +
+
+
+
+ 個別設定 + 全域設定 +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ 列印 - - - -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - -
@@ -82,14 +108,14 @@ selected: null, http_host: "", pageStyle: "", - pSize:"", + pSize: "", allStyle: [], allSize: [], allStyleDetails: [], printData: [], tabletElement: [], observer: null, - isInit:true, + isInit: true, bg: [ { name: "黃1", path: "../../admin/print/html/tablet-1_new.svg" }, { name: "黃2", path: "../../admin/print/html/tablet-1B_new.svg" }, @@ -97,23 +123,23 @@ { name: "紅2", path: "../../admin/print/html/tablet-2B.svg" } ], async init() { - + let HTTP_HOST = "<%=UrlHost()%>"; this.http_host = HTTP_HOST; // Promise.all([ this.getActItem(), this.getPaperSize(), - ]).then(() => { - Promise.all([ + ]).then(() => { + Promise.all([ this.getTabletElement(), this.getTabletStyles(), this.getAllStyleDetails(), this.getData(), - - ]).then(() => { - this.render(); - }) + + ]).then(() => { + this.render(); + }) }) }, async getActItem() { @@ -159,7 +185,7 @@ this.allSize = data.data; //console.log(this.allSize); if (this.allSize) { - this.allSize.forEach(x => { + this.allSize.forEach(x => { $("#paperSizeSel").append(``); }) //if (this.printSize) { @@ -207,7 +233,7 @@ if (response.status == 200) { this.printData = response.data; - + //this.render(); //this.print(); } @@ -223,19 +249,31 @@ let canvas = $(`
`) let nowPageWidth = 0; let tabletpaper; - this.printData.forEach(x => { - if ($("#paperSizeSel").val() == "") { - if (this.pSize&&this.pSize!=undefined) { - $("#paperSizeSel").val(this.pSize); - } else { - $("#paperSizeSel").val("0003"); - } + //列印紙張的尺寸 + if ($("#paperSizeSel").val() == "") { + if (this.pSize && this.pSize != undefined) { + $("#paperSizeSel").val(this.pSize); + } else { + $("#paperSizeSel").val("0001"); } + } + 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); - let pageSize = self.allSize.find(y => y.paperID == $("#paperSizeSel").val()); - let printSize = self.allSize.find(y => y.paperID ==style.printSize); - if ((nowPageWidth + parseFloat(printSize.width)) > pageSize.width) { + //包含空白用來折的尺寸 + let printSize = self.allSize.find(y => y.paperID == style.printSize); + + //用長根寬算出一張紙可以印幾張 + 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"); //$(canvas).css("height", printSize.height + "mm"); //$(canvas).css("justify-content", "center"); @@ -246,7 +284,7 @@ canvas = $(`
`) nowPageWidth = 0; } - nowPageWidth = nowPageWidth + parseFloat(printSize.width); + nowPageWidth = nowPageWidth + 1; //parseFloat(printSize.width); tabletpaper = $(`
`) let img = self.bg.find(y => y.name == style.backendImg); @@ -265,8 +303,9 @@ let mid_items = tablet.mid_items; 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); @@ -281,7 +320,7 @@ details.forEach(d => { if (d.isActive != "hidden") { let newFontSize = self.scaleFontSize(mid, d.fontSize, d.width); - + let html = ""; let alive = ""; let yang = ""; @@ -308,11 +347,12 @@ 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; } - let $span = $(`${z}`).css({ + let $span = $(`${z}`).css({ display: "block", "min-height": `${height}px`, "max-height": `${d.height}px`, @@ -320,7 +360,7 @@ //width: `${newFontSize}px`, "text-align": "justify", "text-align-last": "justify", - "margin-bottom": "40px", + "margin-bottom": "20px", "margin-left": "5px", "text-justify": "inter-character", //"justify-content":"center" @@ -333,17 +373,21 @@ html = self.renderLiveList(left, d); newFontSize = d.fontSize; + } else if (d.elementID === "titletriangle") { + html = self.renderRoster(mid, d) + } + if (newFontSize < 10) { + newFontSize = 10; } - let content = $(`
`) .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" - + "align-items": "center" + }) .html(html); - tabletpaper.append(content); + tabletpaper.append(content); html = ""; alive = ""; yang = ""; @@ -352,6 +396,9 @@ }) + //console.log("xCount:", Math.floor( xCount)); + let xFloor = Math.floor(xCount); + self.pageStyle = ` ` $("#pageStyle").remove(); @@ -515,47 +587,85 @@ //$(canvas).css("justify-content", "center"); $("#printArea").append(canvas); }); - $(".tablet-element").draggable({ - start(e, ui) { - //console.log("gogogogo"); - }, - stop(e, ui) { - //console.log(ui.position.left, ui.position.top); - } - }); + //$(".tablet-element").draggable({ + // start(e, ui) { + // //console.log("gogogogo"); + // }, + // stop(e, ui) { + // //console.log(ui.position.left, ui.position.top); + // } + //}); - $(".tablet-element").on("click", function (e) { - e.preventDefault(); - self.selected = $(this); - let fontSize = $(this).css("fontSize"); - let fontFamily = $(this).css("fontFamily"); - let left = $(this).css("left"); - let top = $(this).css("top"); - }); + //$(".tablet-element").on("click", function (e) { + // e.preventDefault(); + // self.selected = $(this); + // let fontSize = $(this).css("fontSize"); + // let fontFamily = $(this).css("fontFamily"); + // let left = $(this).css("left"); + // let top = $(this).css("top"); + //}); $(".tablet-element").on("contextmenu", function (e) { e.preventDefault(); self.selected = $(this); let fontSize = $(this).css("font-size"); let fontFamily = $(this).css("font-family"); - console.log($(this).css("font-size")); - let textWidth = $(this).find("span").first().css("width"); + + let textWidth;//= $(this).css("width");//find("span").first().css("width"); + let textHeight; //= $(this).css("height"); + + if ($(this).find(".nameList").first()) { + textWidth = $(this).find(".nameList").first().css("width"); + textHeight = $(this).find(".nameList").first().css("height"); + } else if ($(this).find(".liveList").first()) { + textWidth = $(this).find(".liveList").first().css("width"); + textHeight = $(this).find(".liveList").first().css("height"); + } else if ($(this).find(".rosterList").first()) { + textWidth = $(this).find(".rosterList").first().css("width"); + textHeight = $(this).find(".rosterList").first().css("height"); + } + let left = $(this).css("left"); let top = $(this).css("top"); - $("#customMenu").css({ - top: e.pageY + "px", - left: (e.pageX + 30) + "px" - }); + left = left.replace("px", ""); top = top.replace("px", ""); $("#textX").val(self.fix2(left * 0.265)); $("#textY").val(self.fix2(top * 0.265)); $("#fontSize").val(fontSize); $("#textWidth").val(textWidth); - $("#customMenu").show(); + $("#textHeight").val(textHeight); + $("#textX").prop("readonly", false); + $("#textY").prop("readonly", false); + $("#fontSize").prop("readonly", false); }); - + $(".tablet-element span").on("click", function (e) { + e.preventDefault(); + self.selected = $(this); + let fontSize = $(this).css("font-size"); + let fontFamily = $(this).css("font-family"); + let textWidth = $(this).css("max-width"); + let textHeight = $(this).css("min-height"); + let left = $(this).css("left"); + let top = $(this).css("top"); + left = left.replace("px", ""); + top = top.replace("px", ""); + $("#textX").val(""); + $("#textY").val(""); + $("#fontSize").val(""); + $("#textWidth").val(textWidth); + $("#textHeight").val(textHeight); + let parentElement = this.parentElement; + if ($(parentElement).hasClass("nameList") || $(parentElement).hasClass("liveList") || $(parentElement).hasClass("rosterList")) { + $("#textX").prop("readonly", true); + $("#textY").prop("readonly", true); + $("#fontSize").prop("readonly", true); + } + + }); + + }, fix2(val) { return Number.parseFloat(val).toFixed(2); @@ -584,7 +694,7 @@ return $namelist; }, renderLiveSpan(name, el) { - return $(`${name}`).css({ + return $(`${name}`).css({ display: "block", "min-height": `${el.textHeight}px`, "max-height": `${el.height}px`, @@ -592,23 +702,61 @@ height: `${el.textHeight}px`, "text-align": "justify", "text-align-last": "justify", - "margin-bottom": "15px", + "margin-bottom": "10px", "text-justify": "inter-character", }); }, - getTextInfo(text,font) { + // 品字佈局邏輯:一上二下 + 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 = $(`
`).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 = $(`
`).css({ + "display": "flex", + "flex-direction": "column", + "justify-content": "center", + "height": el.textHeight, + }) + items.forEach(x => { + g.append($(`
${x}
`)) + }) + return g; + }, + 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; + }, + 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) { + 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) { @@ -626,24 +774,127 @@ document.body.removeChild(span); return result; }, - scaleFontSize(txtContent, fontSize,elementWidth) { + scaleFontSize(txtContent, fontSize, elementWidth) { - let font = this.getTextSize("講", parseInt(fontSize)); + 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; - //console.log("newfontSize:",newfontSize) - return this.scaleFontSize(txtContent, newfontSize,elementWidth); - } - return fontSize; + //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; + } + //console.log("newfontSize:",newfontSize) + return this.scaleFontSize(txtContent, newfontSize, elementWidth); + } + return fontSize; }, breakWord(txtContent, style, dStyle) { //自動判斷斷字 //1. by 特定字 2.by長度 }, + async changeSetup(config) { + switch (config) { + case "X": + if ($("#indivualSetup").prop("checked")) { + $(this.selected).css("left", $("#textX").val() + "mm"); + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "Y": + if ($("#indivualSetup").prop("checked")) { + $(this.selected).css("top", $("#textY").val() + "mm"); + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "fontSize": + if ($("#indivualSetup").prop("checked")) { + $(this.selected).css("font-size", $("#fontSize").val()) + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "width": + + if ($("#indivualSetup").prop("checked")) { + if (this.selected.find(".nameList").length>=1) { + $(this.selected.find(".nameList").first()).css("width", $("#textWidth").val()) + } else if (this.selected.find(".liveList").length >= 1) { + this.selected.find(".liveList").first().css("width", $("#textWidth").val()) + } else if (this.selected.find(".rosterList").length >= 1) { + this.selected.find(".rosterList").first().css("width", $("#textWidth").val()) + } else if (this.selected.hasClass("nameSpan")) { + let spans = $(this.selected.parent().first()).find(".nameSpan"); + spans.each(function (index, x) { + $(x).css("max-width", $("#textWidth").val()); + }); + } 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()); + }); + } else if (this.selected.hasClass("rosterSpan")) { + let spans = $(this.selected.parent().first()).find(".rosterSpan"); + spans.each(function(index, x) { + $(x).css("max-width", $("#textWidth").val()); + }); + } + + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "height": + if ($("#indivualSetup").prop("checked")) { + if (this.selected.find(".nameList").length >= 1) { + $(this.selected.find(".nameList").first()).css("height", $("#textHeight").val()) + } else if (this.selected.find(".liveList").length >= 1) { + this.selected.find(".liveList").first().css("height", $("#textHeight").val()) + } else if (this.selected.find(".rosterList").length >= 1) { + this.selected.find(".rosterList").first().css("height", $("#textHeight").val()) + } 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()); + }); + } else if (this.selected.hasClass("rosterSpan")) { + let spans = $(this.selected.parent().first()).find(".rosterSpan"); + spans.each(function (index, x){ + $(x).css("min-height", $("#textHeight").val()); + }); + } + + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "breakCount": + if ($("#indivualSetup").prop("checked")) { + + } else if ($("#allSetup").prop("checked")) { + + } + break; + case "breakWord": + if ($("#indivualSetup").prop("checked")) { + + } else if ($("#allSetup").prop("checked")) { + + } + break; + } + }, async changeLocation() { $(this.selected).css("left", $("#textX").val() + "mm"); $(this.selected).css("top", $("#textY").val() + "mm"); @@ -723,9 +974,9 @@ }, } $(document).click(function (e) { - if (!$("#customMenu").is(e.target) && $("#customMenu").has(e.target).length === 0) { - $("#customMenu").hide(); - } + //if (!$("#customMenu").is(e.target) && $("#customMenu").has(e.target).length === 0) { + // $("#customMenu").hide(); + //} }); $(() => Printer.init()); diff --git a/web/admin/print/tablet_edit/editornew.html b/web/admin/print/tablet_edit/editornew.html index 820e131..59f2864 100644 --- a/web/admin/print/tablet_edit/editornew.html +++ b/web/admin/print/tablet_edit/editornew.html @@ -403,7 +403,8 @@ style:"" }, actitem: "", - pageSize:"", + pageSize: "", + defaultStyle:"", isAllSelected: false, dialog: false, addDialog: false, // 新增項目對話框 @@ -506,12 +507,12 @@ 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); + //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); + //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 = []; @@ -526,15 +527,16 @@ 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); + //console.log("actitem:",receivedData.tabletItem.actitem_num_selected.val); // 處理 f_num_tablet 資料 if (this.tabletItem.f_num_tablet) { try { @@ -595,6 +597,9 @@ console.log(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; + console.log("shit:",this.selected.style); this.getStyle(); } } @@ -615,6 +620,7 @@ } } }) + } }) .catch(error => console.log(error))