|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Aucma.Core.BoxFoam.Views;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 发泡计划
|
|
|
|
|
*
|
|
|
|
|
* */
|
|
|
|
|
public partial class FoamPlanPageViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
protected readonly IBoxFoamPlanServices? _boxFoamPlanServices;
|
|
|
|
|
public FoamPlanPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
|
|
|
|
|
WeakReferenceMessenger.Default.Register<string>(this, Recive);
|
|
|
|
|
InitData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async void InitData()
|
|
|
|
|
{
|
|
|
|
|
var task =await _boxFoamPlanServices.QueryAsync();
|
|
|
|
|
if (task == null) return;
|
|
|
|
|
task.OrderBy(d=>d.ObjId);
|
|
|
|
|
foreach (var item in task)
|
|
|
|
|
{
|
|
|
|
|
Id.Add(item.ObjId);
|
|
|
|
|
MaterialCode.Add(item.MaterialCode);
|
|
|
|
|
MaterialName.Add(item.MaterialName);
|
|
|
|
|
PlanAmount.Add(item.PlanAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
private ObservableCollection<int> _id = new ObservableCollection<int>();
|
|
|
|
|
public ObservableCollection<int> Id
|
|
|
|
|
{
|
|
|
|
|
get => _id;
|
|
|
|
|
set => SetProperty(ref _id, value);
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<string> _materialCode = new ObservableCollection<string>();
|
|
|
|
|
public ObservableCollection<string> MaterialCode
|
|
|
|
|
{
|
|
|
|
|
get => _materialCode;
|
|
|
|
|
set => SetProperty(ref _materialCode, value);
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<string> _materialName = new ObservableCollection<string>();
|
|
|
|
|
public ObservableCollection<string> MaterialName
|
|
|
|
|
{
|
|
|
|
|
get => _materialName;
|
|
|
|
|
set => SetProperty(ref _materialName, value);
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<int> _planAmount = new ObservableCollection<int>();
|
|
|
|
|
public ObservableCollection<int> PlanAmount
|
|
|
|
|
{
|
|
|
|
|
get => _planAmount;
|
|
|
|
|
set => SetProperty(ref _planAmount, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
public void AddPlan(string objId)
|
|
|
|
|
{
|
|
|
|
|
SplitPlanView plan = new SplitPlanView(objId);
|
|
|
|
|
plan.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
public async void ClearPlan(string objId)
|
|
|
|
|
{
|
|
|
|
|
int id=int.Parse(objId);
|
|
|
|
|
var obj=await _boxFoamPlanServices.FirstAsync(d=>d.ObjId== id);
|
|
|
|
|
obj.MaterialCode = "";
|
|
|
|
|
obj.MaterialName = "";
|
|
|
|
|
obj.PlanAmount = 0;
|
|
|
|
|
var result= await _boxFoamPlanServices.UpdateAsync(obj);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
ClearData();
|
|
|
|
|
MessageBox.Show("清除计划成功!", "系统提醒");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("清除计划失败!", "系统提醒");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Recive(object recipient, string message)
|
|
|
|
|
{
|
|
|
|
|
if (message == "RefreshTask")
|
|
|
|
|
{
|
|
|
|
|
ClearData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void ClearData()
|
|
|
|
|
{
|
|
|
|
|
Id.Clear();
|
|
|
|
|
MaterialCode.Clear();
|
|
|
|
|
MaterialName.Clear();
|
|
|
|
|
PlanAmount.Clear();
|
|
|
|
|
InitData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|