AssignPoint.razor.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using Microsoft.AspNetCore.Components.Web;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using wispro.sp.web.Models;
  8. namespace wispro.sp.web.Pages.Project
  9. {
  10. public partial class AssignPoint
  11. {
  12. [Inject] public MessageService MsgSvr { get; set; }
  13. [Parameter]
  14. public string id { get; set; }
  15. private AntDesign.Modal model;
  16. Task task = new()
  17. {
  18. ProjectInfo = new ProjectInfo()
  19. {
  20. CaseNo = "S2112394",
  21. CaseName = "美的-洗碗机专利调查",
  22. DoItem = "提出报告",
  23. DoPerson = new List<string>() { "李申", "何倚雯", "王晴", "陆跃" },
  24. ResponseMan = "黄瑜"
  25. },
  26. Id = 1,
  27. Name = "2021年9月专案点数分配任务",
  28. Type = "专案点数分配任务",
  29. ResponseMan = "黄瑜",
  30. State = "待处理",
  31. LimiteDate = DateTime.Now.AddDays(4),
  32. UIUrl = "/Project/AssignPoint"
  33. };
  34. List<ProjectPoint> projectPoints=new List<ProjectPoint>() {
  35. new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="李申", Point=1.0},
  36. new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="何倚雯", Point=2.0},
  37. new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="王晴", Point=1.5},
  38. new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="陆跃", Point=1.0},
  39. new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="B", person="李申", Point=2.0},
  40. new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="B", person="何倚雯", Point=1.5},
  41. new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="B", person="王晴", Point=2.5},
  42. new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="B", person="陆跃", Point=3.0},
  43. };
  44. private class AddDoItem
  45. {
  46. public string Name { get; set; }
  47. public string nanduxishu { get; set; }
  48. public List<ProjectPoint> AddprojectPoints { get; set; }
  49. }
  50. private AddDoItem addDoItem;
  51. private bool _visible = false;
  52. private void AddNew()
  53. {
  54. addDoItem = new AddDoItem();
  55. addDoItem.AddprojectPoints = new List<ProjectPoint>();
  56. foreach (string name in task.ProjectInfo.DoPerson)
  57. {
  58. addDoItem.AddprojectPoints.Add(new ProjectPoint()
  59. {
  60. //doItem = addDoItem.nanduxishu,
  61. //DoItemCoefficient = addDoItem.nanduxishu,
  62. person = name,
  63. Point = 0
  64. });
  65. }
  66. _visible = true;
  67. }
  68. private void HandleOk(MouseEventArgs e)
  69. {
  70. if (!string.IsNullOrEmpty(addDoItem.Name))
  71. {
  72. List<ProjectPoint> temList = new List<ProjectPoint>();
  73. if(projectPoints== null)
  74. {
  75. projectPoints = new List<ProjectPoint>();
  76. }
  77. if (addDoItem.AddprojectPoints != null)
  78. {
  79. foreach(ProjectPoint pp in addDoItem.AddprojectPoints)
  80. {
  81. pp.doItem = addDoItem.Name;
  82. pp.DoItemCoefficient = addDoItem.nanduxishu;
  83. }
  84. }
  85. projectPoints.AddRange(addDoItem.AddprojectPoints);
  86. }
  87. _visible = false;
  88. model.Dispose();
  89. }
  90. private void HandleCancel(MouseEventArgs e)
  91. {
  92. //Console.WriteLine(e);
  93. _visible = false;
  94. model.Dispose();
  95. }
  96. string editId = null;
  97. void startEdit(string id)
  98. {
  99. editId = id;
  100. MsgSvr.Info($"开始编辑{editId}");
  101. }
  102. void stopEdit()
  103. {
  104. //var editedData = addDoItem.AddprojectPoints.FirstOrDefault(x => x.person == editId);
  105. //Console.WriteLine(JsonSerializer.Serialize(editedData));
  106. editId = null;
  107. }
  108. void Delete(string id)
  109. {
  110. if (_visible)
  111. {
  112. var editedData = addDoItem.AddprojectPoints.FirstOrDefault(x => x.person == id);
  113. addDoItem.AddprojectPoints.Remove(editedData);
  114. }
  115. else
  116. {
  117. var editedData = projectPoints.FirstOrDefault(x => x.person == id);
  118. projectPoints.Remove(editedData);
  119. }
  120. }
  121. void OnSave()
  122. {
  123. //添加保存代码
  124. }
  125. void OnCancel()
  126. {
  127. }
  128. }
  129. }