新增合同关联客户功能
This commit is contained in:
parent
4698613d06
commit
2bcbd38692
@ -203,5 +203,40 @@ class Api extends BaseController
|
||||
$content = $list->contract_log($param);
|
||||
return to_assign(0, '', $content);
|
||||
}
|
||||
|
||||
//获取客户列表
|
||||
public function get_customer()
|
||||
{
|
||||
$param = get_params();
|
||||
$where = array();
|
||||
if (!empty($param['keywords'])) {
|
||||
$where[] = ['id|name', 'like', '%' . $param['keywords'] . '%'];
|
||||
}
|
||||
$where[] = ['delete_time', '=', 0];
|
||||
$uid = $this->uid;
|
||||
$auth = isAuth($uid,'customer_admin');
|
||||
$dids = get_department_role($this->uid);
|
||||
if($auth==0){
|
||||
$whereOr[] =['belong_uid', '=', $uid];
|
||||
if(!empty($dids)){
|
||||
$whereOr[] =['belong_did', 'in', $dids];
|
||||
}
|
||||
$whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',share_ids)")];
|
||||
}
|
||||
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||
$list = Db::name('Customer')->field('id,name,address')->order('id asc')->where($where)->paginate($rows, false)->each(function($item, $key){
|
||||
$contact = Db::name('CustomerContact')->where(['cid'=>$item['id'],'is_default'=>1])->find();
|
||||
if(!empty($contact)){
|
||||
$item['contact_name'] = $contact['name'];
|
||||
$item['contact_mobile'] = $contact['mobile'];
|
||||
}
|
||||
else{
|
||||
$item['contact_name'] = '';
|
||||
$item['contact_mobile'] = '';
|
||||
}
|
||||
return $item;
|
||||
});
|
||||
table_assign(0, '', $list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,6 +169,8 @@ class Index extends BaseController
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$type = isset($param['type']) ? $param['type'] : 0;
|
||||
$pid = isset($param['pid']) ? $param['pid'] : 0;
|
||||
$is_customer = Db::name('DataAuth')->where('name','contract_admin')->value('expected_1');
|
||||
View::assign('is_customer', $is_customer);
|
||||
View::assign('id', $id);
|
||||
View::assign('type', $type);
|
||||
View::assign('pid', $pid);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<h3 class="pb-3">权限配置</h3>
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td colspan="4" class="red" style="line-height:1.8">
|
||||
<td colspan="6" class="red" style="line-height:1.8">
|
||||
<p><strong>合同模块使用说明:</strong></p>
|
||||
<p><strong>1、设置合同管理员,可设置多个</strong></p>
|
||||
<p style="text-indent:2em">a、拥有合同管理员权限的员工可以查看、编辑、作废、中止所有合同。</p>
|
||||
@ -29,17 +29,20 @@
|
||||
</td>
|
||||
<td class="layui-td-gray">权限标识</td>
|
||||
<td>{$detail.name}</td>
|
||||
<td class="layui-td-gray-2">开启关联客户</td>
|
||||
<td><input type="radio" name="expected_1" value="1" title="关联" {eq name="$detail.expected_1" value="1"}checked{/eq}>
|
||||
<input type="radio" name="expected_1" value="0" title="不关联" {eq name="$detail.expected_1" value="0"}checked{/eq}></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">权限人员<font>*</font>
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<td colspan="5">
|
||||
<input type="text" id="unames" name="unames" value="{$detail.unames}" readonly placeholder="请选择权限人员" autocomplete="off" class="layui-input picker-more">
|
||||
<input type="hidden" id="uids" name="uids" value="{$detail.uids}" lay-verify="required" lay-reqText="请选择权限人员">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="6">
|
||||
<span class="red" style="font-size: 12px;">{$detail.desc}</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -23,10 +23,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">合同编号<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="code" autocomplete="off" lay-verify="required" lay-reqText="请输入合同编号" placeholder="请输入合同编号" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">签约主体<span style="font-size:12px;">(乙方)</span><font>*</font></td>
|
||||
<td>
|
||||
<select name="subject_id" lay-verify="required" lay-reqText="请选择签约主体公司">
|
||||
@ -35,6 +31,10 @@
|
||||
<option value="{$v.id}">{$v.title}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
<td class="layui-td-gray">合同编号<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="code" autocomplete="off" lay-verify="required" lay-reqText="请输入合同编号" placeholder="请输入合同编号" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">合同类别<font>*</font></td>
|
||||
<td>
|
||||
@ -52,10 +52,12 @@
|
||||
{gt name="$pid" value="0"}
|
||||
<input type="text" name="customer" autocomplete="off" value="{$p_contract.customer}" readonly lay-verify="required" lay-reqText="请输入客户名称" placeholder="请输入客户名称" class="layui-input">
|
||||
{else/}
|
||||
<input type="text" name="customer" autocomplete="off" lay-verify="required" lay-reqText="请输入客户名称" placeholder="请输入客户名称" class="layui-input">
|
||||
{/gt}
|
||||
<input type="text" name="customer" autocomplete="off" {eq name="$is_customer" value="1"}readonly{/eq} lay-verify="required" lay-reqText="请输入客户名称" placeholder="请输入客户名称" class="layui-input {eq name="$is_customer" value="1"}customer-picker{/eq}">
|
||||
{/gt}
|
||||
<input type="hidden" name="customer_id" value="0">
|
||||
|
||||
</td>
|
||||
<td class="layui-td-gray">签约客户代表</td>
|
||||
<td class="layui-td-gray">签约客户代表<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="customer_name" autocomplete="off" lay-verify="required" lay-reqText="请输入客户代表姓名" placeholder="请输入客户代表姓名" class="layui-input">
|
||||
</td>
|
||||
@ -154,7 +156,7 @@
|
||||
<script>
|
||||
const moduleInit = ['tool','employeepicker'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,tool=layui.tool,laydate = layui.laydate,employeepicker = layui.employeepicker;
|
||||
var form = layui.form,tool=layui.tool,table = layui.table,laydate = layui.laydate,employeepicker = layui.employeepicker;
|
||||
//日期
|
||||
lay('.select-time').each(function () {
|
||||
laydate.render({
|
||||
@ -213,6 +215,62 @@
|
||||
tool.post("/contract/index/add", data.field, callback);
|
||||
return false;
|
||||
});
|
||||
|
||||
//选择关联的客户
|
||||
$('.customer-picker').on('click', function () {
|
||||
selectCustomer();
|
||||
});
|
||||
var customeTable;
|
||||
function selectCustomer() {
|
||||
layer.open({
|
||||
title: '选择客户',
|
||||
area: ['600px', '580px'],
|
||||
type: 1,
|
||||
content: '<div class="picker-table">\
|
||||
<form class="layui-form pb-2">\
|
||||
<div class="layui-input-inline" style="width:480px;">\
|
||||
<input type="text" name="keywords" placeholder="客户名称" class="layui-input" autocomplete="off" />\
|
||||
</div>\
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_form">提交搜索</button>\
|
||||
</form>\
|
||||
<div id="customerTable"></div></div>',
|
||||
success: function () {
|
||||
customeTable = table.render({
|
||||
elem: '#customerTable'
|
||||
, url: '/contract/api/get_customer'
|
||||
, page: true //开启分页
|
||||
, limit: 10
|
||||
, cols: [[
|
||||
{ type: 'radio', title: '选择' }
|
||||
, { field: 'id', width: 100, title: '编号', align: 'center' }
|
||||
, { field: 'name', title: '客户名称' }
|
||||
]]
|
||||
});
|
||||
},
|
||||
btn: ['确定'],
|
||||
yes: function () {
|
||||
var checkStatus = table.checkStatus(customeTable.config.id);
|
||||
var data = checkStatus.data;
|
||||
if (data.length > 0) {
|
||||
$('[name="customer_id"]').val(data[0].id);
|
||||
$('[name="customer"]').val(data[0].name);
|
||||
$('[name="customer_name"]').val(data[0].contact_name);
|
||||
$('[name="customer_mobile"]').val(data[0].contact_mobile);
|
||||
$('[name="customer_address"]').val(data[0].address);
|
||||
layer.closeAll();
|
||||
}
|
||||
else {
|
||||
layer.msg('请先选择客户');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//客户搜索提交
|
||||
form.on('submit(search_form)', function (data) {
|
||||
customeTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
@ -22,11 +22,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">合同编号<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="code" value="{$detail.code}" autocomplete="off" lay-verify="required" lay-reqText="请输入合同编号" placeholder="请输入合同编号" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">签约主体<span style="font-size:12px;">(甲方)</span><font>*</font></td>
|
||||
<td class="layui-td-gray">签约主体<span style="font-size:12px;">(乙方)</span><font>*</font></td>
|
||||
<td>
|
||||
<select name="subject_id" lay-verify="required" lay-reqText="请选择签约主体公司">
|
||||
<option value="">请选择签约主体公司</option>
|
||||
@ -34,6 +30,10 @@
|
||||
<option value="{$v.id}" {eq name="$v.id" value="$detail.subject_id" } selected{/eq}>{$v.title}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
<td class="layui-td-gray">合同编号<font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="code" value="{$detail.code}" autocomplete="off" lay-verify="required" lay-reqText="请输入合同编号" placeholder="请输入合同编号" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">合同类别<font>*</font></td>
|
||||
<td>
|
||||
@ -46,9 +46,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">客户名称<span style="font-size:12px;">(乙方)</span><font>*</font></td>
|
||||
<td class="layui-td-gray">客户名称<span style="font-size:12px;">(甲方)</span><font>*</font></td>
|
||||
<td>
|
||||
<input type="text" name="customer" value="{$detail.customer}" autocomplete="off" lay-verify="required" lay-reqText="请输入客户名称" placeholder="请输入客户名称" class="layui-input">
|
||||
<input type="text" name="customer" {eq name="$is_customer" value="1"}readonly{/eq} value="{$detail.customer}" autocomplete="off" lay-verify="required" lay-reqText="请输入客户名称" placeholder="请输入客户名称" class="layui-input {eq name="$is_customer" value="1"}customer-picker{/eq}">
|
||||
</td>
|
||||
<td class="layui-td-gray">签约客户代表</td>
|
||||
<td>
|
||||
@ -151,7 +151,7 @@
|
||||
<script>
|
||||
const moduleInit = ['tool','employeepicker'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,tool=layui.tool,laydate = layui.laydate,employeepicker = layui.employeepicker;
|
||||
var form = layui.form,tool=layui.tool,table = layui.table,laydate = layui.laydate,employeepicker = layui.employeepicker;
|
||||
//日期
|
||||
lay('.select-time').each(function () {
|
||||
laydate.render({
|
||||
@ -210,6 +210,62 @@
|
||||
tool.post("/contract/index/add", data.field, callback);
|
||||
return false;
|
||||
});
|
||||
|
||||
//选择关联的客户
|
||||
$('.customer-picker').on('click', function () {
|
||||
selectCustomer();
|
||||
});
|
||||
var customeTable;
|
||||
function selectCustomer() {
|
||||
layer.open({
|
||||
title: '选择客户',
|
||||
area: ['600px', '580px'],
|
||||
type: 1,
|
||||
content: '<div class="picker-table">\
|
||||
<form class="layui-form pb-2">\
|
||||
<div class="layui-input-inline" style="width:480px;">\
|
||||
<input type="text" name="keywords" placeholder="客户名称" class="layui-input" autocomplete="off" />\
|
||||
</div>\
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_form">提交搜索</button>\
|
||||
</form>\
|
||||
<div id="customerTable"></div></div>',
|
||||
success: function () {
|
||||
customeTable = table.render({
|
||||
elem: '#customerTable'
|
||||
, url: '/contract/api/get_customer'
|
||||
, page: true //开启分页
|
||||
, limit: 10
|
||||
, cols: [[
|
||||
{ type: 'radio', title: '选择' }
|
||||
, { field: 'id', width: 100, title: '编号', align: 'center' }
|
||||
, { field: 'name', title: '客户名称' }
|
||||
]]
|
||||
});
|
||||
},
|
||||
btn: ['确定'],
|
||||
yes: function () {
|
||||
var checkStatus = table.checkStatus(customeTable.config.id);
|
||||
var data = checkStatus.data;
|
||||
if (data.length > 0) {
|
||||
$('[name="customer_id"]').val(data[0].id);
|
||||
$('[name="customer"]').val(data[0].name);
|
||||
$('[name="customer_name"]').val(data[0].contact_name);
|
||||
$('[name="customer_mobile"]').val(data[0].contact_mobile);
|
||||
$('[name="customer_address"]').val(data[0].address);
|
||||
layer.closeAll();
|
||||
}
|
||||
else {
|
||||
layer.msg('请先选择客户');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//客户搜索提交
|
||||
form.on('submit(search_form)', function (data) {
|
||||
customeTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
@ -179,7 +179,7 @@
|
||||
title: '选择合同性质',
|
||||
type:1,
|
||||
area: ['480px', '336px'],
|
||||
content: '<div style="padding:4px 12px 0"><div id="boxselect"></div></div>',
|
||||
content: '<div class="picker-table"><div id="boxselect"></div></div>',
|
||||
success: function() {
|
||||
table_a = table.render({
|
||||
elem: '#boxselect',
|
||||
|
@ -8,6 +8,8 @@
|
||||
.layui-card-title {font-size: 18px;font-weight: 600;padding: 12px 12px 0;}
|
||||
.layui-table, .layui-table-view{margin:0; background-color:#fff;}
|
||||
.layui-table td, .layui-table th{padding:8px;}
|
||||
.picker-table{padding:8px;}
|
||||
.picker-table .layui-table-cell {padding:4px; height: 32px;line-height: 24px;}
|
||||
.layui-table-cell{padding:6px;}
|
||||
.layui-table-box{background-color:#fff;}
|
||||
.layui-table-page{background-color:#fff;border-bottom:1px solid #f1f1f1;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user