_SceneInfo.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. @using IwbZero.ToolCommon.StringModel
  2. @using WeApp.Helpers
  3. @model string
  4. @{
  5. string[] arr = Model.Split('#');
  6. string groupNo = arr[0];
  7. string id = "scene-info";
  8. bool withScript = (arr.Length > 1 ? arr[1] : "").ValB();
  9. }
  10. @Html.Partial("__/_AreaBox", $"情景信息#{id}_{groupNo}")
  11. @if (withScript)
  12. {
  13. using (Html.BeginScripts())
  14. {
  15. <script id="scene-info-script">
  16. var rounds = [], roundPath= "P_R";
  17. var _loadCount = 0, _loadTimeout;
  18. function PreLoad(no) {
  19. _loadCount++;
  20. console.log("加载数据中... " + _loadCount);
  21. if (!$('.load-box').length) {
  22. $('body').append(`<div class="load-box"> <span class="loading">正在加载演练数据</span></div>`);
  23. }
  24. if (_loadCount > 3) {
  25. $('.load-box').fadeOut();
  26. return;
  27. }
  28. $.iwbAjax5({
  29. url: abp.appUrl + "Query/LoadCampPre?no="+no+"&type=0",
  30. timeout: 1000 * 60 * 5,
  31. success:() => {
  32. clearTimeout(_loadTimeout);
  33. $('.load-box').fadeOut().remove();
  34. $.iwbAjax5({
  35. url: abp.appUrl + "Query/LoadCampPre?no="+no+"&type=1",
  36. timeout: 1000 * 60 * 5,
  37. complete: () => {
  38. console.log("加载中... " + _loadCount);
  39. }
  40. });
  41. },
  42. complete: () => {
  43. console.log("加载中... " + _loadCount);
  44. }
  45. });
  46. clearTimeout(_loadTimeout);
  47. _loadTimeout = setTimeout(PreLoad, 1000 * 60 * 2);
  48. }
  49. var isPlaying = false, waitToPlayAttachList = [];
  50. function GetScenes(no) {
  51. $.iwbAjax5({
  52. url: abp.appUrl + 'Query/GetGroupScenes?no=' + no,
  53. success: (res) => {
  54. if (res && res.length) {
  55. res.forEach((v) => {
  56. FormatterScene(v,no);
  57. });
  58. window.Scroll2Bottom($(`#@(id)_${no} .box-body`).closest('.scroll-box'));
  59. } else {
  60. setTimeout(function () {
  61. if (!$(`#@(id)_${no} .box-body .scene-list-box`).length) {
  62. GetScenes(no);
  63. }
  64. }, 5000);
  65. }
  66. }
  67. });
  68. }
  69. function GetSceneInfo(groupNo,sceneNo) {
  70. $.iwbAjax4({
  71. url: abp.appUrl + 'Query/GetGroupSceneInfo?no=' + groupNo+'&scenePath=' + sceneNo,
  72. success: function(res) {
  73. if (res) {
  74. FormatterScene(res,groupNo);
  75. window.Scroll2Bottom($(`#@(id)_${groupNo} .box-body`).closest('.scroll-box'));
  76. } else {
  77. setTimeout(function () { GetSceneInfo(groupNo,sceneNo); }, 5000);
  78. }
  79. }
  80. });
  81. }
  82. function FormatterScene(data,groupNo) {
  83. var str = "";
  84. if (data) {
  85. if ($(`#@(id)_${groupNo} .box-body .scene-list-box[data-path="${data.path}"]`).length > 0) {
  86. return ;
  87. }
  88. str += `<div class="scene-list-box" data-name="${data.name}" data-path="${data.path}" id="scene_${data.id}">
  89. <span class="t">
  90. <i class="fa fa-play-circle"></i>
  91. <span>${data.name}</span>
  92. </span>
  93. <span class="b">
  94. ${data.description}
  95. </span>
  96. </div>`;
  97. if (data.attaches && data.attaches.length) {
  98. data.attaches.forEach(v => {
  99. waitToPlayAttachList.push(v);
  100. });
  101. }
  102. }
  103. if (str) {
  104. $(`#@(id)_${groupNo} .box-body`).append(str);
  105. window.PlayNext(groupNo);
  106. }
  107. }
  108. function FormatterScene_bk(data,groupNo) {
  109. var str = "";
  110. if (data) {
  111. if ($('.card-scene[data-path="' + data.path + '"]').length > 0) {
  112. return ;
  113. }
  114. var round = rounds.find(v => v.groupNo == groupNo);
  115. if (data.path.toUpperCase().indexOf(roundPath + "" + round.index) == 0) {
  116. str += `<div class="card card-scene round shadow-sm collapsed-card">
  117. <div class="card-header">
  118. <div class="card-title text-center w-100"><span>第&nbsp;${round.index}&nbsp;轮</span></div>
  119. </div>
  120. </div>`;
  121. round.index++;
  122. }
  123. var attachStr = "", str1 = "", guideIcon = '', guideStr = '';
  124. //if (data.attaches && data.attaches.length) {
  125. // data.attaches.forEach((v) => {
  126. // v.attachNo = data.id + "_" + v.attachNo;
  127. // waitToPlayAttachList.push(v);
  128. // var icon = v.fileType === "image" ? "fa-image" : v.fileType === "video" ? "fa-video" : "";
  129. // attachStr += `<button id="${v.attachNo}" class="attach btn btn-tool" id="${v.attachNo}" data-type="${v.fileType}" data-path="${v.filePath}" title="点击查看附件:${v.fileTitle}" type="button" onclick="PlayAttach(this,'${groupNo}')"><i class="fas ${icon}"></i></button>`;
  130. // });
  131. //}
  132. //str1 = data.hasEnd ? 'title = "情景已处理"':'';
  133. //if (data.guideInfos && data.guideInfos.length) {
  134. // guideIcon =
  135. // '<button class="btn btn-tool" title="点击查看提示引导信息" onclick="ToggleGuide(this)"><i class="fas fa-question"></i></button>';
  136. // guideStr += '<div class="guide-box" style="display:none"><p class="guide-title">提示:</p>';
  137. // var i = 0;
  138. // data.guideInfos.forEach((v) => {
  139. // i++;
  140. // guideStr += '<p class="guide-info">{0}、{1}</p>'.format(i, v.description);
  141. // });
  142. // guideStr += '</div>';
  143. //}
  144. str += `<div class="card card-scene shadow-sm ${data.hasEnd ? "collapsed-card end " : "flash-scene "}" data-name="${data.name}" data-path="${data.path}" id="scene_${data.id}">
  145. <div class="card-header" ${str1}>
  146. <div class="card-title"><span>${data.name}</span></div>
  147. <div class="card-tools">
  148. ${attachStr} ${guideIcon}
  149. <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas ${data.hasEnd ? "fa-plus" : "fa-minus"}"></i></button>
  150. </div>
  151. </div>
  152. <div class="card-body">
  153. ${guideStr}
  154. <div class="description">${data.description}</div>
  155. </div>
  156. </div>`;
  157. }
  158. if (str) {
  159. $(`#@(id)_${groupNo} .box-body`).append(str);
  160. window.PlayNext(groupNo);
  161. setTimeout(() => {
  162. $(`#@(id)_${groupNo} .box-body`).find(".flash-scene").removeClass("flash-scene");
  163. }, 1000 * 30);
  164. }
  165. }
  166. function ToggleGuide($this) {
  167. var $that = $($this);
  168. if ($that.hasClass('open')) {
  169. $that.removeClass('open').attr("title", "点击查看提示引导信息").find("i").removeClass("fa-question-circle").addClass("fa-question");
  170. $that.closest('.card-scene').find('.guide-box').slideUp(400);
  171. } else {
  172. $that.addClass('open').attr("title", "点击收起提示引导信息").find("i").removeClass("fa-question").addClass("fa-question-circle");
  173. $that.closest('.card-scene').find('.guide-box').slideDown(600);
  174. }
  175. }
  176. function PlayAttach($this,groupNo) {
  177. waitToPlayAttachList = [];
  178. var $that = $($this);
  179. var no = $that.data('id');
  180. var type = $that.data('type');
  181. var path = $that.data('path');
  182. window.Play(path, type, no,groupNo);
  183. }
  184. function DisabledScene1() {
  185. $('.card-scene:not(.round):not(.end)').each(function () {
  186. $(this).addClass('old-scene');
  187. $(this).find('.card-header').removeAttr("onclick");
  188. });
  189. }
  190. function DisabledScene2() {
  191. $('.card-scene.old-scene').each(function() {
  192. $(this).removeClass('old-scene').addClass('end');
  193. $(this).CardWidget("collapse");
  194. });
  195. $('.card-scene.active').removeClass('active');
  196. $('#current-scene-path').val('');
  197. $('.current-scene-box span').text('无');
  198. }
  199. iwbHub.client.getNewScene = function(msg) {
  200. console.log('getNewScene: ', msg);
  201. abp.ui.clearBusy($('body'));
  202. if (msg) {
  203. try {
  204. var data = typeof msg == 'string' ? JSON.parse(msg) : msg;
  205. if (data) {
  206. if ($(`#@(id)_${data.no} .box-body`).find('.card-scene[data-path="' + data.path + '"]').length <= 0) {
  207. DisabledScene2();
  208. GetSceneInfo(data.no,data.sceneNo);
  209. window.Scroll2Bottom($(`#@(id)_${data.no} .box-body`).closest('.scroll-box'));
  210. }
  211. }
  212. } catch (e) {
  213. console.log('getNewScene: ', e);
  214. }
  215. }
  216. };
  217. </script>
  218. }
  219. }
  220. @using (Html.BeginScripts())
  221. {
  222. <script id="scene-info-script">
  223. @*var $baseInfoBody = $('#@id .box-body');
  224. $baseInfoBody.html($('#@id-pre').html());
  225. $(function() {
  226. OverlayScrollbar($baseInfoBody.closest('.scroll-box'));
  227. });*@
  228. abp.signalr.connect(['@(groupNo)']);
  229. rounds.push({
  230. groupNo: '@(groupNo)',
  231. index: 1
  232. });
  233. GetScenes('@(groupNo)');
  234. </script>
  235. }