功德芳名列印,bug修正
This commit is contained in:
@@ -1,20 +1,22 @@
|
|||||||
using Model;
|
using DocumentFormat.OpenXml;
|
||||||
using Newtonsoft.Json;
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Http;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
using System.IO;
|
using Model;
|
||||||
using System.Net.Http;
|
using Newtonsoft.Json;
|
||||||
using System.Net;
|
using Newtonsoft.Json.Linq;
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using static Model.admin_log;
|
|
||||||
using DocumentFormat.OpenXml.Bibliography;
|
|
||||||
using PagedList;
|
using PagedList;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Http;
|
||||||
|
using static Model.admin_log;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ShuWenController 的摘要描述
|
/// ShuWenController 的摘要描述
|
||||||
@@ -395,4 +397,527 @@ public class ShuWenController : ApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/shuwen/GetShuwenData")]
|
||||||
|
public IHttpActionResult GetShuwenData([FromBody] dynamic data)
|
||||||
|
{
|
||||||
|
var json = data;
|
||||||
|
var mode = (json.mode == null ? "" : (string)json.mode);
|
||||||
|
var num = (json.activity_num == null ? 0 : (int)json.activity_num);
|
||||||
|
|
||||||
|
var act = _db.activities.AsQueryable().Where(v => v.num == num).FirstOrDefault();
|
||||||
|
|
||||||
|
var query = _db.pro_order_detail.AsQueryable();
|
||||||
|
query = query.Where(x => (_db.act_bom.AsQueryable().Where(y => y.package_num == null).Select(y => y.item_num).ToList()).
|
||||||
|
Contains(x.actItem_num));
|
||||||
|
query = query.Where(x => (_db.pro_order.AsQueryable().
|
||||||
|
Where(w => w.activity_num == num).Select(w => w.order_no)).ToList().Contains(x.order_no));
|
||||||
|
//query = query.Include(x=>x.actItem).Where(x=>x.actItem.subject.StartsWith("消"));
|
||||||
|
|
||||||
|
//這些是功德主
|
||||||
|
var list = query.OrderByDescending(x => x.price).Select(x => new
|
||||||
|
{
|
||||||
|
x.num,
|
||||||
|
x.order_no,
|
||||||
|
x.actItem_num,
|
||||||
|
x.parent_num,
|
||||||
|
x.print_id,
|
||||||
|
x.f_num_tablet,
|
||||||
|
x.price,
|
||||||
|
subject = _db.actItems.Where(w => w.num == x.actItem_num).Select(w => w.subject).FirstOrDefault(),
|
||||||
|
childs = _db.pro_order_detail.
|
||||||
|
Where(z => z.order_no == x.order_no && z.parent_num == x.num).Select(z => new
|
||||||
|
{
|
||||||
|
z.num,
|
||||||
|
z.order_no,
|
||||||
|
z.actItem_num,
|
||||||
|
z.parent_num,
|
||||||
|
z.print_id,
|
||||||
|
z.f_num_tablet,
|
||||||
|
z.price,
|
||||||
|
subject = _db.actItems.Where(w => w.num == z.actItem_num).Select(w => w.subject).FirstOrDefault(),
|
||||||
|
}).ToList()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var query1 = _db.pro_order_detail.AsQueryable();
|
||||||
|
query1 = query1.Where(x => !(_db.act_bom.AsQueryable().Where(y => y.package_num == null).Select(y => y.item_num).ToList()).
|
||||||
|
Contains(x.actItem_num));
|
||||||
|
query1 = query1.Where(x => x.parent_num == null);
|
||||||
|
query1 = query1.Where(x => (_db.pro_order.AsQueryable().
|
||||||
|
Where(w => w.activity_num == num).Select(w => w.order_no)).ToList().Contains(x.order_no));
|
||||||
|
query1 = query1.Include(x => x.actItem).Where(x => x.actItem.subject.StartsWith(mode == "消" ? "消" : "超"));
|
||||||
|
//這些是非功德主
|
||||||
|
var list1 = query1.Select(x => new
|
||||||
|
{
|
||||||
|
x.num,
|
||||||
|
x.order_no,
|
||||||
|
x.actItem_num,
|
||||||
|
x.parent_num,
|
||||||
|
x.print_id,
|
||||||
|
x.f_num_tablet,
|
||||||
|
x.price,
|
||||||
|
subject = _db.actItems.Where(w => w.num == x.actItem_num).Select(w => w.subject).FirstOrDefault(),
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
//string filePath = "範例文件.docx";
|
||||||
|
string folderPath = HttpContext.Current.Server.MapPath("~/tempfile/");
|
||||||
|
|
||||||
|
// 確保資料夾存在
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 使用 GUID 命名防衝突
|
||||||
|
string fileName = Guid.NewGuid().ToString() + ".docx";
|
||||||
|
string fullPath = Path.Combine(folderPath, fileName);
|
||||||
|
|
||||||
|
if (mode == "消")
|
||||||
|
{
|
||||||
|
// 1. 建立 Word 文件
|
||||||
|
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fullPath, WordprocessingDocumentType.Document, true))
|
||||||
|
{
|
||||||
|
Body body = new Body();
|
||||||
|
var doc = GenerateDocument(wordDocument, body);
|
||||||
|
string preItemName = string.Empty;
|
||||||
|
|
||||||
|
foreach (var dd in list)
|
||||||
|
{
|
||||||
|
if (dd.childs.Count > 0)
|
||||||
|
{
|
||||||
|
if (preItemName != dd.subject)
|
||||||
|
{
|
||||||
|
body.Append(RenderParagraph(44, $"{act.subject}{dd.subject} 消災祈福名單", true, 0));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(preItemName))
|
||||||
|
{
|
||||||
|
preItemName = dd.subject;
|
||||||
|
}
|
||||||
|
List<string> preItemTitle = new List<string>();
|
||||||
|
foreach (var child in dd.childs)
|
||||||
|
{
|
||||||
|
if (!child.subject.StartsWith("消"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//preItemTitle.Append(child)
|
||||||
|
JObject obj = JObject.Parse(child.f_num_tablet);
|
||||||
|
JArray arr = (JArray)obj["mid_items"];
|
||||||
|
foreach (var item in arr)
|
||||||
|
{
|
||||||
|
|
||||||
|
preItemTitle.Add((string)item["fam_name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false, 1134));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ChangePage(body);
|
||||||
|
//if (list1.Count > 0)
|
||||||
|
//{
|
||||||
|
// Hashtable ht = new Hashtable();
|
||||||
|
// string preOrderNo = string.Empty;
|
||||||
|
// body.Append(RenderParagraph(44, $"{act.subject} 消災祈福名單", true));
|
||||||
|
// List<string> preItemTitle = new List<string>();
|
||||||
|
// foreach (var dd in list1)
|
||||||
|
// {
|
||||||
|
// if (preOrderNo != dd.order_no)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// if (preItemTitle.Count > 0)
|
||||||
|
// {
|
||||||
|
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
||||||
|
// }
|
||||||
|
// ht.Clear();
|
||||||
|
// preItemTitle.Clear();
|
||||||
|
// }
|
||||||
|
// JObject obj = JObject.Parse(dd.f_num_tablet);
|
||||||
|
// JArray arr = (JArray)obj["mid_items"];
|
||||||
|
// foreach (var item in arr)
|
||||||
|
// {
|
||||||
|
// if (ht.ContainsKey((string)item["fam_name"]))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// if (string.Join(" ", preItemTitle).Length + ((string)item["fam_name"]).Length > 25)
|
||||||
|
// {
|
||||||
|
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
||||||
|
// preItemTitle.Clear();
|
||||||
|
// }
|
||||||
|
// preItemTitle.Add((string)item["fam_name"]);
|
||||||
|
// ht.Add((string)item["fam_name"], (string)item["fam_name"]);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// preOrderNo = dd.order_no;
|
||||||
|
// }
|
||||||
|
// if (preItemTitle.Count > 0)
|
||||||
|
// {
|
||||||
|
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
SetStraight(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mode == "超")
|
||||||
|
{
|
||||||
|
List<Shuwen> shuwenList = new List<Shuwen>();
|
||||||
|
Shuwen shuwen = new Shuwen();
|
||||||
|
string preOrderNo = string.Empty;
|
||||||
|
foreach (var dd in list)
|
||||||
|
{
|
||||||
|
if (preOrderNo != dd.order_no)
|
||||||
|
{
|
||||||
|
//if(!string.IsNullOrEmpty(shuwen.order_no)&&shuwen.mid_item.Count>0)
|
||||||
|
// shuwenList.Add(shuwen);
|
||||||
|
shuwen = new Shuwen();
|
||||||
|
shuwen.order_no = dd.order_no;
|
||||||
|
shuwen.subject = dd.subject;
|
||||||
|
shuwen.mid_item = new List<string>();
|
||||||
|
}
|
||||||
|
if (dd.childs.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in dd.childs)
|
||||||
|
{
|
||||||
|
if (!item.subject.StartsWith("超"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject obj = JObject.Parse(item.f_num_tablet);
|
||||||
|
JArray mid = (JArray)obj["mid_items"];
|
||||||
|
JArray left = (JArray)obj["left_items"];
|
||||||
|
List<string> leftList = new List<string>();
|
||||||
|
List<string> midList = new List<string>();
|
||||||
|
foreach (var o in mid)
|
||||||
|
{
|
||||||
|
midList.Add((string)o["fam_name"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var o in left)
|
||||||
|
{
|
||||||
|
leftList.Add((string)o["fam_name"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var wen = shuwenList.Where(z => z.alive == string.Join(" ", leftList) && z.order_no == dd.order_no).FirstOrDefault();
|
||||||
|
if (wen != null && wen.alive == string.Join(" ", leftList))
|
||||||
|
{
|
||||||
|
wen.mid_item.AddRange(midList);
|
||||||
|
shuwen = new Shuwen();
|
||||||
|
shuwen.order_no = dd.order_no;
|
||||||
|
shuwen.subject = dd.subject;
|
||||||
|
shuwen.mid_item = new List<string>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shuwen.alive = string.Join(" ", leftList);
|
||||||
|
shuwen.mid_item.AddRange(midList);
|
||||||
|
shuwenList.Add(shuwen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if (shuwen.mid_item.Count > 0)
|
||||||
|
//{
|
||||||
|
// shuwenList.Add(shuwen);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
preOrderNo = dd.order_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fullPath, WordprocessingDocumentType.Document, true))
|
||||||
|
{
|
||||||
|
Body body = new Body();
|
||||||
|
var doc = GenerateDocument(wordDocument, body);
|
||||||
|
string preItem = string.Empty;
|
||||||
|
foreach (var shu in shuwenList)
|
||||||
|
{
|
||||||
|
if (preItem != shu.subject)
|
||||||
|
{
|
||||||
|
body.Append(RenderParagraph(44, $"{act.subject}{shu.subject} 超薦名單", true, 0));
|
||||||
|
}
|
||||||
|
body.Append(RenderParagraph(44, "佛力超薦", true, 0));
|
||||||
|
//foreach (var wen in shu.mid_item)
|
||||||
|
//{
|
||||||
|
// body.Append(RenderParagraph(44, $" {wen}", false));
|
||||||
|
//}
|
||||||
|
//這裡要改切段落
|
||||||
|
List<string> para = new List<string>();
|
||||||
|
foreach (var p in shu.mid_item)
|
||||||
|
{
|
||||||
|
if (string.Join(" ", para).Length + p.Length > 25)
|
||||||
|
{
|
||||||
|
body.Append(RenderParagraph(44, $" {string.Join(" ", para)}", false, 1134));
|
||||||
|
para.Clear();
|
||||||
|
}
|
||||||
|
para.Add(p.ToString());
|
||||||
|
}
|
||||||
|
if (para.Count > 0)
|
||||||
|
{
|
||||||
|
body.Append(RenderParagraph(44, $" {string.Join(" ", para)}", false, 1134));
|
||||||
|
para.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
body.Append(RenderParagraph(44, $"陽上報恩人", true,0));
|
||||||
|
body.Append(RenderParagraph(44, $" {shu.alive}", false, 1134));
|
||||||
|
|
||||||
|
preItem = shu.subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetStraight(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 讀取檔案串流
|
||||||
|
var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
// 建立原始的 HttpResponseMessage
|
||||||
|
var response = new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = new StreamContent(fileStream)
|
||||||
|
};
|
||||||
|
|
||||||
|
// 設定 Word 檔案的 Content-Type 與下載檔名
|
||||||
|
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||||
|
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||||
|
{
|
||||||
|
FileName = $"{act.subject}_{mode}.docx"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 使用 ResponseMessage 方法將 HttpResponseMessage 轉為 IHttpActionResult
|
||||||
|
return ResponseMessage(response);
|
||||||
|
|
||||||
|
//return Ok(new { result = "Y", data = new { list = list, list1 = list1 } });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangePage(Body body)
|
||||||
|
{
|
||||||
|
Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00A56886", RsidRunAdditionDefault = "00D919D0" };
|
||||||
|
|
||||||
|
Run pageBreakRun = new Run();
|
||||||
|
pageBreakRun.Append(new Break() { Type = BreakValues.Page }); // 指定 Break 類型為 Page (換頁)
|
||||||
|
paragraph1.Append(pageBreakRun);
|
||||||
|
|
||||||
|
body.Append(paragraph1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordprocessingDocument GenerateDocument(WordprocessingDocument document1, Body body)
|
||||||
|
{
|
||||||
|
MainDocumentPart mainPart = document1.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
|
||||||
|
|
||||||
|
mainPart.Document.AppendChild(body);
|
||||||
|
|
||||||
|
|
||||||
|
return document1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStraight(Body body)
|
||||||
|
{
|
||||||
|
|
||||||
|
SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "00A56886", RsidSect = "00D919D0" };
|
||||||
|
PageSize pageSize1 = new PageSize() { Width = 16838U, Height = 11906U, Orient = PageOrientationValues.Landscape };
|
||||||
|
PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = 1440U, Bottom = 1440, Left = 1440U, Header = 720U, Footer = 720U, Gutter = 0U };
|
||||||
|
Columns columns1 = new Columns() { Space = "720" };
|
||||||
|
TextDirection textDirection3 = new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft };
|
||||||
|
DocGrid docGrid1 = new DocGrid() { LinePitch = 326 };
|
||||||
|
|
||||||
|
sectionProperties1.Append(pageSize1);
|
||||||
|
sectionProperties1.Append(pageMargin1);
|
||||||
|
sectionProperties1.Append(columns1);
|
||||||
|
sectionProperties1.Append(textDirection3);
|
||||||
|
sectionProperties1.Append(docGrid1);
|
||||||
|
body.Append(sectionProperties1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Paragraph RenderParagraph(int fontSize, string content, bool isBold,int indentSize)
|
||||||
|
{
|
||||||
|
Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00A56886", RsidRunAdditionDefault = "00D919D0" };
|
||||||
|
|
||||||
|
ParagraphProperties paragraphProperties2 = new ParagraphProperties();
|
||||||
|
TextDirection textDirection2 = new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft };
|
||||||
|
|
||||||
|
|
||||||
|
// 2. 建立縮排物件
|
||||||
|
Indentation indent = new Indentation();
|
||||||
|
|
||||||
|
// --- 請依需求選擇以下一種縮排方式設定 ---
|
||||||
|
|
||||||
|
// 懸首縮排 (Hanging): 第一行不動,其餘行縮排。 (1公分約為 567 dxa)
|
||||||
|
indent.Left = $"{ indentSize }"; // 整體左縮排量
|
||||||
|
indent.Hanging = $"{indentSize}";
|
||||||
|
//indent.FirstLine = "1134";
|
||||||
|
paragraphProperties2.Append(indent);
|
||||||
|
|
||||||
|
paragraphProperties2.Append(textDirection2);
|
||||||
|
|
||||||
|
Run run2 = new Run();
|
||||||
|
|
||||||
|
RunProperties runProperties2 = new RunProperties();
|
||||||
|
RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "標楷體", EastAsia = "標楷體" };
|
||||||
|
FontSize fontSize2 = new FontSize() { Val = $"{fontSize}" };
|
||||||
|
|
||||||
|
runProperties2.Append(runFonts2);
|
||||||
|
runProperties2.Append(fontSize2);
|
||||||
|
if (isBold)
|
||||||
|
{
|
||||||
|
runProperties2.Append(new Bold());
|
||||||
|
}
|
||||||
|
Text text2 = new Text();
|
||||||
|
text2.Space = SpaceProcessingModeValues.Preserve;
|
||||||
|
text2.Text = $"{content}";
|
||||||
|
|
||||||
|
run2.Append(runProperties2);
|
||||||
|
run2.Append(text2);
|
||||||
|
paragraph2.Append(paragraphProperties2);
|
||||||
|
paragraph2.Append(run2);
|
||||||
|
|
||||||
|
|
||||||
|
return paragraph2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/shuwen/PrintItemReport")]
|
||||||
|
public IHttpActionResult PrintItemReport([FromBody] dynamic data)
|
||||||
|
{
|
||||||
|
var json = data;
|
||||||
|
var mode = (json.mode == null ? "" : (string)json.mode);
|
||||||
|
var num = (json.activity_num == null ? 0 : (int)json.activity_num);
|
||||||
|
var actItems = (json.actItems == null ? new JArray() : (JArray)json.actItems);
|
||||||
|
List<int?> primitiveIds = actItems.ToObject<List<int?>>();
|
||||||
|
var qry=_db.pro_order_detail.AsQueryable();
|
||||||
|
qry = qry.Where(x=>(_db.pro_order.Where(y=>y.activity_num==num).Select(y=>y.order_no).ToList().
|
||||||
|
Contains(x.order_no))).Where(x=> primitiveIds.Contains(x.actItem_num));
|
||||||
|
|
||||||
|
var list = qry.Select(x => new
|
||||||
|
{
|
||||||
|
x.qty,x.price,
|
||||||
|
name=_db.pro_order.Where(y=>y.order_no==x.order_no).Select(y=>new
|
||||||
|
{
|
||||||
|
u_name=_db.followers.Where(z=>z.num==y.f_num).Select(z=>z.u_name).FirstOrDefault()
|
||||||
|
}).FirstOrDefault()
|
||||||
|
}).ToList();
|
||||||
|
//string filePath = "範例文件.docx";
|
||||||
|
string folderPath = HttpContext.Current.Server.MapPath("~/tempfile/");
|
||||||
|
|
||||||
|
// 確保資料夾存在
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 使用 GUID 命名防衝突
|
||||||
|
string fileName = Guid.NewGuid().ToString() + ".docx";
|
||||||
|
string fullPath = Path.Combine(folderPath, fileName);
|
||||||
|
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fullPath, WordprocessingDocumentType.Document, true))
|
||||||
|
{
|
||||||
|
Body body = new Body();
|
||||||
|
var doc = GenerateDocument(wordDocument, body);
|
||||||
|
|
||||||
|
// 1. 建立表格物件
|
||||||
|
Table table = new Table();
|
||||||
|
|
||||||
|
// 2. 設定表格邊框樣式 (選擇性)
|
||||||
|
TableProperties tblProp = new TableProperties(
|
||||||
|
new TableBorders(
|
||||||
|
new TopBorder { Val = BorderValues.Single, Size = 4 },
|
||||||
|
new BottomBorder { Val = BorderValues.Single, Size = 4 },
|
||||||
|
new LeftBorder { Val = BorderValues.Single, Size = 4 },
|
||||||
|
new RightBorder { Val = BorderValues.Single, Size = 4 },
|
||||||
|
new InsideHorizontalBorder { Val = BorderValues.Single, Size = 4 }, // 修正這行
|
||||||
|
new InsideVerticalBorder { Val = BorderValues.Single, Size = 4 } // 修正這行
|
||||||
|
)
|
||||||
|
);
|
||||||
|
TableWidth tableWidthPercent = new TableWidth()
|
||||||
|
{
|
||||||
|
Width = "5000",
|
||||||
|
Type = TableWidthUnitValues.Pct
|
||||||
|
};
|
||||||
|
|
||||||
|
tblProp.AppendChild(tableWidthPercent);
|
||||||
|
table.AppendChild(tblProp);
|
||||||
|
|
||||||
|
|
||||||
|
// 3. 建立第一列 (標頭列)
|
||||||
|
TableRow row1 = new TableRow();
|
||||||
|
|
||||||
|
TableCell cell1 = new TableCell(RenderParagraph(44, "姓名", false,0));
|
||||||
|
TableCell cell2 = new TableCell(RenderParagraph(44, "姓名", false, 0));
|
||||||
|
|
||||||
|
row1.Append(cell1, cell2);
|
||||||
|
table.Append(row1);
|
||||||
|
TableRow row2 = new TableRow();
|
||||||
|
int i = 0;
|
||||||
|
var newList=list.GroupBy(x => x.name).Select(g => new
|
||||||
|
{
|
||||||
|
name=g.Key,qty=g.Sum(s=>s.qty),price=g.FirstOrDefault().price
|
||||||
|
}).ToList();
|
||||||
|
foreach (var d in newList) {
|
||||||
|
// 4. 建立第二列 (資料列)
|
||||||
|
TableCell cell3 = new TableCell(RenderParagraph(44, d.name.u_name, false, 0));
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
row2 = new TableRow();
|
||||||
|
}
|
||||||
|
row2.Append(cell3);
|
||||||
|
if (i == 1)
|
||||||
|
{
|
||||||
|
table.Append(row2);
|
||||||
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newList.Count%2!=0)
|
||||||
|
{
|
||||||
|
TableCell cell3 = new TableCell(RenderParagraph(44, "", false, 0));
|
||||||
|
row2.Append(cell3);
|
||||||
|
table.Append(row2);
|
||||||
|
}
|
||||||
|
body.Append(table);
|
||||||
|
// 將表格加入到文件主體中
|
||||||
|
//mainPart.Document.Body.Append(table);
|
||||||
|
//mainPart.Document.Save();
|
||||||
|
}
|
||||||
|
// 讀取檔案串流
|
||||||
|
var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
// 建立原始的 HttpResponseMessage
|
||||||
|
var response = new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = new StreamContent(fileStream)
|
||||||
|
};
|
||||||
|
|
||||||
|
// 設定 Word 檔案的 Content-Type 與下載檔名
|
||||||
|
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||||
|
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||||
|
{
|
||||||
|
FileName = $"{mode}.docx"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 使用 ResponseMessage 方法將 HttpResponseMessage 轉為 IHttpActionResult
|
||||||
|
return ResponseMessage(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Shuwen
|
||||||
|
{
|
||||||
|
public Shuwen() { }
|
||||||
|
public string order_no { get; set; }
|
||||||
|
public List<string> mid_item { get; set; }
|
||||||
|
public string alive { get; set; }
|
||||||
|
public string subject { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1053,6 +1053,157 @@ public class activityController : ApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("api/activity/GetActRelaList2")]
|
||||||
|
public IHttpActionResult GetActRelaList2([FromBody] Model.activity q, int page, int pageSize = 100,
|
||||||
|
string sortBy = "", bool sortDesc = false)
|
||||||
|
{ //if pagesize==-1 get all data
|
||||||
|
int this_act_id = q.num;
|
||||||
|
if (this_act_id > 0)
|
||||||
|
{
|
||||||
|
//檢查
|
||||||
|
var prod = _db.activities.Where(o => o.num == this_act_id).FirstOrDefault();
|
||||||
|
if (prod != null)
|
||||||
|
{
|
||||||
|
int kind = prod.kind ?? 0; //分類
|
||||||
|
|
||||||
|
var qry = _db.activity_relating.AsQueryable();
|
||||||
|
qry = qry.Where(o => o.activity_num == this_act_id);
|
||||||
|
qry = qry.OrderBy(o => o.num);
|
||||||
|
//IEnumerable<Model.activity_relating> qry1=qry.AsEnumerable();
|
||||||
|
IEnumerable<Model.activity_relating> qry1 = null;
|
||||||
|
|
||||||
|
//var retD = qry1;
|
||||||
|
var count = qry.Count(); //pageSize = count;//一次取回??
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
//已有值
|
||||||
|
if (pageSize > 0)
|
||||||
|
{
|
||||||
|
qry1 = qry.ToPagedList(page, pageSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qry1 = qry.ToList();
|
||||||
|
}
|
||||||
|
var orderDetails = _db.pro_order_detail
|
||||||
|
.Where(o => o.pro_order.activity_num == this_act_id)
|
||||||
|
.ToList();
|
||||||
|
var ret = new
|
||||||
|
{
|
||||||
|
//list = qry1.ToPagedList(page, pageSize).Select(x => new
|
||||||
|
list = qry1.Select(x => new
|
||||||
|
{
|
||||||
|
id = i++,
|
||||||
|
num = x.num,
|
||||||
|
|
||||||
|
activity_num = x.activity_num,
|
||||||
|
act_item_selected = new
|
||||||
|
{
|
||||||
|
text = x.actItem?.subject,
|
||||||
|
val = x.actItem_num,
|
||||||
|
style = x.actItem.defaultStyle
|
||||||
|
},
|
||||||
|
price = x.price ?? 0,
|
||||||
|
qty = x.qty ?? 0,
|
||||||
|
has_yang_limit = x.has_yang_limit ?? false,
|
||||||
|
has_chao_limit = x.has_yang_limit ?? false,
|
||||||
|
yang_limit_count = x.yang_limit_count ?? 0,
|
||||||
|
chao_limit_count = x.chao_limit_count ?? 0,
|
||||||
|
files = x.actItem?.actItem_files.Select(f => new
|
||||||
|
{
|
||||||
|
num = f.file.num,
|
||||||
|
subject = f.file.subject,
|
||||||
|
list = orderDetails
|
||||||
|
.Where(o => o.actItem_num == x.actItem_num)
|
||||||
|
.OrderBy(o => o.print_id)
|
||||||
|
.ThenBy(o => o.num)
|
||||||
|
.Select(o => new
|
||||||
|
{
|
||||||
|
num = o.num,
|
||||||
|
print_id = o.print_id,
|
||||||
|
order_no = o.order_no,
|
||||||
|
from_id = o.follower1?.u_name,
|
||||||
|
printed_files = o.printed_files,
|
||||||
|
isPrinted = (o.printed_files ?? "").Contains("\"" + f.file.num.ToString() + "\""),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
count = count,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||||
|
return Ok(ret);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//未有資料
|
||||||
|
//帶分類預設
|
||||||
|
if (kind > 0)
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
var qry2 = _db.activity_kind_detail.Where(o => o.activity_kind_num == kind);
|
||||||
|
var count2 = qry2.Count(); //pageSize = count2;//一次取回??
|
||||||
|
var qry2List = (pageSize > 0) ? qry2.ToPagedList(page, pageSize).ToList() : qry2.ToList();
|
||||||
|
var ret = new
|
||||||
|
{
|
||||||
|
list = qry2List.Select(x => new
|
||||||
|
{
|
||||||
|
id = i++,
|
||||||
|
num = 0,
|
||||||
|
activity_num = this_act_id,
|
||||||
|
act_item_selected = new
|
||||||
|
{
|
||||||
|
text = x.actItem?.subject,
|
||||||
|
val = x.actItem_num,
|
||||||
|
style = x.actItem.defaultStyle
|
||||||
|
},
|
||||||
|
price = x.price ?? 0,
|
||||||
|
qty = x.qty ?? 0,
|
||||||
|
files = new
|
||||||
|
{
|
||||||
|
num = "",
|
||||||
|
subject = "",
|
||||||
|
list = new
|
||||||
|
{
|
||||||
|
num = "",
|
||||||
|
from_id = "",
|
||||||
|
printed_files = "",
|
||||||
|
isPrinted = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
count = count2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||||
|
return Ok(ret);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("api/activity/GetActRelaList1")]
|
[Route("api/activity/GetActRelaList1")]
|
||||||
|
|||||||
@@ -109,369 +109,5 @@ public class orderdetailController:ApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
[Route("api/orderdetail/GetShuwenData")]
|
|
||||||
public IHttpActionResult GetShuwenData([FromBody] dynamic data)
|
|
||||||
{
|
|
||||||
var json = data;
|
|
||||||
var mode = (json.mode == null ? "" : (string)json.mode);
|
|
||||||
var num = (json.activity_num == null ? 0 : (int)json.activity_num);
|
|
||||||
|
|
||||||
var act = _db.activities.AsQueryable().Where(v=>v.num==num).FirstOrDefault();
|
|
||||||
|
|
||||||
var query = _db.pro_order_detail.AsQueryable();
|
|
||||||
query=query.Where(x => (_db.act_bom.AsQueryable().Where(y => y.package_num == null).Select(y => y.item_num).ToList()).
|
|
||||||
Contains(x.actItem_num));
|
|
||||||
query = query.Where(x => (_db.pro_order.AsQueryable().
|
|
||||||
Where(w => w.activity_num ==num ).Select(w => w.order_no)).ToList().Contains(x.order_no));
|
|
||||||
//query = query.Include(x=>x.actItem).Where(x=>x.actItem.subject.StartsWith("消"));
|
|
||||||
|
|
||||||
//這些是功德主
|
|
||||||
var list = query.OrderByDescending(x=>x.price).Select(x => new
|
|
||||||
{
|
|
||||||
x.num,x.order_no,x.actItem_num,x.parent_num,x.print_id,x.f_num_tablet,x.price,
|
|
||||||
subject= _db.actItems.Where(w => w.num == x.actItem_num).Select(w => w.subject).FirstOrDefault(),
|
|
||||||
childs =_db.pro_order_detail.
|
|
||||||
Where(z=>z.order_no==x.order_no&&z.parent_num==x.num).Select(z=>new
|
|
||||||
{
|
|
||||||
z.num,
|
|
||||||
z.order_no,
|
|
||||||
z.actItem_num,
|
|
||||||
z.parent_num,
|
|
||||||
z.print_id,
|
|
||||||
z.f_num_tablet,
|
|
||||||
z.price,
|
|
||||||
subject=_db.actItems.Where(w=>w.num==z.actItem_num).Select(w=>w.subject).FirstOrDefault(),
|
|
||||||
}).ToList()
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var query1 = _db.pro_order_detail.AsQueryable();
|
|
||||||
query1 = query1.Where(x => !(_db.act_bom.AsQueryable().Where(y => y.package_num == null).Select(y => y.item_num).ToList()).
|
|
||||||
Contains(x.actItem_num));
|
|
||||||
query1 = query1.Where(x => x.parent_num == null);
|
|
||||||
query1 = query1.Where(x => (_db.pro_order.AsQueryable().
|
|
||||||
Where(w => w.activity_num == num).Select(w => w.order_no)).ToList().Contains(x.order_no));
|
|
||||||
query1 = query1.Include(x => x.actItem).Where(x => x.actItem.subject.StartsWith(mode=="消"?"消":"超"));
|
|
||||||
//這些是非功德主
|
|
||||||
var list1 = query1.Select(x => new
|
|
||||||
{
|
|
||||||
x.num,
|
|
||||||
x.order_no,
|
|
||||||
x.actItem_num,
|
|
||||||
x.parent_num,
|
|
||||||
x.print_id,
|
|
||||||
x.f_num_tablet,
|
|
||||||
x.price,
|
|
||||||
subject = _db.actItems.Where(w => w.num == x.actItem_num).Select(w => w.subject).FirstOrDefault(),
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
//string filePath = "範例文件.docx";
|
|
||||||
string folderPath = HttpContext.Current.Server.MapPath("~/App_Data/");
|
|
||||||
|
|
||||||
// 確保資料夾存在
|
|
||||||
if (!Directory.Exists(folderPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(folderPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 使用 GUID 命名防衝突
|
|
||||||
string fileName = Guid.NewGuid().ToString() + ".docx";
|
|
||||||
string fullPath = Path.Combine(folderPath, fileName);
|
|
||||||
|
|
||||||
if (mode == "消")
|
|
||||||
{
|
|
||||||
// 1. 建立 Word 文件
|
|
||||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fullPath, WordprocessingDocumentType.Document, true))
|
|
||||||
{
|
|
||||||
Body body = new Body();
|
|
||||||
var doc = GenerateDocument(wordDocument, body);
|
|
||||||
string preItemName = string.Empty;
|
|
||||||
|
|
||||||
foreach (var dd in list)
|
|
||||||
{
|
|
||||||
if (dd.childs.Count > 0)
|
|
||||||
{
|
|
||||||
if (preItemName != dd.subject)
|
|
||||||
{
|
|
||||||
body.Append(RenderParagraph(44, $"{act.subject}{dd.subject} 消災祈福名單", true));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(preItemName))
|
|
||||||
{
|
|
||||||
preItemName = dd.subject;
|
|
||||||
}
|
|
||||||
List<string> preItemTitle = new List<string>();
|
|
||||||
foreach (var child in dd.childs)
|
|
||||||
{
|
|
||||||
if (!child.subject.StartsWith("消"))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//preItemTitle.Append(child)
|
|
||||||
JObject obj = JObject.Parse(child.f_num_tablet);
|
|
||||||
JArray arr = (JArray)obj["mid_items"];
|
|
||||||
foreach (var item in arr)
|
|
||||||
{
|
|
||||||
|
|
||||||
preItemTitle.Add((string)item["fam_name"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//ChangePage(body);
|
|
||||||
//if (list1.Count > 0)
|
|
||||||
//{
|
|
||||||
// Hashtable ht = new Hashtable();
|
|
||||||
// string preOrderNo = string.Empty;
|
|
||||||
// body.Append(RenderParagraph(44, $"{act.subject} 消災祈福名單", true));
|
|
||||||
// List<string> preItemTitle = new List<string>();
|
|
||||||
// foreach (var dd in list1)
|
|
||||||
// {
|
|
||||||
// if (preOrderNo != dd.order_no)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// if (preItemTitle.Count > 0)
|
|
||||||
// {
|
|
||||||
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
|
||||||
// }
|
|
||||||
// ht.Clear();
|
|
||||||
// preItemTitle.Clear();
|
|
||||||
// }
|
|
||||||
// JObject obj = JObject.Parse(dd.f_num_tablet);
|
|
||||||
// JArray arr = (JArray)obj["mid_items"];
|
|
||||||
// foreach (var item in arr)
|
|
||||||
// {
|
|
||||||
// if (ht.ContainsKey((string)item["fam_name"]))
|
|
||||||
// {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (string.Join(" ", preItemTitle).Length + ((string)item["fam_name"]).Length > 25)
|
|
||||||
// {
|
|
||||||
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
|
||||||
// preItemTitle.Clear();
|
|
||||||
// }
|
|
||||||
// preItemTitle.Add((string)item["fam_name"]);
|
|
||||||
// ht.Add((string)item["fam_name"], (string)item["fam_name"]);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// preOrderNo = dd.order_no;
|
|
||||||
// }
|
|
||||||
// if (preItemTitle.Count > 0)
|
|
||||||
// {
|
|
||||||
// body.Append(RenderParagraph(44, $" {string.Join(" ", preItemTitle)}", false));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
SetStraight(body);
|
|
||||||
}
|
|
||||||
}else if (mode=="超")
|
|
||||||
{
|
|
||||||
List<Shuwen> shuwenList= new List<Shuwen>();
|
|
||||||
Shuwen shuwen = new Shuwen();
|
|
||||||
string preOrderNo=string.Empty;
|
|
||||||
foreach (var dd in list)
|
|
||||||
{
|
|
||||||
if (preOrderNo!=dd.order_no)
|
|
||||||
{
|
|
||||||
//if(!string.IsNullOrEmpty(shuwen.order_no)&&shuwen.mid_item.Count>0)
|
|
||||||
// shuwenList.Add(shuwen);
|
|
||||||
shuwen = new Shuwen();
|
|
||||||
shuwen.order_no = dd.order_no;
|
|
||||||
shuwen.subject = dd.subject;
|
|
||||||
shuwen.mid_item = new List<string>();
|
|
||||||
}
|
|
||||||
if (dd.childs.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var item in dd.childs)
|
|
||||||
{
|
|
||||||
if (!item.subject.StartsWith("超"))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
JObject obj = JObject.Parse(item.f_num_tablet);
|
|
||||||
JArray mid = (JArray)obj["mid_items"];
|
|
||||||
JArray left = (JArray)obj["left_items"];
|
|
||||||
List<string> leftList=new List<string>();
|
|
||||||
List<string> midList = new List<string>();
|
|
||||||
foreach (var o in mid)
|
|
||||||
{
|
|
||||||
midList.Add((string)o["fam_name"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var o in left)
|
|
||||||
{
|
|
||||||
leftList.Add((string)o["fam_name"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var wen=shuwenList.Where(z => z.alive == string.Join(" ", leftList)&&z.order_no==dd.order_no).FirstOrDefault();
|
|
||||||
if (wen != null&&wen.alive== string.Join(" ", leftList))
|
|
||||||
{
|
|
||||||
wen.mid_item.AddRange(midList);
|
|
||||||
shuwen = new Shuwen();
|
|
||||||
shuwen.order_no = dd.order_no;
|
|
||||||
shuwen.subject = dd.subject;
|
|
||||||
shuwen.mid_item = new List<string>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shuwen.alive = string.Join(" ", leftList);
|
|
||||||
shuwen.mid_item.AddRange(midList);
|
|
||||||
shuwenList.Add(shuwen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if (shuwen.mid_item.Count > 0)
|
|
||||||
//{
|
|
||||||
// shuwenList.Add(shuwen);
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
preOrderNo = dd.order_no;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(fullPath, WordprocessingDocumentType.Document, true))
|
|
||||||
{
|
|
||||||
Body body = new Body();
|
|
||||||
var doc = GenerateDocument(wordDocument, body);
|
|
||||||
string preItem = string.Empty;
|
|
||||||
foreach(var shu in shuwenList)
|
|
||||||
{
|
|
||||||
if (preItem != shu.subject)
|
|
||||||
{
|
|
||||||
body.Append(RenderParagraph(44, $"{act.subject}{shu.subject} 超薦名單", true));
|
|
||||||
}
|
|
||||||
body.Append(RenderParagraph(44, "佛力超薦", true));
|
|
||||||
//foreach (var wen in shu.mid_item)
|
|
||||||
//{
|
|
||||||
// body.Append(RenderParagraph(44, $" {wen}", false));
|
|
||||||
//}
|
|
||||||
//這裡要改切段落
|
|
||||||
List<string> para= new List<string>();
|
|
||||||
foreach (var p in shu.mid_item)
|
|
||||||
{
|
|
||||||
if (string.Join(" ",para).Length+p.Length>25)
|
|
||||||
{
|
|
||||||
body.Append(RenderParagraph(44, $"{string.Join(" ", para)}", false));
|
|
||||||
para.Clear();
|
|
||||||
}
|
|
||||||
para.Add(p.ToString());
|
|
||||||
}
|
|
||||||
if (para.Count>0)
|
|
||||||
{
|
|
||||||
body.Append(RenderParagraph(44, $"{string.Join(" ", para)}", false));
|
|
||||||
para.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
body.Append(RenderParagraph(44, $"陽上報恩人", true));
|
|
||||||
body.Append(RenderParagraph(44, $"{shu.alive}", false));
|
|
||||||
|
|
||||||
preItem=shu.subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetStraight(body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(new { result = "Y", data = new { list = list, list1 = list1 } });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangePage(Body body)
|
|
||||||
{
|
|
||||||
Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00A56886", RsidRunAdditionDefault = "00D919D0" };
|
|
||||||
|
|
||||||
Run pageBreakRun = new Run();
|
|
||||||
pageBreakRun.Append(new Break() { Type = BreakValues.Page }); // 指定 Break 類型為 Page (換頁)
|
|
||||||
paragraph1.Append(pageBreakRun);
|
|
||||||
|
|
||||||
body.Append(paragraph1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WordprocessingDocument GenerateDocument(WordprocessingDocument document1,Body body)
|
|
||||||
{
|
|
||||||
MainDocumentPart mainPart = document1.AddMainDocumentPart();
|
|
||||||
mainPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document();
|
|
||||||
|
|
||||||
mainPart.Document.AppendChild(body);
|
|
||||||
|
|
||||||
|
|
||||||
return document1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetStraight(Body body)
|
|
||||||
{
|
|
||||||
|
|
||||||
SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "00A56886", RsidSect = "00D919D0" };
|
|
||||||
PageSize pageSize1 = new PageSize() { Width = 16838U, Height = 11906U, Orient = PageOrientationValues.Landscape };
|
|
||||||
PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = 1440U, Bottom = 1440, Left = 1440U, Header = 720U, Footer = 720U, Gutter = 0U };
|
|
||||||
Columns columns1 = new Columns() { Space = "720" };
|
|
||||||
TextDirection textDirection3 = new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft };
|
|
||||||
DocGrid docGrid1 = new DocGrid() { LinePitch = 326 };
|
|
||||||
|
|
||||||
sectionProperties1.Append(pageSize1);
|
|
||||||
sectionProperties1.Append(pageMargin1);
|
|
||||||
sectionProperties1.Append(columns1);
|
|
||||||
sectionProperties1.Append(textDirection3);
|
|
||||||
sectionProperties1.Append(docGrid1);
|
|
||||||
body.Append(sectionProperties1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Paragraph RenderParagraph(int fontSize,string content,bool isBold)
|
|
||||||
{
|
|
||||||
Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00A56886", RsidRunAdditionDefault = "00D919D0" };
|
|
||||||
|
|
||||||
ParagraphProperties paragraphProperties2 = new ParagraphProperties();
|
|
||||||
TextDirection textDirection2 = new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft };
|
|
||||||
|
|
||||||
|
|
||||||
// 2. 建立縮排物件
|
|
||||||
Indentation indent = new Indentation();
|
|
||||||
|
|
||||||
// --- 請依需求選擇以下一種縮排方式設定 ---
|
|
||||||
|
|
||||||
// 懸首縮排 (Hanging): 第一行不動,其餘行縮排。 (1公分約為 567 dxa)
|
|
||||||
indent.Left = "1134"; // 整體左縮排量
|
|
||||||
indent.Hanging = "1134";
|
|
||||||
indent.FirstLine = "1134";
|
|
||||||
paragraphProperties2.Append(indent);
|
|
||||||
|
|
||||||
paragraphProperties2.Append(textDirection2);
|
|
||||||
|
|
||||||
Run run2 = new Run();
|
|
||||||
|
|
||||||
RunProperties runProperties2 = new RunProperties();
|
|
||||||
RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "微軟正黑體", EastAsia = "微軟正黑體" };
|
|
||||||
FontSize fontSize2 = new FontSize() { Val = $"{fontSize}" };
|
|
||||||
|
|
||||||
runProperties2.Append(runFonts2);
|
|
||||||
runProperties2.Append(fontSize2);
|
|
||||||
if (isBold)
|
|
||||||
{
|
|
||||||
runProperties2.Append(new Bold());
|
|
||||||
}
|
|
||||||
Text text2 = new Text();
|
|
||||||
text2.Space = SpaceProcessingModeValues.Preserve;
|
|
||||||
text2.Text = $"{content}";
|
|
||||||
|
|
||||||
run2.Append(runProperties2);
|
|
||||||
run2.Append(text2);
|
|
||||||
paragraph2.Append(paragraphProperties2);
|
|
||||||
paragraph2.Append(run2);
|
|
||||||
|
|
||||||
|
|
||||||
return paragraph2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Shuwen
|
|
||||||
{
|
|
||||||
public Shuwen() { }
|
|
||||||
public string order_no { get; set; }
|
|
||||||
public List<string> mid_item { get; set; }
|
|
||||||
public string alive { get; set; }
|
|
||||||
public string subject { get; set; }
|
|
||||||
}
|
|
||||||
Binary file not shown.
+37
-22
@@ -287,6 +287,7 @@
|
|||||||
openFollowerDialog(item) {
|
openFollowerDialog(item) {
|
||||||
this.follower_dialog.current_item = item;
|
this.follower_dialog.current_item = item;
|
||||||
this.follower_dialog.show = true;
|
this.follower_dialog.show = true;
|
||||||
|
//this.follower_dialog.search = true;
|
||||||
// 若開啟時已有關鍵字,可以自動帶入搜尋
|
// 若開啟時已有關鍵字,可以自動帶入搜尋
|
||||||
// this.searchFollowers();
|
// this.searchFollowers();
|
||||||
},
|
},
|
||||||
@@ -296,7 +297,7 @@
|
|||||||
this.follower_dialog.loading = true;
|
this.follower_dialog.loading = true;
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(HTTP_HOST + 'api/follower/GetList', {
|
const response = await axios.post(HTTP_HOST + 'api/follower/GetList', {
|
||||||
f_number: this.follower_dialog.search,
|
//f_number: this.follower_dialog.search,
|
||||||
u_name: this.follower_dialog.search
|
u_name: this.follower_dialog.search
|
||||||
}, {
|
}, {
|
||||||
params: {
|
params: {
|
||||||
@@ -388,6 +389,7 @@
|
|||||||
// 備註:依您的原本邏輯,這裡並未傳送 check_date, check_amount 等欄位,若後端 API 需要這些沖帳資訊,請在這裡一併補上。
|
// 備註:依您的原本邏輯,這裡並未傳送 check_date, check_amount 等欄位,若後端 API 需要這些沖帳資訊,請在這裡一併補上。
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.post('../../api/transfer_register/batch_update', updateList);
|
const res = await axios.post('../../api/transfer_register/batch_update', updateList);
|
||||||
if (res.data && res.data.success) {
|
if (res.data && res.data.success) {
|
||||||
@@ -402,28 +404,28 @@
|
|||||||
},
|
},
|
||||||
async submitData() {
|
async submitData() {
|
||||||
// 檢查必填欄位 - 入帳銀行/帳戶
|
// 檢查必填欄位 - 入帳銀行/帳戶
|
||||||
const missingAccNum = this.items.filter(item => !item.acc_num);
|
//const missingAccNum = this.items.filter(item => !item.acc_num);
|
||||||
if (missingAccNum.length > 0) {
|
//if (missingAccNum.length > 0) {
|
||||||
alert('請選擇入帳銀行/帳戶!有 ' + missingAccNum.length + ' 筆資料未選擇。');
|
// alert('請選擇入帳銀行/帳戶!有 ' + missingAccNum.length + ' 筆資料未選擇。');
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 檢查必填欄位 - 入帳日期
|
//// 檢查必填欄位 - 入帳日期
|
||||||
const missingCheckDate = this.items.filter(item => !item.check_date);
|
//const missingCheckDate = this.items.filter(item => !item.check_date);
|
||||||
if (missingCheckDate.length > 0) {
|
//if (missingCheckDate.length > 0) {
|
||||||
alert('請填寫入帳日期!有 ' + missingCheckDate.length + ' 筆資料未填寫。');
|
// alert('請填寫入帳日期!有 ' + missingCheckDate.length + ' 筆資料未填寫。');
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 檢查必填欄位 - 入帳金額
|
//// 檢查必填欄位 - 入帳金額
|
||||||
const missingCheckAmount = this.items.filter(item => !item.check_amount || item.check_amount <= 0);
|
//const missingCheckAmount = this.items.filter(item => !item.check_amount || item.check_amount <= 0);
|
||||||
if (missingCheckAmount.length > 0) {
|
//if (missingCheckAmount.length > 0) {
|
||||||
alert('請填寫入帳金額!有 ' + missingCheckAmount.length + ' 筆資料未填寫或金額無效。');
|
// alert('請填寫入帳金額!有 ' + missingCheckAmount.length + ' 筆資料未填寫或金額無效。');
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 組出要更新的資料
|
// 組出要更新的資料
|
||||||
const updateList = this.items.map(item => ({
|
const updateList = this.items.filter(item => item.f_num && item.acc_num && item.check_date && item.check_amount && item.check_status).map(item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
f_num: item.f_num,
|
f_num: item.f_num,
|
||||||
status: '2',
|
status: '2',
|
||||||
@@ -436,18 +438,31 @@
|
|||||||
kind: item.kind,
|
kind: item.kind,
|
||||||
verify_note: item.verify_note
|
verify_note: item.verify_note
|
||||||
}));
|
}));
|
||||||
|
//console.log(updateList)
|
||||||
|
if (updateList.length === 0) {
|
||||||
|
this.snackbar.text = "無資料可以送出"
|
||||||
|
this.snackbar.show=true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
;
|
||||||
try {
|
try {
|
||||||
const res = await axios.post('../../api/transfer_register/batch_update', updateList);
|
const res = await axios.post('../../api/transfer_register/batch_update', updateList);
|
||||||
if (res.data && res.data.success) {
|
if (res.data && res.data.success) {
|
||||||
alert('送出成功!');
|
// alert('送出成功!');
|
||||||
|
this.snackbar.text = "送出成功"
|
||||||
|
this.snackbar.show = true
|
||||||
// 重新載入資料
|
// 重新載入資料
|
||||||
await this.loadData();
|
await this.loadData();
|
||||||
} else {
|
} else {
|
||||||
alert('送出失敗,請重試 :' + res.data.message);
|
this.snackbar.text = '送出失敗,請重試 :' + res.data.message
|
||||||
|
this.snackbar.show = true
|
||||||
|
//alert('送出失敗,請重試 :' + res.data.message);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('送出失敗:', e);
|
console.error('送出失敗:', e);
|
||||||
alert('送出失敗,請再試一次!');
|
this.snackbar.text = '送出失敗,請再試一次!'
|
||||||
|
this.snackbar.show = true
|
||||||
|
//alert('送出失敗,請再試一次!');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeWindow() {
|
closeWindow() {
|
||||||
|
|||||||
@@ -477,6 +477,12 @@
|
|||||||
//this.get_activity()
|
//this.get_activity()
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
options: {
|
||||||
|
handler() {
|
||||||
|
this.search_get()
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
selected_activity(newValue, oldValue) {
|
selected_activity(newValue, oldValue) {
|
||||||
const params = {
|
const params = {
|
||||||
page: 1, pageSize: 100
|
page: 1, pageSize: 100
|
||||||
|
|||||||
+386
-39
@@ -17,28 +17,178 @@
|
|||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||||
<div id="content" class="container-md">
|
<div id="content" class="container-md">
|
||||||
<button type="button" @click.prevent="getShuwen('消')">消災疏文</button>
|
<v-tabs
|
||||||
<button type="button" @click.prevent="getShuwen('超')">超薦疏文</button>
|
v-model="tab"
|
||||||
<button type="button">齋條</button>
|
background-color="primary"
|
||||||
<button type="button">燈條</button>
|
centered
|
||||||
<button type="button">供僧</button>
|
dark
|
||||||
<button type="button">供果</button>
|
icons-and-text>
|
||||||
<button type="button">供佛</button>
|
<v-tabs-slider></v-tabs-slider>
|
||||||
<%--<v-data-table
|
|
||||||
v-model="order_data.selected"
|
|
||||||
:items="order_data.list"
|
|
||||||
item-key="order_no"
|
|
||||||
:headers="order_data.header"
|
|
||||||
:loading="order_data.loading"
|
|
||||||
|
|
||||||
|
<v-tab href="#疏文">
|
||||||
|
疏文
|
||||||
|
<v-icon>mdi-book-open-outline</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
|
||||||
|
<v-tab href="#打齋">
|
||||||
|
打齋
|
||||||
|
<v-icon>mdi-bowl-mix-outline</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
|
||||||
|
<v-tab href="#點燈">
|
||||||
|
點燈
|
||||||
|
<v-icon>mdi-dome-light</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
<v-tab href="#供佛">
|
||||||
|
供佛
|
||||||
|
<v-icon>mdi-weather-cloudy</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
<v-tab href="#供僧">
|
||||||
|
供僧
|
||||||
|
<v-icon>mdi-account-circle-outline</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
<v-tab href="#供花果">
|
||||||
|
供花果
|
||||||
|
<v-icon>mdi-flower</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
<v-tab href="#普桌">
|
||||||
|
普桌
|
||||||
|
<v-icon>mdi-desk</v-icon>
|
||||||
|
</v-tab>
|
||||||
|
</v-tabs>
|
||||||
|
|
||||||
|
<v-tabs-items v-model="tab">
|
||||||
|
<v-tab-item
|
||||||
|
value="疏文">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="getShuwen('消')">消災疏文</button>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="getShuwen('超')">超薦疏文</button>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="打齋">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('齋')">列印</button>(請先勾選歸屬打齋功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="fast.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="fast.header"
|
||||||
|
:loading="fast.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
class="elevation-1">
|
class="elevation-1">
|
||||||
<template #item.files ="{item}">
|
<%-- <template #item.print="{item}">
|
||||||
{{getItemCount(item.files)}}
|
<v-icon color="blue" class="mr-2" @click="print(item);" >
|
||||||
</template>
|
mdi-printer
|
||||||
<template #item.print="{item}">
|
</v-icon>
|
||||||
|
</template>--%>
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="點燈">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('燈')">列印</button>(請先勾選歸屬點燈功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="lighter.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="lighter.header"
|
||||||
|
:loading="lighter.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
|
class="elevation-1">
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="供佛">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('佛')">列印</button>(請先勾選歸屬供佛功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="buda.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="buda.header"
|
||||||
|
:loading="buda.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
|
class="elevation-1">
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="供僧">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('僧')">列印</button>(請先勾選歸屬供僧功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="monk.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="monk.header"
|
||||||
|
:loading="monk.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
|
class="elevation-1">
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="供花果">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('花')">列印</button>(請先勾選歸屬供花果功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="fruit.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="fruit.header"
|
||||||
|
:loading="fruit.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
|
class="elevation-1">
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
<v-tab-item
|
||||||
|
value="普桌">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-text>
|
||||||
|
<button type="button" class="btn btn-primary" @click.prevent="print('普')">列印</button>(請先勾選歸屬普桌功德項目)
|
||||||
|
<v-data-table
|
||||||
|
v-model="desk.selected"
|
||||||
|
:items="actItems"
|
||||||
|
item-key="num"
|
||||||
|
:headers="desk.header"
|
||||||
|
:loading="desk.loading"
|
||||||
|
hide-default-footer
|
||||||
|
:items-per-page="-1"
|
||||||
|
show-select
|
||||||
|
class="elevation-1">
|
||||||
|
</v-data-table>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-tab-item>
|
||||||
|
|
||||||
|
</v-tabs-items>
|
||||||
|
|
||||||
</template>
|
|
||||||
</v-data-table>--%>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-dialog v-model="search_dialog.show" max-width="700px">
|
<v-dialog v-model="search_dialog.show" max-width="700px">
|
||||||
@@ -74,6 +224,21 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
<v-snackbar
|
||||||
|
v-model="snackbar.show"
|
||||||
|
timeout="2000"
|
||||||
|
>
|
||||||
|
{{ snackbar.text }}
|
||||||
|
<template v-slot:action="{ attrs }">
|
||||||
|
<v-btn
|
||||||
|
text
|
||||||
|
v-bind="attrs"
|
||||||
|
@click="snackbar.show = false"
|
||||||
|
>
|
||||||
|
關閉
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-snackbar>
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
|
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
@@ -84,9 +249,76 @@
|
|||||||
vuetify: new Vuetify(vuetify_options),
|
vuetify: new Vuetify(vuetify_options),
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
tab: "疏文",
|
||||||
canPrint: false,
|
canPrint: false,
|
||||||
options: {},
|
options: {},
|
||||||
activity_list: [],
|
activity_list: [],
|
||||||
|
actItems: [],
|
||||||
|
snackbar: {
|
||||||
|
show: false,
|
||||||
|
text: "",
|
||||||
|
},
|
||||||
|
fast: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '編號', value: 'num' },
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
lighter: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
buda: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
monk: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fruit: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
desk: {
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selected: [],
|
||||||
|
count: 0,
|
||||||
|
order_no: "",
|
||||||
|
header: [
|
||||||
|
{ text: '功德項目', value: 'subject' },
|
||||||
|
],
|
||||||
|
},
|
||||||
order_data: {
|
order_data: {
|
||||||
loading: false,
|
loading: false,
|
||||||
list: [],
|
list: [],
|
||||||
@@ -169,15 +401,105 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
print(item) {
|
||||||
|
let curr = this.search_dialog.current;
|
||||||
|
let target = $(`[data-search-control=${curr.id}]`)
|
||||||
|
let searchData = { activity_num: target.children("input:hidden").val(), mode: item, actItems: [] }
|
||||||
|
if (searchData.activity_num == null || searchData.activity_num=="") {
|
||||||
|
this.snackbar.text = "請先選擇法會"
|
||||||
|
this.snackbar.show = true
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (item) {
|
||||||
|
case "齋":
|
||||||
|
Object.assign(searchData.actItems, this.fast.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
case "佛":
|
||||||
|
Object.assign(searchData.actItems, this.buda.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
case "僧":
|
||||||
|
Object.assign(searchData.actItems, this.monk.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
case "花":
|
||||||
|
Object.assign(searchData.actItems, this.fruit.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
case "普":
|
||||||
|
Object.assign(searchData.actItems, this.desk.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
case "燈":
|
||||||
|
Object.assign(searchData.actItems, this.lighter.selected.map(item => item.num))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (searchData.actItems.length == 0) {
|
||||||
|
this.snackbar.text = "請勾選歸屬功德項目"
|
||||||
|
this.snackbar.show = true
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
axios
|
||||||
|
.post(HTTP_HOST + 'api/shuwen/PrintItemReport', searchData, { responseType: 'blob' })
|
||||||
|
.then(response => {
|
||||||
|
// 1. Create a dynamic URL object from the binary blob
|
||||||
|
const blob = new Blob([response.data], {
|
||||||
|
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||||
|
});
|
||||||
|
const fileUrl = window.URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
// 2. Create a temporary 'a' element to trigger download
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
|
||||||
|
// 3. Set desired file name
|
||||||
|
link.setAttribute('download', `${searchData.activity_num}_${searchData.mode}.docx`);
|
||||||
|
|
||||||
|
// 4. Append, click and cleanup
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(fileUrl); // Free up memory allocation
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
getShuwen(mode) {
|
getShuwen(mode) {
|
||||||
let curr = this.search_dialog.current;
|
let curr = this.search_dialog.current;
|
||||||
let target = $(`[data-search-control=${curr.id}]`)
|
let target = $(`[data-search-control=${curr.id}]`)
|
||||||
let searchData = { activity_num: target.children("input:hidden").val(), mode: mode }
|
let searchData = { activity_num: target.children("input:hidden").val(), mode: mode }
|
||||||
|
if (searchData.activity_num == null || searchData.activity_num == "") {
|
||||||
|
this.snackbar.text = "請選擇法會"
|
||||||
|
this.snackbar.show = true
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
axios
|
axios
|
||||||
.post(HTTP_HOST + 'api/orderdetail/GetShuwenData', searchData)
|
.post(HTTP_HOST + 'api/shuwen/GetShuwenData', searchData, { responseType: 'blob' })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response)
|
// 1. Create a dynamic URL object from the binary blob
|
||||||
|
const blob = new Blob([response.data], {
|
||||||
|
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||||
|
});
|
||||||
|
const fileUrl = window.URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
// 2. Create a temporary 'a' element to trigger download
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
|
||||||
|
// 3. Set desired file name
|
||||||
|
link.setAttribute('download', `${searchData.activity_num}_${searchData.mode}.docx`);
|
||||||
|
|
||||||
|
// 4. Append, click and cleanup
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(fileUrl); // Free up memory allocation
|
||||||
})
|
})
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error downloading the file:', error);
|
||||||
|
alert('Failed to download file.');
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getItemCount(item) {
|
getItemCount(item) {
|
||||||
//console.log("getItemCount:",item[0]?.list.length)
|
//console.log("getItemCount:",item[0]?.list.length)
|
||||||
@@ -272,11 +594,29 @@
|
|||||||
this.get_activity()
|
this.get_activity()
|
||||||
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
||||||
},
|
},
|
||||||
|
getActItem() {
|
||||||
get_activity() {
|
|
||||||
const params = {
|
const params = {
|
||||||
page: 1, pageSize: 1000
|
page: 1, pageSize: 1000
|
||||||
};
|
};
|
||||||
|
axios
|
||||||
|
.post(HTTP_HOST + 'api/activity/GetItemList', {}, { params: params })
|
||||||
|
.then(response => {
|
||||||
|
console.log("getActItem:", response);
|
||||||
|
if (response.status == 200) {
|
||||||
|
Object.assign(this.actItems, response.data.list)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
get_activity() {
|
||||||
|
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||||
|
const params = {
|
||||||
|
sortBy: "", sortDesc: false,
|
||||||
|
page: page, pageSize: itemsPerPage
|
||||||
|
};
|
||||||
|
//const params = {
|
||||||
|
// page: 1, pageSize: 10
|
||||||
|
//};
|
||||||
let curr = this.search_dialog.current;
|
let curr = this.search_dialog.current;
|
||||||
let target = $(`[data-search-control=${curr.id}]`)
|
let target = $(`[data-search-control=${curr.id}]`)
|
||||||
this.search = { num: target.children("input:hidden").val() }
|
this.search = { num: target.children("input:hidden").val() }
|
||||||
@@ -308,25 +648,32 @@
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//this.get_activity()
|
//this.get_activity()
|
||||||
|
this.getActItem();
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selected_activity(newValue, oldValue) {
|
options: {
|
||||||
const params = {
|
handler() {
|
||||||
page: 1, pageSize: 100
|
this.search_get()
|
||||||
};
|
|
||||||
console.log("selected_activity:", newValue)
|
|
||||||
if (newValue !== oldValue) {
|
|
||||||
axios
|
|
||||||
.post(HTTP_HOST + 'api/orderdetail/GetList', { activity_num: this.selected_activity }, { params: params })
|
|
||||||
.then(response => {
|
|
||||||
this.order_data.list = response.data.list
|
|
||||||
})
|
|
||||||
.catch(error => console.log(error))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'order_data.selected'(newValue, oldValue) {
|
deep: true,
|
||||||
console.log(newValue)
|
},
|
||||||
}
|
//selected_activity(newValue, oldValue) {
|
||||||
|
// const params = {
|
||||||
|
// page: 1, pageSize: 100
|
||||||
|
// };
|
||||||
|
// //console.log("selected_activity:", newValue)
|
||||||
|
// if (newValue !== oldValue) {
|
||||||
|
// axios
|
||||||
|
// .post(HTTP_HOST + 'api/orderdetail/GetList', { activity_num: this.selected_activity }, { params: params })
|
||||||
|
// .then(response => {
|
||||||
|
// this.order_data.list = response.data.list
|
||||||
|
// })
|
||||||
|
// .catch(error => console.log(error))
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
//'order_data.selected'(newValue, oldValue) {
|
||||||
|
// console.log(newValue)
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using System.Web.Http;
|
||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
public partial class admin_print_shuwen : System.Web.UI.Page
|
public partial class admin_print_shuwen : MyWeb.config
|
||||||
{
|
{
|
||||||
protected void Page_Load(object sender, EventArgs e)
|
protected void Page_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user