user_permission_modal.ejs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <% include ./user_add_modal.ejs %>
  2. <section class="drawer" id="edit-user2" data-drawer-target="">
  3. <div class="drawer__overlay" tabindex="-1"></div>
  4. <form class="drawer__wrapper" method="post" action="/setting/user/permission?_csrf_j=<%= ctx.csrf %>">
  5. <div class="modal-header">
  6. <h5 class="modal-title">
  7. 编辑权限
  8. </h5>
  9. <!-- <button type="button" class="close" data-drawer-close="" aria-label="Close Drawer">-->
  10. <!-- <span aria-hidden="true">&times;</span>-->
  11. <!-- </button>-->
  12. <!-- <button class="drawer__close" data-drawer-close="" aria-label="Close Drawer"></button>-->
  13. </div>
  14. <div class="drawer__content">
  15. <% for (const pm in permission) { %>
  16. <div class="form-group permission-div">
  17. <h6 class="modal-title permission-title"><%= permission[pm].title %></h6>
  18. <div>
  19. <% for (const ip of permission[pm].children) { %>
  20. <% if (ip.show === undefined && ip.show !== false) { %>
  21. <div class="form-check form-check-inline">
  22. <input class="form-check-input" type="<%= permission[pm].type %>" id="<%= pm %>_<%= ip.value %>" name="<%= pm %><% if (permission[pm].type === 'checkbox') { %>[]<% } %>" value="<%= ip.value %>">
  23. <label class="form-check-label" for="<%= pm %>_<%= ip.value %>"><%= ip.title %></label>
  24. <% if (ip.hint && ip.hintIcon) { %>
  25. <a href="" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<%- ip.hint%>"><i class="fa <%- ip.hintIcon%>"></i></a>
  26. <% } %>
  27. </div>
  28. <% } %>
  29. <% } %>
  30. </div>
  31. <% if (permission[pm].tips) { %>
  32. <!--需要勾选 创建标段 ,协作办公才能勾选-->
  33. <div class="alert alert-secondary" style="margin: .5rem 0 0 0;">
  34. <p class="mb-0"><%- permission[pm].tips %></p>
  35. </div>
  36. <% } %>
  37. </div>
  38. <% } %>
  39. <div class="form-group permission-div">
  40. <h6 class="modal-title permission-title">微信通知<a href="#wx-setting" data-toggle="modal" data-target="#wx-setting" class="pull-right"><i style="font-size: 16px" class="fa fa-cog"></i></a></h6>
  41. <div class="form-check form-check-inline">
  42. <span style="margin:0 .5rem 0 1rem; font-weight: bold;">重新发送</span>
  43. <div class="custom-control custom-switch">
  44. <input type="checkbox" class="custom-control-input" id="again_all" name="again_all" value="1">
  45. <label class="custom-control-label" for="again_all"></label>
  46. </div>
  47. </div>
  48. <div style="margin: .5rem 0 0 2rem">
  49. <div class="row">
  50. <% for (const sp in noticeAgainConst.sp) { %>
  51. <div class="col-2 form-check form-check-inline">
  52. <input class="form-check-input" type="checkbox" id="again_<%- sp %>" name="again_<%- sp %>" value="1">
  53. <label class="form-check-label" for="again_<%- sp %>"><%- noticeAgainConst.sp[sp].name %></label>
  54. </div>
  55. <% } %>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="modal-footer">
  61. <input type="hidden" name="id" value="">
  62. <button type="button" class="btn btn-secondary btn-sm" data-drawer-close="">关闭</button>
  63. <button type="submit" class="btn btn-primary btn-sm">提交修改</button>
  64. </div>
  65. </form>
  66. </section>
  67. <div class="modal fade" data-backdrop="static" id="wx-setting">
  68. <div class="modal-dialog" role="document">
  69. <div class="modal-content">
  70. <div class="modal-header">
  71. <h5 class="modal-title">微信通知设置(所有人共用)</h5>
  72. </div>
  73. <div class="modal-body">
  74. <div style="margin: 0 0 .5rem .5rem">消息重新发送间隔</div>
  75. <div style="margin-left: 1rem;margin-bottom: .5rem">
  76. <div class="form-check form-check-inline">
  77. <input class="form-check-input" type="radio" id="wx_send_type_1" name="wx_send_type" value="fixed" <% if (noticeSet.mode === 'fixed') { %>checked<% } %>>
  78. <label class="form-check-label" for="wx_send_type_1">固定间隔</label>
  79. </div>
  80. <div class="form-check form-check-inline">
  81. <input class="form-check-input" type="radio" id="wx_send_type_2" name="wx_send_type" value="activity" <% if (noticeSet.mode === 'activity') { %>checked<% } %>>
  82. <label class="form-check-label" for="wx_send_type_2">活动间隔</label>
  83. </div>
  84. </div>
  85. <div style="margin-left: 1.5rem;margin-top: .25rem; <% if (noticeSet.mode === 'activity') { %>display: none;<% } %>" id="wx_type_1">
  86. <div class="w-100 d-inline-flex"><label class="right-duiqi">每间隔:</label>
  87. <input id="fixed_time" style="width: 50px;" class="time-input form-control form-control-sm" type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="72" value="<%- noticeSet.fixed %>">
  88. <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
  89. <% for (let i = 1; i <= 72;i++) { %>
  90. <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
  91. <% } %>
  92. </div><label style="line-height: 25px;">&nbsp; 小时</label>
  93. </div>
  94. </div>
  95. <div style="margin-left: 1.5rem;margin-top: .25rem; <% if (noticeSet.mode === 'fixed') { %>display: none;<% } %>" id="wx_type_2">
  96. <div class="w-100 d-inline-flex"><label class="right-duiqi">第1次间隔:</label>
  97. <input id="activity_first_time" style="width: 50px;" class="time-input form-control form-control-sm" type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="72" value="<%- noticeSet.activity.first %>">
  98. <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
  99. <% for (let i = 1; i <= 72;i++) { %>
  100. <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
  101. <% } %>
  102. </div><label style="line-height: 25px;">&nbsp; 小时</label>
  103. </div>
  104. <div class="w-100 d-inline-flex"><label class="right-duiqi">第2次间隔:</label>
  105. <input id="activity_second_time" style="width: 50px;" class="time-input form-control form-control-sm" type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="72" value="<%- noticeSet.activity.second %>">
  106. <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
  107. <% for (let i = 1; i <= 72;i++) { %>
  108. <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
  109. <% } %>
  110. </div><label style="line-height: 25px;">&nbsp; 小时</label>
  111. </div>
  112. <div class="w-100 d-inline-flex"><label class="right-duiqi">往后间隔:</label>
  113. <input id="activity_later_time" style="width: 50px;" class="time-input form-control form-control-sm" type="number" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" min="0" step="1" max="72" value="<%- noticeSet.activity.later %>">
  114. <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
  115. <% for (let i = 1; i <= 72;i++) { %>
  116. <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
  117. <% } %>
  118. </div><label style="line-height: 25px;">&nbsp; 小时</label>
  119. </div>
  120. </div>
  121. <div style="margin: .5rem 0 .5rem .5rem">消息屏蔽时段</div>
  122. <div style="margin-left: 1rem;margin-bottom: .5rem">
  123. <div class="input-group input-group-sm mb-2">
  124. <div class="input-group-prepend">
  125. <span class="input-group-text">开始时间:</span>
  126. </div>
  127. <select class="form-control form-control-sm" id="shield_start_time" style="width: 90px!important;flex: none;">
  128. <option value="">不限制</option>
  129. <% for (let i = 0; i <= 23;i++) { %>
  130. <option value="<%- i %>" <% if (noticeSet.shield_times.start === i) { %>selected<% } %>><%- (i < 10 ? '0' + i : i) + ':00' %></option>
  131. <% } %>
  132. </select>
  133. <span class="text-danger mx-2"></span>
  134. </div>
  135. <div class="input-group input-group-sm mb-2">
  136. <div class="input-group-prepend">
  137. <span class="input-group-text">截止时间:</span>
  138. </div>
  139. <select class="form-control form-control-sm" id="shield_end_time" style="width: 90px!important;flex: none;">
  140. <option value="">不限制</option>
  141. <% for (let i = 0; i <= 23;i++) { %>
  142. <option value="<%- i %>" <% if (noticeSet.shield_times.end === i) { %>selected<% } %>><%- (i < 10 ? '0' + i : i) + ':00' %></option>
  143. <% } %>
  144. </select>
  145. <span class="text-danger mx-2"></span>
  146. </div>
  147. </div>
  148. <!-- <div style="margin-left: 1rem;margin-bottom: .5rem">开始时间:<input style="width: 130px" type="time" placeholder="00:00~07:00" /></div>-->
  149. <!-- <div style="margin-left: 1rem;margin-bottom: .5rem">截止时间:<input style="width: 130px" type="time" placeholder="00:00~07:00" /></div>-->
  150. </div>
  151. <div class="modal-footer">
  152. <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
  153. <button type="button" class="btn btn-primary btn-sm" id="set_wx_button">确定</button>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <script>
  159. $(function (){
  160. $('input[name="wx_send_type"]').on('click', function () {
  161. const type = $(this).val();
  162. if (type === 'fixed') {
  163. $('#wx_type_1').show();
  164. $('#wx_type_2').hide();
  165. } else {
  166. $('#wx_type_1').hide();
  167. $('#wx_type_2').show();
  168. }
  169. });
  170. $('.change_time').on('click', function () {
  171. $(this).parents('.dropdown-menu').siblings('input').val(parseInt($(this).data('value')));
  172. $(this).parents('.dropdown-menu').hide();
  173. });
  174. $('.time-input').on('click', function () {
  175. $(this).siblings('.dropdown-menu').show();
  176. });
  177. // 回车提交
  178. $('.time-input').on('keypress', function () {
  179. if(window.event.keyCode === 13) {
  180. $(this).blur();
  181. }
  182. });
  183. $('.time-input').blur(function () {
  184. const _self = $(this);
  185. setTimeout(function () {
  186. _self.siblings('.dropdown-menu').hide();
  187. let rate = parseFloat(_self.val());
  188. if (_.isNaN(rate)) {
  189. toastr.error('请输入1-72之前的整数值');
  190. _self.val(72);
  191. return;
  192. }
  193. // 如果是小数,自动转成整数
  194. if (rate.toString().indexOf('.') !== -1) {
  195. toastr.warning('请输入1-72之前的整数值');
  196. }
  197. rate = parseInt(rate);
  198. if(rate < 1 || rate > 72) {
  199. toastr.error('请输入1-72之前的整数值');
  200. _self.val(72);
  201. return;
  202. }
  203. _self.val(rate);
  204. }, 500);
  205. });
  206. $('#set_wx_button').click(function () {
  207. let flag = false;
  208. // 判断屏蔽时段是否合理
  209. const start_time = $('#shield_start_time').val() !== '' ? parseInt($('#shield_start_time').val()) : null;
  210. const end_time = $('#shield_end_time').val() !== '' ? parseInt($('#shield_end_time').val()) : null;
  211. if ((start_time === null && end_time !== null) || (start_time !== null && end_time === null)) {
  212. toastr.error('屏蔽时段必须配置开始和截止时间,要么都为不限制');
  213. flag = true;
  214. } else if (start_time !== null && end_time !== null && start_time === end_time) {
  215. toastr.error('屏蔽时间段开始和截止时间不能相同');
  216. flag = true;
  217. }
  218. if (flag) {
  219. return false;
  220. }
  221. const pData = {
  222. mode: $('#wx-setting input[name="wx_send_type"]:checked').val(),
  223. fixed: parseInt($('#fixed_time').val()),
  224. activity: {
  225. first: parseInt($('#activity_first_time').val()),
  226. second: parseInt($('#activity_second_time').val()),
  227. later: parseInt($('#activity_later_time').val()),
  228. },
  229. shield_times: {
  230. start: start_time,
  231. end: end_time,
  232. }
  233. };
  234. console.log(pData);
  235. postData('/setting/update/projectset', { field: 'notice_setting', pData }, function (result) {
  236. toastr.success('设置成功');
  237. $('#wx-setting').modal('hide');
  238. });
  239. });
  240. });
  241. </script>