define(['fastflow-fixed-columns'], function (undefined) {
var fastflowBase = {
api: {
renderbadge: function () {
$.ajax({
type: "POST",
url: "fastflow/flow/bill/getBadge",
data: {},
dataType: "json",
success: function (data) {
if (data['code'] == 1) {
let parentWindow = window.parent.document;
$('.fastflow-badge', parentWindow).remove();
data['data'].forEach(function (item) {
if (item['count'] > 0) {
$('a[addtabs=' + item['id'] + ']', parentWindow).append(' ' + item['show'] + '');
}
});
if($('#bill-page',parentWindow).length === 1){
let topWindow = top.window.document;
$('.fastflow-badge', topWindow).remove();
data['data'].forEach(function (item) {
if (item['count'] > 0) {
$('a[addtabs=' + item['id'] + ']', topWindow).append(' ' + item['show'] + '');
}
});
}
}
}
});
},
formatter: {
id: function (value, row, index) {
return '' + value + '';
},
progress: function (value, row, index) {
return '
'
+ '
'
+ ''
+ Math.round(value * 100)
+ '% '
+ '
';
},
flowinfo: function (value, row, index) {
let html = '';
console.log('config',Config.initiator_id)
let backin = '';
if(row.initiator_id == Config.initiator_id && row.flow_auth.code!=4){
backin = '撤销';
}
if (row['flow_auth']['code'] == -3 || row['flow_auth']['code'] == -1 || row['flow_auth']['code'] == 3) {
let labelcolor = {
'-3': 'label-danger',
'-1': 'label-warning',
'3': 'label-warning',
};
html = '' + row['flow_auth']['msg'] + ''
+backin
+ '查看'
+ '流程图';
} else if (row['flow_auth']['code'] == 2) {
if (row['fastflow_signature_status'] == -1) {
html = '发起签章'
} else if (row['fastflow_signature_status'] == 0) {
html = '待签章'
} else if (row['fastflow_signature_status'] == 1) {
html = '已签章'
} else {
html = '' + row['flow_auth']['msg'] + ''
}
html +=
backin +
'查看'
+ '流程图';
} else if (row['flow_auth']['code'] == -2) {
html = '' + row['flow_auth']['msg'] + '';
} else if (row['flow_auth']['code'] == 0) {
html = '' + row['flow_auth']['msg'] + '';
} else if (row['flow_auth']['code'] == 1) {
needCheckCount = 0;
row['runthread_info'] = Array.from(row['runthread_info']);
row['runthread_info'].forEach(function (item) {
if (item['auth_info'] !== false) {
needCheckCount += 1;
}
});
html = ''
+ needCheckCount + ''
+ row['flow_auth']['msg'] + ''
+backin
+ '查看'
+ '流程图';
} else if (row['flow_auth']['code'] == 4) {
html = '' + row['flow_auth']['msg'] + ''
+backin
+ '查看';
}else if (row['flow_auth']['code'] == 5) {
html = '' + row['flow_auth']['msg'] + ''
+backin
+ '查看';
}
return html;
},
detail: function (index, row, e) {
if (row['runthread_info'] == -1 || row['runthread_info'] == 2) {
$(e).parent().prev().find('.detail-icon').trigger('click').addClass('hidden');
return '';
}
detailtable = '| 步骤编号 | 步骤名称 | 审批人 | 会签 | 回退 | 上一步骤 | 下一步骤 | 被代理人(组) | 代理人(组) | 审批 |
';
row['runthread_info'] = Array.from(row['runthread_info']);
row['runthread_info'].forEach(function (item) {
var zrin = '转审';
checkButton = '';
if (item['auth_info'] !== false) {
checkButton = (item['auth_info']['agency'] == true ? '代理' : '')
+ '同意'
+zrin
+ (item['can_back'] == 1 ? '驳回' : '')
+ (item['can_sign'] == 1 ? '会签' : '');
} else {
checkButton = '无审批权限';
}
checkButton = '' + checkButton + '
';
checkUser = '';
item['check_worker_list'].forEach(function (worker) {
checked = false;
for (i = 0; i < item['checked_worker_list'].length; i++) {
if (worker == item['checked_worker_list'][i]) {
checked = true;
break;
}
}
if (checked) {
checkUser += '' + worker + ',';
} else {
checkUser += worker + ',';
}
});
detailtable += '| ' + item['id'] + ' | ' + item['name'] + ' | '
+ (checkUser == '' ? '【错误】未设置审批人' : (item['checkmode'] == 1 ? '联合审批:' : '任一审批:') + checkUser.slice(0, checkUser.length - 1))
+ ' | '
+ (item['is_sign'] == 1 ? '是' : '否')
+ ' | '
+ (item['is_back'] == 1 ? '是' : '否')
+ ' | '
+ item['pre_step']
+ ' | '
+ (item['next_step'] == '' ? '【错误】请完善流程设计,条件转出步骤必须设置' : item['next_step'])
+ ' | '
+ (item['agency_info'] !== null ? item['agency_info']['principal_name'] : '')
+ ' | '
+ (item['agency_info'] !== null ? item['agency_info']['agent_name'] : '')
+ ' | '
+ checkButton
+ ' |
';
});
detailtable += '
';
return detailtable;
},
},
events: {
flowinfo: {
'click .btn-cancheck': function (e, value, row, index) {
e.stopPropagation();
$('tr[data-index="' + index + '"]').find('.detail-icon').trigger('click');
},
'click .btn-cx': function (e, value, row, index) {
e.stopPropagation();
console.log('rowrow',row.runthread_info[0].id)
// row['bill'] row['id']
Layer.confirm("是否确定撤销?", {icon: 3}, function (index) {
if(row.runthread_info[0].id==''){
Toastr.success("撤销失败1");
return false;
}
Fast.api.ajax({
url:'fastflow/flow/flow/revoke',
data:{bill:row['bill'],bill_id:row['id'],tid:row.runthread_info[0].id}
}, function(data, ret){
//成功的回调
layer.close(index);
$('#table').bootstrapTable('refresh');
Toastr.success("提交撤销成功");
return false;
}, function(data, ret){
//失败的回调
layer.close(index);
Toastr.success("提交撤销失败");
return false;
});
Toastr.success("提交成功");
});
}
}
},
bindevent: function (table) {
$('.btn-expandall').click(function (e) {
$('#table').bootstrapTable('expandAllRows');
});
$('.btn-collapseall').click(function (e) {
$('#table').bootstrapTable('collapseAllRows');
});
let indexUrl = $.fn.bootstrapTable.defaults.extend.index_url.replace(location.search,'');
$(document).on("click", ".btn-mine", function () {
table.bootstrapTable('refresh', {url: indexUrl + '?show=mine'});
$(this).addClass('disabled');
$(".btn-showcancheck").removeClass('disabled');
$(".btn-showall").removeClass('disabled');
return false;
});
$(document).on("click", ".btn-showcancheck", function () {
table.bootstrapTable('refresh', {url: indexUrl + '?show=cancheck'});
$(this).addClass('disabled');
$(".btn-mine").removeClass('disabled');
$(".btn-showall").removeClass('disabled');
return false;
});
$(document).on("click", ".btn-showall", function () {
table.bootstrapTable('refresh', {url: indexUrl});
$(this).addClass('disabled');
$(".btn-mine").removeClass('disabled');
$(".btn-showcancheck").removeClass('disabled');
return false;
});
$('th.detail').css({
"text-align": "center",
"vertical-align": "middle",
"width": "36px",
"color": "#4397fd"
});
$('th.detail').html('');
$('th.detail .detail-toggle').click(function (e) {
if ($(this).data('expand') == false) {
$('#table').bootstrapTable('expandAllRows');
$(this).data('expand', true);
$('i', this).removeClass('glyphicon-plus icon-plus').addClass('glyphicon-minus icon-minus');
} else {
$('#table').bootstrapTable('collapseAllRows');
$(this).data('expand', false);
$('i', this).removeClass('glyphicon-minus icon-minus').addClass('glyphicon-plus icon-plus');
}
});
}
}
}
return fastflowBase;
})