CustomerList.razor.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components.Web;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace wispro.sp.web.Pages
  9. {
  10. public partial class CustomerList
  11. {
  12. private List<entity.Customer> _Customers =new List<entity.Customer>()
  13. {
  14. new entity.Customer()
  15. {
  16. Id=1,
  17. Name = "OPPO广东移动通信有限公司",
  18. Address="广东省东莞市长安镇乌沙海滨路18号",
  19. Phone="4001-666-888",
  20. ContactMan="刘波",
  21. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  22. ResponseManId= 1
  23. },
  24. new entity.Customer()
  25. {
  26. Id = 2,
  27. Name = "OPPO广东移动通信有限公司",
  28. Address = "广东省东莞市长安镇乌沙海滨路18号",
  29. Phone = "4001-666-888",
  30. ContactMan = "刘波",
  31. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  32. ResponseManId= 1
  33. },
  34. new entity.Customer()
  35. {
  36. Id = 3,
  37. Name = "OPPO广东移动通信有限公司",
  38. Address = "广东省东莞市长安镇乌沙海滨路18号",
  39. Phone = "4001-666-888",
  40. ContactMan = "刘波",
  41. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  42. ResponseManId= 1
  43. },
  44. new entity.Customer()
  45. {
  46. Id = 4,
  47. Name = "OPPO广东移动通信有限公司",
  48. Address = "广东省东莞市长安镇乌沙海滨路18号",
  49. Phone = "4001-666-888",
  50. ContactMan = "刘波",
  51. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  52. ResponseManId= 1
  53. },
  54. new entity.Customer()
  55. {
  56. Id = 5,
  57. Name = "OPPO广东移动通信有限公司",
  58. Address = "广东省东莞市长安镇乌沙海滨路18号",
  59. Phone = "4001-666-888",
  60. ContactMan = "刘波",
  61. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  62. ResponseManId= 1
  63. },
  64. new entity.Customer()
  65. {
  66. Id = 6,
  67. Name = "OPPO广东移动通信有限公司",
  68. Address = "广东省东莞市长安镇乌沙海滨路18号",
  69. Phone = "4001-666-888",
  70. ContactMan = "刘波",
  71. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  72. ResponseManId= 1
  73. },
  74. new entity.Customer()
  75. {
  76. Id = 7,
  77. Name = "OPPO广东移动通信有限公司",
  78. Address = "广东省东莞市长安镇乌沙海滨路18号",
  79. Phone = "4001-666-888",
  80. ContactMan = "刘波",
  81. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  82. ResponseManId= 1
  83. },
  84. new entity.Customer()
  85. {
  86. Id = 8,
  87. Name = "OPPO广东移动通信有限公司",
  88. Address = "广东省东莞市长安镇乌沙海滨路18号",
  89. Phone = "4001-666-888",
  90. ContactMan = "刘波",
  91. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  92. ResponseManId= 1
  93. },
  94. new entity.Customer()
  95. {
  96. Id = 9,
  97. Name = "OPPO广东移动通信有限公司",
  98. Address = "广东省东莞市长安镇乌沙海滨路18号",
  99. Phone = "4001-666-888",
  100. ContactMan = "刘波",
  101. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  102. ResponseManId= 1
  103. },
  104. new entity.Customer()
  105. {
  106. Id = 10,
  107. Name = "OPPO广东移动通信有限公司",
  108. Address = "广东省东莞市长安镇乌沙海滨路18号",
  109. Phone = "4001-666-888",
  110. ContactMan = "刘波",
  111. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  112. ResponseManId= 1
  113. },
  114. new entity.Customer()
  115. {
  116. Id = 11,
  117. Name = "OPPO广东移动通信有限公司",
  118. Address = "广东省东莞市长安镇乌沙海滨路18号",
  119. Phone = "4001-666-888",
  120. ContactMan = "刘波",
  121. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  122. ResponseManId= 1
  123. },
  124. new entity.Customer()
  125. {
  126. Id = 12,
  127. Name = "OPPO广东移动通信有限公司",
  128. Address = "广东省东莞市长安镇乌沙海滨路18号",
  129. Phone = "4001-666-888",
  130. ContactMan = "刘波",
  131. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  132. ResponseManId= 1
  133. },
  134. new entity.Customer()
  135. {
  136. Id = 13,
  137. Name = "OPPO广东移动通信有限公司",
  138. Address = "广东省东莞市长安镇乌沙海滨路18号",
  139. Phone = "4001-666-888",
  140. ContactMan = "刘波",
  141. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  142. ResponseManId= 1
  143. },
  144. new entity.Customer()
  145. {
  146. Id = 14,
  147. Name = "OPPO广东移动通信有限公司",
  148. Address = "广东省东莞市长安镇乌沙海滨路18号",
  149. Phone = "4001-666-888",
  150. ContactMan = "刘波",
  151. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  152. ResponseManId= 1
  153. },
  154. new entity.Customer()
  155. {
  156. Id = 15,
  157. Name = "OPPO广东移动通信有限公司",
  158. Address = "广东省东莞市长安镇乌沙海滨路18号",
  159. Phone = "4001-666-888",
  160. ContactMan = "刘波",
  161. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  162. ResponseManId= 1
  163. },
  164. new entity.Customer()
  165. {
  166. Id = 16,
  167. Name = "OPPO广东移动通信有限公司",
  168. Address = "广东省东莞市长安镇乌沙海滨路18号",
  169. Phone = "4001-666-888",
  170. ContactMan = "刘波",
  171. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  172. ResponseManId= 1
  173. },
  174. new entity.Customer()
  175. {
  176. Id = 17,
  177. Name = "OPPO广东移动通信有限公司",
  178. Address = "广东省东莞市长安镇乌沙海滨路18号",
  179. Phone = "4001-666-888",
  180. ContactMan = "刘波",
  181. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  182. ResponseManId= 1
  183. },
  184. new entity.Customer()
  185. {
  186. Id = 18,
  187. Name = "OPPO广东移动通信有限公司",
  188. Address = "广东省东莞市长安镇乌沙海滨路18号",
  189. Phone = "4001-666-888",
  190. ContactMan = "刘波",
  191. ResponseMan= new entity.Staff(){Name ="钟子敏",Id =1},
  192. ResponseManId= 1
  193. }
  194. };
  195. IEnumerable<entity.Customer> selectedRows;
  196. ITable table;
  197. int _pageIndex = 1;
  198. int _pageSize = 10;
  199. int _total = 0;
  200. bool _loading = false;
  201. entity.Customer Editing = null;
  202. bool _visible = false;
  203. bool _isAdd = false;
  204. protected override void OnInitialized()
  205. {
  206. _loading = true;
  207. //await System.Threading.Thread.Sleep();
  208. //List<wispro.sp.entity.StaffGrade> data = await Http.GetFromJsonAsync<List<wispro.sp.entity.StaffGrade>>($"http://localhost:39476/api/StaffGrade/GetAll");
  209. _loading = false;
  210. _total = _Customers.Count;
  211. }
  212. private void HandlePageChange(PaginationEventArgs args)
  213. {
  214. if (_pageIndex != args.Page)
  215. {
  216. _pageIndex = args.Page;
  217. }
  218. if (_pageSize != args.PageSize)
  219. {
  220. _pageSize = args.PageSize;
  221. }
  222. }
  223. Dictionary<string, object> OnRow(RowData<entity.Customer> row)
  224. {
  225. Dictionary<string, object> ret = new Dictionary<string, object>();
  226. ret.Add("id", row.Data.Id);
  227. ret.Add("onclick", ((Action)delegate
  228. {
  229. //_message.Info($"row {row.Data.Grade} was clicked");
  230. }));
  231. return ret;
  232. }
  233. public void RemoveSelection(int id)
  234. {
  235. //var selected = selectedRows.Where(x => x.Id != id);
  236. //selectedRows = selected;
  237. }
  238. private void Delete(int id)
  239. {
  240. var DelCustumer = _Customers.Where(x => x.Id == id).FirstOrDefault<entity.Customer>();
  241. if (DelCustumer != null)
  242. {
  243. Editing = DelCustumer;
  244. _isAdd = false;
  245. _visible = true;
  246. }
  247. else
  248. {
  249. }
  250. _total = _Customers.Count;
  251. }
  252. private void Edit(int id)
  253. {
  254. Editing = _Customers.Where(x => x.Id == id).FirstOrDefault<entity.Customer>();
  255. if (Editing != null)
  256. {
  257. _isAdd = false;
  258. _visible = true;
  259. }
  260. else
  261. {
  262. }
  263. _total = _Customers.Count;
  264. }
  265. private void AddNew()
  266. {
  267. Editing = new entity.Customer();
  268. //_isAdd = true;
  269. _visible = true;
  270. }
  271. private async Task HandleOk(MouseEventArgs e)
  272. {
  273. //var data = await Http.PostAsJsonAsync<wispro.sp.entity.StaffGrade>($"http://localhost:39476/api/StaffGrade/Save", EditingStaff);
  274. //if (data.IsSuccessStatusCode)
  275. //{
  276. // ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  277. // await Task.Delay(1000);
  278. // if (result.Success)
  279. // {
  280. // await _message.Success("数据已保存!");
  281. // }
  282. // else
  283. // {
  284. // await _message.Error($"{result.ErrorMessage}");
  285. // }
  286. //}
  287. //else
  288. //{
  289. // await _message.Error($"请求发生错误 {data.StatusCode}");
  290. //}
  291. _visible = false;
  292. }
  293. private void HandleCancel(MouseEventArgs e)
  294. {
  295. Console.WriteLine(e);
  296. _visible = false;
  297. }
  298. }
  299. }