//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e function OnInitializeData() { OnAllList(); } function OnCloseForm() { } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function OnAllList(){ callStudent(11); } var g_studengs = [ '宫照堰*', '杨蕊源*', '梁含璋#', '余天然', '黄千骏', '曹宝泉', '鞠欣睿', '王鑫宇', '邓钧', '宋岩', '丹增达哇' ]; function getRandomArrayElements(arr, count) { var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index; while (i-- > min) { index = Math.floor((i + 1) * Math.random()); temp = shuffled[index]; shuffled[index] = shuffled[i]; shuffled[i] = temp; } return shuffled.slice(min); } function callStudent(num) { var students = getRandomArrayElements(g_studengs, num); ui.list.table = [ ['姓名'] ].concat((students.map(item => { return [item]; }))); var idx = 0; var colors = students.map(item => { //@item.@String colors.@Array if (item.indexOf('*') !== -1) {return [idx++, 0, '#00FF00'];} if (item.indexOf('#') !== -1) {return [idx++, 0, '#00FFFF'];} return [idx++, 0, '#FFFF00']; }); colors.forEach(item => { ui.list.color = item; }); ui.list.head_size = [0]; } function OnSingle() { callStudent(1); model.Test(ui.list.table); } function OnMulti() { callStudent(5); model.Test(ui.list.table); } ////////////////////////////////////////////////////////////////////////// // Utils Functions. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe /*Usage of BLOCK_EVENT BLOCK_EVENT(()=>{ ui.[name].[var] = ...; }); */ function BLOCK_EVENT(cb) { ui.block_event = true; cb(); ui.block_event = false; }