123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- $(function () {
- autoFlashHeight();
- let timer = null;
- let oldSearchVal = null;
- $('body').on('input propertychange', '.gr-search', function(e) {
- oldSearchVal = e.target.value;
- timer && clearTimeout(timer);
- timer = setTimeout(() => {
- const newVal = $(this).val();
- const code = $(this).attr('data-code');
- 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>`
- });
- $('#' + code + '_dropdownMenu .book-list').empty();
- $('#' + code + '_dropdownMenu .book-list').append(html);
- } else {
- if (!$('#' + code + '_dropdownMenu .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}">`;
- 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>';
- });
- $('#' + code + '_dropdownMenu .book-list').empty();
- $('#' + code + '_dropdownMenu .book-list').append(html);
- }
- }
- }, 400);
- });
- // 添加审批流程按钮逻辑
- $('body').on('click', '.book-list 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;
- });
- // 选中审批人
- $('body').on('click', 'dl dd', function () {
- const id = parseInt($(this).attr('data-id'));
- if (!id) return;
- const this_code = $(this).parents('.dropdown').data('code');
- if (_.findIndex(rpt_audit, { uid: id }) !== -1) {
- toastr.error('该表单角色已存在,请勿重复添加');
- return;
- }
- const user = _.find(accountList, function (item) {
- return item.id === id;
- });
- $('#' + this_code + '_user').html(`<span>${user.name}</span><i role="button" class="fa fa-close text-danger remove-audit stamp-img" data-code="${this_code}"></i>`);
- $(this).parents('.select-audit').hide();
- $('#' + this_code + '_user').show();
- rpt_audit[this_code].uid = id;
- rpt_audit[this_code].name = user.name;
- console.log(rpt_audit);
- });
- // 移除审批人
- $('body').on('click', '.remove-audit', function () {
- const this_code = parseInt($(this).attr('data-code'));
- $('#' + this_code + '_user').html(``);
- $('#' + this_code + '_user').hide();
- $('#' + this_code + '_user').siblings('.select-audit').show();
- rpt_audit[this_code].uid = null;
- delete rpt_audit[this_code].name;
- console.log(rpt_audit);
- });
- // 重新加载角色数据
- $('#set-bdjs').on('show.bs.modal', function () {
- if (old_rpt_audit) {
- for (const [i, r] of old_rpt_audit.entries()) {
- if (r.uid) {
- $('#' + i + '_user').html(`<span>${r.name}</span><i role="button" class="fa fa-close text-danger remove-audit stamp-img" data-code="${i}"></i>`);
- $('#' + i + '_user').show();
- $('#' + i + '_user').siblings('.select-audit').hide();
- } else {
- $('#' + i + '_user').html(``);
- $('#' + i + '_user').hide();
- $('#' + i + '_user').siblings('.select-audit').show();
- }
- }
- }
- rpt_audit = _.cloneDeep(old_rpt_audit);
- });
- // 绑定表单角色
- $('#bind_rpt_audit_btn').click(function () {
- if (!is_first) {
- if (_.findIndex(rpt_audit, { uid: null }) !== -1) {
- toastr.error('请绑定所有表单角色再提交');
- return;
- }
- }
- postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'rpt_audit', rpt_audit }, function (result) {
- toastr.success('设置成功');
- old_rpt_audit = _.cloneDeep(rpt_audit);
- if (result.is_first) {
- $('#first_msg').show();
- } else {
- $('#first_msg').hide();
- }
- $('#set-bdjs').modal('hide');
- });
- });
- $('#show-add-btn').click(function () {
- if (_.findIndex(old_rpt_audit, { uid: null }) !== -1) {
- toastr.error('未配置好表单角色无法新建表单');
- $('#set-bdjs').modal('show');
- } else {
- $('#add-catalogue').modal('show');
- }
- });
- $('#add-detail-btn').click(function () {
- if (_.trim($('#add-detail-code').val()) === '') {
- toastr.error('请输入编号');
- return false;
- }
- if ($('#add-detail-time').val() === '') {
- toastr.error('请输入日期');
- return false;
- }
- console.log($('#add-detail-time').val());
- postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'add-detail', code: _.trim($('#add-detail-code').val()), s_time: $('#add-detail-time').val() }, function (result) {
- window.location.href = '/payment/' + tenderId + '/detail/' + result.id;
- });
- });
- // 获取审批流程
- $('a[data-target="#sp-list" ]').on('click', function () {
- const data = {
- order: $(this).attr('m-order'),
- };
- postData('/payment/' + tenderId + '/list/'+ trId + '/auditors', data, function (result) {
- const { auditHistory, auditors, user } = result
- let auditorsHTML = ''
- let historyHTML = ''
- auditors.forEach((auditor, idx) => {
- if (idx === 0) {
- auditorsHTML += `<li class="list-group-item">
- <i class="fa fa fa-play-circle fa-rotate-90"></i> ${auditor.name}
- <small class="text-muted">${auditor.role}</small>
- <span class="pull-right">原报</span>
- </li>`
- } else if(idx === auditors.length -1 && idx !== 0) {
- auditorsHTML += `<li class="list-group-item">
- <i class="fa fa fa-stop-circle"></i> ${auditor.name}
- <small class="text-muted">${auditor.role}</small>
- <span class="pull-right">终审</span>
- </li>`
- } else {
- auditorsHTML += `<li class="list-group-item">
- <i class="fa fa-chevron-circle-down"></i> ${auditor.name}
- <small class="text-muted">${auditor.role}</small>
- <span class="pull-right">${transFormToChinese(idx)}审</span>
- </li>`
- }
- })
- $('#auditor-list').empty()
- $('#auditor-list').append(auditorsHTML)
- const leftAuditors = auditors;
- auditHistory.forEach((auditors, idx) => {
- if(idx === auditHistory.length - 1 && auditHistory.length !== 1) {
- historyHTML += `<div class="text-right"><a href="javascript: void(0);" id="fold-btn" data-target="show"
- >展开历史审批流程</a></div>`
- }
- historyHTML += `<div class="${idx < auditHistory.length - 1 ? 'fold-card' : ''}">
- <div class="text-center text-muted">${idx + 1}#</div>
- <ul class="timeline-list list-unstyled mt-2">`
- auditors.forEach((auditor, index) => {
- if (index === 0) {
- historyHTML += `<li class="timeline-list-item pb-2">
- <div class="timeline-item-date">
- ${formatDate(auditor.begin_time)}
- </div>
- <div class="timeline-item-tail"></div>
- <div class="timeline-item-icon bg-success text-light">
- <i class="fa fa-caret-down"></i>
- </div>
- <div class="timeline-item-content">
- <div class="card">
- <div class="card-body p-3">
- <div class="card-text">
- <p class="mb-1"><span
- class="h5">${user.name}</span><span
- class="pull-right text-success">${idx !== 0 ? '重新' : ''}上报审批</span>
- </p>
- <p class="text-muted mb-0">${user.role}</p>
- </div>
- </div>
- </div>
- </div>
- </li>
- <li class="timeline-list-item pb-2">
- <div class="timeline-item-date">
- ${formatDate(auditor.end_time)}
- </div>`
- if(index < auditors.length - 1) {
- historyHTML += `<div class="timeline-item-tail"></div>`
- }
- if(auditor.status === auditConst.status.checked) {
- historyHTML += `<div class="timeline-item-icon bg-success text-light">
- <i class="fa fa-check"></i>
- </div>`
- } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
- historyHTML += `<div class="timeline-item-icon bg-warning text-light">
- <i class="fa fa-level-up"></i>
- </div>`
- } else if(auditor.status === auditConst.status.checking) {
- historyHTML += `<div class="timeline-item-icon bg-warning text-light">
- <i class="fa fa-ellipsis-h"></i>
- </div>`
- } else {
- historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
- }
- historyHTML += `<div class="timeline-item-content">
- <div class="card">
- <div class="card-body p-3">
- <div class="card-text">
- <p class="mb-1"><span class="h5">${auditor.name}</span><span
- class="pull-right ${auditConst.statusClass[auditor.status]}">${auditConst.statusString[auditor.status]}</span>
- </p>
- <p class="text-muted mb-0">${auditor.role}</p>
- </div>
- </div>`
- if (auditor.opinion) {
- historyHTML += `<div class="card-body p-3 border-top">
- <p style="margin: 0;">${auditor.opinion}</p>
- </div>`
- }
- historyHTML += `</div></div></li>`
- } else {
- historyHTML += `<li class="timeline-list-item pb-2">
- <div class="timeline-item-date">
- ${formatDate(auditor.end_time)}
- </div>`
- if(index < auditors.length - 1) {
- historyHTML += `<div class="timeline-item-tail"></div>`
- }
- if(auditor.status === auditConst.status.checked) {
- historyHTML += `<div class="timeline-item-icon bg-success text-light">
- <i class="fa fa-check"></i>
- </div>`
- } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
- historyHTML += `<div class="timeline-item-icon bg-warning text-light">
- <i class="fa fa-level-up"></i>
- </div>`
- } else if(auditor.status === auditConst.status.checking) {
- historyHTML += `<div class="timeline-item-icon bg-warning text-light">
- <i class="fa fa-ellipsis-h"></i>
- </div>`
- } else {
- historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
- }
- historyHTML += `<div class="timeline-item-content">
- <div class="card">
- <div class="card-body p-3">
- <div class="card-text">
- <p class="mb-1"><span class="h5">${auditor.name}</span>
- <span
- class="pull-right
- ${auditConst.statusClass[auditor.status]}">${auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''}
- ${auditor.status === auditConst.status.checkNo ? user.name : ''}
- ${auditor.status === auditConst.status.checkNoPre ? leftAuditors.find(item => item.sort === auditor.sort-1).name : ''}
- </span>
- </p>
- <p class="text-muted mb-0">${auditor.role}</p>
- </div>
- </div>`
- if (auditor.opinion) {
- historyHTML += `<div class="card-body p-3 border-top">
- <p style="margin: 0;">${auditor.opinion} </p>
- </div>`
- }
- historyHTML += `</div></div></li>`
- }
- })
- historyHTML += '</ul></div>'
- })
- $('#audit-list').empty()
- $('#audit-list').append(historyHTML)
- });
- });
- // 展开/收起历史审核记录
- $('#audit-list').on('click', 'a', function() {
- const type = $(this).data('target')
- const auditCard = $(this).parent().parent()
- console.log('auditCard', auditCard)
- if (type === 'show') {
- $(this).data('target', 'hide')
- auditCard.find('.fold-card').slideDown('swing', () => {
- auditCard.find('#end-target').text($(this).data('idx') + '#')
- auditCard.find('#fold-btn').text('收起历史审核记录')
- })
- } else {
- $(this).data('target', 'show')
- auditCard.find('.fold-card').slideUp('swing', () => {
- auditCard.find('#end-target').text('1#')
- auditCard.find('#fold-btn').text('展开历史审核记录')
- })
- }
- });
- function formatDate(date) {
- if (!date) return '';
- date = new Date(date)
- const year = date.getFullYear();
- let mon = date.getMonth() + 1;
- let day = date.getDate();
- let hour = date.getHours();
- let minute = date.getMinutes();
- let scond = date.getSeconds();
- if (mon < 10) {
- mon = '0' + mon.toString();
- }
- if (day < 10) {
- day = '0' + day.toString();
- }
- if (hour < 10) {
- hour = '0' + hour.toString();
- }
- if (minute < 10) {
- minute = '0' + minute.toString();
- }
- if (scond < 10) {
- scond = '0' + scond.toString();
- }
- return `${year}<span>${mon}-${day}</span><span>${hour}:${minute}:${scond}</span>`;
- };
- });
|