123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using AntDesign;
- using Microsoft.AspNetCore.Components;
- using Microsoft.AspNetCore.Components.Web;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.share;
- using wispro.sp.web.Models;
- using wispro.sp.web.Services;
- namespace wispro.sp.web.Pages.Project
- {
- public partial class AssignPoint
- {
- [Inject] public MessageService MsgSvr { get; set; }
- [Inject] protected PerformanceItemServices _itemService { get; set; }
- [Inject] NavigationManager _NavigationManager { get; set; }
- private AntDesign.Modal model;
- ProjectPointRecord task = new()
- {
-
- CaseNo = "S2112394",
- CaseName = "美的-洗碗机专利调查",
-
- ProjectDoItemPoints = new List<ProjectDoItemPoint>()
- {
- new ProjectDoItemPoint(){ DoItem="检索策略评估", DoItemCoefficient="B",
- PersonPoints=new List<PersonPoint>{
- new PersonPoint(){Id="1", Person ="李申", Point=1.0 },
- new PersonPoint(){Id="2", Person ="张三", Point=1.0 },
- new PersonPoint(){Id="3", Person ="李四", Point=1.0 },
- }},
- new ProjectDoItemPoint(){ DoItem="专利分类", DoItemCoefficient="A",
- PersonPoints=new List<PersonPoint>{
- new PersonPoint(){Id="1", Person ="李申", Point=2.0 },
- new PersonPoint(){Id="2", Person ="张三", Point=1.50 },
- new PersonPoint(){Id="3", Person ="李四", Point=2.5 },
- }},
- }
- };
- ProjectDoItemPoint addDoItem;
- bool isAdd = false;
- private bool _visible = false;
- private void AddNew()
- {
- addDoItem = new ProjectDoItemPoint();
- isAdd = true;
- _visible = true;
- }
- private void HandleOk(MouseEventArgs e)
- {
- if (isAdd)
- {
- if (!string.IsNullOrEmpty(addDoItem.DoItem))
- {
- task.ProjectDoItemPoints.Add(addDoItem);
- }
- }
-
- _visible = false;
- model.Dispose();
- }
- private void HandleCancel(MouseEventArgs e)
- {
- //Console.WriteLine(e);
- _visible = false;
- model.Dispose();
- }
- string editId = null;
- void startEdit(string id)
- {
- editId = id;
- MsgSvr.Info($"开始编辑{editId}");
- }
- void deletePersonPoint(string id)
- {
- var delObj = addDoItem.PersonPoints.FirstOrDefault<PersonPoint>(f => f.Id == id);
- addDoItem.PersonPoints.Remove(delObj);
- }
- void stopEdit()
- {
- //var editedData = addDoItem.AddprojectPoints.FirstOrDefault(x => x.person == editId);
- //Console.WriteLine(JsonSerializer.Serialize(editedData));
- editId = null;
- }
- void Delete(string doItem, string person)
- {
- Console.WriteLine(JsonSerializer.Serialize(task));
- if (_visible)
- {
- var editedData = addDoItem.PersonPoints.FirstOrDefault(x => x.Person == person);
- addDoItem.PersonPoints.Remove(editedData);
- }
- else
- {
-
- var editedData = task.ProjectDoItemPoints .FirstOrDefault(x => x.DoItem == doItem);
- Console.WriteLine(JsonSerializer.Serialize(editedData));
- var personPoint = editedData.PersonPoints.FirstOrDefault(x => x.Id == person);
- Console.WriteLine(JsonSerializer.Serialize(personPoint));
- editedData.PersonPoints.Remove(personPoint);
-
- }
- Console.WriteLine(JsonSerializer.Serialize(task));
- StateHasChanged();
- }
- void DeleteDoItem(string doItem)
- {
- var delData = task.ProjectDoItemPoints.FirstOrDefault(x => x.DoItem == doItem);
- task.ProjectDoItemPoints.Remove(delData);
- }
- void EditDoItem(string doItem)
- {
- isAdd = false;
- addDoItem = task.ProjectDoItemPoints.FirstOrDefault(x => x.DoItem == doItem);
- _visible = true;
- }
- private string GetId(List<PersonPoint> personPoints)
- {
- int i = personPoints.Count;
- begin:
- foreach(var pp in personPoints)
- {
- if(pp.Id == i.ToString())
- {
- i++;
- goto begin;
- }
- }
- return i.ToString();
- }
- void addRow()
- {
- if(addDoItem.PersonPoints == null)
- {
- addDoItem.PersonPoints = new List<PersonPoint>();
- }
- string strId = GetId(addDoItem.PersonPoints);
- addDoItem.PersonPoints.Add(
- new PersonPoint() { Id = strId, Person ="修改处理人姓名", Point = 0}
- ) ;
- editId = strId;
- StateHasChanged();
- }
- async Task OnSave()
- {
- //添加保存代码
- await _itemService.AddProjectPerformanctItem(task);
- await MsgSvr.Info("项目绩效保存成功!");
- _NavigationManager.NavigateTo("/MyCaseList");
- }
- void OnCancel()
- {
- _NavigationManager.NavigateTo("/MyCaseList");
- }
- }
-
- }
|