Leader.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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-box').html('<div class="btn btn-small">已下达</div>');
  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 h = 50 + (Math.floor(data.word.length / 60)+1) * 21,
  155. msg = data.word ? data.word : "",
  156. state = data.logState == '@(LogStateDefinition.New)' ? '' : 'send',
  157. btn = data.logState == '@(LogStateDefinition.New)' ? '<div class="btn btn-small" onclick="RoleHandle(this)">下达指令</div>' : '<div class="btn btn-small">已下达</div>';
  158. console.log(h)
  159. str = '<div class="log-box {0}" data-id="{1}" style="min-height:{5}px"><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,h);
  160. }
  161. return str;
  162. }
  163. function GetQuestionLogs() {
  164. $.iwbAjax4({
  165. url: abp.appUrl + "query/GetQuestionLogs?no=@(id)",
  166. success: function(res) {
  167. if (res && res.length) {
  168. res.forEach(v => {
  169. if (_phoneLogIds.indexOf(v) < 0) {
  170. _phoneLogIds.push(v);
  171. }
  172. });
  173. PhoneQuestion();
  174. }
  175. }
  176. });
  177. }
  178. var _phoneLogIds = [], _currentPhoneLogId, _currentPhoneQuestionText, _voiceText, isPhoning = false;
  179. function PhoneQuestion() {
  180. if (isPhoning) {
  181. return;
  182. }
  183. _currentPhoneLogId = _phoneLogIds.shift();
  184. if (_currentPhoneLogId) {
  185. isPhoning = true;
  186. $('.question').fadeIn();
  187. }
  188. }
  189. function ShowQuestion() {
  190. if (_currentPhoneLogId) {
  191. if (!_currentPhoneQuestionText) {
  192. $.iwbAjax4({
  193. url: abp.appUrl + "query/GetQuestionByLog?no=" + _currentPhoneLogId,
  194. success: function(res) {
  195. _voiceText = _currentPhoneQuestionText = res.content;
  196. $('#modal .question-text').html(_currentPhoneQuestionText);
  197. Show();
  198. }
  199. });
  200. } else {
  201. Show();
  202. }
  203. }
  204. function Show() {
  205. if (_voiceText) {
  206. //voice(_voiceText);
  207. playVoice(_voiceText);
  208. _voiceText = undefined;
  209. }
  210. OpenModal({
  211. url: abp.appUrl + 'eval/OperationPhone',
  212. data: { id: _currentPhoneLogId, campNo: '@(campNo)', groupNo: '@(group.Id)' },
  213. success: function() {
  214. $('.question').fadeOut();
  215. _currentPhoneLogId = undefined;
  216. _currentPhoneQuestionText = undefined;
  217. isPhoning = false;
  218. if (_phoneLogIds.length) {
  219. setTimeout(PhoneQuestion, 1500);
  220. }
  221. }
  222. });
  223. }
  224. }
  225. function voice(text) {
  226. if (!text) {
  227. return;
  228. }
  229. try {
  230. // 语音播报
  231. var utterThis = new window.SpeechSynthesisUtterance();
  232. utterThis.text = text; //播放内容按
  233. window.speechSynthesis.speak(utterThis);
  234. } catch (e) {
  235. console.error("语音播报出错:", e);
  236. }
  237. }
  238. function playVoice(callText) {
  239. //$.iwbAjax5({
  240. // url: abp.appUrl+`Query/voice?txt=${callText}&rate=0`,
  241. // success: function(res) {
  242. // var audioPlay = document.getElementById("voiceAudio");
  243. // audioPlay.src = res;
  244. // audioPlay.play();
  245. // }
  246. //});
  247. if (!callText) {
  248. return;
  249. }
  250. var audioPlay = document.getElementById("voiceAudio");
  251. audioPlay.src = "/Exercise/voice?txt=" + callText;
  252. audioPlay.play();
  253. }
  254. </script>
  255. <script>
  256. abp.signalr.connect(['@(id)', '@(campNo)']);
  257. iwbHub.client.getReloadAll = function(msg) {
  258. console.log('getReloadAll: ', msg);
  259. if (msg) {
  260. try {
  261. var data = JSON.parse(msg);
  262. if (data) {
  263. if (data.no == '@(id)' || data.no == '@(campNo)') {
  264. window.location.reload();
  265. }
  266. }
  267. } catch (e) {
  268. console.log('getReloadAll: ', e);
  269. }
  270. }
  271. };
  272. iwbHub.client.getReloadLeader = function(msg) {
  273. console.log('getReloadLeader: ', msg);
  274. if (msg) {
  275. try {
  276. var data = JSON.parse(msg);
  277. if (data) {
  278. if (data.no == '@(id)' || data.no == '@(campNo)') {
  279. window.location.reload();
  280. }
  281. }
  282. } catch (e) {
  283. console.log('getReloadLeader: ', e);
  284. }
  285. }
  286. };
  287. iwbHub.client.getOperationLog = function(msg) {
  288. console.log('getOperationLog: ', msg);
  289. if (msg) {
  290. try {
  291. var data = JSON.parse(msg);
  292. if (data) {
  293. if (data.no == '@(id)') {
  294. $('#log-box .empty').remove();
  295. var str = FormatLog(data);
  296. $('#log-box').prepend(str);
  297. }
  298. }
  299. } catch (e) {
  300. console.log('getOperationLog: ', e);
  301. }
  302. }
  303. };
  304. iwbHub.client.getPhoneQuestion = function(msg) {
  305. console.log('getPhoneQuestion: ', msg);
  306. if (msg) {
  307. try {
  308. var data = JSON.parse(msg);
  309. if (!data) {
  310. return;
  311. }
  312. if (data.no == '@(id)') {
  313. if (_phoneLogIds.indexOf(v) < 0) {
  314. _phoneLogIds.push(data.id);
  315. }
  316. PhoneQuestion();
  317. };
  318. } catch (e) {
  319. console.log('getPhoneQuestion: ', e);
  320. }
  321. }
  322. };
  323. </script>
  324. }