diff --git a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs index 404458f..7ff65e8 100644 --- a/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs +++ b/Admin.NET/Admin.NET.Application/Service/PrintCodeDetail/PrintCodeDetailService.cs @@ -107,6 +107,11 @@ public class PrintCodeDetailService : IDynamicApiController, ITransient await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } + public async Task UpdateByEntity(PrintCodeDetail entity) + { + await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + /// /// 获取打印条码详情 /// diff --git a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs index 6aca1b8..bd9b5dd 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportDetailTable/ReportDetailTableService.cs @@ -10,9 +10,11 @@ namespace Admin.NET.Application; public class ReportDetailTableService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; - public ReportDetailTableService(SqlSugarRepository rep) + private readonly PrintCodeDetailService _codeDetailService; + public ReportDetailTableService(SqlSugarRepository rep, PrintCodeDetailService codeDetailService) { _rep = rep; + _codeDetailService = codeDetailService; } /// @@ -100,8 +102,26 @@ public class ReportDetailTableService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "Add")] public async Task Add(AddReportDetailTableInput input) { + var details = await _codeDetailService.List(); + if (details == null || details.Count < 1) + { + return 0; + } + var printDetails = details.FindAll(a => a.TempListId == input.UpdateUserId); + if (printDetails.Count < 1) + { + return 0; + } var entity = input.Adapt(); await _rep.InsertAsync(entity); + for (int i = 0; i < printDetails.Count; i++) + { + var item = printDetails[i]; + item.ReportTableId = entity.Id; + var ent = item.Adapt(); + await _codeDetailService.UpdateByEntity(ent); + } + return entity.Id; } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/AddReportContext.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/AddReportContext.cs index fc89c74..cceaa2a 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/AddReportContext.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/AddReportContext.cs @@ -33,6 +33,10 @@ public class AddReportContext /// public string? Batch { get; set; } /// + /// 物料ID + /// + public long? MaterialsId { get; set; } + /// /// 打印数据 /// public List PrintDatas { get; set; } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs index 08fc496..a3c56a3 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/Dto/PrintCodeTreeData.cs @@ -44,6 +44,11 @@ public class PrintCodeTreeData /// 子码数 /// public int? ChildCount { get; set; } + /// + /// 备注 + /// + public string? Remarks { get; set; } public List Children { get; set; } + public bool HasChildren { get; set; } = true; } diff --git a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs index 3680a72..85c20d3 100644 --- a/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs +++ b/Admin.NET/Admin.NET.Application/Service/ReportTable/ReportTableService.cs @@ -3,6 +3,8 @@ using Admin.NET.Application.Const; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; using Admin.NET.Application.Service.ReportTable.Dto; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types; +using Nest; namespace Admin.NET.Application; /// @@ -84,8 +86,25 @@ public class ReportTableService : IDynamicApiController, ITransient [ApiDescriptionSettings(Name = "Add")] public async Task Add(AddReportTableInput input) { + //input.UpdateUserId + var details = await _codeDetailService.List(); + if (details == null || details.Count < 1) + { + return 0; + } + var printDetails = details.FindAll(a => a.TempListId == input.UpdateUserId); + if (printDetails.Count < 1) + { + return 0; + } var entity = input.Adapt(); await _rep.InsertAsync(entity); + for (int i = 0; i < printDetails.Count; i++) + { + var item = printDetails[i]; + item.ReportTableId = entity.Id; + await _codeDetailService.Update(item.Adapt()); + } return entity.Id; } @@ -174,13 +193,13 @@ public class ReportTableService : IDynamicApiController, ITransient } /// - /// 新增汇报单 + /// 新增打印详情单 /// /// /// [HttpPost] - [ApiDescriptionSettings(Name = "AddPrintList")] - public async Task> AddPrintList(AddReportContext input) + [ApiDescriptionSettings(Name = "AddPrintDetail")] + public async Task> AddPrintDetail(AddReportContext input) { var result = new List(); var unitGroup = await _repUnitGroup.Detail(new QueryByIdSysUnitGroupInput() { Id = input.UnitGroupId }); @@ -197,7 +216,7 @@ public class ReportTableService : IDynamicApiController, ITransient if (unit == null) throw new ArgumentNullException(nameof(unitGroup)); - var newReport = new AddReportTableInput() { CreateTime = DateTime.Now, IsDelete = false, OddNumber = DateTime.Now.ToString("yyyyMMddhhmmss"), State = 1 }; + var newReport = new AddReportTableInput() { CreateTime = DateTime.Now, IsDelete = false, OddNumber = DateTime.Now.ToString("yyyyMMddhhmmss"), State = 0,UpdateUserId = input.MaterialsId }; var addReport = await Add(newReport); var others = units.FindAll(a => a.Rate < unit.Rate).OrderBy(a => a.Rate).ToList(); others.Reverse(); @@ -221,7 +240,7 @@ public class ReportTableService : IDynamicApiController, ITransient } treeData1.Children = new List(); var currUnit = tempUnits.FirstOrDefault(); - var printDatas = await _printDataService.GetPrintDatas(currUnit.Name, codeType, currUnit.ChildUnitCount); + var printDatas = await _printDataService.GetPrintDatas(currUnit.Name, codeType, unit.ChildUnitCount); foreach (var dt in printDatas) { var code2 = string.IsNullOrEmpty(dt.BarCode) ? dt.QrCode : dt.BarCode; @@ -232,7 +251,7 @@ public class ReportTableService : IDynamicApiController, ITransient { treeData2.Children = new List(); var currUnit3 = tempUnits[1]; - var printDatas3 = await _printDataService.GetPrintDatas(currUnit3.Name, codeType, currUnit3.ChildUnitCount); + var printDatas3 = await _printDataService.GetPrintDatas(currUnit3.Name, codeType, currUnit.ChildUnitCount); foreach (var dt3 in printDatas3) { var code3 = string.IsNullOrEmpty(dt3.BarCode) ? dt3.QrCode : dt3.BarCode; @@ -243,7 +262,7 @@ public class ReportTableService : IDynamicApiController, ITransient { treeData3.Children = new List(); var currUnit4 = tempUnits[2]; - var printDatas4 = await _printDataService.GetPrintDatas(currUnit4.Name, codeType, currUnit4.ChildUnitCount); + var printDatas4 = await _printDataService.GetPrintDatas(currUnit4.Name, codeType, currUnit3.ChildUnitCount); foreach (var dt4 in printDatas4) { var code4 = string.IsNullOrEmpty(dt4.BarCode) ? dt4.QrCode : dt4.BarCode; @@ -261,5 +280,73 @@ public class ReportTableService : IDynamicApiController, ITransient } return result; } + + /// + /// 获取打印详情单 + /// + /// + /// + [HttpGet] + [ApiDescriptionSettings(Name = "GetPrintDetail")] + public async Task> GetPrintDetail(long? id) + { + var result = new List(); + //var report = await Detail(new QueryByIdReportTableInput() { Id = id }); + //if (report==null) + //{ + // return result; + //} + var details = await _codeDetailService.List(); + if (details == null || details.Count < 1) + { + return result; + } + var printDetails = details.FindAll(a => a.TempListId == id || a.ReportTableId == id); + if (printDetails.Count<1) + { + return result; + } + var father = printDetails.FindAll(a => a.FatherId == null || a.FatherId == 0); + foreach (var item in father) + { + var treeData1 = item.Adapt(); + var list1 = printDetails.FindAll(a => a.FatherId == item.Id); + if (list1.Count > 0) + { + treeData1.Children = new List(); + treeData1.HasChildren = false; + foreach (var dt in list1) + { + var list2 = printDetails.FindAll(a => a.FatherId == dt.Id); + var treeData2 = dt.Adapt(); + if (list2.Count > 0) + { + treeData2.Children = new List(); + treeData2.HasChildren = false; + foreach (var dt3 in list2) + { + var list3 = printDetails.FindAll(a => a.FatherId == dt3.Id); + var treeData3 = dt3.Adapt(); + if (list3.Count > 0) + { + treeData3.Children = new List(); + treeData3.HasChildren = false; + foreach (var dt4 in list3) + { + var treeData4 = dt4.Adapt(); + treeData3.Children.Add(treeData4); + } + } + treeData2.Children.Add(treeData3); + } + } + treeData1.Children.Add(treeData2); + } + } + + result.Add(treeData1); + } + return result; + } } diff --git a/Web/src/api-services/models/print-code-tree-data.ts b/Web/src/api-services/models/print-code-tree-data.ts new file mode 100644 index 0000000..e2b2ede --- /dev/null +++ b/Web/src/api-services/models/print-code-tree-data.ts @@ -0,0 +1,110 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 业务应用 + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + /** + * 打印信息 + * + * @export + * @interface PrintCodeTreeData + */ + export interface PrintCodeTreeData { + + /** + * 雪花Id + * + * @type {number} + * @memberof PrintCodeTreeData + */ + id?: number; + + /** + * 条码 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + code?: string | null; + + /** + * 上级码 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + fatherCode?: string | null; + + /** + * 条码类型 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + codeName?: string | null; + + /** + * 单位 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + unit?: string | null; + + /** + * 数量 + * + * @type {number} + * @memberof PrintCodeTreeData + */ + count?: number; + + /** + * 基本单位 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + baseUnit?: string | null; + + /** + * 基本数量 + * + * @type {number} + * @memberof PrintCodeTreeData + */ + baseCount?: number; + + /** + * 子码数 + * + * @type {number} + * @memberof PrintCodeTreeData + */ + childCount?: number; + + /** + * 备注 + * + * @type {string} + * @memberof PrintCodeTreeData + */ + remark?: string | null; + + /** + * 子项 + * + * @type {PrintCodeTreeData[]} + * @memberof PrintCodeTreeData + */ + children?: PrintCodeTreeData[] | null; +} diff --git a/Web/src/api/main/reportTable.ts b/Web/src/api/main/reportTable.ts index 9dd43b6..795cc85 100644 --- a/Web/src/api/main/reportTable.ts +++ b/Web/src/api/main/reportTable.ts @@ -5,6 +5,8 @@ enum Api { UpdateReportTable = '/api/reportTable/update', PageReportTable = '/api/reportTable/page', DetailReportTable = '/api/reportTable/detail', + AddPrintDetail = '/api/reportTable/addPrintDetail', + GetPrintDetail = '/api/reportTable/getPrintDetail', } // 增加汇报单 @@ -47,4 +49,18 @@ export const detailReportTable = (id: any) => data: { id }, }); +// 新增打印详情单 +export const addPrintDetail = (params?: any) => + request({ + url: Api.AddPrintDetail, + method: 'post', + data: params, + }); +// 获取打印详情单 +export const getPrintDetail = (id: any) => + request({ + url: Api.GetPrintDetail, + method: 'get', + data: { id }, + }); \ No newline at end of file diff --git a/Web/src/views/labelPrinting/materialPrinting/component/editAccess.vue b/Web/src/views/labelPrinting/materialPrinting/component/editAccess.vue index 792967f..5e8a8b1 100644 --- a/Web/src/views/labelPrinting/materialPrinting/component/editAccess.vue +++ b/Web/src/views/labelPrinting/materialPrinting/component/editAccess.vue @@ -74,6 +74,11 @@ + + @@ -86,13 +91,14 @@ import { ElMessageBox, ElMessage, TabsPaneContext } from 'element-plus'; import VueJsonPretty from 'vue-json-pretty'; import 'vue-json-pretty/lib/styles.css'; import {getCodeConfig} from "/@/api/main/codeElement"; +import { addReportTable, addPrintDetail} from "/@/api/main/reportTable"; import { hiprint } from 'vue-plugin-hiprint'; import providers from '../../print/component/hiprint/providers'; import PrintPreview from '../../print/component/hiprint/preview.vue'; import { PrintDataApiFp } from '../../../../api-services/apis/print-data-api'; import { async } from '../../../../router/backEnd'; - +import detailForm from '/@/views/labelPrinting/printDataDetail/component/editDialog.vue' const props = defineProps({ title: String, @@ -103,7 +109,8 @@ let hiprintTemplate = ref(); const preViewRef = ref(); const codeConfigData = ref([]); const printData = ref([]); - +const editDialogRef = ref(); +const editReportTableTitle = ref("打印详情"); //定义printInfoFrom字段 const printInfoFrom = reactive({ name: '', @@ -162,7 +169,7 @@ const queryUnitByGroupId = async (groupId:number) => { //定义matterSubmit方法 -const printSubmit = () => { +const printSubmit = async () => { if(printInfoFrom.printDataTem=='') { ElMessage.error('请先选择打印模板'); @@ -179,13 +186,16 @@ const printSubmit = () => { printData.value, {}, { - callback: () => { + callback: async () => { state.waitShowPrinter = false; + let contexts={unitGroupId:state.matterFrom.unitGroupId, materialsId:state.matterFrom.id, name:printInfoFrom.package, productDate:printInfoFrom.productDate, loseDate:printInfoFrom.loseDate, batch:printInfoFrom.batch, printDatas:printData.value}; + let details = await addPrintDetail(contexts); + editDialogRef.value.openDialog(details.data.result); }, } ); }); - + } @@ -237,6 +247,8 @@ const closeDialog = () => { state.isShowDialog = false; }; + + //定义printLabel方法,打开打印设置界面 const printLabel = (data:any) => { const unitGroupId = data.unitGroupId diff --git a/Web/src/views/labelPrinting/printDataDetail/component/editDialog.vue b/Web/src/views/labelPrinting/printDataDetail/component/editDialog.vue index 9b8c011..0f4f091 100644 --- a/Web/src/views/labelPrinting/printDataDetail/component/editDialog.vue +++ b/Web/src/views/labelPrinting/printDataDetail/component/editDialog.vue @@ -1,75 +1,37 @@