fix: 客户检索分页查询
This commit is contained in:
@@ -129,4 +129,46 @@ class Customer extends Common
|
||||
return $this->sendSuccess($ret);
|
||||
}
|
||||
|
||||
// 客户检索 - 分页查询合作伙伴公司
|
||||
public function SearchPartnerCompany()
|
||||
{
|
||||
$param = request()->post();
|
||||
|
||||
$currPage = isset($param['page']) ? $param['page'] : 1;
|
||||
$pageSize = isset($param['limit']) ? $param['limit'] : 10;
|
||||
$company_name = isset($param['company_name']) ? $param['company_name'] : '';
|
||||
|
||||
// 构建查询条件
|
||||
$query = db('partner_company');
|
||||
|
||||
// 查询客户类型
|
||||
$query->whereIn('company_type', [1, 5]);
|
||||
|
||||
if (!empty($company_name)) {
|
||||
$query->where('company_name', 'like', '%' . $company_name . '%');
|
||||
}
|
||||
|
||||
// 查询列表数据
|
||||
$list = $query->page($currPage, $pageSize)
|
||||
->order('company_id desc')
|
||||
->select();
|
||||
|
||||
// 查询总记录数
|
||||
$totalQuery = db('partner_company');
|
||||
$totalQuery->whereIn('company_type', [1, 5]);
|
||||
|
||||
if (!empty($company_name)) {
|
||||
$totalQuery->where('company_name', 'like', '%' . $company_name . '%');
|
||||
}
|
||||
|
||||
$total = $totalQuery->count();
|
||||
|
||||
$result = [
|
||||
'list' => $list,
|
||||
'total' => $total
|
||||
];
|
||||
|
||||
return $this->sendSuccess($result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -831,9 +831,10 @@ class Work extends Common
|
||||
$user_id = $param['user_id'];
|
||||
$currPage = isset($param['currPage']) ? $param['currPage'] : 1;
|
||||
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 10;
|
||||
$project_name = isset($param['project_name']) ? $param['project_name'] : '';
|
||||
|
||||
$user = new User();
|
||||
$project_work = $this->GetProjectListPaginated($user_id, $currPage, $pageSize);
|
||||
$project_work = $this->GetProjectListPaginated($user_id, $currPage, $pageSize, $project_name);
|
||||
|
||||
for ($i = 0; $i < count($project_work['list']); $i++) {
|
||||
$involve_manager = $project_work['list'][$i]['involve_manager'];
|
||||
@@ -849,7 +850,7 @@ class Work extends Common
|
||||
}
|
||||
|
||||
//获取参与的客户项目列表 - 分页版本
|
||||
public function GetProjectListPaginated($user_id, $currPage, $pageSize)
|
||||
public function GetProjectListPaginated($user_id, $currPage, $pageSize, $project_name = '')
|
||||
{
|
||||
//判断登录用户的角色,如果是管理员,就获取所有的项目信息
|
||||
$user_info = db('system_user')->where('id', $user_id)->find();
|
||||
@@ -859,6 +860,11 @@ class Work extends Common
|
||||
->where('p.project_state', '<', 10) //未关闭的项目
|
||||
->field('p.*, s.desp as project_state_name,1 as project_types');
|
||||
|
||||
// 添加项目名称模糊查询
|
||||
if (!empty($project_name)) {
|
||||
$query->where('p.project_name', 'like', '%' . $project_name . '%');
|
||||
}
|
||||
|
||||
if (1 != $user_info['user_role']) {
|
||||
$query->where(function ($query) use ($user_id) {
|
||||
$query->where('p.involve_manager', $user_id)
|
||||
@@ -877,6 +883,11 @@ class Work extends Common
|
||||
->join('project_state s', 's.id =p.project_state', 'left')
|
||||
->where('p.project_state', '<', 10);
|
||||
|
||||
// 添加项目名称模糊查询到总数查询
|
||||
if (!empty($project_name)) {
|
||||
$totalQuery->where('p.project_name', 'like', '%' . $project_name . '%');
|
||||
}
|
||||
|
||||
if (1 != $user_info['user_role']) {
|
||||
$totalQuery->where(function ($query) use ($user_id) {
|
||||
$query->where('p.involve_manager', $user_id)
|
||||
|
||||
@@ -1,76 +1,89 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export default {
|
||||
|
||||
//获取客户信息列表
|
||||
GetCustomerList(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
//添加客户信息
|
||||
AddCustomerInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/AddCustomerInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
GetProjectInfoList(param) {
|
||||
return request({
|
||||
url: `/Project/GetProjectInfoList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
AddProjectInfo(param) {
|
||||
return request({
|
||||
url: `/Project/AddProjectInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
UpdateProjectInfo(param) {
|
||||
return request({
|
||||
url: `/Project/updateProjectInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
//添加客户联系人
|
||||
AddCustomerMemberInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/AddCustomerMemberInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
GetCustomerMemberList(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerMemberList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
GetCustomerInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取客户信息列表
|
||||
export function GetCustomerList(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
// 添加客户信息
|
||||
export function AddCustomerInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/AddCustomerInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export function GetProjectInfoList(param) {
|
||||
return request({
|
||||
url: `/Project/GetProjectInfoList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export function AddProjectInfo(param) {
|
||||
return request({
|
||||
url: `/Project/AddProjectInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export function UpdateProjectInfo(param) {
|
||||
return request({
|
||||
url: `/Project/updateProjectInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
// 添加客户联系人
|
||||
export function AddCustomerMemberInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/AddCustomerMemberInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export function GetCustomerMemberList(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerMemberList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export function GetCustomerInfo(param) {
|
||||
return request({
|
||||
url: `/Customer/GetCustomerInfo`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
// 客户检索 - 搜索合作伙伴公司
|
||||
export function searchPartnerCompany(param) {
|
||||
return request({
|
||||
url: `/Customer/SearchPartnerCompany`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
GetCustomerList,
|
||||
AddCustomerInfo,
|
||||
GetProjectInfoList,
|
||||
AddProjectInfo,
|
||||
UpdateProjectInfo,
|
||||
AddCustomerMemberInfo,
|
||||
GetCustomerMemberList,
|
||||
GetCustomerInfo,
|
||||
searchPartnerCompany
|
||||
}
|
||||
|
||||
@@ -1,30 +1,140 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<el-row>
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>客户检索</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="about">
|
||||
<el-row>
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>客户检索</span>
|
||||
</div>
|
||||
|
||||
<!-- 搜索表单 -->
|
||||
<el-form :inline="true" :model="searchForm" class="search-form">
|
||||
<el-form-item label="公司名称">
|
||||
<el-input
|
||||
v-model="searchForm.company_name"
|
||||
placeholder="请输入公司名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleSearch"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :loading="loading" type="primary" @click="handleSearch">搜索</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
style="width: 100%">
|
||||
<el-table-column prop="company_id" label="公司ID" width="80"/>
|
||||
<el-table-column prop="company_name" label="公司名称" min-width="200"/>
|
||||
<el-table-column prop="company_intro" label="公司介绍" min-width="200"/>
|
||||
<el-table-column prop="company_type" label="公司类型" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.company_type == 1" type="primary">客户</el-tag>
|
||||
<el-tag v-else type="warning">供应商/客户</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column prop="contact_person" label="联系人" width="120"></el-table-column>-->
|
||||
<!-- <el-table-column prop="contact_phone" label="联系电话" width="140"></el-table-column>-->
|
||||
<!-- <el-table-column prop="contact_email" label="联系邮箱" min-width="180"></el-table-column>-->
|
||||
<el-table-column prop="address" label="地址" min-width="200"/>
|
||||
<el-table-column prop="create_time" label="创建时间" width="160"/>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="pagination-container">
|
||||
<el-pagination
|
||||
:current-page="pagination.page"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pagination.limit"
|
||||
:total="pagination.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { searchPartnerCompany } from '@/api/customer'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
searchForm: {
|
||||
company_name: ''
|
||||
},
|
||||
tableData: [],
|
||||
pagination: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList()
|
||||
},
|
||||
created() {
|
||||
|
||||
return {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
// 获取列表数据
|
||||
getList() {
|
||||
this.loading = true
|
||||
const params = {
|
||||
page: this.pagination.page,
|
||||
limit: this.pagination.limit,
|
||||
company_name: this.searchForm.company_name
|
||||
}
|
||||
|
||||
},
|
||||
created() {
|
||||
searchPartnerCompany(params).then(response => {
|
||||
console.log('API响应:', response) // 调试用
|
||||
if (response.data.success || response.data.code === 20000) {
|
||||
this.tableData = response.data.data.list
|
||||
this.pagination.total = response.data.data.total
|
||||
} else {
|
||||
this.$message.error(response.data.message || '获取数据失败')
|
||||
}
|
||||
this.loading = false
|
||||
}).catch(error => {
|
||||
console.error('获取数据失败:', error)
|
||||
this.$message.error('获取数据失败')
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
// 搜索
|
||||
handleSearch() {
|
||||
this.pagination.page = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.searchForm.company_name = ''
|
||||
this.pagination.page = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
// 每页显示条数改变
|
||||
handleSizeChange(val) {
|
||||
this.pagination.limit = val
|
||||
this.pagination.page = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
// 当前页改变
|
||||
handleCurrentChange(val) {
|
||||
this.pagination.page = val
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -34,4 +144,12 @@ export default {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -87,6 +87,21 @@
|
||||
<div slot="header" class="clearfix">
|
||||
<span>我参与的项目</span>
|
||||
</div>
|
||||
<!-- 添加搜索表单 -->
|
||||
<el-form :inline="true" size="small" style="margin-bottom: 15px;">
|
||||
<el-form-item label="项目名称">
|
||||
<el-input
|
||||
v-model="work_info_project_name"
|
||||
placeholder="请输入项目名称"
|
||||
clearable
|
||||
style="width: 200px;"
|
||||
@keyup.enter.native="handleProjectSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleProjectSearch">搜索</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="work_info_list" border fit highlight-current-row style="width: 100%; margin-left: 2px;">
|
||||
<!--el-table-column prop="project_number" label="项目编号" align="left">
|
||||
</el-table-column-->
|
||||
@@ -254,6 +269,7 @@ export default {
|
||||
work_info_total: 0,
|
||||
work_info_pageNum: 1,
|
||||
work_info_pageSize: 10,
|
||||
work_info_project_name: '', // 添加项目名称搜索变量
|
||||
work_story_list: [],
|
||||
work_story_total: 0,
|
||||
work_story_pageNum: 1,
|
||||
@@ -599,7 +615,8 @@ export default {
|
||||
var param = {
|
||||
user_id: localStorage.getItem('user_id'),
|
||||
currPage: this.work_info_pageNum,
|
||||
pageSize: this.work_info_pageSize
|
||||
pageSize: this.work_info_pageSize,
|
||||
project_name: this.work_info_project_name
|
||||
}
|
||||
work.GetWorkInfoByLoginIdPaginated(param).then(res => {
|
||||
this.work_info_list = res.data.data.list
|
||||
@@ -620,6 +637,11 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
handleProjectSearch() {
|
||||
this.work_info_pageNum = 1 // 重置到第一页
|
||||
this.get_work_info_list()
|
||||
},
|
||||
|
||||
showWorkTask(storyId) {
|
||||
this.story_id = storyId
|
||||
this.dialogVisibleShowWorkTask = true
|
||||
|
||||
Reference in New Issue
Block a user