新增凭证增删改查

master
chenzhi 5 years ago
parent afd362d847
commit 6b5f60f8e6

@ -261,6 +261,81 @@ class AggregateFinanceStatementController extends ThinkController
$this->assign("data",$senddata);
$this->display();
}
//上传凭证
public function uploadVoucher()
{
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$this->assign("id",$id);
$this->display();
}
//修改凭证
public function editVoucher()
{
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$info = M("aggregate_statement","tab_")->field("id,verify_status,ext_field")->where("id = '{$id}'")->find();
$this->assign("id",$id);
$this->assign("ext_field",$info['ext_field']);
$this->display();
}
//保存凭证
public function saveVoucher()
{
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$path = '/Uploads/';
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 0 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');;// 设置附件上传类型
$upload->rootPath = '.'.$path; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if(!$info) {// 上传错误提示错误信息
$msg = $upload->getError();
$array= array('status' => 0, 'info' => $msg);
}else{// 上传成功
//
$pf = $path.$info['file']['savepath'].$info['file']['savename'];
$save = [
"ext_field"=>$pf,
];
//获取旧值,存在删除
$info = M("aggregate_statement","tab_")->field("id,verify_status,ext_field")->where("id = '{$id}'")->find();
if(!empty($info['ext_field'])){
unlink("./".$info['ext_field']);
}
//如果是开票状态就改状态
if($info["verify_status"] == 3){
$save['verify_status'] = 4;
$save['create_time'] = time();
}
M("aggregate_statement","tab_")->where("id = '{$id}'")->save($save);
$array=array(
'status' => 1,
"info"=>"上传成功",
"file_path"=>$pf,
);
}
$this->ajaxReturn($array);
}
//删除凭证
public function delVoucher(){
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$info = M("aggregate_statement","tab_")->field("id,ext_field")->where("id = '{$id}'")->find();
if(!empty($info['ext_field'])){
unlink("./".$info['ext_field']);
}
M("aggregate_statement","tab_")->where("id = '{$id}'")->save(['ext_field'=>'']);
$this->ajaxReturn(array(
'status' => 1,
'info' => "删除成功"
));
}
//导出
public function export()
{

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title></title>
<link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/module.css">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
</head>
<style>
html {
min-width:100%;
}
body {
padding: 0px;
}
.hide{
display: none !important;
}
</style>
<body>
<div id="main" class="main" style="min-height: 342px;margin-top: 20px;padding-left: 50px;">
<table border="0" cellspacing="0" cellpadding="0">
<tr style="padding: 10px;height: 50px;">
<td class="l">文件选择: </td>
<td >
<input type="file" id="fileinput" name="file" accept="image/*">
</td>
<td style="color: #777;font-size: 12px;">仅能添加一张凭证,重复添加将覆盖</td>
</tr>
</table>
<div class="jssearch search_list fl cf">
<div class="input-list">
<div class="sch-btn uploadfile" style="width: 100px;padding: 5px;">确认修改</div>
<div id="delVoucher" class="sch-btn " style="width: 100px;padding: 5px;background-color: red;">删除凭证</div>
</div>
</div>
<div style="display: block;clear: both;">
<img id="voucher" src="{$ext_field}" class="" style="width: auto;height: 350px;margin: auto;">
</div>
</div>
<script>
var id = {$id};
$(function(){
$(".uploadfile").on("click",function(){
var acceptedTypes = ['image/png','image/jpeg','image/jpg','image/gif'];
var type = document.getElementById('fileinput').files[0].type;
if (acceptedTypes.indexOf(type) === -1) {
layer.msg("只允许图片格式文件");
return false;
}
var formData = new FormData();
formData.append("id",id);
formData.append("file", document.getElementById("fileinput").files[0]);
var index = layer.load();
$.ajax({
url:"{:U('saveVoucher')}",
type:"post",
data:formData,
processData:false,
contentType:false,
success:function(data){
layer.close(index);
if(data.status == 1){
//file_path\
layer.msg("上传成功");
$('#voucher').attr("src",data.file_path).removeClass("hide");
$('#delVoucher').removeClass("hide");
$("#fileinput").val('');
}else{
layer.alert(data.info);
}
},
error:function(e){
layer.alert("网络错误");
}
});
})
$("#delVoucher").on("click",function(){
var index = layer.load();
var formData = new FormData();
formData.append("id",id);
$.ajax({
url:"{:U('delVoucher')}",
type:"post",
data:formData,
processData:false,
contentType:false,
success:function(data){
layer.close(index);
if(data.status == 1){
//file_path\
layer.msg("删除成功");
$('#voucher').attr("src",'').addClass("hide");
$('#delVoucher').addClass("hide");
$("#fileinput").val('');
}else{
layer.alert(data.info);
}
},
error:function(e){
layer.alert("网络错误");
}
});
})
});
</script>
</body>
</html>

@ -178,7 +178,10 @@
<td>{$data.admin_name}</td>
<td>{$data.create_time}</td>
<td>
<a class="confirm viewStatement" data-id="{$data.id}" data-type="{$data.statement_type}">查看</a>
<a class="confirm viewStatement" data-id="{$data.id}">查看</a>
<a class="confirm uploadVoucher" data-id="{$data.id}">上传凭证</a>
<a class="confirm viewVoucher" data-img="{$data.ext_field}" data-id="{$data.id}">查看凭证</a>
<a class="confirm editVoucher" data-id="{$data.id}">编辑凭证</a>
<switch name="data.verify_status">
<case value="-1">
<!-- <a class="confirm statement_view" id="createStatement" data-id="{$data.id}">申请开票</a> -->
@ -377,6 +380,48 @@
content:'/admin.php?s=/AggregateFinanceStatement/editStatement/id/'+id
});
});
//上传凭证
$(".uploadVoucher").click(function () {
var id = $(this).data("id");
layer.open({
type: 2,
title: "上传凭证",
shadeClose: true,
shade: 0.8,
area: ['60%', '60%'],
content:'/admin.php?s=/AggregateFinanceStatement/uploadVoucher/id/'+id,
end:function(){
reload();
}
});
});
//查看凭证
$(".viewVoucher").click(function () {
var img = $(this).data("img");
layer.open({
type: 1,
title:false,
content:"<img src='"+img+"' style='width: auto;height: 450px;margin: auto;'>"
});
});
//编辑凭证
$(".editVoucher").click(function () {
var id = $(this).data("id");
layer.open({
type: 2,
title: "编辑凭证",
shadeClose: true,
shade: 0.8,
area: ['60%', '60%'],
content:'/admin.php?s=/AggregateFinanceStatement/editVoucher/id/'+id,
end:function(){
reload();
}
});
});
//
// $("#downstream").click(function () {
// layer.open({

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title></title>
<link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/module.css">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
</head>
<style>
html {
min-width:100%;
}
body {
padding: 0px;
}
.hide{
display: none !important;
}
</style>
<body>
<div id="main" class="main" style="min-height: 342px;margin-top: 20px;padding-left: 50px;">
<table border="0" cellspacing="0" cellpadding="0">
<tr style="padding: 10px;height: 50px;">
<td class="l">文件选择: </td>
<td >
<input type="file" id="fileinput" name="file" accept="image/*">
</td>
<td style="color: #777;font-size: 12px;">仅能添加一张凭证,重复添加将覆盖</td>
</tr>
</table>
<div class="jssearch search_list fl cf">
<div class="input-list">
<div class="sch-btn uploadfile" style="width: 100px;padding: 5px;">确认添加</div>
<div id="delVoucher" class="sch-btn hide" style="width: 100px;padding: 5px;background-color: red;">删除凭证</div>
</div>
</div>
<div style="display: block;clear: both;">
<img id="voucher" src="" class="hide" style="width: auto;height: 350px;margin: auto;">
</div>
</div>
<script>
var id = {$id};
$(function(){
$(".uploadfile").on("click",function(){
var acceptedTypes = ['image/png','image/jpeg','image/jpg','image/gif'];
var type = document.getElementById('fileinput').files[0].type;
if (acceptedTypes.indexOf(type) === -1) {
layer.msg("只允许图片格式文件");
return false;
}
var formData = new FormData();
formData.append("id",id);
formData.append("file", document.getElementById("fileinput").files[0]);
var index = layer.load();
$.ajax({
url:"{:U('saveVoucher')}",
type:"post",
data:formData,
processData:false,
contentType:false,
success:function(data){
layer.close(index);
if(data.status == 1){
//file_path\
layer.msg("上传成功");
$('#voucher').attr("src",data.file_path).removeClass("hide");
$('#delVoucher').removeClass("hide");
$("#fileinput").val('');
}else{
layer.alert(data.info);
}
},
error:function(e){
layer.alert("网络错误");
}
});
})
$("#delVoucher").on("click",function(){
var index = layer.load();
var formData = new FormData();
formData.append("id",id);
$.ajax({
url:"{:U('delVoucher')}",
type:"post",
data:formData,
processData:false,
contentType:false,
success:function(data){
layer.close(index);
if(data.status == 1){
//file_path\
layer.msg("删除成功");
$('#voucher').attr("src",'').addClass("hide");
$('#delVoucher').addClass("hide");
$("#fileinput").val('');
}else{
layer.alert(data.info);
}
},
error:function(e){
layer.alert("网络错误");
}
});
})
});
</script>
</body>
</html>
Loading…
Cancel
Save