255 lines
13 KiB
Plaintext
255 lines
13 KiB
Plaintext
@page "/_Admin/WTM_CONTRACT"
|
|
@using wtmProject.ViewModel._Admin.WTM_CONTRACTVMs;
|
|
@inherits BasePage
|
|
@attribute [ActionDescription("合同管理", "wtmProject.Controllers,WTM_CONTRACT")]
|
|
|
|
@*<WTSearchPanel OnSearch="@DoSearch">*@
|
|
<ValidateForm Model="@SearchModel">
|
|
<Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Inline">
|
|
|
|
<Select @bind-Value="@SearchModel.CustomId" Items="@AllWTM_CUSTOMs" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.All"]" />
|
|
<Select @bind-Value="@SearchModel.MarkManageId" Items="@AllFrameworkUsers" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.All"]" />
|
|
<BootstrapInput @bind-Value="@SearchModel.ContractName" />
|
|
<WTDateRange @bind-Value="@SearchModel.SignDate" />
|
|
<MultiSelect @bind-Value="@SearchModel.SelectedItemsID" Items="AllWTM_PROJECTs" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
|
|
@* <Select @bind-Value="@SearchModel.ProjectId" Items="@AllWTM_PROJECTs" ShowSearch="true" PlaceHolder="@WtmBlazor.Localizer["Sys.All"]" /> *@
|
|
<Select @bind-Value="@SearchModel.AreaId" Items="@AllWTM_AREAs" ShowSearch="true" PlaceHolder="@WtmBlazor.Localizer["Sys.All"]" />
|
|
<Button Color="Color.Primary" Icon="fa fa-search" Text="@WtmBlazor.Localizer["Sys.Search"]" OnClick="@DoSearch" />
|
|
</Row>
|
|
</ValidateForm>
|
|
@*</WTSearchPanel>*@
|
|
|
|
|
|
|
|
<Table @ref="dataTable" TItem="WTM_CONTRACT_View" OnQueryAsync="OnSearch" IsPagination="true" IsStriped="false" IsBordered="true" ShowRefresh="false"
|
|
FixedMultipleColumn="true" IsFixedHeader="true" ShowFooter="true" Height="500" ShowColumnList="true"
|
|
ShowToolbar="true" IsMultipleSelect="true" ShowExtendButtons="true" ShowDefaultButtons="false" ShowExtendEditButton="false" ShowExtendDeleteButton="false" style="margin-top:10px;">
|
|
<TableColumns>
|
|
<TableColumn @bind-Field="@context.Year" Width="100" Fixed Filterable="true" Sortable="true" />
|
|
<TableColumn @bind-Field="@context.CustomAllName_view" Width="300" TextWrap="true" Fixed Filterable="true" />
|
|
<TableColumn @bind-Field="@context.AreaName_view" Width="100" Filterable="true" />
|
|
@*<TableColumn @bind-Field="@context.PersonName_view" />*@
|
|
<TableColumn @bind-Field="@context.ProjectName_view" Width="100" Filterable="true" />
|
|
<TableColumn @bind-Field="@context.ContractName" Width="300" TextWrap="true" Filterable="true">
|
|
<Template Context="value">
|
|
<div class="text-primary" @onclick ="()=>OnDetailsClick(value.Row)">@value.Value</div>
|
|
</Template>
|
|
</TableColumn>
|
|
@* <TableColumn @bind-Field="@context.ContractCode" Width="150" />
|
|
<TableColumn @bind-Field="@context.ERPName" Width="300" TextWrap="true" />
|
|
<TableColumn @bind-Field="@context.ERPCode" Width="150" /> *@
|
|
<TableColumn @bind-Field="@context.SignDate" Width="150" FormatString="yyyy-MM-dd" Filterable="true" Sortable="true" />
|
|
<TableColumn @bind-Field="@context.ContractAmount" Width="100" />
|
|
<TableColumn @bind-Field="@context.RefundAmount" Width="100" />
|
|
<TableColumn @bind-Field="@context.RefundCount" Width="100" />
|
|
<TableColumn @bind-Field="@context.Name_view2" Width="200" Filterable="true" />
|
|
<TableColumn @bind-Field="@context.Name_view" Width="250" Filterable="true" />
|
|
@*<TableColumn @bind-Field="@context.GrossProfitMargin" />*@
|
|
</TableColumns>
|
|
@* <TableFooter>
|
|
<TableFooterCell Text="合计:" colspan="7" Align=Alignment.Left />
|
|
<TableFooterCell Aggregate=AggregateType.Sum Field="@nameof(WTM_CONTRACT_View.ContractAmount)" />
|
|
</TableFooter> *@
|
|
<FooterTemplate>
|
|
<tr>
|
|
<td colspan="7">
|
|
<div class="d-flex align-items-center justify-content-end">合计:</div>
|
|
<div class="d-flex align-items-center justify-content-end">不含税金额:</div>
|
|
</td>
|
|
<td>
|
|
<div>
|
|
@GetSum(context)
|
|
</div>
|
|
<div>
|
|
@GetSum2(context)
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</FooterTemplate>
|
|
<TableToolbarTemplate>
|
|
@if (IsAccessable("/api/WTM_CONTRACT/Add") && UserInfo.Roles.FirstOrDefault(t=>t.RoleName == "超级管理员") != null)
|
|
{
|
|
<TableToolbarButton TItem="WTM_CONTRACT_View" Color="Color.Primary" Icon="fa fa-fw fa-plus" Text="@WtmBlazor.Localizer["Sys.Create"]" OnClickCallback="OnCreateClick" />
|
|
}
|
|
@*@if (IsAccessable("/api/WTM_CONTRACT/BatchDelete"))
|
|
{
|
|
<TableToolbarPopconfirmButton TItem="WTM_CONTRACT_View" Color="Color.Primary"
|
|
Icon="fa fa-fw fa-trash" Text="@WtmBlazor.Localizer["Sys.BatchDelete"]"
|
|
OnConfirm="@OnBatchDeleteClick" Content="@WtmBlazor.Localizer["Sys.BatchDeleteConfirm"]" CloseButtonText="@WtmBlazor.Localizer["Sys.Close"]"
|
|
ConfirmButtonText="@WtmBlazor.Localizer["Sys.BatchDelete"]" ConfirmButtonColor="Color.Danger" />
|
|
}*@
|
|
|
|
@if (IsAccessable("/api/WTM_CONTRACT/Import") && UserInfo.Roles.FirstOrDefault(t => t.RoleName == "超级管理员") != null)
|
|
{
|
|
<TableToolbarButton TItem="WTM_CONTRACT_View" Color="Color.Primary" Icon="fa fa-fw fa-upload" Text="@WtmBlazor.Localizer["Sys.Import"]" OnClickCallback="@OnImportClick" />
|
|
}
|
|
@if (IsAccessable("/api/WTM_CONTRACT/ExportExcel") && UserInfo.Roles.FirstOrDefault(t => t.RoleName == "超级管理员") != null)
|
|
{
|
|
<TableToolbarButton TItem="WTM_CONTRACT_View" Color="Color.Primary" Icon="fa fa-fw fa-download" Text="@WtmBlazor.Localizer["Sys.Export"]" OnClickCallback="@OnExportClick" IsAsync="true" />
|
|
}
|
|
|
|
@* <Button TItem="WTM_CONTRACT_View" Color="Color.Primary" Icon="fa fa-fw fa-upload" Text="@WtmBlazor.Localizer["执行"]" OnClick="()=>SyncContract()" IsAsync="true" />*@
|
|
</TableToolbarTemplate>
|
|
<RowButtonTemplate>
|
|
<div style="padding-right:10px;">
|
|
@if (IsAccessable("/api/WTM_CONTRACT/Edit") && UserInfo.Roles.FirstOrDefault(t => t.RoleName == "超级管理员") != null)
|
|
{
|
|
<TableCellButton Size="Size.ExtraSmall" Color="Color.Success" Icon="fa fa-edit" Text="@WtmBlazor.Localizer["Sys.Edit"]" OnClick="() => OnEditClick(context)" />
|
|
}
|
|
@if (IsAccessable("/api/WTM_CONTRACT/{id}"))
|
|
{
|
|
<TableCellButton Size="Size.ExtraSmall" Color="Color.Info" Icon="fa fa-info" Text="@WtmBlazor.Localizer["Sys.Details"]" OnClick="()=>OnDetailsClick(context)" />
|
|
}
|
|
@if (IsAccessable("/api/WTM_CONTRACT/BatchDelete") && UserInfo.Roles.FirstOrDefault(t => t.RoleName == "超级管理员") != null)
|
|
{
|
|
<PopConfirmButton Icon="fa fa-trash" Text="@WtmBlazor.Localizer["Sys.Delete"]" OnConfirm="() => OnDeleteClick(context)" Color="Color.Danger" Size="Size.ExtraSmall"
|
|
Content="@WtmBlazor.Localizer["Sys.DeleteConfirm"]" CloseButtonText="@WtmBlazor.Localizer["Sys.Close"]" ConfirmButtonText="@WtmBlazor.Localizer["Sys.Delete"]" ConfirmButtonColor="Color.Danger" />
|
|
}
|
|
</div>
|
|
</RowButtonTemplate>
|
|
</Table>
|
|
|
|
@code{
|
|
private WTM_CONTRACTVM Model = new WTM_CONTRACTVM();
|
|
public List<WTM_CONTRACT_View> list = new List<WTM_CONTRACT_View>();
|
|
private ValidateForm vform { get; set; }
|
|
private WTM_CONTRACTSearcher SearchModel = new WTM_CONTRACTSearcher();
|
|
private Table<WTM_CONTRACT_View> dataTable;
|
|
private List<SelectedItem> AllWTM_CUSTOMs = new List<SelectedItem>();
|
|
private List<SelectedItem> AllFrameworkUsers = new List<SelectedItem>();
|
|
private List<SelectedItem> AllWTM_PROJECTs = new List<SelectedItem>();
|
|
private List<SelectedItem> AllWTM_AREAs = new List<SelectedItem>();
|
|
private static decimal? GetSum(IEnumerable<WTM_CONTRACT_View> items) => items != null && items.Any() ? items.Sum(i => i.ContractAmount == null ? 0 : i.ContractAmount) : 0;
|
|
// private static decimal? GetSum2(IEnumerable<WTM_CONTRACT_View> items) => items != null && items.Any() ? decimal.Round((items.Sum(i => i.ContractAmount == null ? 0 : (decimal)i.ContractAmount)) / (decimal)1.06, 2) : 0;
|
|
private static decimal? GetSum2(IEnumerable<WTM_CONTRACT_View> items)
|
|
{
|
|
decimal? sum = null;
|
|
if (items != null && items.Any())
|
|
{
|
|
var sumTemp = items.Sum(i => i.ContractAmount == null ? 0 : (decimal)i.ContractAmount);
|
|
if (sumTemp != 0)
|
|
{
|
|
sum = decimal.Round(sumTemp / (decimal)1.06, 2);
|
|
}
|
|
else
|
|
{
|
|
sum = 0;
|
|
}
|
|
}
|
|
return sum;
|
|
}
|
|
[Inject]
|
|
private IJSRuntime jsRuntime { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
//var temp = await WtmBlazor.Api.CallAPI<List<WTM_CONTRACT_View>>($"/api/WTM_CONTRACT/SyncContract");
|
|
//list = temp.Data;
|
|
AllWTM_CUSTOMs = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetWTM_CUSTOMs", placeholder: WtmBlazor.Localizer["Sys.All"]);
|
|
AllWTM_PROJECTs = await WtmBlazor.Api.CallItemsApi("/api/WTM_BILLING_LIST/GetWTM_PROJECTs", placeholder: WtmBlazor.Localizer["Sys.All"]);
|
|
AllWTM_AREAs = await WtmBlazor.Api.CallItemsApi("/api/WTM_BILLING_LIST/GetWTM_AREAs", placeholder: WtmBlazor.Localizer["Sys.All"]);
|
|
AllFrameworkUsers = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetFrameworkUsers", placeholder: WtmBlazor.Localizer["Sys.All"]);
|
|
_ = jsRuntime.InvokeVoidAsync("setTabTitle", "合同信息");
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task<QueryData<WTM_CONTRACT_View>> OnSearch(QueryPageOptions opts)
|
|
{
|
|
return await StartSearch<WTM_CONTRACT_View>("/api/WTM_CONTRACT/Search", SearchModel, opts);
|
|
}
|
|
|
|
private void DoSearch()
|
|
{
|
|
dataTable.QueryAsync();
|
|
}
|
|
|
|
private async Task OnCreateClick(IEnumerable<WTM_CONTRACT_View> items)
|
|
{
|
|
if (await OpenDialog<Create>(WtmBlazor.Localizer["Sys.Create"]) == DialogResult.Yes)
|
|
{
|
|
await dataTable.QueryAsync();
|
|
}
|
|
}
|
|
|
|
private async Task OnEditClick(WTM_CONTRACT_View item)
|
|
{
|
|
if (await OpenDialog<Edit>(WtmBlazor.Localizer["Sys.Edit"], x => x.id == item.ID.ToString()) == DialogResult.Yes)
|
|
{
|
|
await dataTable.QueryAsync();
|
|
}
|
|
}
|
|
|
|
private async Task OnDetailsClick(WTM_CONTRACT_View item)
|
|
{
|
|
await OpenDialog<Details>(WtmBlazor.Localizer["Sys.Details"], x => x.id == item.ID.ToString());
|
|
}
|
|
|
|
private async Task OnBatchDeleteClick()
|
|
{
|
|
if (dataTable.SelectedRows?.Any() == true)
|
|
{
|
|
await PostsData(dataTable.SelectedRows.Select(x => x.ID).ToList(), $"/api/WTM_CONTRACT/batchdelete", (s) => WtmBlazor.Localizer["Sys.BatchDeleteSuccess", s]);
|
|
await dataTable.QueryAsync();
|
|
}
|
|
else
|
|
{
|
|
await WtmBlazor.Toast.Information(WtmBlazor.Localizer["Sys.Info"], WtmBlazor.Localizer["Sys.SelectOneRowMin"]);
|
|
}
|
|
}
|
|
|
|
private async Task OnDeleteClick(WTM_CONTRACT_View item)
|
|
{
|
|
await PostsData(new List<string> { item.ID.ToString() }, $"/api/WTM_CONTRACT/batchdelete", (s) => "Sys.OprationSuccess");
|
|
await dataTable.QueryAsync();
|
|
}
|
|
|
|
|
|
private async Task OnExportClick(IEnumerable<WTM_CONTRACT_View> items)
|
|
{
|
|
if (dataTable.SelectedRows?.Any() == true)
|
|
{
|
|
await Download("/api/WTM_CONTRACT/ExportExcelByIds", dataTable.SelectedRows.Select(x => x.ID.ToString()).ToList());
|
|
}
|
|
else
|
|
{
|
|
await Download("/api/WTM_CONTRACT/ExportExcel", SearchModel);
|
|
}
|
|
}
|
|
private async Task OnImportClick(IEnumerable<WTM_CONTRACT_View> items)
|
|
{
|
|
if (await OpenDialog<Import>(WtmBlazor.Localizer["Sys.Import"]) == DialogResult.Yes)
|
|
{
|
|
await dataTable.QueryAsync();
|
|
}
|
|
}
|
|
private async Task SyncContract()
|
|
{
|
|
if (list != null && list.Any())
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
vform = new ValidateForm();
|
|
Model = new WTM_CONTRACTVM();
|
|
Model.Entity.ID = item.ID;
|
|
Model.Entity.ContractCode = item.ContractCode;
|
|
Model.Entity.ContractName = item.ContractName;
|
|
Model.Entity.ERPCode = item.ERPCode;
|
|
Model.Entity.ERPName = item.ERPName;
|
|
Model.Entity.Year = item.Year;
|
|
Model.Entity.CustomId = item.CustomId;
|
|
Model.Entity.CustomClass = item.CustomClass;
|
|
Model.Entity.AreaId = item.AreaId;
|
|
Model.Entity.MarkManageId = item.MarkManageId;
|
|
Model.Entity.ProjectManageId = item.ProjectManageId;
|
|
Model.Entity.ProjectId = item.ProjectId;
|
|
Model.Entity.SignDate = item.SignDate;
|
|
Model.Entity.ContractAmount = item.ContractAmount;
|
|
Model.Entity.ContractCycle = item.ContractCycle;
|
|
vform.Model = Model;
|
|
await PostsForm(vform, "/api/WTM_CONTRACT/add");
|
|
}
|
|
await WtmBlazor.Toast.Success(WtmBlazor.Localizer["Sys.Info"], WtmBlazor.Localizer["Sys.OprationSuccess"]);
|
|
}
|
|
}
|
|
}
|