PopupForm Field OnChange

This commit is contained in:
Sedat Öztürk 2025-12-18 23:31:31 +03:00
parent 407fbd80ba
commit a1333ec647
6 changed files with 30 additions and 8 deletions

View file

@ -42,6 +42,17 @@ public static class LookupQueryValues
$"ORDER BY \"{DisplayExpr}\";";
}
public static string MaterialValues =
$"SELECT " +
$"\"Id\" AS \"Key\", " +
$"\"Name\" AS \"Name\", " +
$"\"UomId\" AS \"UomId\", " +
$"\"SalesPrice\" AS \"UnitPrice\", " +
$"1 AS \"Quantity\" " +
$"FROM \"{FullNameTable(TableNameEnum.Material)}\" " +
$"WHERE \"IsDeleted\" = 'false' " +
$"ORDER BY \"Name\";";
public static string ProjectPhaseValues =
$"SELECT " +
$"\"Id\" AS \"Key\", " +

View file

@ -2778,11 +2778,11 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency
{
new() {
Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[
new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox },
new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorScript = EditorScriptValues.MaterialOnChange },
new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 3, DataField="UnitPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 4, DataField="TotalAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 5, DataField="Uom", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox },
new EditingFormItemDto { Order = 5, DataField="UomId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox },
new EditingFormItemDto { Order = 6, DataField="DiscountRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 7, DataField="DiscountAmount", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 8, DataField="TaxRate", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
@ -2835,7 +2835,13 @@ public class ListFormSeeder_Crm : IDataSeedContributor, ITransientDependency
IsActive = true,
IsDeleted = false,
AllowSearch = true,
LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Material), "Id", "Name"),
LookupJson = JsonSerializer.Serialize(new LookupDto
{
DataSourceType = UiLookupDataSourceTypeEnum.Query,
DisplayExpr = "Name",
ValueExpr = "Key",
LookupQuery = LookupQueryValues.MaterialValues
}),
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),

View file

@ -1153,7 +1153,7 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Uom",
FieldName = "UomId",
Width = 200,
ListOrderNo = 5,
Visible = true,

View file

@ -3209,7 +3209,7 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend
Order=1, ColCount=1, ColSpan=1, ItemType="group", Items =[
new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 3, DataField="Uom", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 3, DataField="UomId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 4, DataField="EstimatedPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 5, DataField="Specification", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 6, DataField="Justification", ColSpan = 1, EditorType2 = EditorTypes.dxTextBox },
@ -4158,7 +4158,7 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend
Order=1, ColCount=1, ColSpan=1, ItemType="group", Items =[
new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired =true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 2, DataField="Quantity", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 3, DataField="Uom", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 3, DataField="UomId", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 4, DataField="UnitPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 5, DataField="TotalPrice", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 6, DataField="LeadTime", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox, EditorOptions = EditorOptionValues.NumberStandartFormat },
@ -4865,7 +4865,7 @@ public class ListFormSeeder_SupplyChain : IDataSeedContributor, ITransientDepend
new EditingFormItemDto { Order = 1, DataField="MaterialId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 2, DataField="UnitPrice", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 3, DataField="Quantity", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 4, DataField="Uom", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 4, DataField="UomId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 5, DataField="TotalPrice", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 6, DataField="Description", ColSpan = 1, EditorType2 = EditorTypes.dxTextArea },
]}

View file

@ -32,7 +32,8 @@ public static class PlatformConsts
{
public static string CalcTotalDaysFromDates = "(() => {const d=v=>!v?null:(v instanceof Date?v:new Date(v));const nf={...formData,[editor.dataField]:e?.value};const s=d(nf.StartDate),t=d(nf.EndDate);setFormData({...formData,TotalDays: s&&t?Math.max(0,Math.floor((Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())-Date.UTC(s.getFullYear(),s.getMonth(),s.getDate()))/(24*60*60*1000))+1):null});})();";
public static string CalcTotalHoursFromTimes = "(()=>{const toD=v=>!v?null:(v instanceof Date?v:new Date(v));const next={...formData,[e.dataField]:e.value};const s=toD(next.StartTime),t=toD(next.EndTime);let h=null;if(s&&t){h=(t-s)/36e5;if(h<0)h+=24;h=Math.round(h*10)/10;}setFormData({...next,TotalHours:h});})();";
}
public static string MaterialOnChange = "(() => { const p = e.component.option('selectedItem'); setFormData({ ...formData, Quantity: p.Quantity, UnitPrice: p.UnitPrice, UomId: p.UomId } ) })();";
}
public static class Prefix
{

View file

@ -229,6 +229,8 @@ const useListFormColumns = ({
key: a.Key,
name: a.Name,
group: a.Group,
...a
}))
})
} catch (error: any) {
@ -276,6 +278,8 @@ const useListFormColumns = ({
key: eval(keySelector),
name: eval(nameSelector),
group: eval(groupSelector),
...a,
}))
})
} catch {