Leader.cshtml 13 KB

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