Headquarter.cshtml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. @using WeApp.TrainingCampGroup.Dto
  2. @{
  3. Layout = "~/Views/Shared/Layout/_Layout.Stu.cshtml";
  4. CampGroupDto group = ViewBag.Group;
  5. bool isLeader = ViewBag.IsLeader, hasBuilded = ViewBag.HasBuilded;
  6. string id = group.Id,
  7. groupName = group.Name,
  8. campNo = group.CampNo;
  9. ViewBag.Title = (isLeader ? "指挥长组建指挥部" : "学员屏指挥部") + "(" + groupName + ")";
  10. var name = hasBuilded ? groupName + "指挥部——" + (isLeader ? "指挥长" : "组员") : isLeader ? "指挥长组建指挥部" : "指挥部组建中...";
  11. var title = hasBuilded ? "指挥部" : "创建指挥部";
  12. var stu = isLeader ? "" : "stu";
  13. }
  14. @section css{
  15. <link href="~/Content/Css/ExerciseV2/stu-zhb.min.css?v=1.1" rel="stylesheet" />
  16. }
  17. @Html.Partial("Layout/V2/_Bg",false)
  18. <div class="box no-select">
  19. <div id="bg_title">
  20. <span class="title">@(title)</span>
  21. </div>
  22. <div class="box-body">
  23. <div class="box-header">
  24. <span class="title">@name</span>
  25. </div>
  26. <div class="body" style="margin-top: 5px">
  27. @if (!hasBuilded)
  28. {
  29. <div class="body-card select">
  30. <div class="select-box">
  31. </div>
  32. @if (isLeader)
  33. {
  34. <div class="add-role" data-id="self" onclick="GroupToggle(this)">
  35. <div class="icon">
  36. <img src="/Content/Image/ExerciseV2/zhb/zh_icon-add-role.svg" alt="" />
  37. </div>
  38. <div class="text">自定义角色</div>
  39. </div>
  40. }
  41. </div>
  42. }
  43. <div class="body-card role">
  44. <div class="content-box">
  45. @if (!hasBuilded && isLeader)
  46. {
  47. <div class="role-content self" id="c_self">
  48. <div class="role-box">
  49. <div class="role-item add" id="add-role" onclick="$('#add-role').hide();$('#add-box').fadeIn(800).css('display', 'flex');$('#self-role-text').focus();">
  50. <div class="icon">
  51. <img src="~/Content/Image/ExerciseV2/zhb/zh_icon-add-role-2.svg" />
  52. </div>
  53. <div class="text">点击添加角色</div>
  54. </div>
  55. </div>
  56. <div class="add-box" id="add-box">
  57. <input type="text" id="self-role-text" value="" pattern="请输入新增角色名称" />
  58. <div class="btn-box">
  59. <button type="button" class="btn btn-small cancel" onclick="$('#add-box').fadeOut(500);$('#add-role').fadeIn(800).css('display', 'flex');">取消</button>
  60. <button type="button" class="btn btn-small submit" onclick="CreateSelfRole()">添加</button>
  61. </div>
  62. </div>
  63. </div>
  64. }
  65. else
  66. {
  67. <div class="role-content" style="display: none"></div>
  68. }
  69. </div>
  70. </div>
  71. @if (!hasBuilded && isLeader)
  72. {
  73. <div class="body-card">
  74. <div class="btn" onclick="CreateGroupRole()">创建指挥部</div>
  75. </div>
  76. <div style="display: none">
  77. <img src="/Content/Image/ExerciseV2/zhb/zh_icon-checkbox.svg" style="opacity: 0" />
  78. <img src="/Content/Image/ExerciseV2/zhb/zh_icon-checkbox-selected.svg" style="opacity: 0" />
  79. </div>
  80. }
  81. </div>
  82. </div>
  83. <div style="position: absolute; left: 0; bottom: 0; color: #ddd; opacity: 0.5;">@(groupName)</div>
  84. </div>
  85. @section scripts
  86. {
  87. <script>
  88. $(function () {
  89. resizeHeight_head();
  90. window.addEventListener('resize', resizeHeight_head);
  91. @if (hasBuilded)
  92. {
  93. <text>
  94. GetGroupRoles();
  95. </text>
  96. }
  97. else
  98. {
  99. <text>
  100. GetCampRoleGroups();
  101. </text>
  102. }
  103. $('#self-role-text').keydown(function(e) {
  104. var theEvent = window.event || e;
  105. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  106. if (code == 13) {
  107. CreateSelfRole();
  108. }
  109. });
  110. });
  111. function resizeHeight_head() {
  112. resizeHeight((h, wh) => {
  113. var height = 355;
  114. @if (hasBuilded)
  115. {
  116. <text>
  117. height = 175;
  118. </text>
  119. }
  120. else if (!isLeader)
  121. {
  122. <text>
  123. height = 305;
  124. </text>
  125. }
  126. $(".content-box").height(wh - h - height)
  127. })
  128. }
  129. var selectStr = '<div class="check-box-icon"></div>已选择<span>(点击取消)</span>';
  130. var noSelectStr = '<div class="check-box-icon"></div>未选择<span>(点击选择)</span>';
  131. var roleInfo = '<div class="role-item {1}" data-name="{0}"><div class="icon"><img src="/Content/Image/ExerciseV2/zhb/zh_icon-user.svg" alt="" /></div><div class="text">{0}</div>{2}</div> ';
  132. function GetGroupRoles() {
  133. $.iwbAjax4({
  134. url: abp.appUrl + "Query/GetGroupRoleInfos?no=@(id)",
  135. success: function(res) {
  136. FormatterBuildGroupRole(res);
  137. OverlayScrollbar($('.content-box'));
  138. }
  139. });
  140. }
  141. function GetCampRoleGroups() {
  142. $.iwbAjax4({
  143. url: abp.appUrl + "Query/GetCampRoleGroupInfos?no=@(campNo)",
  144. success: function(res) {
  145. FormatterGroupRole(res);
  146. OverlayScrollbar($('.content-box'));
  147. }
  148. });
  149. }
  150. function FormatterBuildGroupRole(data) {
  151. if (data && data.length > 0) {
  152. var str = '<div class="role-content active"><div class="role-box">';
  153. data.forEach(function(r) {
  154. str += roleInfo.format(r, "", "");
  155. });
  156. str += '</div></div>';
  157. $('.content-box').html(str);
  158. }
  159. }
  160. function FormatterGroupRole(data) {
  161. var str1 = "", str2 = "";
  162. if (data && data.length > 0) {
  163. data.forEach(function(v) {
  164. str1 += FormatterGroup(v);
  165. str2 += FormatterRole(v);
  166. });
  167. }
  168. if (str1) {
  169. $('.role .content-box .role-content').before(str2);
  170. $('.select-box').html(str1);
  171. $('.select-box .select-item:first-child').trigger("click");
  172. }
  173. }
  174. function FormatterGroup(data) {
  175. var str = '';
  176. if (data) {
  177. str += '<div class="select-item" id="t_{0}" data-id="{0}" onclick="GroupToggle(this)">'.format(data.id);
  178. str += '<div class="check-box-icon @(stu)" data-id="{0}" onclick="GroupCheckToggle(this)"></div>'.format(data.id);
  179. str += '<div class="icon"><img data-id="{0}" src="/Content/Image/ExerciseV2/zhb/zh_icon-{0}.svg"/></div >'
  180. .format(data.id);
  181. str += '<span class="text">{0}</span>'.format(data.roleGroupName);
  182. str += '</div>';
  183. }
  184. return str;
  185. }
  186. function FormatterRole(data) {
  187. var str = '';
  188. if (data) {
  189. str += '<div class="role-content" id="c_{0}">'.format(data.id);
  190. str += '<div class="role-select @(stu)" data-id="{1}" onclick="GroupCheckToggle(this)">{0}</div>'.format(noSelectStr,
  191. data.id);
  192. str += '<div class="role-box">';
  193. if (data.roleNames) {
  194. var arr = data.roleNames.split(',');
  195. arr.forEach(function(v) {
  196. str += roleInfo.format(v, "", "");
  197. });
  198. }
  199. str += '</div>';
  200. str += '</div>';
  201. }
  202. return str;
  203. }
  204. function GroupToggle(that) {
  205. var e = window.event;
  206. e.stopPropagation();
  207. e.preventDefault();
  208. var $that = $(that);
  209. var id = $that.data('id');
  210. $('.role-content').removeClass('active');
  211. $('#c_' + id).addClass('active');
  212. $('.select-box .select-item').removeClass('active');
  213. $that.addClass('active');
  214. }
  215. function GroupCheckToggle(that) {
  216. var e = window.event;
  217. e.stopPropagation();
  218. e.preventDefault();
  219. var $that = $(that);
  220. var id = $that.data('id');
  221. if ($('#t_' + id).hasClass('check')) {
  222. $('#t_' + id).removeClass('check');
  223. $('#c_' + id).find('.role-select').removeClass('check').html(noSelectStr);
  224. $('#c_' + id).find('.role-item').removeClass('check');
  225. } else {
  226. $('#t_' + id).addClass('check');
  227. $('#c_' + id).find('.role-select').addClass('check').html(selectStr);
  228. $('#c_' + id).find('.role-item').addClass('check');
  229. }
  230. }
  231. function CreateSelfRole() {
  232. var name = $('#self-role-text').val();
  233. if (name) {
  234. var str = roleInfo.format(name,
  235. " check",
  236. '<span class="close" onclick="$(this).parent().remove()">&times;</span>');
  237. $('#add-role').before(str);
  238. $('#self-role-text').val('');
  239. }
  240. $('#add-box').hide();
  241. $('#add-role').fadeIn(800).css('display', 'flex');
  242. }
  243. function CreateGroupRole() {
  244. var groupNo = "@(id)";
  245. abp.message.confirm("您确认提交吗?提交后不可再更改。",
  246. "创建指挥部",
  247. function (isConfirmed) {
  248. if (isConfirmed) {
  249. var roleGroupNos = [], selfRoleNames = [];
  250. $(".select-item.check").each(function (i, v) {
  251. var no = $(v).data("id");
  252. if (no != 'self') {
  253. roleGroupNos.push(no);
  254. }
  255. });
  256. $("#c_self .check").each(function (i, v) {
  257. selfRoleNames.push($(v).data("name"));
  258. });
  259. console.log(roleGroupNos, selfRoleNames);
  260. if (roleGroupNos.length <= 0 && selfRoleNames.length <= 0) {
  261. abp.message.warn("您还未选择角色。");
  262. return;
  263. }
  264. $.iwbAjax1({
  265. url: abp.appUrl + "/Eval/CreateGroupRole",
  266. isAlert: false,
  267. isValidate: false,
  268. data: { GroupNo: groupNo, RoleGroupNos: roleGroupNos, SelfRoleNames: selfRoleNames },
  269. success: function () {
  270. //window.iwbHub.server.sendPageState(JSON.stringify({ groupNo: groupNo, cmd: "reload" }));
  271. //window.iwbHub.server.sendPageState(JSON.stringify({ groupNo: groupNo, cmd: "reload-public" }));
  272. //window.iwbHub.server.sendRefreshRole(groupNo);
  273. window.location.reload();
  274. abp.message.success("角色预案创建成功");
  275. }
  276. });
  277. }
  278. });
  279. }
  280. </script>
  281. <script id="hub">
  282. abp.signalr.connect(['@(id)', '@(campNo)']);
  283. iwbHub.client.getReloadAll = function(msg) {
  284. console.log('getReloadAll: ', msg);
  285. if (msg) {
  286. try {
  287. var data = JSON.parse(msg);
  288. if (data) {
  289. if (data.no == '@(id)' || data.no == '@(campNo)') {
  290. window.location.reload();
  291. }
  292. }
  293. } catch (e) {
  294. console.log('getReloadAll: ', e);
  295. }
  296. }
  297. };
  298. @if (isLeader)
  299. {
  300. <text>
  301. iwbHub.client.getReloadLeader = function(msg) {
  302. console.log('getReloadLeader: ', msg);
  303. if (msg) {
  304. try {
  305. var data = JSON.parse(msg);
  306. if (data) {
  307. if (data.no == '@(id)' || data.no == '@(campNo)') {
  308. window.location.reload();
  309. }
  310. }
  311. } catch (e) {
  312. console.log('getReloadLeader: ', e);
  313. }
  314. }
  315. };
  316. </text>
  317. }
  318. else
  319. {
  320. <text>
  321. iwbHub.client.getReloadStu = function(msg) {
  322. console.log('getReloadStu: ', msg);
  323. if (msg) {
  324. try {
  325. var data = JSON.parse(msg);
  326. if (data) {
  327. if (data.no == '@(id)' || data.no == '@(campNo)') {
  328. window.location.reload();
  329. }
  330. }
  331. } catch (e) {
  332. console.log('getReloadStu: ', e);
  333. }
  334. }
  335. };
  336. </text>
  337. }
  338. </script>
  339. }