123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <% include ./user_add_modal.ejs %>
- <section class="drawer" id="edit-user2" data-drawer-target="">
- <div class="drawer__overlay" tabindex="-1"></div>
- <form class="drawer__wrapper" method="post" action="/setting/user/permission?_csrf_j=<%= ctx.csrf %>">
- <div class="modal-header">
- <h5 class="modal-title">
- 编辑权限
- </h5>
- <!-- <button type="button" class="close" data-drawer-close="" aria-label="Close Drawer">-->
- <!-- <span aria-hidden="true">×</span>-->
- <!-- </button>-->
- <!-- <button class="drawer__close" data-drawer-close="" aria-label="Close Drawer"></button>-->
- </div>
- <div class="drawer__content">
- <% for (const pm in permission) { %>
- <div class="form-group permission-div">
- <h6 class="modal-title permission-title"><%= permission[pm].title %></h6>
- <div>
- <% for (const ip of permission[pm].children) { %>
- <% if (ip.show === undefined && ip.show !== false) { %>
- <div class="form-check form-check-inline">
- <input class="form-check-input" type="<%= permission[pm].type %>" id="<%= pm %>_<%= ip.value %>" name="<%= pm %><% if (permission[pm].type === 'checkbox') { %>[]<% } %>" value="<%= ip.value %>">
- <label class="form-check-label" for="<%= pm %>_<%= ip.value %>"><%= ip.title %></label>
- <% if (ip.hint && ip.hintIcon) { %>
- <a href="" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<%- ip.hint%>"><i class="fa <%- ip.hintIcon%>"></i></a>
- <% } %>
- </div>
- <% } %>
- <% } %>
- </div>
- <% if (permission[pm].tips) { %>
- <!--需要勾选 创建标段 ,协作办公才能勾选-->
- <div class="alert alert-secondary" style="margin: .5rem 0 0 0;">
- <p class="mb-0"><%- permission[pm].tips %></p>
- </div>
- <% } %>
- </div>
- <% } %>
- <div class="form-group permission-div">
- <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>
- <div class="form-check form-check-inline">
- <span style="margin:0 .5rem 0 1rem; font-weight: bold;">重新发送</span>
- <div class="custom-control custom-switch">
- <input type="checkbox" class="custom-control-input" id="again_all" name="again_all" value="1">
- <label class="custom-control-label" for="again_all"></label>
- </div>
- </div>
- <div style="margin: .5rem 0 0 2rem">
- <div class="row">
- <% for (const sp in noticeAgainConst.sp) { %>
- <div class="col-2 form-check form-check-inline">
- <input class="form-check-input" type="checkbox" id="again_<%- sp %>" name="again_<%- sp %>" value="1">
- <label class="form-check-label" for="again_<%- sp %>"><%- noticeAgainConst.sp[sp].name %></label>
- </div>
- <% } %>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <input type="hidden" name="id" value="">
- <button type="button" class="btn btn-secondary btn-sm" data-drawer-close="">关闭</button>
- <button type="submit" class="btn btn-primary btn-sm">提交修改</button>
- </div>
- </form>
- </section>
- <div class="modal fade" data-backdrop="static" id="wx-setting">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">微信通知设置(所有人共用)</h5>
- </div>
- <div class="modal-body">
- <div style="margin: 0 0 .5rem .5rem">消息重新发送间隔</div>
- <div style="margin-left: 1rem;margin-bottom: .5rem">
- <div class="form-check form-check-inline">
- <input class="form-check-input" type="radio" id="wx_send_type_1" name="wx_send_type" value="fixed" <% if (noticeSet.mode === 'fixed') { %>checked<% } %>>
- <label class="form-check-label" for="wx_send_type_1">固定间隔</label>
- </div>
- <div class="form-check form-check-inline">
- <input class="form-check-input" type="radio" id="wx_send_type_2" name="wx_send_type" value="activity" <% if (noticeSet.mode === 'activity') { %>checked<% } %>>
- <label class="form-check-label" for="wx_send_type_2">活动间隔</label>
- </div>
- </div>
- <div style="margin-left: 1.5rem;margin-top: .25rem; <% if (noticeSet.mode === 'activity') { %>display: none;<% } %>" id="wx_type_1">
- <div class="w-100 d-inline-flex"><label class="right-duiqi">每间隔:</label>
- <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 %>">
- <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
- <% for (let i = 1; i <= 72;i++) { %>
- <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
- <% } %>
- </div><label style="line-height: 25px;"> 小时</label>
- </div>
- </div>
- <div style="margin-left: 1.5rem;margin-top: .25rem; <% if (noticeSet.mode === 'fixed') { %>display: none;<% } %>" id="wx_type_2">
- <div class="w-100 d-inline-flex"><label class="right-duiqi">第1次间隔:</label>
- <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 %>">
- <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
- <% for (let i = 1; i <= 72;i++) { %>
- <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
- <% } %>
- </div><label style="line-height: 25px;"> 小时</label>
- </div>
- <div class="w-100 d-inline-flex"><label class="right-duiqi">第2次间隔:</label>
- <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 %>">
- <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
- <% for (let i = 1; i <= 72;i++) { %>
- <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
- <% } %>
- </div><label style="line-height: 25px;"> 小时</label>
- </div>
- <div class="w-100 d-inline-flex"><label class="right-duiqi">往后间隔:</label>
- <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 %>">
- <div class="dropdown-menu" style="max-height: 500px;overflow: auto;">
- <% for (let i = 1; i <= 72;i++) { %>
- <a class="dropdown-item change_time" href="javascript:void(0);" data-value="<%- i %>"><%- i %></a>
- <% } %>
- </div><label style="line-height: 25px;"> 小时</label>
- </div>
- </div>
- <div style="margin: .5rem 0 .5rem .5rem">消息屏蔽时段</div>
- <div style="margin-left: 1rem;margin-bottom: .5rem">
- <div class="input-group input-group-sm mb-2">
- <div class="input-group-prepend">
- <span class="input-group-text">开始时间:</span>
- </div>
- <select class="form-control form-control-sm" id="shield_start_time" style="width: 90px!important;flex: none;">
- <option value="">不限制</option>
- <% for (let i = 0; i <= 23;i++) { %>
- <option value="<%- i %>" <% if (noticeSet.shield_times.start === i) { %>selected<% } %>><%- (i < 10 ? '0' + i : i) + ':00' %></option>
- <% } %>
- </select>
- <span class="text-danger mx-2"></span>
- </div>
- <div class="input-group input-group-sm mb-2">
- <div class="input-group-prepend">
- <span class="input-group-text">截止时间:</span>
- </div>
- <select class="form-control form-control-sm" id="shield_end_time" style="width: 90px!important;flex: none;">
- <option value="">不限制</option>
- <% for (let i = 0; i <= 23;i++) { %>
- <option value="<%- i %>" <% if (noticeSet.shield_times.end === i) { %>selected<% } %>><%- (i < 10 ? '0' + i : i) + ':00' %></option>
- <% } %>
- </select>
- <span class="text-danger mx-2"></span>
- </div>
- </div>
- <!-- <div style="margin-left: 1rem;margin-bottom: .5rem">开始时间:<input style="width: 130px" type="time" placeholder="00:00~07:00" /></div>-->
- <!-- <div style="margin-left: 1rem;margin-bottom: .5rem">截止时间:<input style="width: 130px" type="time" placeholder="00:00~07:00" /></div>-->
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
- <button type="button" class="btn btn-primary btn-sm" id="set_wx_button">确定</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- $(function (){
- $('input[name="wx_send_type"]').on('click', function () {
- const type = $(this).val();
- if (type === 'fixed') {
- $('#wx_type_1').show();
- $('#wx_type_2').hide();
- } else {
- $('#wx_type_1').hide();
- $('#wx_type_2').show();
- }
- });
- $('.change_time').on('click', function () {
- $(this).parents('.dropdown-menu').siblings('input').val(parseInt($(this).data('value')));
- $(this).parents('.dropdown-menu').hide();
- });
- $('.time-input').on('click', function () {
- $(this).siblings('.dropdown-menu').show();
- });
- // 回车提交
- $('.time-input').on('keypress', function () {
- if(window.event.keyCode === 13) {
- $(this).blur();
- }
- });
- $('.time-input').blur(function () {
- const _self = $(this);
- setTimeout(function () {
- _self.siblings('.dropdown-menu').hide();
- let rate = parseFloat(_self.val());
- if (_.isNaN(rate)) {
- toastr.error('请输入1-72之前的整数值');
- _self.val(72);
- return;
- }
- // 如果是小数,自动转成整数
- if (rate.toString().indexOf('.') !== -1) {
- toastr.warning('请输入1-72之前的整数值');
- }
- rate = parseInt(rate);
- if(rate < 1 || rate > 72) {
- toastr.error('请输入1-72之前的整数值');
- _self.val(72);
- return;
- }
- _self.val(rate);
- }, 500);
- });
- $('#set_wx_button').click(function () {
- let flag = false;
- // 判断屏蔽时段是否合理
- const start_time = $('#shield_start_time').val() !== '' ? parseInt($('#shield_start_time').val()) : null;
- const end_time = $('#shield_end_time').val() !== '' ? parseInt($('#shield_end_time').val()) : null;
- if ((start_time === null && end_time !== null) || (start_time !== null && end_time === null)) {
- toastr.error('屏蔽时段必须配置开始和截止时间,要么都为不限制');
- flag = true;
- } else if (start_time !== null && end_time !== null && start_time === end_time) {
- toastr.error('屏蔽时间段开始和截止时间不能相同');
- flag = true;
- }
- if (flag) {
- return false;
- }
- const pData = {
- mode: $('#wx-setting input[name="wx_send_type"]:checked').val(),
- fixed: parseInt($('#fixed_time').val()),
- activity: {
- first: parseInt($('#activity_first_time').val()),
- second: parseInt($('#activity_second_time').val()),
- later: parseInt($('#activity_later_time').val()),
- },
- shield_times: {
- start: start_time,
- end: end_time,
- }
- };
- console.log(pData);
- postData('/setting/update/projectset', { field: 'notice_setting', pData }, function (result) {
- toastr.success('设置成功');
- $('#wx-setting').modal('hide');
- });
- });
- });
- </script>
|