fix: 供应商检索

This commit is contained in:
2026-03-18 14:24:44 +08:00
parent daf1b166e1
commit 22396bb4ce
5 changed files with 244 additions and 25 deletions

View File

@@ -155,4 +155,52 @@ class Supplier extends Common
}
}
// 供应商检索
public function searchSuppliers()
{
$param = request()->param();
$currPage = isset($param['currPage']) ? $param['currPage'] : 1;
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 20;
// 构建查询条件
$where = [];
$where['company_type'] = 4; // 4代表供应商
// 公司名模糊搜索
if (isset($param['company_name']) && !empty($param['company_name'])) {
$where['company_name'] = ['like', '%' . $param['company_name'] . '%'];
}
// 查询供应商列表
$supplierList = db('partner_company')
->where($where)
->order('company_id', 'desc')
->page($currPage, $pageSize)
->select();
// 遍历供应商列表,补充服务类型信息
foreach ($supplierList as &$supplier) {
// 获取服务类型名称
if ($supplier['service_type']) {
$serviceType = db('partner_service_type')
->where('type_id', $supplier['service_type'])
->field('type_name')
->find();
$supplier['service_type_name'] = $serviceType ? $serviceType['type_name'] : '';
} else {
$supplier['service_type_name'] = '';
}
}
unset($supplier);
// 查询总记录数
$total = db('partner_company')->where($where)->count();
$res['list'] = $supplierList;
$res['total'] = $total;
return $this->sendSuccess($res);
}
}

View File

@@ -47,4 +47,13 @@ export default {
data: param
})
},
// 供应商检索
searchSuppliers(param) {
return request({
url: `/Supplier/searchSuppliers`,
method: 'post',
data: param
})
},
}

View File

@@ -13,8 +13,8 @@
</el-table-column>
<el-table-column prop="operate_time" label="操作时间" align="left">
</el-table-column>
<el-table-column fixed="right" label="操作" width="250px">
</el-table-column>
<!-- <el-table-column fixed="right" label="操作" width="250px">
</el-table-column> -->
</el-table>
<el-pagination style="margin-top: 10px;" background layout="sizes,prev, pager, next,->,total"
:page-sizes="[20, 50, 100]" :page-size="pageSize" :total="total" :pager-count="3"

View File

@@ -21,7 +21,7 @@
clearable/>
</el-form-item>
<el-form-item label="合同分类">
<el-select v-model="queryParam.contract_category" filterable placeholder="合同分类">
<el-select v-model="queryParam.contract_category" filterable placeholder="合同分类" @change="onSubmit">
<el-option label="全部合同" value="0"/>
<el-option label="销售合同" value="1"/>
<el-option label="销售技术协议" value="2"/>
@@ -247,7 +247,7 @@ export default {
try {
const params = {
contract_category: this.queryParam.contract_category,
page: this.currentPage,
currPage: this.currentPage,
pageSize: this.pageSize
}

View File

@@ -1,37 +1,199 @@
<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>
<div>
<el-form :inline="true" :model="queryParam" class="form-inline" style="margin-left: 10px;margin-top: 10px;">
<el-form-item label="公司名称">
<el-input
v-model="queryParam.company_name"
placeholder="请输入公司名称"
clearable
style="width: 250px;"
@keyup.enter.native="onSubmit"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
<el-button @click="onReset">重置</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
</el-row>
<!-- 供应商列表表格 -->
<el-row style="margin-top: 20px;">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>供应商列表</span>
<span style="float: right;"> {{ total }} 条记录</span>
</div>
<el-table
v-loading="loading"
:data="supplierList"
style="width: 100%"
stripe
border>
<el-table-column
prop="company_id"
label="供应商ID"
width="100"/>
<el-table-column
prop="company_name"
label="公司名称"
min-width="200"/>
<el-table-column
prop="service_type_name"
label="服务类型"
width="150">
<template slot-scope="scope">
{{ scope.row.service_type_name || '-' }}
</template>
</el-table-column>
<el-table-column
prop="company_address"
label="公司地址"
min-width="200">
<template slot-scope="scope">
{{ scope.row.company_address || '-' }}
</template>
</el-table-column>
<el-table-column
prop="contacts_name"
label="联系人"
width="120">
<template slot-scope="scope">
{{ scope.row.contacts_name || '-' }}
</template>
</el-table-column>
<el-table-column
prop="contacts_phone"
label="联系电话"
width="130">
<template slot-scope="scope">
{{ scope.row.contacts_phone || '-' }}
</template>
</el-table-column>
<el-table-column
prop="create_time"
label="创建时间"
width="160">
<template slot-scope="scope">
{{ scope.row.create_time || '-' }}
</template>
</el-table-column>
<template slot="empty">
<div style="padding: 20px;">
<i class="el-icon-office-building" style="font-size: 48px; color: #ddd;"/>
<p style="margin-top: 10px; color: #999;">暂无供应商数据</p>
</div>
</template>
</el-table>
<!-- 分页组件 -->
<div style="margin-top: 20px; text-align: right;">
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</el-card>
</el-row>
</div>
</template>
<script>
import supplierApi from '@/api/supplier'
export default {
data() {
data() {
return {
queryParam: {
company_name: ''
},
supplierList: [],
loading: false,
// 分页相关
currentPage: 1,
pageSize: 20,
total: 0
}
},
mounted() {
this.loadSuppliers()
},
methods: {
onSubmit() {
this.currentPage = 1
this.loadSuppliers()
},
onReset() {
this.queryParam.company_name = ''
this.currentPage = 1
this.loadSuppliers()
},
// 分页大小改变
handleSizeChange(val) {
this.pageSize = val
this.currentPage = 1
this.loadSuppliers()
},
// 当前页改变
handleCurrentChange(val) {
this.currentPage = val
this.loadSuppliers()
},
async loadSuppliers() {
this.loading = true
return {
};
},
mounted() {
try {
const params = {
company_name: this.queryParam.company_name,
currPage: this.currentPage,
pageSize: this.pageSize
}
},
created() {
const response = await supplierApi.searchSuppliers(params)
},
methods: {
}
const apiResponse = response.data || response
if (apiResponse.code === 20000) {
const data = apiResponse.data
this.supplierList = Array.isArray(data.list) ? data.list : []
this.total = parseInt(data.total) || 0
if (this.supplierList.length === 0 && this.queryParam.company_name) {
this.$message.info('未找到符合条件的供应商数据')
}
} else {
this.$message.error(apiResponse.msg || '查询失败')
this.supplierList = []
this.total = 0
}
} catch (error) {
console.error('查询供应商失败:', error)
this.$message.error('查询失败,请稍后重试')
this.supplierList = []
this.total = 0
} finally {
this.loading = false
}
}
}
}
</script>
<style scoped>
.about {
padding: 20px;
padding: 20px;
height: 100%;
}
</style>