_SceneInfo.cshtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. @using WeApp.Helpers
  2. @model WeApp.Views.Exercise.ScreenModel
  3. @{
  4. string id = "scene-info";
  5. string id2 = $"{id}_{Model.GroupNo}";
  6. }
  7. <style>
  8. @*#@id2 .card-header{
  9. display: flex;
  10. justify-content: space-between
  11. }*@
  12. #scene-info .card-header:after {
  13. display: none;
  14. }
  15. .current-scene-box {
  16. background: var(--mc);
  17. color: #fff;
  18. padding: 0 15px;
  19. height: 30px;
  20. line-height: 30px;
  21. text-align: center;
  22. border-radius: 0.25rem;
  23. font-size: 14px;
  24. }
  25. .current-scene-box span {
  26. font-weight: bold;
  27. }
  28. .card-scene {
  29. width: 100%;
  30. margin: 10px 0;
  31. border-radius: 0.5rem;
  32. --bg: var(--mc);
  33. }
  34. .card-scene.round {
  35. --bg: #ffdd20;
  36. }
  37. .card-scene.end {
  38. --bg: #ff7c63;
  39. }
  40. .card-scene.active {
  41. border: 1px solid var(--bg);
  42. }
  43. .card-scene > .card-header {
  44. color: var(--bg);
  45. padding: 0.4rem 0.8rem;
  46. border-radius: 0.5rem 0.5rem 0 0;
  47. font-weight: bold;
  48. font-size: 14px;
  49. cursor: pointer;
  50. transition: 0.3s all ease-in;
  51. }
  52. .card-scene.active .card-header {
  53. color: #fff;
  54. background: var(--bg)
  55. }
  56. .card-scene.collapsed-card > .card-header {
  57. border-radius: 0.5rem;
  58. }
  59. .card-scene > .card-header .card-title {
  60. font-weight: bold;
  61. font-size: 15px
  62. }
  63. .card-scene > .card-header .btn-tool {
  64. background: #ddd;
  65. color: var(--bg);
  66. padding: 0;
  67. margin-right: 0.25rem;
  68. width: 28px;
  69. }
  70. .card-scene > .card-header .attach.btn-tool.playing {
  71. color: #fff;
  72. background: var(--bg);
  73. }
  74. .card-scene > .card-header .btn-tool:hover {
  75. color: #fff;
  76. background: var(--bg);
  77. }
  78. .card-scene.active > .card-header .attach.btn-tool.playing {
  79. color: var(--bg);
  80. background: #fff;
  81. }
  82. .card-scene.active > .card-header .btn-tool:hover {
  83. color: var(--bg);
  84. background: #eee;
  85. }
  86. .card-scene > .card-header:before {
  87. content: "";
  88. position: absolute;
  89. left: 0;
  90. top: 0;
  91. width: 7px;
  92. height: 100%;
  93. background: var(--bg);
  94. border-radius: 8px 0 0 0;
  95. transition: 0.3s all ease-in;
  96. }
  97. .card-scene.collapsed-card > .card-header:before {
  98. border-radius: 8px 0 0 8px;
  99. }
  100. .card-scene > .card-body {
  101. color: #8c91a8;
  102. padding: 5px 10px 5px 15px;
  103. font-size: 12px;
  104. border-radius: 0 0 0.5rem 0.5rem;
  105. position: relative;
  106. }
  107. .card-scene > .card-body:before {
  108. content: "";
  109. position: absolute;
  110. left: 0;
  111. top: -1px;
  112. width: 7px;
  113. height: calc(100% + 1px);
  114. background: var(--bg);
  115. border-radius: 0 0 0 8px;
  116. }
  117. .card-scene > .card-body .description {
  118. text-indent: 2em;
  119. }
  120. .guide-box {
  121. font-size: 12px;
  122. color: #666;
  123. padding: 0 8px 5px;
  124. margin: 5px 10px;
  125. border: 1px dashed darkgray;
  126. border-radius: 5px;
  127. }
  128. .guide-title {
  129. font-weight: bold;
  130. margin: 5px 0;
  131. }
  132. .guide-info {
  133. margin: 0 0 5px 0;
  134. text-indent: 2em;
  135. }
  136. .flash-scene .card-title {
  137. animation: flash 1s infinite;
  138. }
  139. @@keyframes flash {
  140. 0% {
  141. opacity: 1.0;
  142. color: inherit;
  143. transform: scale(1);
  144. }
  145. 50% {
  146. opacity: 0.5;
  147. color: red;
  148. transform: scale(0.95);
  149. }
  150. 100% {
  151. opacity: 1.0;
  152. color: inherit;
  153. transform: scale(1);
  154. }
  155. }
  156. .load-box {
  157. position: fixed;
  158. top: 0;
  159. bottom: 0;
  160. left: 0;
  161. right: 0;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. font-size: 40px;
  166. font-weight: 600;
  167. color: #007bff;
  168. z-index: 1000;
  169. background: rgba(255,255,255,0.6);
  170. }
  171. .loading {
  172. margin-top:-10%;
  173. }
  174. .loading:after {
  175. overflow: hidden;
  176. display: inline-block;
  177. vertical-align: bottom;
  178. animation: ellipsis 2s infinite;
  179. content: "\2026";
  180. }
  181. @@keyframes ellipsis {
  182. from {
  183. width: 2px;
  184. margin-right:33px;
  185. }
  186. to {
  187. width: 35px;
  188. margin-right: 0;
  189. }
  190. }
  191. </style>
  192. <script>
  193. var roundPath = "P_R", round = 1, isPlaying = false, waitToPlayAttachList = [];
  194. </script>
  195. @Html.Partial("_Run/_AreaBox", $"情景区#{id2}")
  196. @if (Model.WithScript)
  197. {
  198. using (Html.BeginScripts())
  199. {
  200. <script id="scene-script">
  201. var _loadCount = 0, _loadTimeout;
  202. function PreLoad(no) {
  203. _loadCount++;
  204. console.log("加载数据中... " + _loadCount);
  205. if (!$('.load-box').length) {
  206. $('body').append(`<div class="load-box"> <span class="loading">正在加载演练数据</span></div>`);
  207. }
  208. if (_loadCount > 3) {
  209. $('.load-box').fadeOut();
  210. return;
  211. }
  212. $.iwbAjax5({
  213. url: abp.appUrl + "Query/LoadCampPre?no="+no+"&type=0",
  214. timeout: 1000 * 60 * 5,
  215. success:() => {
  216. clearTimeout(_loadTimeout);
  217. $('.load-box').fadeOut().remove();
  218. $.iwbAjax5({
  219. url: abp.appUrl + "Query/LoadCampPre?no="+no+"&type=1",
  220. timeout: 1000 * 60 * 5,
  221. complete: () => {
  222. console.log("加载中... " + _loadCount);
  223. }
  224. });
  225. },
  226. complete: () => {
  227. console.log("加载中... " + _loadCount);
  228. }
  229. });
  230. clearTimeout(_loadTimeout);
  231. _loadTimeout = setTimeout(PreLoad, 1000 * 60 * 2);
  232. }
  233. function GetScenes(no) {
  234. $.iwbAjax5({
  235. url: abp.appUrl + 'Query/GetGroupScenes?no=' + no,
  236. success: (res) => {
  237. if (res && res.length) {
  238. res.forEach((v) => {
  239. FormatterScene(v,no);
  240. });
  241. window.Scroll2Bottom($(`#@(id)_${no} .box-body`).closest('.scroll-box'));
  242. }
  243. }
  244. });
  245. }
  246. function GetSceneInfo(groupNo,sceneNo) {
  247. $.iwbAjax4({
  248. url: abp.appUrl + 'Query/GetGroupSceneInfo?no=' + groupNo+'&scenePath=' + sceneNo,
  249. success: function(res) {
  250. if (res) {
  251. FormatterScene(res,groupNo);
  252. window.Scroll2Bottom($(`#@(id)_${groupNo} .box-body`).closest('.scroll-box'));
  253. if (!window.startFlag) {
  254. window.startFlag = true;
  255. window.GetLogs();
  256. }
  257. } else {
  258. setTimeout(function () { GetSceneInfo(groupNo,sceneNo); }, 5000);
  259. }
  260. }
  261. });
  262. }
  263. function FormatterScene(data,groupNo) {
  264. var str = "";
  265. if (data) {
  266. if ($('.card-scene[data-path="' + data.path + '"]').length > 0) {
  267. return ;
  268. }
  269. if (data.path.toUpperCase().indexOf(roundPath + "" + round) == 0) {
  270. str += `<div class="card card-scene round shadow-sm collapsed-card">
  271. <div class="card-header">
  272. <div class="card-title text-center w-100"><span>第&nbsp;${round}&nbsp;轮</span></div>
  273. </div>
  274. </div>`;
  275. round++;
  276. }
  277. var attachStr = "";
  278. if (data.attaches && data.attaches.length) {
  279. data.attaches.forEach((v) => {
  280. v.attachNo = data.id + "_" + v.attachNo;
  281. waitToPlayAttachList.push(v);
  282. var icon = v.fileType === "image" ? "fa-image" : v.fileType === "video" ? "fa-video" : "";
  283. 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>`;
  284. });
  285. }
  286. var str1 = data.hasEnd ? 'title = "情景已处理"':'';
  287. var guideIcon = '', guideStr = '';
  288. if (data.guideInfos && data.guideInfos.length) {
  289. guideIcon =
  290. '<button class="btn btn-tool" title="点击查看提示引导信息" onclick="ToggleGuide(this)"><i class="fas fa-question"></i></button>';
  291. guideStr += '<div class="guide-box" style="display:none"><p class="guide-title">提示:</p>';
  292. var i = 0;
  293. data.guideInfos.forEach((v) => {
  294. i++;
  295. guideStr += '<p class="guide-info">{0}、{1}</p>'.format(i, v.description);
  296. });
  297. guideStr += '</div>';
  298. }
  299. 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}">
  300. <div class="card-header" ${str1}>
  301. <div class="card-title"><span>${data.name}</span></div>
  302. <div class="card-tools">
  303. ${attachStr} ${guideIcon}
  304. <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas ${data.hasEnd ? "fa-plus" : "fa-minus"}"></i></button>
  305. </div>
  306. </div>
  307. <div class="card-body">
  308. ${guideStr}
  309. <div class="description">${data.description}</div>
  310. </div>
  311. </div>`;
  312. }
  313. if (str) {
  314. $(`#@(id)_${groupNo} .box-body`).append(str);
  315. window.PlayNext(groupNo);
  316. setTimeout(() => {
  317. $(`#@(id)_${groupNo} .box-body`).find(".flash-scene").removeClass("flash-scene");
  318. }, 1000 * 30);
  319. }
  320. }
  321. function ToggleGuide($this) {
  322. var $that = $($this);
  323. if ($that.hasClass('open')) {
  324. $that.removeClass('open').attr("title", "点击查看提示引导信息").find("i").removeClass("fa-question-circle").addClass("fa-question");
  325. $that.closest('.card-scene').find('.guide-box').slideUp(400);
  326. } else {
  327. $that.addClass('open').attr("title", "点击收起提示引导信息").find("i").removeClass("fa-question").addClass("fa-question-circle");
  328. $that.closest('.card-scene').find('.guide-box').slideDown(600);
  329. }
  330. }
  331. function PlayAttach($this,groupNo) {
  332. waitToPlayAttachList = [];
  333. var $that = $($this);
  334. var no = $that.data('id');
  335. var type = $that.data('type');
  336. var path = $that.data('path');
  337. window.Play(path, type, no,groupNo);
  338. }
  339. function DisabledScene1() {
  340. $('.card-scene:not(.round):not(.end)').each(function () {
  341. $(this).addClass('old-scene');
  342. $(this).find('.card-header').removeAttr("onclick");
  343. });
  344. }
  345. function DisabledScene2() {
  346. $('.card-scene.old-scene').each(function() {
  347. $(this).removeClass('old-scene').addClass('end');
  348. $(this).CardWidget("collapse");
  349. });
  350. $('.card-scene.active').removeClass('active');
  351. $('#current-scene-path').val('');
  352. $('.current-scene-box span').text('无');
  353. }
  354. iwbHub.client.getNewScene = function(msg) {
  355. console.log('getNewScene: ', msg);
  356. abp.ui.clearBusy($('body'));
  357. if (msg) {
  358. try {
  359. var data = typeof msg == 'string' ? JSON.parse(msg) : msg;
  360. if (data) {
  361. if (@(Model.Type) == 2 || data.no == '@(Model.GroupNo)') {
  362. if ($(`#@(id)_${data.no} .box-body`).find('.card-scene[data-path="' + data.path + '"]').length <= 0) {
  363. DisabledScene2();
  364. GetSceneInfo(data.no,data.sceneNo);
  365. window.Scroll2Bottom($(`#@(id)_${data.no} .box-body`).closest('.scroll-box'));
  366. }
  367. }
  368. }
  369. } catch (e) {
  370. console.log('getNewScene: ', e);
  371. }
  372. }
  373. };
  374. </script>
  375. }
  376. }