This article describes how to realize the business documents module of the inventory management system , business documents module including purchase orders , purchase returns , sales orders , sales returns 4 menu pages . As the purchase and sale of documents with similar fields, so the design of a common page component class.
- Project code: JxcLite
- Open source address:/known/JxcLite
1. Configuration module
Run the project, configure the following module menu in [System Management - Module Management], refer to the previous tutorial for configuration tutorial.
Level 1 module | Secondary modules | coding | icon (computing) | Url | descriptive |
---|---|---|---|---|---|
Incoming Goods Management | Import | import | |||
purchase order | ImportList | unordered-list | /bms/ImportList | Queries and maintains purchase purchase order information. | |
Purchase returns | ImportReturn | unordered-list | /bms/ImportReturn | Query and maintain purchase return order information. | |
sales management | Export | export | |||
sales order | ExportList | unordered-list | /bms/ExportList | Query and maintain sales shipment order information. | |
Sales Returns | ExportReturn | unordered-list | /bms/ExportReturn | Query and maintain sales return order information. |
2. Entity classes
existJxcLite
sports eventEntities
Under the folder addrespond in singing
Two entity class files , entity class code can be directly copied from the module management generated by the model settings code. Article only a brief description of the definition of the entity class , the specific code see the open source , the code definition is as follows:
namespace ;
/// <summary>
/// The business document header information class.
/// </summary>
public class JxBillHead : EntityBase { }
/// <summary>
/// The business document form information class.
/// </summary>
public class JxBillList : EntityBase { }
3. Table-building scripts
show (a ticket)sports event
Resources
folder of theresource file, copy and paste the table building script generated by the [module management - model settings]. The article only briefly describes the table building script, the specific script see the open source, as follows:
CREATE TABLE [JxBillHead] (
[Id] varchar(50) NOT NULL PRIMARY KEY,
...
[Files] nvarchar(500) NULL
);
CREATE TABLE [JxBillList] (
[Id] varchar(50) NOT NULL PRIMARY KEY,
...
[Note] ntext NULL
);
4. Service interfaces
existJxcLite
sports eventServices
Add the Business Documents Module service interface below the folder with the file name defined asThis interface defines Api access methods for front-end and back-end interaction, including paging queries, batch deletion of entities, and saving entities. Specific method definitions are as follows:
namespace ;
public interface IBillService : IService
{
// Query business document information in pages
Task<PagingResult<JxBillHead>> QueryBillsAsync(PagingCriteria criteria);
//Get the default bill information according to the bill type.
Task<JxBillHead> GetDefaultBillAsync(string type);; //Get the default bill information according to the bill type.
//Get the list of bill body information according to the header ID.
Task<List<JxBillList>> GetBillListsAsync(string headId);
//Batch delete business document information
Task<Result> DeleteBillsAsync(List<JxBillHead> models);
//Save the bill information
Task<Result> SaveBillAsync(UploadInfo<JxBillHead> info);
}
5. Service realization
existsports event
Services
Add the implementation class for the service interface of the business documents module under the folder, with the filename defined as, the article only briefly describe the definition of the implementation of the class and inheritance, the specific implementation of the see open source, defined as follows:
namespace ;
class BillService(Context context) : ServiceBase(context), IBaseDataService
{
public Task<PagingResult<JxBillHead>> QueryBillsAsync(PagingCriteria criteria) { }
public Task<JxBillHead> GetDefaultBillAsync(string type) { }
public Task<List<JxBillList>> GetBillListsAsync(string headId) { }
public Task<Result> DeleteBillsAsync(List<JxBillHead> models) { }
public Task<Result> SaveBillAsync(UploadInfo<JxBillHead> info) { }
}
double-click to openin the project
file in the
AddJxcLiteCore
method to register the service class, and the front-end component can create instances of the service through the dependency injection factory. The code is as follows:
public static class AppWeb
{
public static void AddJxcLiteCore(this IServiceCollection services)
{
<IBillService, BillService>();
}
}
6. Data dependency
existsports event
Repositories
Add the business documents module data dependency class below the folder, with the filename defined as, the article only briefly describes the definition of the dependency class, the specific implementation of the see open source, the definition is as follows:
namespace ;
class BillRepository
{
internal static Task<PagingResult<JxBillHead>> QueryBillsAsync(Database db, PagingCriteria criteria) { }
internal static Task<List<JxBillList>> GetBillListsAsync(Database db, string headId) { }
//Get the maximum business order number based on the prefix
internal static Task<string> GetMaxBillNoAsync(Database db, string prefix) { }
}
7. List page
existsports event
Pages\BillData
Under the folder addList of documents component , the component is a list of incoming and outgoing orders and return forms of the list of components shared class , the specific implementation of the open source , part of the code is as follows :
namespace ;
public class BillList : BaseTablePage<JxBillHead>
{
private IBillService Service;
//Obtaining business document types(imported goods、inbound and outbound、sell goods、sell back),Overwrite the type by the specific document page
protected virtual string Type { get; }
protected override async Task OnPageInitAsync()
{
await ();
Service = await CreateServiceAsync<IBillService>();//Create Service
= typeof(BillForm);//Customizing form types
= QueryBillsAsync; //Search method
//Here is the template for setting the list field display
(c => ).Template((b, r) => ());
(c => ).Type();
}
//additional
public async void New()
{
var row = await (Type);
(, row);
}
//compiler
public async void Edit(JxBillHead row)
{
= await ();
(, row);
}
//Batch deletion and deletion
public void DeleteM() => ();
public void Delete(JxBillHead row) => (, row);
//Duplicates and returns
public void Copy() => (async row => {});
public void Return() => (async row => {});
//printable
public void Print() => (async row =>
{
= await ();
//BillPrint为业务单据printable组件
await <BillPrint>(f => (c => , row));
});
//derive
public async void Export() => await ExportDataAsync();
private Task<PagingResult<JxBillHead>> QueryBillsAsync(PagingCriteria criteria)
{
//Set document type query conditions
(nameof(), , Type);
return (criteria);
}
}
8. Supplier and customer selection boxes
existsports event
Shared
Under the folder add, the component inherits BasePicker, used to pop-up window to select the customer and supplier information , the specific implementation of the open source , part of the code is as follows :
namespace ;
public class PartnerPicker : BasePicker<JxPartner>
{
private IBaseDataService Service;
private TableModel<JxPartner> Table;
//Get the list of data selected by the popup box
public override List<JxPartner> SelectedItems => ?.ToList();
//Getting or setting the business partner type(our customers、provider)
[Parameter] public string Type { get; set; }
protected override async Task OnInitAsync() {}
protected override void BuildContent(RenderTreeBuilder builder) => (Table);
}
9. Commodity information selection box
existsports event
Shared
Under the folder add, the component inherits BasePicker, used to pop-up window to select product information , see the open source for specific implementation , part of the code is as follows :
namespace ;
public class GoodsPicker : BasePicker<JxGoods>
{
private IBaseDataService Service;
private TableModel<JxGoods> Table;
//Get the list of data selected by the popup box
public override List<JxGoods> SelectedItems => ?.ToList();
protected override async Task OnInitAsync() {}
protected override void BuildContent(RenderTreeBuilder builder) => (Table);
}
10. Forms component
first insports event
Shared
Under the folder addcap (a poem)
file, add the business document header type form component and business document body type form component with the following code:
namespace ;
public class BillHeadTypeForm : AntForm<JxBillHead> { }
public class BillListTypeTable : AntTable<JxBillList> { }
relocatesports event
Pages\BillData
Under the folder addcap (a poem)
Documentation , due to the document form component is a bit complex , the code is long , so the use of razor syntax to achieve , the component is a list of incoming and outgoing orders and return form components share class , the specific implementation of the open source , part of the code is as follows :
@inherits BaseForm<JxBillHead>
<BillHeadTypeForm Form="Model">
<AntRow>
<DataItem Span="6" Label="business order number" Required>
<AntInput Disabled @bind-Value="@" />
</DataItem>
<DataItem Span="6" Label="status of documents">
<KTag Text="@" />
</DataItem>
<DataItem Span="6" Label="Date of document" Required>
<AntDatePicker @bind-Value="@" />
</DataItem>
<DataItem Span="6" Label="Business Partners" Required>
<PartnerPicker Value="@" AllowClear
Type="@GetPartnerPickerType(context)" />
</DataItem>
</AntRow>
</BillHeadTypeForm>
<KToolbar>
<KTitle Text="Product breakdown" />
<div>
@if (!)
{
<Button Type="@" Icon="plus" OnClick="OnAdd">increase</Button>
}
</div>
</KToolbar>
<BillListTypeTable DataSource="" HidePagination ScrollX="1300px" ScrollY="200px">
<IntegerColumn Title="serial number" Field="@" Width="60" Fixed="left" />
<StringColumn Title="product code" Width="120" Fixed="left">
<AntInput @bind-Value="@" Style="width:100px" />
</StringColumn>
<StringColumn Title="sum of money" Width="100">
<AntDecimal @bind-Value="@" OnChange="e=>OnGoodsChange(3, context)" />
</StringColumn>
@if (!)
{
<ActionColumn Title="manipulate" Align="" Width="100" Fixed="right">
<Tag Color="red-inverse" OnClick="e=>OnDelete(context)">removing</Tag>
</ActionColumn>
}
<SummaryRow>
<SummaryCell Fixed="left">add up the total</SummaryCell>
<SummaryCell>@(l => )</SummaryCell>
<SummaryCell />
@if (!)
{
<SummaryCell />
}
</SummaryRow>
</BillListTypeTable>
namespace ;
partial class BillForm
{
private KUpload upload;
private static string GetPartnerPickerType(JxBillHead model) {}
private async void OnFilesChanged(List<FileDataInfo> files) {}
private void OnAdd() {}
private void OnDelete(JxBillList row) => (row);
private void OnGoodsChange(int field, JxBillList row) {}
}
11. Printing components
existsports event
Pages\BillData
Under the folder add, the component is to print the contents of business documents component , the specific implementation of the open source , part of the code is as follows :
namespace ;
class BillPrint : ComponentBase
{
//Business Document Entity Object
[Parameter] public JxBillHead Model { get; set; }
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
BuildStyle(builder);//Building Style Sheets,Calling the browser's preview when printing,Select printer to print
BuildForm(builder); //Building Print Forms
}
private static void BuildStyle(RenderTreeBuilder builder)
{
(@"<style>
.bill-print {position:relative;}
</style>");
}
private void BuildForm(RenderTreeBuilder builder) {}
}