新增親友

This commit is contained in:
2026-04-12 20:55:09 +08:00
parent 21a3ec6198
commit 1afb90f3ba
3 changed files with 349 additions and 257 deletions
+22
View File
@@ -76,6 +76,28 @@ public class designerController : ApiController
//return Ok(data); //return Ok(data);
} }
[HttpPost]
[Route("api/tablet/saveFamily")]
public IHttpActionResult saveFamily([FromBody] family_members familyMember)
{
LogUtility log = new LogUtility();
_db.family_members.Add(familyMember);
_db.SaveChanges();
return Ok(new { result = "Y", data= familyMember });
//object[] obj = new StyleDataAccess().GetStyle("", "");
//if (obj[0].ToString() == "Y")
//{
// return Ok(new { result = "Y", data = obj[2] });
//}
//else
//{
// return Ok(new { result = "N", message = obj[1] });
// //throw new HttpResponseException(HttpStatusCode.NotFound);
//}
//return Ok(data);
}
[HttpPost] [HttpPost]
[Route("api/tablet/GetStyleData")] [Route("api/tablet/GetStyleData")]
public IHttpActionResult GetStyleData([FromBody] dynamic data) public IHttpActionResult GetStyleData([FromBody] dynamic data)
+2 -1
View File
@@ -951,7 +951,8 @@
title: this.titleword() // 確保標題被包含 title: this.titleword() // 確保標題被包含
}, },
familyMembers: familyMembers, familyMembers: familyMembers,
host: HTTP_HOST host: HTTP_HOST,
follower_id:this.follower_id
}; };
iframe.contentWindow.postMessage(itemInfo, '*'); iframe.contentWindow.postMessage(itemInfo, '*');
+108 -39
View File
@@ -85,10 +85,15 @@
<div class="col-10"> <div class="col-10">
<div class="form-floating mb-3"> <div class="form-floating mb-3">
<input class="form-control" type="text" id="filter_txt" <input class="form-control" type="text" id="filter_txt"
onkeyup="designer.filterToSel()" placeholder="請輸入名稱" /> onkeyup="designer.filterToSel()" placeholder="篩選條件" />
<label for="filter_txt">請輸入名稱</label> <label for="filter_txt">篩選條件</label>
</div> </div>
</div> </div>
<div class="col-2">
<button type="button" data-bs-toggle="modal" data-bs-target="#familyModal" title="新增親友">
<i class="mdi mdi-account-multiple-plus" style="font-size:30px;"></i>
</button>
</div>
</div> </div>
<ul class="canselectItem" style="margin-left: 1rem;margin-right:1rem;"> <ul class="canselectItem" style="margin-left: 1rem;margin-right:1rem;">
</ul> </ul>
@@ -99,6 +104,41 @@
</div> </div>
</div> </div>
<div class="modal fade hide" id="familyModal" tabindex="-1" aria-labelledby="familyModalLabel" aria-hidden="true" style="z-index:10000 !important;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">新增親友</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<div class="form-floating mb-3">
<input class="form-control" type="text" id="family_txt"
placeholder="姓名" />
<label for="family_txt">姓名</label>
</div>
</div>
<div class="col-12">
<div class="form-floating mb-3">
<select class="form-select" id="deceased_sel"
placeholder="存歿">
<option value="False"></option>
<option value="True">歿</option>
</select>
<label for="deceased_sel">存歿</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">關閉</button>
<button type="button" class="btn btn-primary" onclick="designer.saveFamily()">存檔</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
const designer = { const designer = {
code: { code: {
@@ -128,7 +168,7 @@
family_deceased_N_selected: [], // 消災/陽上名單 family_deceased_N_selected: [], // 消災/陽上名單
family_left_title: [], family_left_title: [],
family_right_title: [], family_right_title: [],
family_address:"", family_address: "",
allStyle: [], allStyle: [],
allStyleDetails: [], allStyleDetails: [],
allSize: [], allSize: [],
@@ -143,8 +183,10 @@
address: "",//地址 address: "",//地址
alive: [],//陽上 alive: [],//陽上
tabletType: "A", tabletType: "A",
http_host:"", http_host: "",
//toast:null, follower_id:"",
toast: null,
modal:null,
bg: [ bg: [
{ name: "黃1", path: "../../../admin/print/html/tablet-1_new.svg" }, { name: "黃1", path: "../../../admin/print/html/tablet-1_new.svg" },
{ name: "黃2", path: "../../../admin/print/html/tablet-1B_new.svg" }, { name: "黃2", path: "../../../admin/print/html/tablet-1B_new.svg" },
@@ -157,7 +199,8 @@
.then(res => res.json()) .then(res => res.json())
.then(data => { this.phrases = data; }) .then(data => { this.phrases = data; })
.catch(err => console.error('載入 phrases.json 失敗:', err)); .catch(err => console.error('載入 phrases.json 失敗:', err));
//this.toast = new bootstrap.Toast(document.querySelector(".toast")); //this.toast = new bootstrap.Toast($('#familyModal'));
this.modal = new bootstrap.Modal($('#familyModal'));
//this.toast.hide(); //this.toast.hide();
}, },
async getActItem() { async getActItem() {
@@ -340,7 +383,7 @@
let myAddress = []; let myAddress = [];
Object.assign(ltitle, self.leftProperTitle); Object.assign(ltitle, self.leftProperTitle);
Object.assign(rtitle, self.rightProperTitle); Object.assign(rtitle, self.rightProperTitle);
if (self.address!="") { if (self.address != "") {
myAddress.push(self.address) myAddress.push(self.address)
} }
@@ -370,7 +413,7 @@
if (d.isActive != "hidden") { if (d.isActive != "hidden") {
let element = self.tabletElement.find(y => y.elementID == d.elementID); let element = self.tabletElement.find(y => y.elementID == d.elementID);
let newFontSize =self.scaleFontSize(mid, d.fontSize, d.width); let newFontSize = self.scaleFontSize(mid, d.fontSize, d.width);
let html = ""; let html = "";
let alive = ""; let alive = "";
let yang = ""; let yang = "";
@@ -785,7 +828,7 @@
//} //}
} else if (target.hasClass("address")) { } else if (target.hasClass("address")) {
self.address=($("#custom_txt").val()); self.address = ($("#custom_txt").val());
let obj = { let obj = {
IsShuWen: false, IsShuWen: false,
deceased: false, deceased: false,
@@ -796,7 +839,7 @@
num: 0, num: 0,
option_break: false option_break: false
} }
self.family_address=self.address self.family_address = self.address
//self.family_deceased_N_selected.push(obj); //self.family_deceased_N_selected.push(obj);
} }
@@ -895,7 +938,7 @@
[self.family_deceased_N_selected[index - 1], self.family_deceased_N_selected[index]] = [self.family_deceased_N_selected[index - 1], self.family_deceased_N_selected[index]] =
[self.family_deceased_N_selected[index], self.family_deceased_N_selected[index - 1]]; [self.family_deceased_N_selected[index], self.family_deceased_N_selected[index - 1]];
} }
} else if ($(self.selectedElement).children().first().hasClass("ancestor-wrapper") ) { } else if ($(self.selectedElement).children().first().hasClass("ancestor-wrapper")) {
let index = self.properTitle.indexOf(curr.text()); let index = self.properTitle.indexOf(curr.text());
if (index == 0) { if (index == 0) {
@@ -930,7 +973,7 @@
let curr = $(e.currentTarget.parentElement).find(".selected").first(); let curr = $(e.currentTarget.parentElement).find(".selected").first();
if ($(self.selectedElement).children().first().hasClass("liveList")) { if ($(self.selectedElement).children().first().hasClass("liveList")) {
let index = self.alive.indexOf(curr.text()); let index = self.alive.indexOf(curr.text());
if (index == self.alive.length-1) { if (index == self.alive.length - 1) {
} else { } else {
[self.alive[index], self.alive[index + 1]] = [self.alive[index + 1], self.alive[index]]; [self.alive[index], self.alive[index + 1]] = [self.alive[index + 1], self.alive[index]];
@@ -940,7 +983,7 @@
} else if ($(self.selectedElement).children().first().hasClass("nameList") || } else if ($(self.selectedElement).children().first().hasClass("nameList") ||
$(self.selectedElement).children().first().hasClass("rosterList")) { $(self.selectedElement).children().first().hasClass("rosterList")) {
let index = self.properTitle.indexOf(curr.text()); let index = self.properTitle.indexOf(curr.text());
if (index == self.properTitle.length-1) { if (index == self.properTitle.length - 1) {
} else { } else {
[self.properTitle[index], self.properTitle[index + 1]] = [self.properTitle[index + 1], self.properTitle[index]]; [self.properTitle[index], self.properTitle[index + 1]] = [self.properTitle[index + 1], self.properTitle[index]];
@@ -949,7 +992,7 @@
} }
} else if ($(self.selectedElement).children().first().hasClass("ancestor-wrapper")) { } else if ($(self.selectedElement).children().first().hasClass("ancestor-wrapper")) {
let index = self.properTitle.indexOf(curr.text()); let index = self.properTitle.indexOf(curr.text());
if (index == self.properTitle.length-1) { if (index == self.properTitle.length - 1) {
} else { } else {
[self.properTitle[index], self.properTitle[index + 1]] = [self.properTitle[index + 1], self.properTitle[index]]; [self.properTitle[index], self.properTitle[index + 1]] = [self.properTitle[index + 1], self.properTitle[index]];
@@ -963,7 +1006,7 @@
if (index == 0) { if (index == 0) {
} else { } else {
[self.leftProperTitle[index], self.leftProperTitle[index+1]] = [self.leftProperTitle[index+1], self.properTitle[index]]; [self.leftProperTitle[index], self.leftProperTitle[index + 1]] = [self.leftProperTitle[index + 1], self.properTitle[index]];
} }
} else if ($(self.selectedElement).children().first().hasClass("righttitle")) { } else if ($(self.selectedElement).children().first().hasClass("righttitle")) {
@@ -971,7 +1014,7 @@
if (index == 0) { if (index == 0) {
} else { } else {
[self.rightProperTitle[index], self.rightProperTitle[index+1]] = [self.rightProperTitle[index+1], self.properTitle[index]]; [self.rightProperTitle[index], self.rightProperTitle[index + 1]] = [self.rightProperTitle[index + 1], self.properTitle[index]];
}; };
} }
@@ -1077,7 +1120,7 @@
return Number.parseFloat(val).toFixed(2); return Number.parseFloat(val).toFixed(2);
}, },
renderNormal(mid, d) { renderNormal(mid, d) {
console.log("renderNormal:",d) console.log("renderNormal:", d)
let self = this; let self = this;
let txt = $(`<div class='${d.elementID}'>${mid}</div>`).css({ let txt = $(`<div class='${d.elementID}'>${mid}</div>`).css({
"z-index": 9999, visibility: d.visibility, "z-index": 9999, visibility: d.visibility,
@@ -1189,7 +1232,7 @@
if (bot.length) h.append(this.renderNameGroups(bot, el)); if (bot.length) h.append(this.renderNameGroups(bot, el));
return h return h
}, },
renderCombined(mid,d) { renderCombined(mid, d) {
ancestorFontSize = d.fontSize; ancestorFontSize = d.fontSize;
newFontSize = d.fontSize; newFontSize = d.fontSize;
const parts = mid.join("\n").split('\n'); const parts = mid.join("\n").split('\n');
@@ -1267,7 +1310,7 @@
let allList = document.querySelector(".canselectItem").querySelectorAll("li"); //$(".canselectItem").querySelectorAll("li"); let allList = document.querySelector(".canselectItem").querySelectorAll("li"); //$(".canselectItem").querySelectorAll("li");
allList.forEach(x => { allList.forEach(x => {
let curr = $(x).children().eq(1); let curr = $(x).children().eq(1);
x.setAttribute("style","display:none") x.setAttribute("style", "display:none")
$(x).css("style", "display:none") $(x).css("style", "display:none")
if (curr && curr.text().includes($("#filter_txt").val())) { if (curr && curr.text().includes($("#filter_txt").val())) {
x.setAttribute("style", "display:") x.setAttribute("style", "display:")
@@ -1276,28 +1319,50 @@
} }
}); });
}, },
async saveFamily() {
let self = this;
if (this.follower_id == "") {
console.log("follower_id:", this.follower_id);
return false
}
let pro_order_detail =
{
// num: this.editedItem.num,//原先載入時的家人num
//f_num: this.editedItem.f_num_selected.val, //儲存時的家人num
//leader: this.follower_id,
//appellation_id: this.editedItem.appellation_id_selected.val, //儲存時的稱謂
follower_num: this.follower_id,
fam_name: $("#family_txt").val(),
deceased: $("#deceased_sel").val() == "False" ? false : true,
num:0
}
this.modal.toggle();
//$(this.modal).toggle();
//$(this.modal).addClass("hide");
//console.log(pro_order_detail);
//console.log(this.modal);
//$(this.modal).hide();
axios
.post('/api/tablet/saveFamily', pro_order_detail)
.then(response => {
console.log(response);
if (response.status == 200 && response.result == "Y") {
let data = response.data;
this.familyMembers.push(data);
alert("新增成功");
self.modal.toggle();
} else {
}
});
},
async save() { async save() {
//console.log("tabletItem:", designer.tabletItem); //console.log("tabletItem:", designer.tabletItem);
//拚牌位的內容 //拚牌位的內容
let self = this; let self = this;
//let target = self.familyMembers.filter(x => self.alive.includes(x.fam_name));
//designer.family_deceased_Y_selected.length = 0;
//self.alive.forEach(x => {
// let t = target.find(y => y.fam_name == x);
// let obj = {
// IsShuWen: false,
// deceased: false,
// fam_gender: "",
// fam_name: t.fam_name,
// fam_file: "",
// nospace: true,
// num: t.num,
// option_break: false
// }
// designer.family_deceased_Y_selected.push(obj);
//});
//console.log(designer.family_deceased_Y_selected, designer.family_deceased_N_selected);
let tablet = { let tablet = {
mid_items: designer.family_deceased_N_selected, mid_items: designer.family_deceased_N_selected,
left_items: designer.family_deceased_Y_selected, left_items: designer.family_deceased_Y_selected,
@@ -1407,7 +1472,8 @@
designer.rightProperTitle = [];//右正名 designer.rightProperTitle = [];//右正名
designer.address = "";//地址 designer.address = "";//地址
designer.alive = [];//陽上 designer.alive = [];//陽上
designer.tabletType= "A"; designer.tabletType = "A";
designer.follower_id = "";
$(".printArea").empty(); $(".printArea").empty();
$(".selectItem").empty(); $(".selectItem").empty();
$(".canselectItem").empty(); $(".canselectItem").empty();
@@ -1430,6 +1496,8 @@
designer.family_deceased_Y_selected = []; designer.family_deceased_Y_selected = [];
designer.family_deceased_N_selected = []; designer.family_deceased_N_selected = [];
designer.http_host = receivedData.host; designer.http_host = receivedData.host;
designer.follower_id = receivedData.follower_id;
console.log("123:",receivedData);
if (receivedData.tabletItem) { if (receivedData.tabletItem) {
//console.log('editor.html - updating tabletItem:', receivedData.tabletItem); //console.log('editor.html - updating tabletItem:', receivedData.tabletItem);
designer.tabletItem = receivedData.tabletItem; designer.tabletItem = receivedData.tabletItem;
@@ -1449,12 +1517,13 @@
} }
designer.actitem = receivedData.tabletItem.actitem_num_selected.val; designer.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 資料 // 處理 f_num_tablet 資料
if (designer.tabletItem.f_num_tablet) { if (designer.tabletItem.f_num_tablet) {
try { try {
const data = JSON.parse(designer.tabletItem.f_num_tablet); const data = JSON.parse(designer.tabletItem.f_num_tablet);
console.log("阿巫醫ㄟ喔:", data)
if (designer.item_type === 'B') { if (designer.item_type === 'B') {
// B類型:超渡、超薦等 // B類型:超渡、超薦等
designer.family_deceased_Y_selected = data.mid_items || []; designer.family_deceased_Y_selected = data.mid_items || [];