Student.cshtml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/Exercise/stu-leader.min.css" rel="stylesheet" />
  12. <style>
  13. </style>
  14. }
  15. <div class="body">
  16. <div class="title-box box">
  17. <div class="left-box">
  18. <div class="line"></div>
  19. <div class="title">@(groupName)指挥部 —— 组员</div>
  20. </div>
  21. </div>
  22. <div class="handle-box box">
  23. <div class="form-box">
  24. <div class="role">
  25. <select class="form-control" id="role-select" name="role" style="width: 100%" autocomplete="off" placeholder="请选择角色"></select>
  26. </div>
  27. <textarea class="form-control txt" rows="6" name="message" placeholder="请输入指令内容"></textarea>
  28. <button type="button" class="btn btn-submit" onclick="RoleHandle(this)">提交</button>
  29. <div class="help-box">
  30. <select class="form-control" name="help" style="width: 100%" autocomplete="off" data-placeholder="提示信息">
  31. <option value="">请选择提示信息</option>
  32. </select>
  33. </div>
  34. </div>
  35. <div class="form-box">
  36. <div class="role">
  37. <input class="form-control" id="role-name" name="role" style="width: 100%" autocomplete="off" placeholder="请填写自定义角色" />
  38. </div>
  39. <textarea class="form-control txt" rows="6" name="message" placeholder="请输入指令内容"></textarea>
  40. <button type="button" class="btn btn-submit" onclick="RoleHandle(this)">提交</button>
  41. <div class="help-box">
  42. <select class="form-control" name="help" style="width: 100%" autocomplete="off" data-placeholder="提示信息">
  43. <option value="">请选择提示信息</option>
  44. </select>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. @section scripts
  50. {
  51. <script>
  52. $(function() {
  53. $.iwbAjax4({
  54. url: abp.appUrl + 'Query/GetGroupRoleSelectStr?no=@(id)',
  55. success: function(res) {
  56. if (res) {
  57. $('#role-select').html(res).select2();
  58. }
  59. }
  60. });
  61. $.iwbAjax4({
  62. url: abp.appUrl + 'Query/GetStuHelpContentSelectStrByCamp?no=@(campNo)',
  63. success: function(res) {
  64. if (res) {
  65. $('select[name="help"]').html(`<option value="">请选择提示信息</option>`+res).select2();
  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('.form-box').find('.txt');
  82. $txt.val($txt.val() + " " + $(this).find('option:selected').text());
  83. $(this).val('');
  84. }
  85. });
  86. });
  87. function RoleHandle(that) {
  88. var $that = $(that).closest('.form-box'),
  89. role = $that.find('.form-control[name="role"]').val(),
  90. word = $that.find('textarea').val();
  91. if (!role) {
  92. abp.message.warn('请选择(或填写)角色后再提交!');
  93. return;
  94. }
  95. if (!word) {
  96. abp.message.warn('请输入指令后再提交!');
  97. return;
  98. }
  99. $.iwbAjax4({
  100. url: abp.appUrl + 'Eval/SaveOperationScene',
  101. data: { groupNo: '@(id)', behaviorRole: role, behaviorWord: word},
  102. success: function() {
  103. $that.find('textarea').val('').focus();
  104. }
  105. });
  106. @*window.iwbHub.server.sendOperationLog('@(id)',role,text).done(function() {
  107. abp.log.debug('OperationLog[' + id + ']:', role, word);
  108. });*@
  109. }
  110. </script>
  111. <script id="hub">
  112. abp.signalr.connect(['@(id)','@(campNo)']);
  113. iwbHub.client.getReloadAll = function (msg) {
  114. console.log('getReloadAll: ', msg);
  115. if (msg) {
  116. try {
  117. var data = JSON.parse(msg);
  118. if (data) {
  119. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  120. window.location.reload();
  121. }
  122. }
  123. } catch (e) {
  124. console.log('getReloadAll: ', e);
  125. }
  126. }
  127. };
  128. iwbHub.client.getReloadStu = function (msg) {
  129. console.log('getReloadStu: ', msg);
  130. if (msg) {
  131. try {
  132. var data = JSON.parse(msg);
  133. if (data) {
  134. if (data.no == '@(id)'|| data.no == '@(campNo)') {
  135. window.location.reload();
  136. }
  137. }
  138. } catch (e) {
  139. console.log('getReloadStu: ', e);
  140. }
  141. }
  142. };
  143. </script>
  144. }