Student.cshtml 6.1 KB

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