mainfrm_pane.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. function OnInitializeData() {
  5. callstudent(11);
  6. }
  7. function OnCloseForm() {
  8. }
  9. function OnException(err) {
  10. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  11. }
  12. //////////////////////////////////////////////////////////////////////////
  13. // Callback Functions.
  14. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  15. var g_students = [
  16. '宫照堰*',
  17. '杨蕊源*',
  18. '梁含璋#',
  19. '余天然',
  20. '黄千骏',
  21. '曹宝泉',
  22. '鞠欣睿',
  23. '王鑫宇',
  24. '邓钧',
  25. '宋岩',
  26. '丹增达哇'
  27. ];
  28. function getRandom(array, num) {
  29. var arr = array.slice(0),
  30. i = arr.length,
  31. min = i - num,
  32. temp, index;
  33. while (i-- > min) {
  34. index = Math.floor((i + 1) * Math.random());
  35. temp = arr[index];
  36. arr[index] = arr[i];
  37. arr[i] = temp;
  38. }
  39. return arr.slice(min);
  40. }
  41. function callstudent(num) {
  42. var students = getRandom(g_students, num);
  43. ui.list.table = [
  44. ['姓名']
  45. ].concat((students.map(item => {
  46. return [item];
  47. })));
  48. var idx = 0;
  49. var colors = students.map(item => { //@item.@String colors.@Array
  50. if (item.indexOf('*') !== -1) {
  51. return [idx++, 0, '#00FF00'];
  52. }
  53. if (item.indexOf('#') !== -1) {
  54. return [idx++, 0, '#00FFFF'];
  55. }
  56. return [idx++, 0, '#FFFF00'];
  57. });
  58. colors.forEach(item => {
  59. ui.list.color = item;
  60. });
  61. ui.list.head_size = [0];
  62. model.Test(ui.list.table);
  63. }
  64. function sortOne() {
  65. callstudent(1);
  66. }
  67. function sortMutiple() {
  68. callstudent(6);
  69. }
  70. //////////////////////////////////////////////////////////////////////////
  71. // Utils Functions.
  72. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  73. /*Usage of BLOCK_EVENT
  74. BLOCK_EVENT(()=>{
  75. ui.[name].[var] = ...;
  76. });
  77. */
  78. function BLOCK_EVENT(cb) {
  79. ui.block_event = true;
  80. cb();
  81. ui.block_event = false;
  82. }