Leader.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. @using WeApp.Configuration
  2. @using WeApp.TrainingCampGroup.Dto
  3. @{
  4. Layout = "~/Views/Shared/Layout/_Layout.Stu.cshtml";
  5. CampGroupDto group = ViewBag.Group;
  6. ViewBag.Title = "指挥长屏(" + group.Name + ")";
  7. string id = group.Id,
  8. groupName = group.Name,
  9. campNo = group.CampNo;
  10. }
  11. @section css{
  12. <link href="~/Content/Css/ExerciseV2/stu-cmd_leader.min.css" rel="stylesheet" />
  13. }
  14. @Html.Partial("Layout/V2/_Bg",false)
  15. <div class="box no-select" style="">
  16. <div id="bg_title">
  17. <span class="title">决策指令下达</span>
  18. </div>
  19. <div class="box-body ">
  20. <div class="box-header">
  21. <span class="title">@(groupName)指挥部 —— 指挥长</span>
  22. </div>
  23. <div class="body">
  24. <div class="body-card" id="cmd-box">
  25. <div id="log-box" class="logs-box">
  26. <div class='empty'>暂无指令,等待组员发送指令</div>
  27. </div>
  28. </div>
  29. <div class="body-card">
  30. <div class="btn" onclick="SubmitNextScene()">进入下一阶段场景</div>
  31. </div>
  32. </div>
  33. </div>
  34. <div style="position: absolute; left: 0; bottom: 0; color: #ddd; opacity: 0.5;">@(groupName)</div>
  35. </div>
  36. <div class="question" title="点击处理来电" onclick="ShowQuestion()">
  37. <button type="button" class="btn-danger" style="--w: 80px;">
  38. <i class="fa fa-phone-volume"></i>
  39. </button>
  40. </div>
  41. <div class="modal fade" id="modal" tabindex="-1">
  42. <div class="modal-dialog modal-lg">
  43. <div class="modal-content">
  44. <div class="modal-header" style="cursor: move;">
  45. <h4 class="modal-title">
  46. <span>处置电话提问</span>
  47. </h4>
  48. <button type="button" class="close" data-dismiss="modal"></button>
  49. </div>
  50. <div class="modal-body">
  51. <form class="form-horizontal " id="form">
  52. <input id="id" name="id" type="hidden" value="">
  53. <input id="campNo" name="campNo" type="hidden" value="">
  54. <input id="groupNo" name="groupNo" type="hidden" value="">
  55. <div class="question-text">
  56. </div>
  57. <div class="form-group row">
  58. <div class="" style="width: 100%">
  59. <div class="input-group input-group-sm ">
  60. <textarea rows="5" class="form-control required" id="handleContent" name="handleContent" placeholder="请输入处理内容..." value="" style="" aria-required="true"></textarea>
  61. </div>
  62. </div>
  63. </div>
  64. </form>
  65. </div>
  66. <div class="modal-footer" style="text-align: center;">
  67. <button type="button" class="btn btn-sm btn-outline-iwb waves-effect" data-dismiss="modal" style="min-width:100px;">取消</button>
  68. <button type="button" class="btn btn-iwb btn-sm save-btn waves-effect" style="min-width:100px;">保存</button>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <audio id="voiceAudio" style="display: none">
  74. <source type="audio/wav" />
  75. </audio>
  76. @section scripts
  77. {
  78. <script>
  79. $(function () {
  80. resizeHeight_Leader();
  81. window.addEventListener('resize', resizeHeight_Leader);
  82. GetLog();
  83. GetQuestionLogs();
  84. OverlayScrollbar($('#cmd-box'));
  85. $('#handleContent').keydown(function(e) {
  86. var theEvent = window.event || e;
  87. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  88. if (code == 13) {
  89. $('#modal .save-btn').click();
  90. }
  91. });
  92. });
  93. function resizeHeight_Leader() {
  94. resizeHeight((h, wh) => {
  95. var height = 225;
  96. $(".logs-box").height(wh - h - height)
  97. })
  98. }
  99. function RoleHandle(that) {
  100. MsgConfirm("您确认下达这条指令吗?",
  101. "下达指令",
  102. function() {
  103. var $that = $(that).closest('.log-box');
  104. var id = $that.data('id');
  105. $.iwbAjax4({
  106. url: abp.appUrl + "Eval/OperationScene?id=" + id,
  107. success: function() {
  108. $that.addClass('send');
  109. $that.find('.btn').html('已下达');
  110. }
  111. });
  112. });
  113. }
  114. function SubmitNextScene() {
  115. var log = $("#log-box .log-box.send");
  116. if (!log || log.length <= 0) {
  117. abp.message.warn("请至少下达一条指令后再操作!");
  118. return;
  119. }
  120. MsgConfirm("您确认进入到下一情景吗?",
  121. "情景流转",
  122. function() {
  123. $.iwbAjax4({
  124. url: abp.appUrl + "Eval/NextFlowNode?groupNo=@(id)&campNo=none",
  125. success: function(res) {
  126. $("#log-box").html("<div class='empty'>暂无指令,等待组员发送指令</div>");
  127. }
  128. });
  129. });
  130. }
  131. function GetLog() {
  132. $.iwbAjax5({
  133. url: abp.appUrl + "Query/GetCurrentSceneLog?no=@(id)",
  134. success: function(res) {
  135. if (res) {
  136. $("#box-body").empty();
  137. var str = '';
  138. for (var i = 0; i < res.length; i++) {
  139. var item = res[i];
  140. str += FormatLog(item);
  141. }
  142. if (str) {
  143. $("#log-box").html(str);
  144. } else {
  145. $("#log-box").html("<div class='empty'>暂无指令,等待组员发送指令</div>");
  146. }
  147. }
  148. }
  149. });
  150. }
  151. function FormatLog(data) {
  152. var str = "";
  153. if (data) {
  154. var msg = data.word ? data.word : "",
  155. state = data.logState == '@(LogStateDefinition.New)' ? '' : 'send',
  156. btn = data.logState == '@(LogStateDefinition.New)' ? '<div class="btn btn-small" onclick="RoleHandle(this)">下达指令</div>' : '<div class="btn btn-small">已下达</div>';
  157. str = '<div class="log-box {0}" data-id="{1}"><div class="content"><div class="title">{2}</div><div class="text">{3}</div></div><div class="btn-box">{4}</div></div>'.format(state, data.id, data.role, msg, btn);
  158. }
  159. return str;
  160. }
  161. function GetQuestionLogs() {
  162. $.iwbAjax4({
  163. url: abp.appUrl + "query/GetQuestionLogs?no=@(id)",
  164. success: function(res) {
  165. if (res && res.length) {
  166. res.forEach(v => {
  167. if (_phoneLogIds.indexOf(v) < 0) {
  168. _phoneLogIds.push(v);
  169. }
  170. });
  171. PhoneQuestion();
  172. }
  173. }
  174. });
  175. }
  176. var _phoneLogIds = [], _currentPhoneLogId, _currentPhoneQuestionText, _voiceText, isPhoning = false;
  177. function PhoneQuestion() {
  178. if (isPhoning) {
  179. return;
  180. }
  181. _currentPhoneLogId = _phoneLogIds.shift();
  182. if (_currentPhoneLogId) {
  183. isPhoning = true;
  184. $('.question').fadeIn();
  185. }
  186. }
  187. function ShowQuestion() {
  188. if (_currentPhoneLogId) {
  189. if (!_currentPhoneQuestionText) {
  190. $.iwbAjax4({
  191. url: abp.appUrl + "query/GetQuestionByLog?no=" + _currentPhoneLogId,
  192. success: function(res) {
  193. _voiceText = _currentPhoneQuestionText = res.content;
  194. $('#modal .question-text').html(_currentPhoneQuestionText);
  195. Show();
  196. }
  197. });
  198. } else {
  199. Show();
  200. }
  201. }
  202. function Show() {
  203. if (_voiceText) {
  204. //voice(_voiceText);
  205. playVoice(_voiceText);
  206. _voiceText = undefined;
  207. }
  208. OpenModal({
  209. url: abp.appUrl + 'eval/OperationPhone',
  210. data: { id: _currentPhoneLogId, campNo: '@(campNo)', groupNo: '@(group.Id)' },
  211. success: function() {
  212. $('.question').fadeOut();
  213. _currentPhoneLogId = undefined;
  214. _currentPhoneQuestionText = undefined;
  215. isPhoning = false;
  216. if (_phoneLogIds.length) {
  217. setTimeout(PhoneQuestion, 1500);
  218. }
  219. }
  220. });
  221. }
  222. }
  223. function voice(text) {
  224. if (!text) {
  225. return;
  226. }
  227. try {
  228. // 语音播报
  229. var utterThis = new window.SpeechSynthesisUtterance();
  230. utterThis.text = text; //播放内容按
  231. window.speechSynthesis.speak(utterThis);
  232. } catch (e) {
  233. console.error("语音播报出错:", e);
  234. }
  235. }
  236. function playVoice(callText) {
  237. //$.iwbAjax5({
  238. // url: abp.appUrl+`Query/voice?txt=${callText}&rate=0`,
  239. // success: function(res) {
  240. // var audioPlay = document.getElementById("voiceAudio");
  241. // audioPlay.src = res;
  242. // audioPlay.play();
  243. // }
  244. //});
  245. if (!callText) {
  246. return;
  247. }
  248. var audioPlay = document.getElementById("voiceAudio");
  249. audioPlay.src = "/Exercise/voice?txt=" + callText;
  250. audioPlay.play();
  251. }
  252. </script>
  253. <script>
  254. abp.signalr.connect(['@(id)', '@(campNo)']);
  255. iwbHub.client.getReloadAll = function(msg) {
  256. console.log('getReloadAll: ', msg);
  257. if (msg) {
  258. try {
  259. var data = JSON.parse(msg);
  260. if (data) {
  261. if (data.no == '@(id)' || data.no == '@(campNo)') {
  262. window.location.reload();
  263. }
  264. }
  265. } catch (e) {
  266. console.log('getReloadAll: ', e);
  267. }
  268. }
  269. };
  270. iwbHub.client.getReloadLeader = function(msg) {
  271. console.log('getReloadLeader: ', msg);
  272. if (msg) {
  273. try {
  274. var data = JSON.parse(msg);
  275. if (data) {
  276. if (data.no == '@(id)' || data.no == '@(campNo)') {
  277. window.location.reload();
  278. }
  279. }
  280. } catch (e) {
  281. console.log('getReloadLeader: ', e);
  282. }
  283. }
  284. };
  285. iwbHub.client.getOperationLog = function(msg) {
  286. console.log('getOperationLog: ', msg);
  287. if (msg) {
  288. try {
  289. var data = JSON.parse(msg);
  290. if (data) {
  291. if (data.no == '@(id)') {
  292. $('#log-box .empty').remove();
  293. var str = FormatLog(data);
  294. $('#log-box').prepend(str);
  295. }
  296. }
  297. } catch (e) {
  298. console.log('getOperationLog: ', e);
  299. }
  300. }
  301. };
  302. iwbHub.client.getPhoneQuestion = function(msg) {
  303. console.log('getPhoneQuestion: ', msg);
  304. if (msg) {
  305. try {
  306. var data = JSON.parse(msg);
  307. if (!data) {
  308. return;
  309. }
  310. if (data.no == '@(id)') {
  311. if (_phoneLogIds.indexOf(v) < 0) {
  312. _phoneLogIds.push(data.id);
  313. }
  314. PhoneQuestion();
  315. };
  316. } catch (e) {
  317. console.log('getPhoneQuestion: ', e);
  318. }
  319. }
  320. };
  321. </script>
  322. }