1:在cakephp 中查询第一个满足条件的数据
$pdf_url = $this->LossReportingProcess->find('first',array('conditions'=>array('voucher_id'=>$voucher_id),'order'=>'create_time DESC'));
// 查出来的数据 array(
0 => array(
'LossReportingProcess' =>array(
'数据库字段1' =>'111'
..............
)
)
)
// 修改 报损审核流程 中的审核状态
public function edit_aduit_status($data){
$loss_data = $this->LossReportingProcess->find('first',[
'conditions' =>[
'audit_number' => $data['process_uuid']
]
]);
if(!$loss_data){
$res = [
"code"=>400, //200成功,400失败
"message"=>"数据库中不存在此数据!"//信息,失败了返回失败原因
];
}else{
$loss_data = $loss_data['LossReportingProcess'];
$loss_data['aduit_content'] = $data['remark'];
$loss_data['current_user_name'] = $data['current_user_name'];
$loss_data['audit_time'] = $data['audit_time'];
switch($data['status']){
case 'finished': //已完成
$loss_data['audit_status'] = 2;
break;
case 'reject': //驳回
$loss_data['audit_status'] = 3;
break;
case 'cancel': // 撤销
$loss_data['audit_status'] = 4;
break;
}
if($this->LossReportingProcess->save($loss_data)){
$res = [
"code"=>200, //200成功,400失败
"message"=>"审核成功!"//信息,失败了返回失败原因
];
}else{
$res = [
"code"=>400, //200成功,400失败
"message"=>"审核修改数据失败!"//信息,失败了返回失败原因
];
}
}
return $res;
}
2:layui open 一个新的页面: layer.open 的type 设置为1 0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
function add_reporting(){
var payment_voucher_number = voucher_id;
// 创建弹窗
var layerIndex = layer.open({
title: '审核流程',
type: 1,
content: '',
area: ['800px', '800px'],
btn: ['关闭'],
yes: function(index_examine, layero) {
layer.close(index_examine);
},
success: function(layero, index_examine) {
// 创建表格容器元素并添加到弹窗内容中
var tableDiv = document.createElement('div');
tableDiv.id = 'examine';
tableDiv.className = 'layui-hide';
tableDiv.setAttribute('lay-filter', 'examine');
layero.find('.layui-layer-content').append(tableDiv);
table.render({
elem: '#examine'
,height: 'full-340'
, url: '/reporting/show_examine_status/'+voucher_id
,title: '审核状态'
,page: true //开启分页
,limit: 50 //每页显示的数量
,limits: [50, 200, 300]
,toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
,totalRow: true //开启合计行
,cols: [[ //表头
{type: 'checkbox', fixed: 'left' ,totalRowText:"合计"}
,{
field: 'id',
width: 30,
title: 'id',
}
,{field: 'audit_number', width: 30, title: '审计编号 '}
,{field: 'voucher_id', width: 30, title: '凭证编号'}
,{field: 'contract_number', width: 30, title: '合同号'}
,{field: 'audit_status', width: 30, title: '审核状态'}
,{field: 'number_of_reported_losses', width: 30, title: '报损数量'}
,{field: 'reported_loss_amount', width: 30, title: '报损金额'}
,{field: 'voucher_address', width: 30, title: '凭证地址'}
,{field: 'department_group', width: 30, title: '部门组'}
,{field: 'aduit_content', width: 30, title: '审核内容'}
,{field: 'current_user_name', width: 30, title: '当前审核人名'}
,{field: 'apply_date', width: 30, title: '申请日期'}
,{field: 'applicant', width: 30, title: '申请人'}
,{field: 'audit_time', width: 30, title: '审核时间'}
]]
, done: function(res, curr, count) {
}
});
}
})
3:layer.open 打开一个新的页面 来展示 多个 pdf 并且点击 查看详情 跳转新的页面 查看
reporting_toolbar.attachEvent("onClick", function(id) {
if(id == 'open'){
var text = '报损pdf';
var number = voucher_id;
$.ajaxSettings.async = false;
$.getJSON('/reporting/audit_button_judge/'+voucher_id,function(es){
var msg = es.msg
var button = '';
if (es.code == 400){
layer.alert(es.msg);
return false;
}else{
var embedHTMLArray = [];
for (var i = 0; i < es.data.length; i++) {
var contractUrl = es.data[i]; // 合同的 URL
// 创建 <embed> 标签的 HTML 字符串并添加到数组中
var embedHTML = '<embed src="' + contractUrl + '" type="application/pdf" width="300px" height="300px" />';
embedHTMLArray.push(embedHTML);
}
// 创建包含所有预览图的容器 div 元素
var containerDiv = document.createElement('div');
containerDiv.id = 'contractContainer';
containerDiv.style.display = 'flex';
containerDiv.style.flexWrap = 'wrap';
containerDiv.style.height = '600px';
containerDiv.style.overflowY = 'auto'; // 允许垂直滚动
// 添加每个预览图的 div 元素到容器中
for (var k = 0; k < embedHTMLArray.length; k++) {
var embedDiv = document.createElement('div');
embedDiv.innerHTML = embedHTMLArray[k];
embedDiv.style.display = 'inline-block';
embedDiv.style.width = '300px';
embedDiv.style.margin = '10px';
embedDiv.style.textAlign = 'center';
// 创建查看合同详情的按钮
var btn = document.createElement('a');
btn.innerText = '查看合同详情';
btn.href = es.data[k];
btn.target = '_blank'; // 在新窗口打开链接
// 点击按钮时跳转到新页面
btn.onclick = function() {
// 如果需要在点击按钮后执行其他操作,请在此处添加代码
// 如果不希望<a>标签直接跳转,返回false阻止默认行为
return true; // 或者 false,具体根据需求而定
};
// 将按钮和预览图添加到 div 元素中
embedDiv.appendChild(btn);
containerDiv.appendChild(embedDiv);
}
// 弹出窗口并显示容器 div
layer.open({
type: 1,
title:'报损pdf',
content: containerDiv.outerHTML,
area: ['1200px', '900px'],
});
}
})
}else if(id == 'page_setup') {
//审核状态
add_reporting();
}else if(id == 'page_audit'){
var login_people = '<?php echo $this->Session->read('Auth.User.username');?>';
//补充协议提交审核
page_audit(voucher_id);
}
})