Student.cshtml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. if (res) {
  52. res+="<option value='self'>自定义角色</option>"
  53. $('#role-select').html(res).select2();
  54. }
  55. }
  56. });
  57. $.iwbAjax4({
  58. url: abp.appUrl + 'Query/GetStuHelpContentSelectStrByCamp?no=@(campNo)',
  59. success: function(res) {
  60. if (res) {
  61. //$('.help-box').show();
  62. $('select[name="help"]').html(`<option value="">请选择提示信息</option>` + res);//.select2();
  63. } else {
  64. $('.help-box').hide();
  65. }
  66. }
  67. });
  68. $('.txt').keydown(function (e) {
  69. var theEvent = window.event || e;
  70. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  71. if (code == 13) {
  72. RoleHandle(this);
  73. }
  74. });
  75. $('select[name="help"]').on('change',
  76. function () {
  77. if ($(this).val()) {
  78. var $txt = $(this).closest('.form-box').find('.txt');
  79. $txt.val($txt.val() + " " + $(this).find('option:selected').text());
  80. $(this).val('');
  81. }
  82. });
  83. });
  84. function resizeHeight_Stu() {
  85. var fs = 38;
  86. var h = $("#bg_header").height();
  87. var newFs = fs * h / 126;
  88. $(".box .box-title").height(h)
  89. .css("fontSize", newFs + "px");
  90. resizeHeight((h, wh) => {
  91. var height = 215;
  92. $(".txt").height(wh - h - height)
  93. })
  94. }
  95. function RoleHandle(that) {
  96. var $that = $(that).closest('.form'),
  97. role = $that.find('.form-control[name="role"]').val(),
  98. word = $that.find('textarea').val();
  99. if (!role) {
  100. abp.message.warn('请选择角色后再提交!');
  101. return;
  102. }
  103. if (role == 'self') {
  104. role = $that.find('.form-control[name="self-role"]').val()
  105. if (!role) {
  106. abp.message.warn('请填写角色后再提交!');
  107. return;
  108. }
  109. }
  110. if (!word) {
  111. abp.message.warn('请输入指令后再提交!');
  112. return;
  113. }
  114. $.iwbAjax4({
  115. url: abp.appUrl + 'Eval/SaveOperationScene',
  116. data: { groupNo: '@(id)', behaviorRole: role, behaviorWord: word},
  117. success: function() {
  118. $that.find('textarea').val('').focus();
  119. }
  120. });
  121. }
  122. </script>
  123. <script id="hub">
  124. abp.signalr.connect(['@(id)','@(campNo)']);
  125. iwbHub.client.getReloadAll = function (msg) {
  126. console.log('getReloadAll: ', msg);
  127. if (msg) {
  128. try {
  129. var data = JSON.parse(msg);
  130. if (data) {
  131. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  132. window.location.reload();
  133. }
  134. }
  135. } catch (e) {
  136. console.log('getReloadAll: ', e);
  137. }
  138. }
  139. };
  140. iwbHub.client.getReloadStu = function (msg) {
  141. console.log('getReloadStu: ', msg);
  142. if (msg) {
  143. try {
  144. var data = JSON.parse(msg);
  145. if (data) {
  146. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  147. window.location.reload();
  148. }
  149. }
  150. } catch (e) {
  151. console.log('getReloadStu: ', e);
  152. }
  153. }
  154. };
  155. </script>
  156. }