优化添加

master
chenzhi 5 years ago
parent e5dc86118e
commit b5a604d385

@ -55,9 +55,46 @@ class CompanyRelationController extends AdminController
public function addRelation()
{
if ($_POST) {
$params = I('post.');
if ($params['first_company_type'] == $params['second_company_type']) {
$this->error('合作甲乙双方不能是同类型公司');
}
if ($params['first_company_type']!=0 && $params['second_company_type']!=0) {
$this->error('合作甲乙双方必须有个是己方公司');
}
$params['remark'] = $params['remark'] ?? '';
$params['status'] = 0;
$params['verify_log']=json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]);
//判断已有未审核
$where = "
(
(first_company_type ='{$params['first_company_type']}' and first_company_id = '{$params['first_company_id']}')
OR
(first_company_type ='{$params['second_company_type']}' and first_company_id = '{$params['second_company_id']}')
)
AND
(
(second_company_type ='{$params['first_company_type']}' and second_company_id = '{$params['first_company_id']}')
OR
(second_company_type ='{$params['second_company_type']}' and second_company_id = '{$params['second_company_id']}')
)
AND
status < 2
";
$hasdb = $this->DBlogModel->field("count(id) count")->where($where)->find()['count'];
if($hasdb > 0){
$this->error('当前甲乙双方已有审批单,请直接搜索后修改');
}
$id = $this->DBlogModel->add($params);
addOperationLog(['op_type'=>0,'key'=>$id,'op_name'=>'新增','url'=>U('lists')]);
$this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("lists")]);
} else {
$this->assign('companyType',$this->CompanyType);
$this->display();
}
}
public function editRelation()
{

@ -305,6 +305,7 @@ $(function(){
}
},1500);
}else{
$(that).removeClass('disabled').prop('disabled',false);
layer.msg(data.msg,{icon: 2});
}
});

@ -95,7 +95,7 @@
<div class="tab-wrap">
<div class="tab-content tabcon1711" >
<!-- 表单 -->
<form id="form" action="{:U('addRatio')}" method="post" class="form-horizontal" >
<form id="form" action="{:U('addRelation')}" method="post" class="form-horizontal" >
<div style="display: flex;">
<!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1">
@ -193,6 +193,13 @@
</td>
</tr>
<tr>
<td class="l">开票内容:</td>
<td class="r table_radio">
<input type="text" name="invoice_content" id="invoice_content" class="input" value="技术服务费"></textarea>
</td>
</tr>
<tr>
<td class="l">是否有打款流程:</td>
<td class="r table_radio">
@ -287,8 +294,6 @@ $(function(){
var target = $('form').get(0).action;
var query = $('form').serialize();
var that = this;
console.log(query);
return false;
$(that).addClass('disabled').attr('autocomplete','off').prop('disabled',true);
$.post(target,query).success(function(data){
if(layer) {layer.closeAll('loading');}
@ -309,6 +314,7 @@ $(function(){
}
},1500);
}else{
$(that).removeClass('disabled').prop('disabled',false);
layer.msg(data.msg,{icon: 2});
}
});

@ -330,6 +330,7 @@ $(function(){
}
},1500);
}else{
$(that).removeClass('disabled').prop('disabled',false);
layer.msg(data.msg,{icon: 2});
}
});

Loading…
Cancel
Save