|
@@ -228,7 +228,6 @@ $(function () {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
-
|
|
|
// 更改审批流程状态
|
|
|
$('#process_set .form-check input').on('change', function () {
|
|
|
// 获取所有审批的checked值并更新
|
|
@@ -250,7 +249,7 @@ $(function () {
|
|
|
});
|
|
|
|
|
|
// 选中审批流里的审批人
|
|
|
- $('body').on('click', '.lc-show dl dd', function () {
|
|
|
+ $('body').on('click', '#process_set .lc-show dl dd', function () {
|
|
|
const id = parseInt($(this).data('id'));
|
|
|
if (!id) return;
|
|
|
|
|
@@ -370,7 +369,7 @@ $(function () {
|
|
|
});
|
|
|
|
|
|
// 移除审批人
|
|
|
- $('body').on('click', '.remove-audit', function () {
|
|
|
+ $('body').on('click', '#process_set .remove-audit', function () {
|
|
|
const id = parseInt($(this).data('id'));
|
|
|
const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
|
|
|
const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
|
|
@@ -412,7 +411,7 @@ $(function () {
|
|
|
});
|
|
|
|
|
|
// 固定审批流-添加流程
|
|
|
- $('body').on('click', '.add-audit', function () {
|
|
|
+ $('body').on('click', '#process_set .add-audit', function () {
|
|
|
const num = $(this).parents('ul').children('li').length;
|
|
|
const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id'));
|
|
|
const addhtml = makeSelectAudit(this_tr_id, transFormToChinese(num));
|
|
@@ -464,7 +463,7 @@ $(function () {
|
|
|
' <span class="col-auto">' + i + '审</span>\n' +
|
|
|
' <span class="col-7 spr-span">\n' +
|
|
|
' <span class="d-inline-block">\n' +
|
|
|
- ' <div class="dropdown text-right">\n' +
|
|
|
+ ' <div class="dropdown text-right" >\n' +
|
|
|
' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
|
|
|
' 选择审批人\n' +
|
|
|
' </button>\n' +
|
|
@@ -510,5 +509,248 @@ $(function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ };
|
|
|
+
|
|
|
+ // 安全生产费 流程设置相关
|
|
|
+ class ProgressMaker {
|
|
|
+ constructor (setting) {
|
|
|
+ const self = this;
|
|
|
+ this.domId = setting.domId;
|
|
|
+ this.obj = $(setting.domId);
|
|
|
+ if (setting.rptInfo) this.loadRptInfo(setting.rptInfo);
|
|
|
+
|
|
|
+ // 选中上报人
|
|
|
+ $(setting.domId).on('click', '[name=user] dl dd', function () {
|
|
|
+ const uid = parseInt($(this).data('id'));
|
|
|
+ if (!uid) return;
|
|
|
+
|
|
|
+ let tr_id = self.rptInfo.id;
|
|
|
+ const user = _.find(accountList, function (item) { return item.id === uid; });
|
|
|
+ if (!user) {
|
|
|
+ toastr.error('用户列表不存在此人');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = { tr_id, uid, type: 'update-report' };
|
|
|
+ postData('process/save', data, function (result) {
|
|
|
+ for (const prop in result.updateData) {
|
|
|
+ self.rptInfo[prop] = result.updateData[prop];
|
|
|
+ }
|
|
|
+ self.refreshUserHtml();
|
|
|
+ if (result.updateRows) {
|
|
|
+ toastr.warning('上报人不能同时作为审批人,审批流已移除 ' + user.name);
|
|
|
+ self.loadAuditList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更改审批流程状态
|
|
|
+ $('.form-check input', setting.domId).on('change', function () {
|
|
|
+ // 获取所有审批的checked值并更新
|
|
|
+ const status = parseInt($(this).val());
|
|
|
+ let tr_id = self.rptInfo.id;
|
|
|
+ const spt = sp_status_list[status];
|
|
|
+ $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
|
|
|
+ // 拼接post json
|
|
|
+ const prop = { type: 'change-status', tr_id, status };
|
|
|
+ postData('/payment/' + tenderId + '/process/save', prop, function (data) {
|
|
|
+ self.rptInfo.sp_status = status;
|
|
|
+ self.setLcShowHtml(self.rptInfo, data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 选中审批流里的审批人
|
|
|
+ $(setting.domId).on('click', '.lc-show dl dd', function () {
|
|
|
+ const tr_id = self.rptInfo.id;
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
+ if (!id) return;
|
|
|
+ const user = _.find(accountList, function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+
|
|
|
+ const status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
|
|
|
+ if (status === sp_status.gdspl) {
|
|
|
+ // 判断是否已存在审批人
|
|
|
+ const aid_num = $(this).parents('ul').find('.remove-audit').length;
|
|
|
+ for (let i = 0; i < aid_num; i++) {
|
|
|
+ const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
|
|
|
+ if (aid === id) {
|
|
|
+ toastr.warning('该审核人已存在,请勿重复添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const prop = { status, tr_id, audit_id: id, type: 'add-audit' };
|
|
|
+ const _self = $(this);
|
|
|
+ postData('/payment/' + tenderId + '/process/save', prop, function (data) {
|
|
|
+ if (status === sp_status.gdspl) {
|
|
|
+ _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
|
|
|
+ }
|
|
|
+ _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
|
|
|
+ '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
|
|
|
+ ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
|
|
|
+ ' <div class="dropdown-menu">\n' +
|
|
|
+ ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
|
|
|
+ ' <div class="dropdown-divider"></div>\n' +
|
|
|
+ ' <div class="px-2 py-1 text-center">\n' +
|
|
|
+ ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
|
|
|
+ ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </span> ' +
|
|
|
+ ' </span></span></span>\n');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 移除审批人
|
|
|
+ $(setting.domId).on('click', '.remove-audit', function () {
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
+ const status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
|
|
|
+ const tr_id = self.rptInfo.id;
|
|
|
+ const prop = { status, tr_id, audit_id: id, type: 'del-audit' };
|
|
|
+ const _self = $(this);
|
|
|
+ postData('process/save', prop, function (data) {
|
|
|
+ if (status === sp_status.gdspl) {
|
|
|
+ const _selflc = _self.parents('.lc-show');
|
|
|
+ _self.parents('li').remove();
|
|
|
+ const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length);
|
|
|
+ if (aid_num === 0) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n';
|
|
|
+ addhtml += makeSelectAudit(tr_id, '一');
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ _selflc.html(addhtml);
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < aid_num; i++) {
|
|
|
+ _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (status === sp_status.gdzs) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n' +
|
|
|
+ ' <li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">授权审批人</span>\n' +
|
|
|
+ ' <span class="col-7">\n' +
|
|
|
+ ' <span class="d-inline-block"></span>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>\n';
|
|
|
+ addhtml += self.getAuditSelectHtml();
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ _self.parents('.lc-show').html(addhtml);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ // 固定审批流-添加流程
|
|
|
+ $(setting.domId).on('click', '.add-audit', function () {
|
|
|
+ const num = $(this).parents('ul').children('li').length;
|
|
|
+ const addhtml = self.getAuditSelectHtml(transFormToChinese(num));
|
|
|
+ $(this).parents('ul').append(addhtml);
|
|
|
+ $(this).parents('li').remove();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ getAccountHtml(uid) {
|
|
|
+ const html = [];
|
|
|
+ accountGroup.forEach((group, idx) => {
|
|
|
+ if (!group) return;
|
|
|
+
|
|
|
+ const groupHtml = [];
|
|
|
+ group.groupList.forEach(item => {
|
|
|
+ if (item.id === uid) return;
|
|
|
+ groupHtml.push('<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
|
|
|
+ '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
|
|
|
+ ' class="ml-auto">' + item.mobile + '</span></p>\n' +
|
|
|
+ ' <span class="text-muted">' + item.role + '</span>\n' +
|
|
|
+ ' </dd>\n');
|
|
|
+ });
|
|
|
+ html.push(`<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}">${groupHtml.join('')}</div>`);
|
|
|
+ });
|
|
|
+ return html.join('');
|
|
|
+ }
|
|
|
+ getSelectHtml(name) {
|
|
|
+ const tr_id = this.rptInfo.id;
|
|
|
+ return '<span class="d-inline-block">\n' +
|
|
|
+ ' <div class="dropdown text-right">\n' +
|
|
|
+ ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
|
|
|
+ ` ${name}\n` +
|
|
|
+ ' </button>\n' +
|
|
|
+ ' <div class="dropdown-menu dropdown-menu-left" id="' + tr_id + '_dropdownMenu2" aria-labelledby="' + tr_id + '_dropdownMenuButton2" style="width:220px">\n' +
|
|
|
+ ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
|
|
|
+ ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
|
|
|
+ ' <dl class="list-unstyled book-list">\n' + this.getAccountHtml(this.rptInfo.uid) +
|
|
|
+ ' </dl>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </span>\n';
|
|
|
+ }
|
|
|
+ getAuditSelectHtml(i = '终') {
|
|
|
+ let html = '<li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">' + i + '审</span>\n' +
|
|
|
+ ' <span class="col-7 spr-span">\n' + this.getSelectHtml('选择审批人') +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>';
|
|
|
+ return html;
|
|
|
+ }
|
|
|
+ refreshUserHtml() {
|
|
|
+ const html = ['<div class="mr-2">上报人<b class="text-danger">*</b></div>'];
|
|
|
+ if (this.rptInfo.uid) {
|
|
|
+ const userInfo = _.find(accountList, { id: this.rptInfo.uid });
|
|
|
+ html.push(`<div class="mr-2">${userInfo.name}</div>`, `<div>${this.getSelectHtml('替换')}</div>`);
|
|
|
+ } else {
|
|
|
+ html.push(`<div>${this.getSelectHtml('选择上报人')}</div>`);
|
|
|
+ }
|
|
|
+ $('[name=user]', this.domId).html(html.join(''));
|
|
|
+ }
|
|
|
+ setLcShowHtml() {
|
|
|
+ if (this.rptInfo.sp_status === sp_status.sqspr) {
|
|
|
+ $('.lc-show', this.domId).html('');
|
|
|
+ } else if (this.rptInfo.sp_status === sp_status.gdspl) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n';
|
|
|
+ if (this.rptInfo.auditData.length !== 0) {
|
|
|
+ for(const [i, audit] of this.rptInfo.auditData.entries()) {
|
|
|
+ addhtml += makeAudit(audit, transFormToChinese(i+1));
|
|
|
+ }
|
|
|
+ addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
|
|
|
+ } else {
|
|
|
+ addhtml += this.getAuditSelectHtml('一');
|
|
|
+ }
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ $('.lc-show', this.domId).html(addhtml);
|
|
|
+ } else if (this.rptInfo.sp_status === sp_status.gdzs) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n' +
|
|
|
+ ' <li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">授权审批人</span>\n' +
|
|
|
+ ' <span class="col-7">\n' +
|
|
|
+ ' <span class="d-inline-block"></span>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>\n';
|
|
|
+ addhtml += this.rptInfo.auditData ? makeAudit(this.rptInfo.auditData) : this.getAuditSelectHtml();
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ $('.lc-show', this.domId).html(addhtml);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ async loadAuditList() {
|
|
|
+ const prop = {
|
|
|
+ type: 'get-audits',
|
|
|
+ tr_id: this.rptInfo.id,
|
|
|
+ status: this.rptInfo.sp_status,
|
|
|
+ };
|
|
|
+ this.rptInfo.auditData = await postDataAsync('process/save', prop);
|
|
|
+ this.setLcShowHtml();
|
|
|
+ }
|
|
|
+ initProgress() {
|
|
|
+ this.obj.attr('data-trid', this.rptInfo.id);
|
|
|
+ $('.card-title', this.domId).find('.card-title').text(this.rptInfo.rpt_name);
|
|
|
+ this.refreshUserHtml();
|
|
|
+ $('input[name="tender_process"][value="'+ this.rptInfo.sp_status +'"]', this.obj).prop('checked', true).attr('data-trid', this.rptInfo.id);
|
|
|
+ const spt = sp_status_list[this.rptInfo.sp_status];
|
|
|
+ $('.alert-warning', this.domId).text(spt.name + ':' + spt.msg);
|
|
|
+ this.loadAuditList();
|
|
|
+ }
|
|
|
+ loadRptInfo(rptInfo) {
|
|
|
+ this.rptInfo = rptInfo;
|
|
|
+ this.initProgress();
|
|
|
+ }
|
|
|
}
|
|
|
+ const safeProgress = new ProgressMaker({ domId: '#safe', rptInfo: safeRpt });
|
|
|
});
|