_Screen - 复制.cshtml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. @using WeApp.Configuration
  2. @using WeApp.Helpers
  3. @model WeApp.Views.Exercise.ScreenModel
  4. @{
  5. string groupNo = Model.GroupNo, campNo = Model.CampNo;
  6. bool show = Model.WithScript;
  7. int type = Model.Type;
  8. }
  9. @if (show)
  10. {
  11. <link href="~/Content/Css/Exercise/public.min.css" rel="stylesheet" />
  12. }
  13. <a href="javascript:void(0)" onclick="ShowGroupRole('@(groupNo)')" class="btn-info btn" style="right: 30px;">角色方案</a>
  14. <div class="box" style="width: 45%; height: 100%;" id="scene_@(groupNo)" data-isRefresh="true">
  15. <div class="box-title">
  16. <span>情景区</span>
  17. </div>
  18. <div class="box-body" style="height: calc(100% - 370px)"><div class="body-content"></div></div>
  19. <div class="media-box" style="height:300px;">
  20. <div class="body-content">
  21. <span>播放区</span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="box" style="width: 38%; height: 100%" id="log_@(groupNo)">
  26. <div class="box-title" style="position: relative">
  27. <span>决策指挥中心</span>
  28. <a id="warning-btn" href="javascript:void(0)" onclick="ShowWaring()" class="btn-danger btn" style="position: absolute; top: 6px; left: 30px; margin-bottom: 0; z-index: 2; padding: 8px 20px;display:none">查看告警</a>
  29. </div>
  30. <div class="box-body" style=""><div class="body-content"></div></div>
  31. </div>
  32. <div class="" style="width: 17%; height: 100%; float: left;">
  33. <div class="box" style="width: 100%; height: 70%" id="role_@(groupNo)">
  34. <div class="box-title">
  35. <span>指挥部</span>
  36. </div>
  37. <div class="box-body" style=""><div class="body-content"></div></div>
  38. </div>
  39. <div class="box" style="width: 100%; height: 30%; border-top: 0" id="score_@(groupNo)">
  40. <div class="box-title" style="border-top: 3px solid #eee;">
  41. <span>评估信息</span>
  42. </div>
  43. <div class="box-body" style="">
  44. <div class="body-content">
  45. @*<div class="score-box">
  46. <span class="name">系统评分</span><span style="padding: 0 5px;">:</span><span class="score">800</span><span style="padding-left: 5px;">分</span>
  47. </div>*@
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. @using (Html.BeginScripts())
  53. {
  54. <script>
  55. $(function() {
  56. abp.signalr.connect(['@(groupNo)']);
  57. OverlayScrollbar($('.box-body'), { className: "os-theme-thin-light"});
  58. GetScenes('@(groupNo)');
  59. GetLogs('@(groupNo)');
  60. GetRoles('@(groupNo)');
  61. GetScore('@(groupNo)');
  62. });
  63. </script>
  64. }
  65. @if (show)
  66. {
  67. using (Html.BeginScripts())
  68. {
  69. <script>
  70. var overlayScrollbar;
  71. $(function() {
  72. abp.signalr.connect(['@(campNo)']);
  73. });
  74. function Scroll2Bottom(that) {
  75. var instance = window.OverlayScrollbars($(that)[0]);
  76. instance.scroll({ y: "100%" });
  77. }
  78. function ShowGroupRole(no) {
  79. $.iwbAjax4({
  80. url: abp.appUrl + 'Query/GetGroupRolePlans?no=' + no,
  81. success: function(res) {
  82. if (res && res.plans && res.plans.length > 0) {
  83. var str = '';
  84. res.plans.forEach(function(v) {
  85. str += FormatterRolePlan(v);
  86. });
  87. if (str) {
  88. $(document).iwbModal('create',
  89. {
  90. modal: 'modal-role-plan',
  91. modaltitle: '角色预案详情',
  92. modalBody: str,
  93. save: function() {
  94. $('#modal-role-plan').modal('hide');
  95. }
  96. });
  97. }
  98. } else {
  99. abp.message.warn("还未创建指挥部!");
  100. }
  101. }
  102. });
  103. }
  104. function FormatterRolePlan(data) {
  105. var str = '';
  106. if (data) {
  107. str += '<div class="plan-box box">';
  108. str += '<div class="plan-name">{0}</div>'.format(data.name);
  109. str += '<div class="plan-role">';
  110. if (data.roleName) {
  111. data.roleName.forEach(function(v) {
  112. str += '<div class="role-box"><div class="image"><img src="../../Content/Image/user.png" /></div><div class="name">{0}</div></div>'
  113. .format(v);
  114. });
  115. }
  116. str += '</div>';
  117. str += '</div>';
  118. }
  119. return str;
  120. }
  121. </script>
  122. <script id="scene-s">
  123. function GetScenes(no) {
  124. $.iwbAjax5({
  125. url: abp.appUrl + 'Query/GetGroupScenes?no=' + no,
  126. success: function (res) {
  127. if (res) {
  128. FormatterScenes(res, no);
  129. }
  130. }
  131. });
  132. }
  133. function FormatterScenes(data, no) {
  134. var str = "";
  135. if (data && data.length > 0) {
  136. data.forEach(function (v) {
  137. str += FormatterSceneInfo(v, false);
  138. });
  139. }
  140. if (str) {
  141. $('#scene_' + no + ' .box-body .body-content').html(str);
  142. Scroll2Bottom($('#scene_' + no + ' .box-body'));
  143. }
  144. }
  145. function GetSceneInfo(groupNo, sceneNo) {
  146. $.iwbAjax5({
  147. url: abp.appUrl + 'Query/GetGroupSceneInfo?no=' + groupNo + '&sceneNo=' + sceneNo,
  148. success: function (res) {
  149. if (res) {
  150. var str = FormatterSceneInfo(res, true);
  151. if (str) {
  152. $('#scene_' + groupNo + ' .box-body .body-content').append(str);
  153. AutoPlay();
  154. var t = $('#scene_' + groupNo).data('t');
  155. //clearTimeout(t);
  156. //t =
  157. //setTimeout(function () {
  158. // $("#scene_" + groupNo + ' .box-body .body-content').find(".flash-scene").removeClass("flash-scene");
  159. //}, 1000 * 20);
  160. $('#scene_' + groupNo).data('t', t);
  161. Scroll2Bottom($('#scene_' + groupNo + ' .box-body'));
  162. }
  163. } else {
  164. setTimeout(function () { GetSceneInfo(groupNo, sceneNo); }, 5000);
  165. }
  166. }
  167. });
  168. }
  169. function FormatterSceneInfo(data, isNew) {
  170. var str = "";
  171. if (data) {
  172. var c = isNew ? "flash-scene new-scene" : "", attachStr = '';
  173. if (data.attaches && data.attaches.length > 0) {
  174. var template = '<span class="badge badge-{3} attach attach-{0}" data-attach-type="{0}" data-path="{1}" style="margin-left:10px;cursor: pointer;padding:6px 10px" onclick="EventAttach(this)">{2}</span>';
  175. for (var i = 0; i < data.attaches.length; i++) {
  176. var item = data.attaches[i];
  177. if (item.fileType) {
  178. if (item.fileType === "image") {
  179. attachStr += template.format(item.fileType, item.filePath, '图片', 'success');
  180. } else if (item.fileType === "video") {
  181. attachStr += template.format(item.fileType, item.filePath, '视频', 'danger');
  182. }
  183. }
  184. }
  185. }
  186. str +=
  187. '<div class="scene-box {3}" data-id="{0}" data-path="{5}"><div class="title">{1}<div class="attach-box">{4}</div></div><div class="desc">{2}</div></div>'
  188. .format(data.id, data.name, data.description, c, attachStr,data.path);
  189. }
  190. return str;
  191. }
  192. var imageTemplate = '<img src="{0}" style=""/>',
  193. videoTemplate = '<video id="video" style="" controls autoplay><source src="{0}" type="video/mp4">您的浏览器不支持 HTML5 video 标签。</video>',
  194. audioTemplate = '<audio id="audio" style="" controls autoplay><source src="{0}" type="audio/mp3">您的浏览器不支持 HTML5 audio 标签。</audio>';
  195. var at;
  196. function EventAttach(that, event) {
  197. var type = $(that).data('attach-type');
  198. var path = $(that).data('path');
  199. if (type) {
  200. var str = type === "image" ? imageTemplate.format(path) : type === "video" ? videoTemplate.format(path) : type === "audio" ? audioTemplate.format(path) : '';
  201. $(that).closest(".box").find(".media-box .body-content").html(str);
  202. $(that).closest(".box").find(".current-scene").removeClass("current-scene");
  203. $(that).closest(".scene-box").addClass("current-scene");
  204. event = event || function () { InitMedia($(that)) };
  205. var video = document.getElementById("video");
  206. if (video) {
  207. video.loop = false;
  208. video.addEventListener('ended', function () { setTimeout(function () { event.call(that); }, 1000 * 3) }, false);
  209. } else {
  210. clearTimeout(at);
  211. at = setTimeout(function () { event.call(that); }, 1000 * 10);
  212. }
  213. }
  214. }
  215. function AutoPlay($that) {
  216. if ($that !== undefined && $that != null && $that.length <= 0) {
  217. return;
  218. }
  219. $that = $that === undefined ? $('.new-scene') : $that;
  220. var $attach = $that.find('.attach');
  221. if ($attach.length <= 0) {
  222. var $next = $that.next();
  223. if ($next.length > 0) {
  224. AutoPlay();
  225. } else {
  226. InitMedia($that);
  227. }
  228. } else {
  229. if (!$that) { return; }
  230. $attach = $that.find('.attach').first();
  231. EventAttach($attach, function () { AutoPlay($that); });
  232. $attach.removeClass('attach');
  233. }
  234. }
  235. function InitMedia(that) {
  236. var $that = (that).closest(".box");
  237. $that.find(".current-scene").removeClass("current-scene");
  238. $that.find(".media-box .body-content").html('<span>播放区</span>');
  239. }
  240. </script>
  241. <script id="log-s">
  242. function GetLogs(no) {
  243. $.iwbAjax5({
  244. url: abp.appUrl + 'Query/GetGroupLogs?no=' + no,
  245. success: function(res) {
  246. if (res) {
  247. FormatterLog(res, no);
  248. }
  249. }
  250. });
  251. }
  252. function FormatterLog(data, no) {
  253. var str = "";
  254. if (data && data.length > 0) {
  255. data.forEach(function(v) {
  256. str += FormatLog(v);
  257. });
  258. }
  259. if (str) {
  260. $('#log_' + no + ' .box-body .body-content').html(str);
  261. }
  262. }
  263. function FormatLog(data) {
  264. var c = '';
  265. if (data.logState == '@(LogStateDefinition.Submit)' || data.logState == '@(LogStateDefinition.Send)'|| data.logState == '@(LogStateDefinition.HasMatch)') {
  266. c = "send";
  267. }
  268. var str =
  269. '<div class="log-box {3} log_{0}" data-id="{0}" ><span class="role">{1}</span><span style="padding:0 5px;">:</span><span class="word">{2}</span></div>'
  270. .format(data.id, data.role, data.word, c);
  271. return str;
  272. }
  273. </script>
  274. <script id="role-s">
  275. function GetRoles(no) {
  276. $.iwbAjax5({
  277. url: abp.appUrl + 'Query/GetGroupRoleInfos?no=' + no,
  278. success: function (res) {
  279. if (res) {
  280. FormatterRole(res, no);
  281. }
  282. }
  283. });
  284. }
  285. function FormatterRole(data, no) {
  286. var str = "";
  287. if (data && data.length > 0) {
  288. data.forEach(function (v) {
  289. str +=
  290. '<div class="role-box"><div class="image"><img src="../../Content/Image/user.png" /></div><div class="name">{0}</div></div>'
  291. .format(v);
  292. });
  293. }
  294. if (str) {
  295. $('#role_' + no + ' .box-body .body-content').html(str);
  296. }
  297. }
  298. </script>
  299. <script id="score-s">
  300. function GetScore(no) {
  301. $.iwbAjax5({
  302. url: abp.appUrl + 'Query/GetGroupScoreInfo?no=' + no,
  303. success: function (res) {
  304. if (res) {
  305. res.systemScore = undefined;
  306. FormatterScore(res, no);
  307. }
  308. }
  309. });
  310. }
  311. function FormatterScore(data, no) {
  312. var str = "",
  313. template =
  314. '<div class="score-box {2}"><span class="name">{0}</span><span style="padding:0 5px;">:</span><span class="score">{1}</span><span style="padding-left: 5px;">分</span></div>';
  315. if (data.systemScore) {
  316. str += template.format("系统评分", data.systemScore,"system-score");
  317. }
  318. var tags = data.behaviorTagScoreInfo ? JSON.parse(data.behaviorTagScoreInfo) : data.tagScores;
  319. if (tags && tags.length > 0) {
  320. tags.forEach(function (v) {
  321. var score = v.correctionScore ? v.correctionScore : v.systemScore;
  322. if (score > 0) {
  323. str += template.format(v.tagNo, score, "tag-score");
  324. }
  325. });
  326. }
  327. if (str) {
  328. $('#score_' + no + ' .box-body .body-content').prepend(str);
  329. }
  330. }
  331. </script>
  332. <script id="hub-s">
  333. iwbHub.client.getReloadAll = function(msg) {
  334. console.log('getReloadAll: ', msg);
  335. if (msg) {
  336. try {
  337. var data = JSON.parse(msg);
  338. if (data) {
  339. if (data.no == '@(groupNo)' || data.no == '@(campNo)') {
  340. window.location.reload();
  341. }
  342. }
  343. } catch (e) {
  344. console.log('getReloadAll: ', e);
  345. }
  346. }
  347. };
  348. iwbHub.client.getOperationLog = function(msg) {
  349. console.log('getOperationLog: ', msg);
  350. if (msg) {
  351. try {
  352. var data = JSON.parse(msg);
  353. if (@(type) == 2 || data.no=='@(groupNo)') {
  354. var str = FormatLog(data);
  355. $('#log_' + data.no + ' .box-body .body-content').prepend(str);
  356. }
  357. } catch (e) {
  358. console.log('getOperationLog: ', e);
  359. }
  360. }
  361. };
  362. iwbHub.client.getOperationLogSubmit = function(msg) {
  363. console.log('getOperationLogSubmit: ', msg);
  364. if (msg) {
  365. try {
  366. var data = JSON.parse(msg);
  367. if (@(type) == 2 || data.no=='@(groupNo)') {
  368. $('#log_' + data.no + ' .box-body .body-content').find('.log_' + data.logId).addClass('send');
  369. }
  370. } catch (e) {
  371. console.log('getOperationLogSubmit: ', e);
  372. }
  373. }
  374. };
  375. iwbHub.client.getNewScene = function(msg) {
  376. console.log('getNewScene: ', msg);
  377. if (msg) {
  378. try {
  379. var data = JSON.parse(msg);
  380. if (data) {
  381. if (@(type) == 2 || data.no == '@(groupNo)') {
  382. if ($('#scene_' + data.no).find('.scene-box[data-path="' + data.path + '"]').length <= 0) {
  383. GetSceneInfo(data.no, data.sceneNo);
  384. }
  385. }
  386. }
  387. } catch (e) {
  388. console.log('getNewScene: ', e);
  389. }
  390. }
  391. };
  392. iwbHub.client.getRoundScore = function(msg) {
  393. console.log('getRoundScore: ', msg);
  394. if (msg) {
  395. try {
  396. var data = JSON.parse(msg);
  397. if (@(type) == 2 || data.no=='@(groupNo)') {
  398. data.systemScore = undefined;
  399. FormatterScore(data, data.no);
  400. };
  401. } catch (e) {
  402. console.log('getRoundScore: ', e);
  403. }
  404. }
  405. };
  406. iwbHub.client.getSendScore = function(msg) {
  407. console.log('getSendScore: ', msg);
  408. if (msg) {
  409. try {
  410. var data = JSON.parse(msg);
  411. if (@(type) == 2 || data.no=='@(groupNo)') {
  412. FormatterScore(data, data.no);
  413. };
  414. } catch (e) {
  415. console.log('getSendScore: ', e);
  416. }
  417. }
  418. };
  419. </script>
  420. }
  421. }