Commit 6e8c0431 authored by hujun's avatar hujun

客户列表新增客户修改

parent e0aeccda
...@@ -10,7 +10,6 @@ namespace app\index\controller; ...@@ -10,7 +10,6 @@ namespace app\index\controller;
use app\api_broker\service\OrderLogService; use app\api_broker\service\OrderLogService;
use app\api_broker\untils\PlsDemo;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AAgents; use app\model\AAgents;
use app\model\OBargainModel; use app\model\OBargainModel;
......
...@@ -292,14 +292,15 @@ class Member extends Basic{ ...@@ -292,14 +292,15 @@ class Member extends Basic{
public function pcEditClient() { public function pcEditClient() {
$data = []; $data = [];
if (empty($this->params['user_nick']) || empty($this->params['id'])) { if (empty($this->params['user_nick']) || empty($this->params['user_phone'])) {
return $this->response(101, 'user_nick or user_phone or id is null'); return $this->response(101, 'user_nick or user_phone or id is null');
} }
if ($this->request->isPost()) { if ($this->request->isPost()) {
//编辑用户
if (isset($this->params['id'])) {
$user_data = $this->user->getUserById('id,agent_id', $this->params['id']); $user_data = $this->user->getUserById('id,agent_id', $this->params['id']);
if (empty($user_data)) { if (empty($user_data)) {
return $this->response(101, '没有用户信息'); return $this->response(101, '没有用户信息');
} else { } else {
...@@ -307,15 +308,38 @@ class Member extends Basic{ ...@@ -307,15 +308,38 @@ class Member extends Basic{
if ($this->params['agents_id'] != $user_data['agent_id']) { if ($this->params['agents_id'] != $user_data['agent_id']) {
$agent = new AAgents(); $agent = new AAgents();
$agent_data = $agent->getAgentInfo('name,phone', $this->params['agents_id']); $agent_data = $agent->getAgentInfo('name,phone', $this->params['agents_id']);
$remark = '修改客方为'.$agent_data['name'].'-'.$agent_data['phone']; $remark = '修改为' . $agent_data['name'] . '-' . $agent_data['phone'];
} else { } else {
$remark = '用户编辑'; $remark = '用户编辑';
} }
$data['start'] = $this->user->edit($this->params, $this->params['id']); //新增或编辑
}
} else {
//新增用户
$where['user_phone'] = $this->params['user_phone'];
$num = $this->user->all_user_count($where);
if ($num > 0) {
return $this->response(101, '该用户已经存在!');
}
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('name,phone', $this->params['agents_id']);
$remark = '新增为' . $agent_data['name'] . '-' . $agent_data['phone'];
$result = $this->user->edit($this->params, $this->params['id']); //新增或编辑
if ($result == -1) {
return $this->response(101, '该用户已经存在!');
}
$this->params['id'] = $result;
} }
$data['start'] = $this->user->edit($this->params, $this->params['id']); //新增或编辑
$this->operating_records($this->userId, $type=3, $remark, $this->params['id']); $this->operating_records($this->userId, $type=3, $remark, $this->params['id']);
} else { } else {
//编辑获取用户信息
if (empty(($this->params['id']))) {
return $this->response(101, 'Id is null');
}
$data['list'] = $this->user->getClient($this->params['id']); $data['list'] = $this->user->getClient($this->params['id']);
} }
return $this->response($this->code, $this->msg,$data); return $this->response($this->code, $this->msg,$data);
......
...@@ -67,9 +67,7 @@ ...@@ -67,9 +67,7 @@
<div class="pull-right"> <div class="pull-right">
<ul class="bread_btn"> <ul class="bread_btn">
<li> <li>
<!-- <a href="#modal_add_user" data-toggle="modal" class="btn btn-default"><i class="icon-plus"></i> <a href="#modal_add_user" data-toggle="modal" class="btn btn-default add_alert"><i class="icon-plus"></i>
添加客户</a> -->
<a href="#modal_add_user" data-toggle="modal" class="btn btn-default"><i class="icon-plus"></i>
添加客户</a> 添加客户</a>
</li> </li>
</ul> </ul>
......
...@@ -216,7 +216,8 @@ class Users extends Model ...@@ -216,7 +216,8 @@ class Users extends Model
$insert_data['source'] = 20; $insert_data['source'] = 20;
$insert_data['status'] = -1; $insert_data['status'] = -1;
$insert_data['create_time'] = date('Y-m-d H:i:s'); $insert_data['create_time'] = date('Y-m-d H:i:s');
$return_id = $this->save($insert_data); $this->save($insert_data);
$return_id = $this->id;
} else { } else {
$return_id = -1; $return_id = -1;
} }
......
auxiliary.org-netbeans-modules-php-smarty.smarty-framework=true
include.path=${php.global.include.path}
php.version=PHP_70
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>think</name>
</data>
</configuration>
</project>
...@@ -35,6 +35,12 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', ' ...@@ -35,6 +35,12 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
$("#close").click(function () { $("#close").click(function () {
document.getElementById("add_user_form").reset(); document.getElementById("add_user_form").reset();
$(".user-ul").empty();
});
$(".close").click(function(){
document.getElementById("add_user_form").reset();
$(".user-ul").empty();
}); });
$("#confirm_delete").click(function(){ $("#confirm_delete").click(function(){
...@@ -403,11 +409,10 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', ' ...@@ -403,11 +409,10 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
var params = {}; var params = {};
params.user_nick = $("#add_user_form input[name='user_nick']").val(); params.user_nick = $("#add_user_form input[name='user_nick']").val();
params.user_phone = $("#add_user_form input[name='user_phone']").val(); params.user_phone = $("#add_user_form input[name='user_phone']").val();
params.agent_id = $("#add_user_form input[name='agent_id']").val();//客方 params.agents_id = $("#add_user_form input[name='agent_id']").val();//客方
params.sex = $("#user_sex option:selected").val(); params.sex = $("#user_sex option:selected").val();
params.type = 'add';
if (params.realname == '') { if (params.user_nick == '') {
alert('姓名不能为空'); alert('姓名不能为空');
$("input[name='realname']").focus(); $("input[name='realname']").focus();
return ; return ;
...@@ -422,6 +427,11 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', ' ...@@ -422,6 +427,11 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
$("input[name='pwd']").focus(); $("input[name='pwd']").focus();
return ; return ;
} }
if (params.user_phone.length != 11) {
alert('手机号错误');
$("input[name='user_phone']").focus();
return ;
}
$.ajax ({ $.ajax ({
url: '/index/pcEditClient', url: '/index/pcEditClient',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment