Headquarter.cshtml 13 KB

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