123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- <% if (auditPermission.admin) { %>
- <!-- 弹窗新建目录 -->
- <div class="modal fade" id="add-folder" data-backdrop="static">
- <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 class="form-group" id="parent_folder" style="display: none">
- <label for="parent_folder_name">父文件夹名称</label>
- <input type="text" class="form-control form-control-sm" id="parent_folder_name" readonly>
- </div>
- <div class="form-group">
- <label for="new_folder_name">文件夹名称</label>
- <input type="text" class="form-control form-control-sm" id="new_folder_name" placeholder="请输入文件夹名称" required>
- <div class="invalid-feedback">
- <!--名称超过100个字,请缩减名称-->
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <input type="hidden" id="parent_id" value="0">
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-sm btn-primary" id="new_folder_btn">确定添加</button>
- </div>
- </div>
- </div>
- </div>
- <div class="modal fade" id="edit-name" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">修改文件夹</h5>
- </div>
- <div class="modal-body">
- <form>
- <div class="form-group">
- <label for="edit_name_input">名称</label>
- <input type="text" class="form-control form-control-sm" id="edit_name_input" placeholder="请输入名称" required>
- <div class="invalid-feedback">
- <!--名称超过100个字,请缩减名称-->
- </div>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <input type="hidden" id="edit_name_id" />
- <input type="hidden" id="edit_name_type" />
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-sm btn-primary" id="edit_name_btn">确定修改</button>
- </div>
- </div>
- </div>
- </div>>
- <!-- 弹窗新建标段 -->
- <div class="modal fade" id="add-tender" data-backdrop="static">
- <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 class="form-group">
- <label for="add_tender_folder_name">文件夹名称</label>
- <input type="text" class="form-control form-control-sm" id="add_tender_folder_name" readonly>
- </div>
- <div class="form-group">
- <label for="add_tender_name">标段名称</label>
- <input type="text" class="form-control form-control-sm" id="add_tender_name" placeholder="请输入标段名称" required>
- <div class="invalid-feedback">
- <!--名称超过100个字,请缩减名称-->
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <input type="hidden" id="add_tender_folder_id" />
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-sm btn-primary" id="new_tender_btn">确定添加</button>
- </div>
- </div>
- </div>
- </div>
- <!-- 弹窗删除项目 -->
- <div class="modal fade" id="del-project" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">删除标段</h5>
- </div>
- <div class="modal-body">
- <h6>确认删除 <span></span>?</h6>
- </div>
- <div class="modal-footer">
- <input type="hidden" id="del_id" />
- <input type="hidden" id="del_type" />
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-sm btn-danger" id="del_btn">确定删除</button>
- </div>
- </div>
- </div>
- </div>
- <% } %>
- <% if (ctx.session.sessionUser.is_admin) { %>
- <link href="/public/css/bootstrap/bootstrap-table.min.css" rel="stylesheet">
- <link href="/public/css/bootstrap/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
- <style>
- /*.bootstrap-table .fixed-table-container.fixed-height:not(.has-footer) {*/
- /*border-bottom: 0;*/
- /*}*/
- @-moz-document url-prefix() {
- table {
- table-layout: fixed;
- }
- }
- </style>
- <!-- 弹窗编辑项目 -->
- <div class="modal fade" id="authority-list" data-backdrop="static">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">权限管理</h5>
- </div>
- <div class="modal-body">
- <div class="d-flex flex-row bg-graye">
- <div class="p-2">
- <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton"
- data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- 添加用户
- </button>
- <div class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownMenuButton" style="width:220px">
- <div class="mb-2 p-2"><input class="form-control form-control-sm" placeholder="姓名/手机 检索"
- id="gr-search" autocomplete="off"></div>
- <dl class="list-unstyled book-list">
- <% accountGroup.forEach((group, idx) => { %>
- <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>"
- data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
- <div class="dd-content" data-toggleid="<%- idx %>">
- <dd class="border-bottom p-2 mb-0" data-groupname="<%- group.groupName %>"><p class="mb-0 d-flex"><span class="text-primary">该单位下所有组员</span></p></dd>
- <% group.groupList.forEach(item => { %>
- <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
- <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
- class="ml-auto"><%- item.mobile %></span></p>
- <span class="text-muted"><%- item.role %></span>
- </dd>
- <% });%>
- </div>
- <% }) %>
- </dl>
- </div>
- </div>
- <div class="p-2"><a href="javascript:void(0)" id="del-permission-audits-btn">批量删除</a></div>
- </div>
- <div style="height:300px">
- <table id="permission-audit-table" class="table table-bordered" data-height="300" data-toggle="table">
- <thead>
- <tr>
- <th class="text-center">选择</th>
- <th class="text-center">用户名</th>
- <th class="text-center">单位</th>
- <th class="text-center">添加时间</th>
- <th class="text-center">模块管理员</th>
- <th class="text-center">查看所有标段</th>
- <th class="text-center">操作</th>
- </tr>
- </thead>
- <tbody id="permission-audit-list">
- <% for (const pa of permissionAudits) { %>
- <tr>
- <td class="text-center"><input type="checkbox" name="uid[]" value="<%- pa.uid %>"></td>
- <td class="text-left"><%- pa.name %></td>
- <td class="text-left"><%- pa.company %></td>
- <td class="text-left"><%- ctx.helper.formatFullDate(pa.create_time) %></td>
- <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="admin" value="<%- pa.uid %>" <% if (pa.permission_json.admin) { %>checked<% } %>></td>
- <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="view_all" value="<%- pa.uid %>" <% if (pa.permission_json.view_all) { %>checked<% } %>></td>
- <td class="text-center"><a href="javascript:void(0);" class="text-danger del-permission-audit-a" data-id="<%- pa.uid %>">移除</a></td>
- </tr>
- <% } %>
- </tbody>
- </table>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-sm btn-outline-dark" data-dismiss="modal">关闭</button>
- </div>
- </div>
- </div>
- </div>
- <!-- 弹窗删除权限用户 -->
- <div class="modal fade" id="del-permission-audit" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">删除用户</h5>
- </div>
- <div class="modal-body">
- <h6>确认删除当前所选用户?</h6>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <input type="hidden" id="del-audit-ids" />
- <button type="button" class="btn btn-sm btn-danger" id="del-audit-btn">确定删除</button>
- </div>
- </div>
- </div>
- </div>
- <% if (noSpTenderList.length > 0) { %>
- <div class="modal fade" id="nosp-list" data-backdrop="static">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">关联标段</h5>
- </div>
- <div class="modal-body" style="position: relative;overflow: auto;max-height: 800px;padding-top: 0;margin-top: 1rem;">
- <style>
- .c-NoSpBody .table thead th {
- border: none;
- outline-width: 1px;
- outline-style: solid;
- outline-color: #dee2e6;
- }
- </style>
- <div class="c-NoSpBody">
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-sm btn-primary" id="bind-spBtn">确定</button>
- </div>
- </div>
- </div>
- </div>
- <% } %>
- <% } %>
- <% if (ctx.session.sessionUser.is_admin) { %>
- <script src="/public/js/bootstrap/bootstrap-table.min.js"></script>
- <script src="/public/js/bootstrap/locales/bootstrap-table-zh-CN.min.js"></script>
- <!--<script src="/public/js/bootstrap/bootstrap-table-fixed-columns.min.js"></script>-->
- <script>
- <% if (noSpTenderList.length > 0) { %>
- const noSpTenderList = JSON.parse(unescape('<%- escape(JSON.stringify(noSpTenderList)) %>'));
- const noSpFolderList = JSON.parse(unescape('<%- escape(JSON.stringify(noSpFolderList)) %>'));
- <% } %>
- $(function () {
- // $("#permission-audit-table").bootstrapTable('destroy').bootstrapTable({
- // fixedColumns: true,
- // // height:200
- // // fixedNumber: 1 //固定列数
- // });
- let timer = null
- let oldSearchVal = null
- let permissionAudits = JSON.parse(unescape('<%- escape(JSON.stringify(permissionAudits)) %>'));
- const accountGroup = JSON.parse(unescape('<%- escape(JSON.stringify(accountGroup)) %>'));
- const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
- $('#gr-search').bind('input propertychange', function(e) {
- oldSearchVal = e.target.value
- timer && clearTimeout(timer)
- timer = setTimeout(() => {
- const newVal = $('#gr-search').val()
- let html = ''
- if (newVal && newVal === oldSearchVal) {
- accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`
- })
- $('.book-list').empty()
- $('.book-list').append(html)
- } else {
- if (!$('.acc-btn').length) {
- accountGroup.forEach((group, idx) => {
- if (!group) return
- html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
- </a> ${group.groupName}</dt>
- <div class="dd-content" data-toggleid="${idx}">
- <dd class="border-bottom p-2 mb-0" data-groupname="${group.groupName}"><p class="mb-0 d-flex"><span class="text-primary">该单位下所有组员</span></p></dd>`
- group.groupList.forEach(item => {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`
- });
- html += '</div>'
- })
- $('.book-list').empty()
- $('.book-list').append(html)
- }
- }
- }, 400);
- });
- // 添加到成员中
- $('.book-list').on('click', 'dt', function () {
- const idx = $(this).find('.acc-btn').attr('data-groupid')
- const type = $(this).find('.acc-btn').attr('data-type')
- if (type === 'hide') {
- $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
- $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
- $(this).find('.acc-btn').attr('data-type', 'show')
- })
- } else {
- $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
- $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
- $(this).find('.acc-btn').attr('data-type', 'hide')
- })
- }
- return false
- });
- // 添加到成员中
- $('dl').on('click', 'dd', function () {
- const id = parseInt($(this).data('id'));
- const groupName = $(this).data('groupname');
- console.log(groupName);
- if (!isNaN(id) && id !== 0) {
- postData('/sp/' + spid + '/payment/permission/save', { type: 'add-audit', id: id }, function (result) {
- permissionAudits = result;
- setList(permissionAudits);
- })
- } else if (groupName && groupName !== '') {
- const groupAuditList = _.filter(accountList, { company: groupName });
- const groupAidList = _.map(groupAuditList, 'id');
- const groupPAList = _.map(permissionAudits, 'uid');
- const addAidList = _.difference(groupAidList, groupPAList);
- console.log(groupAidList, groupPAList, addAidList);
- if (addAidList.length > 0) {
- postData('/sp/' + spid + '/payment/permission/save', { type: 'add-audit', id: addAidList }, function (result) {
- // toastr.success(`成功添加 位用户`);
- permissionAudits = result;
- setList(permissionAudits);
- })
- } else {
- toastr.warning('暂无用户添加');
- }
- }
- });
- function setList(datas) {
- let list = '';
- for (const pa of datas) {
- list += `<tr>
- <td class="text-center"><input type="checkbox" name="uid[]" value="${pa.uid}"></td>
- <td class="text-left">${pa.name}</td>
- <td class="text-left">${pa.company}</td>
- <td class="text-left">${moment(pa.create_time).format('YYYY-MM-DD HH:mm:ss')}</td>
- <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="admin" value="${pa.uid}" ${pa.permission_json.admin ? 'checked' : ''}></td>
- <td class="text-center"><input type="checkbox" class="permission-checkbox" data-type="view_all" value="${pa.uid}" ${pa.permission_json.view_all ? 'checked' : ''}></td>
- <td class="text-center"><a href="javascript:void(0);" class="text-danger del-permission-audit-a" data-id="${pa.uid}">移除</a></td>
- </tr>`;
- }
- $('#permission-audit-list').html(list);
- $("#permission-audit-table").bootstrapTable('resetView');
- }
- let first = 1;
- $('#authority-list').on('shown.bs.modal', function () {
- if (first) {
- const option = {
- // fixedColumns: true,
- // fixedNumber: 1, //固定列数
- locale: 'zh-CN',
- height: 300,
- }
- // if (permissionAudits.length === 0) {
- // option.formatName = function () {
- // return '暂无数据';
- // }
- // }
- $("#permission-audit-table").bootstrapTable('destroy').bootstrapTable(option);
- first = 0;
- }
- })
- $('#del-permission-audits-btn').click(function () {
- const checkArray = [];
- $('#permission-audit-list input[name="uid[]"]:checked').each(function() {
- checkArray.push(parseInt($(this).val())); //向数组中添加元素
- });
- console.log(checkArray);
- if (checkArray.length === 0) {
- toastr.warning('暂无用户被选中');
- } else {
- $('#del-audit-ids').val(checkArray.join(','));
- $('#del-permission-audit').modal('show');
- }
- });
- $('body').on('click', '.del-permission-audit-a', function () {
- $('#del-audit-ids').val($(this).attr('data-id'));
- $('#del-permission-audit').modal('show');
- });
- $('#del-audit-btn').click(function () {
- let uids = $('#del-audit-ids').val();
- postData('/sp/' + spid + '/payment/permission/save', { type: 'del-audit', id: uids.split(',') }, function (result) {
- // toastr.success(`成功添加 位用户`);
- $('#del-permission-audit').modal('hide');
- permissionAudits = result;
- setList(permissionAudits);
- })
- });
- // 权限勾选
- $('body').on('click', '.permission-checkbox', function () {
- const type = $(this).attr('data-type');
- const value = $(this).is(':checked') ? 1 : 0;
- const userInfo = _.find(permissionAudits, { uid: parseInt($(this).val()) });
- if (!userInfo) {
- toastr.error('用户不存在');
- }
- userInfo.permission_json[type] = value;
- if (value === 1 && type === 'admin') {
- userInfo.permission_json['view_all'] = value;
- $(this).parents('tr').find('input[data-type="view_all"]').prop('checked', value);
- }
- const updateInfo = {
- uid: userInfo.uid,
- permission_json: userInfo.permission_json,
- }
- postData('/sp/' + spid + '/payment/permission/save', { type: 'save-permission-one', updateData: updateInfo }, function (result) {
- // toastr.success(`成功添加 位用户`);
- })
- });
- // $('body').on('click', '.permission-all-checkbox', function () {
- // console.log($(this).attr('data-type'), $(this).is(':checked'));
- // const type = $(this).attr('data-type');
- // const value = $(this).is(':checked') ? 1 : 0;
- // postData('/sp/' + spid + '/payment/permission/save', { type: 'save-permission-all', permission_type: type, value }, function (result) {
- // // toastr.success(`成功添加 位用户`);
- // permissionAudits = result;
- // setList(permissionAudits);
- // })
- // })
- <% if (noSpTenderList.length > 0) { %>
- let noSpTenderTree = [];
- let noSpParentId = 0;
- function initNoSpTenderTree(folderList, tenderList) {
- noSpTenderTree = [];
- const folders = folderList;
- const tenders = tenderList;
- function makeNoSpTenderTree(parent) {
- if (parent.is_leaf) {
- parent.children = _.filter(tenders, { folder_id: parent.folder_id });
- if (parent.children.length > 0) {
- parent.is_tender = true;
- parent.children.forEach((value, index) => {
- value.level = parent.level + 1;
- });
- }
- } else {
- const children = _.filter(folders, { parent_id: parent.folder_id });
- parent.children = children;
- if (children.length > 0) {
- for (const c of children) {
- makeNoSpTenderTree(c);
- }
- }
- }
- }
- const level0Folders = _.filter(folders, { level: 1 });
- for (const l of level0Folders) {
- makeNoSpTenderTree(l);
- noSpTenderTree.push(l);
- }
- console.log(noSpTenderTree);
- }
- function recursiveGetNoSpTenderNodeHtml (node, arr, pid) {
- const html = [];
- html.push('<tr fid="' + (node.parent_id !== undefined ? node.id: 0) + '" pid="' + pid + '">');
- // 选择框
- html.push('<td style="width: 5%;text-align: center;">');
- if (node.parent_id === undefined) {
- html.push('<input type="checkbox" name="tender[]" value="' + node.id + '">');
- }
- html.push('</td>');
- // 名称
- html.push('<td class="in-' + node.level + '">');
- if (node.parent_id !== undefined) {
- // html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
- html.push('<i class="fa fa-folder-o"></i> ', node.name);
- } else {
- html.push('<span class="text-muted mr-2">');
- html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
- html.push('</span>');
- //html.push('<a href="/tender/' + node.id + '">', node[c.field], '</a>');
- html.push(node.name);
- }
- html.push('</td>');
- // 创建人
- html.push('<td style="width: 15%" class="text-center">', node.user_name ? node.user_name : '', '</td>');
- // 创建时间
- html.push('<td style="width: 20%" class="text-center">', node.in_time && node.parent_id === undefined ? moment(node.in_time).format('YYYY-MM-DD HH:mm:ss') : '', '</td>');
- html.push('</tr>');
- if (node.children) {
- for (const c of node.children) {
- html.push(recursiveGetNoSpTenderNodeHtml(c, node.children, node.sort_id));
- }
- }
- return html.join('');
- }
- // 根据TenderTree数据获取Html代码
- function getNoSpTenderTreeHtml () {
- if (noSpTenderTree.length > 0) {
- const html = [];
- html.push('<table class="table table-hover table-bordered">');
- html.push('<thead style="position: sticky;left:56px;top: 0;">', '<tr>');
- html.push('<th class="text-center" style="width: 5%;">', '<input type="checkbox" id="select-all-tender" />', '</th>');
- html.push('<th class="text-center">', '名称', '</th>');
- html.push('<th class="text-center" style="width: 15%">', '创建人', '</th>');
- html.push('<th class="text-center" style="width: 20%">', '创建时间', '</th>');
- html.push('</tr>', '</thead>');
- noSpParentId = 0;
- for (const t of noSpTenderTree) {
- html.push(recursiveGetNoSpTenderNodeHtml(t, noSpTenderTree, ''));
- }
- html.push('</table>');
- return html.join('');
- } else {
- return '';
- }
- }
- function makeNoSpList(folderList, tenderList) {
- initNoSpTenderTree(folderList, tenderList);
- $('.c-NoSpBody').html(getNoSpTenderTreeHtml());
- $('[data-toggle="tooltip"]').tooltip()
- }
- makeNoSpList(noSpFolderList, noSpTenderList);
- $('body').on('click', '#select-all-tender', function () {
- const checked = $(this).is(':checked');
- $('.c-NoSpBody table').find('input[type="checkbox"]').prop('checked', checked);
- });
- $("#bind-spBtn").click(function () {
- const checkedTender = $('.c-NoSpBody table tbody').find('input[type="checkbox"]:checked');
- const tenderIds = [];
- checkedTender.each(function () {
- tenderIds.push(parseInt($(this).val()));
- });
- if (tenderIds.length === 0) {
- toastr.error('请选择需要关联的标段');
- return;
- }
- console.log(tenderIds);
- postData('/sp/' + spid + '/payment/permission/save', { type: 'bind-sp', tids: tenderIds }, function (result) {
- window.location.reload();
- })
- })
- <% } %>
- })
- </script>
- <% } %>
|