Student.cshtml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. @using WeApp.TrainingCampGroup.Dto
  2. @{
  3. Layout = "~/Views/Shared/Layout/_Layout.Stu.cshtml";
  4. CampGroupDto group = ViewBag.Group;
  5. ViewBag.Title = "学员屏(" + group.Name + ")";
  6. string id = group.Id,
  7. groupName = group.Name,
  8. campNo = group.CampNo;
  9. }
  10. @section css{
  11. <link href="~/Content/Css/ExerciseV2/stu-cmd.min.css" rel="stylesheet" />
  12. }
  13. @Html.Partial("Layout/V2/_Bg", false)
  14. <div class="box public no-select" style="">
  15. <div class="box-title">决策指令下达</div>
  16. <div class="box-body ">
  17. <div class="box-header">
  18. <span class="title">@(groupName)指挥部 —— 组员</span>
  19. </div>
  20. <div class="body">
  21. <div class="form">
  22. <div class="role-box">
  23. <div class="body-card select-box">
  24. <select class="form-control " id="role-select" name="role" style="width: 100%" autocomplete="off" placeholder="请选择角色" onchange="$(this).val()=='self'?$('.input-box').show():$('.input-box').hide()"></select>
  25. </div>
  26. <div class="body-card input-box ">
  27. <input class="form-control " id="role-input" name="self-role" style="width: 100%" autocomplete="off" placeholder="请输入自定义角色" />
  28. </div>
  29. </div>
  30. <div class="body-card cmd-box">
  31. <textarea class="form-control txt" rows="6" name="message" placeholder="请输入指令内容"></textarea>
  32. <button type="button" class="btn btn-submit" onclick="RoleHandle(this)">提交</button>
  33. <div class="help-box">
  34. <select class="form-control" name="help" style="width: 100%" autocomplete="off" data-placeholder="提示信息"></select>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div style="position: absolute; left: 0; bottom: 0; color: #ddd; opacity: 0.5;">@(groupName)</div>
  41. </div>
  42. @section scripts
  43. {
  44. <script>
  45. $(function () {
  46. resizeHeight_Stu();
  47. window.addEventListener('resize', resizeHeight_Stu);
  48. $.iwbAjax4({
  49. url: abp.appUrl + 'Query/GetGroupRoleSelectStr?no=@(id)',
  50. success: function (res) {
  51. var str = "<option value='self'>自定义角色</option>"
  52. if (res) {
  53. res += str
  54. $('#role-select').html(res).select2({ minimumResultsForSearch: -1 });
  55. } else {
  56. $('#role-select').html(str).select2({ minimumResultsForSearch: -1 });
  57. }
  58. }
  59. });
  60. $.iwbAjax4({
  61. url: abp.appUrl + 'Query/GetStuHelpContentSelectStrByCamp?no=@(campNo)',
  62. success: function(res) {
  63. if (res) {
  64. //$('.help-box').show();
  65. $('select[name="help"]').html(`<option value="">请选择提示信息</option>` + res).select2({ minimumResultsForSearch: -1 });
  66. } else {
  67. $('.help-box').hide();
  68. }
  69. }
  70. });
  71. $('.txt').keydown(function (e) {
  72. var theEvent = window.event || e;
  73. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  74. if (code == 13) {
  75. RoleHandle(this);
  76. }
  77. });
  78. $('select[name="help"]').on('change',
  79. function () {
  80. if ($(this).val()) {
  81. var $txt = $(this).closest('.cmd-box').find('.txt');
  82. var text = $txt.val() + " " + $(this).find('option:selected').text()
  83. if (text.length<500) {
  84. $txt.val(text);
  85. } else {
  86. abp.message.warn('指令输入不超过500字符。');
  87. }
  88. $(this).val('');
  89. }
  90. });
  91. });
  92. function resizeHeight_Stu() {
  93. var fs = 38;
  94. var h = $("#bg_header").height();
  95. var newFs = fs * h / 126;
  96. $(".box .box-title").height(h)
  97. .css("fontSize", newFs + "px");
  98. resizeHeight((h, wh) => {
  99. var height = 215;
  100. $(".txt").height(wh - h - height)
  101. })
  102. }
  103. function RoleHandle(that) {
  104. var $that = $(that).closest('.form'),
  105. role = $that.find('.form-control[name="role"]').val(),
  106. word = $that.find('textarea').val();
  107. if (!role) {
  108. abp.message.warn('请选择角色后再提交!');
  109. return;
  110. }
  111. if (role == 'self') {
  112. role = $that.find('.form-control[name="self-role"]').val()
  113. if (!role) {
  114. abp.message.warn('请填写角色后再提交!');
  115. return;
  116. }
  117. }
  118. if (!word) {
  119. abp.message.warn('请输入指令后再提交!');
  120. return;
  121. }
  122. if ( word.length >= 500) {
  123. abp.message.warn('指令输入不超过500字符。');
  124. return;
  125. }
  126. $.iwbAjax4({
  127. url: abp.appUrl + 'Eval/SaveOperationScene',
  128. data: { groupNo: '@(id)', behaviorRole: role, behaviorWord: word},
  129. success: function() {
  130. $that.find('textarea').val('').focus();
  131. }
  132. });
  133. }
  134. </script>
  135. <script id="hub">
  136. abp.signalr.connect(['@(id)','@(campNo)']);
  137. iwbHub.client.getReloadAll = function (msg) {
  138. console.log('getReloadAll: ', msg);
  139. if (msg) {
  140. try {
  141. var data = JSON.parse(msg);
  142. if (data) {
  143. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  144. window.location.reload();
  145. }
  146. }
  147. } catch (e) {
  148. console.log('getReloadAll: ', e);
  149. }
  150. }
  151. };
  152. iwbHub.client.getReloadStu = function (msg) {
  153. console.log('getReloadStu: ', msg);
  154. if (msg) {
  155. try {
  156. var data = JSON.parse(msg);
  157. if (data) {
  158. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  159. window.location.reload();
  160. }
  161. }
  162. } catch (e) {
  163. console.log('getReloadStu: ', e);
  164. }
  165. }
  166. };
  167. </script>
  168. }