新增推广公司添加

master
chenzhi 5 years ago
parent 6a612565c6
commit 1f1e75e736

@ -80,77 +80,35 @@ class PromoteCompanyController extends ThinkController
{
if ($_POST) {
$company_name = I('post.company_name', '');
$status = intval(I('post.status', 1));
if (empty($company_name)) {
$this->error('请输入推广公司名称');
}
if (empty(I('post.settlement_contact'))) {
$this->error('请输入结算联系人');
}
if (empty(I('post.contact_phone'))) {
$this->error('请输入联系人电话');
}
$pattern = "/^1[3|4|5|6|7|8|9]\\d{9}$/i";
if(!preg_match($pattern, I('post.contact_phone'))) {
$this->error("手机号码格式不合法");
return false;
}
if (empty(I('post.address'))) {
$this->error('请输入所在地址');
}
if (empty(I('post.bank_card'))) {
$this->error('请输入银行卡号');
}
$bank_card_pattern = "/^\d{10,19}$/u";
if (!preg_match($bank_card_pattern, I('post.bank_card'))) {
$this->error('卡号格式错误');
return false;
}
if (empty(I('post.bank_cardname'))) {
$this->error('请输入银行卡名');
}
if (empty(I('post.bank_name'))) {
$this->error('请输入收款银行');
}
if (empty(I('post.bank_address'))) {
$this->error('请输入开户网点');
}
if (!in_array($status, [0, 1])) {
$this->error('参数异常');
}
if (!empty(I('post.content'))) {
$save['content'] = I('post.content');
}
$model = M($this->modelName, 'tab_');
$map['company_name'] = $company_name;
$res = $model->where($map)->getField('id');
if ($res) {
$this->error('推广公司已存在');
$this->ajaxReturn(array(
'status' => 0,
'info' => "推广公司已经存在"
));
}
$time = time();
$save['company_name'] = $company_name;
$save['status'] = $status;
$save['uid'] = UID;
$save = I('post.');//前端已经验证
$save['create_time'] = $time;
$save['last_up_time'] = $time;
$save['settlement_contact'] = I('post.settlement_contact');
$save['contact_phone'] = I('post.contact_phone');
$save['address'] = I('post.address');
$save['bank_card'] = I('post.bank_card');
$save['bank_cardname'] = I('post.bank_cardname');
$save['bank_name'] = I('post.bank_name');
$save['bank_address'] = I('post.bank_address');
if(isset($save['resources'])){
$save['resources'] = json_encode($save['resources'],JSON_UNESCAPED_UNICODE);
}
$res = $model->add($save);
if ($res) {
\Think\Log::actionLog('PromoteCompany/add', 'partner', $res);
$this->success('保存成功', U('lists'));
$array=array(
"info"=>"添加成功",
"status"=>1
);
$this->ajaxReturn($array);
} else {
$this->error('保存失败');
$this->ajaxReturn(array(
'status' => 0,
'info' => "保存失败"
));
}
} else {
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'PromoteCompany/add'])->find());

@ -2,6 +2,8 @@
<block name="css">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<style>
#form .txt_area.download_url {width:400px;}
.tabcon1711 .table_radio2 .table_btn {width:215px;}
@ -14,7 +16,10 @@
<script type="text/javascript" src="__STATIC__/webuploader/webuploader.js"></script>
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"charset="UTF-8"></script>
<script src="__STATIC__/juicer-min.js" type="text/javascript"></script>
<script src="__STATIC__/czinputcheck.js?v=1.29" type="text/javascript"></script>
<style>
.coin-detail{
display: block;
@ -72,7 +77,7 @@
<tr>
<td class="l">开票税点:</td>
<td class="r" >
<input type="number" class="txt" name="fax_ratio" value="" placeholder="请输入开票税点">
<input type="number" class="txt" name="fax_ratio" value="0" placeholder="请输入开票税点">
<span>%</span>
</td>
</tr>
@ -139,12 +144,12 @@
<input type="text" class="txt " name="bank_card" value="" placeholder="请输入银行卡号">
</td>
</tr>
<tr>
<!-- <tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>银行卡名:</td>
<td class="r" >
<input type="text" class="txt " name="bank_cardname" value="" placeholder="请输入银行卡名">
</td>
</tr>
</tr> -->
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>收款银行:</td>
<td class="r" >
@ -252,6 +257,20 @@
PROMOTE.juicerFun();
// window.parent.addFile(info);
}
$('#contact_begin').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
minView: 2,
autoclose: true
});
$('#datetimepicker').datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
minView: 2,
autoclose: true,
pickerPosition: 'bottom-left'
})
$(".coin-detail").click(function () {
var url = $(this).data('url');
var title = '文档添加';
@ -264,6 +283,64 @@
content: url
});
});
var isclick = false;
$("#submit").on("click",function(){
if(isclick){
return;
}
isclick = true;
var obj = {
"company_name":["required","推广公司名称不允许为空"],
"platform_name":["nocheck"],
"contact_begin":["date","合同开始时间不能为空"],
"contact_end":["date","合同结束时间不能为空"],
"fax_ratio":["number","开票税率必须是数字如果无此项请填0"],
"company_type":["required","公司性质不能为空","select"],
"is_sign_contact":["required","是否签署合同项不能为空","select"],
"company_belong":["required","团体归属不能为空","select"],
"settlement_contact":["required","结算联系人不能为空"],
"contact_phone":["phone","联系人电话格式不对或不能为空"],
"address":["required","联系人地址不能为空"],
"bank_card":["bankid","银行卡格式错误或不能为空"],
"bank_name":["required","银行名称不能为空"],
"bank_address":["required","银行开户网点不能为空"],
"content":["nocheck"],
"status":["nocheck","","radio"]
}
var cres = CIC.checkAddInput(obj);
if(!cres){
return false;
}
if (Date.parse(cres.contact_begin) > Date.parse(cres.contact_end)) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
//验证通过
if(doc.length > 0){
cres.resources = doc;
}
//添加
$.ajax({
url:"{:U('PromoteCompany/add')}",
type:"post",
data:cres,
dataType:"json",
success:function(data){
isclick = false;
if(data.status == 1){
layer.msg(data.info,function(){
window.location.href="{:U('PromoteCompany/lists')}";
});
}else{
layer.msg(data.info);
}
},
error:function(e){
isclick = false;
}
});
})
var PROMOTE = {
juicerFun(){
var tpl =$("#doctpl").html();

@ -0,0 +1,80 @@
/**
* @info 前端input验证类
* @version 20200213
* @author chenzhi
* var obj = {
"type": ["required", "点击事件不能为空",'select'],
"sort":["number", "排序不能为空"],
"click_option": ["nocheck", "配置信息", "textarea"],
"remark": ["nocheck", "备注无需验证", "textarea"],
}
*/
(function(){
function czinputcheck(){
var cic = this;
cic.verify= {
required: [/[\S]+/, "必填项不能为空"],
phone: [/^1\d{10}$/, "请输入正确的手机号"],
email: [/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
url: [/(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
intnumber: [/^\d+$/, "数字格式错误,数字不能含有小数"],
number:[/^\d+(\.{1}\d+)?$/,"数字格式错误"],
date: [/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
identity: [/(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"],
password:[/^[\S]{6,12}$/,"密码必须6到12位且不能出现空格"],
isbn:[/^\d{13}$/, "isbn格式错误"],
price:[/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,"价格格式错误"],
bankid:[/^([1-9]{1})\d{9,19}$/,"银行卡格式错误"],
nocheck:[false,"无需验证,存在填,不存在舍弃"],
checkno:[false,"验证,存在填,不存在报错"],
};
cic.checkAddInput=function(arr){
var rearr = {};
for(var i in arr) {
var reg = cic.verify[arr[i][0]][0];
var name = "input";
var selecttypename='';
if(typeof arr[i][2] !== "undefined") name = arr[i][2];
if(name == "radio") {
name="input";
selecttypename=":checked";
}
if(!reg){
//nocheck时不验证
var val = $(name+"[name='"+i+"']"+selecttypename).val();
if(val != ''){
rearr[i]=val;
}
}else{
if(reg.test($(name+"[name='"+i+"']"+selecttypename).val())) {
rearr[i] = $(name+"[name='"+i+"']"+selecttypename).val();
}else {
layer.alert(arr[i][1], {
icon: 2,
skin: 'layer-ext-moon'
});
return false;
break;
}
}
}
return rearr;
};
cic.setEditData=function(ydata,ndata){
var data = {};
for (var i in ndata) {
if(ndata[i] != ydata[i]){
data[i] = ndata[i]
}
}
if($.isEmptyObject(data)) {
parent.layer.close(parent.layer.getFrameIndex(window.name));
return false;
}else{
data.id = ydata.id;
return data;
}
};
};
window.CIC = new czinputcheck();
})()
Loading…
Cancel
Save