- 在 app/functions.php 中添加 getOrderTypeName 函数,用于获取订单类型名称 - 在 config/middleware.php 中添加 psi 中间件配置,包括跨域中间件、初始化中间件、登录验证中间件、权限认证中间件和操作日志记录中间件
153 lines
4.8 KiB
PHP
153 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\psi\lists\psi_order;
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
use app\common\model\beforehand_order\BeforehandOrder;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\auth\Admin;
|
|
use app\common\model\supplier\Supplier;
|
|
use app\common\model\system_store\SystemStore;
|
|
use app\common\lists\ListsExcelInterface;
|
|
use app\common\model\psi\psi_order\PsiOrder;
|
|
use app\common\model\psi\warehouse\Warehouse;
|
|
|
|
/**
|
|
* 进销存单列表
|
|
* Class PsiOrderLists
|
|
* @package app\admin\listswarehouse_order
|
|
*/
|
|
class PsiOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author admin
|
|
* @date 2024/08/20 10:50
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['financial_pm', 'supplier_id', 'warehouse_id', 'store_id','id'],
|
|
'%like'=>['code'],
|
|
'between_time' => 'create_time'
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取仓储商品单列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author admin
|
|
* @date 2024/08/20 10:50
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
return PsiOrder::where($this->searchWhere)
|
|
->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time','oid', 'order_type'])
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order(['id' => 'desc'])
|
|
->select()->each(function ($item) {
|
|
if ($item->financial_pm == 0) {
|
|
$item->financial_pm_name = '出库';
|
|
} else {
|
|
$item->financial_pm_name = '入库';
|
|
}
|
|
if ($item->financial_pm == 0) {
|
|
if ($item->store_id) {
|
|
$item->system_store = SystemStore::where('id', $item->store_id)->value('name');
|
|
} else {
|
|
$item->system_store = '';
|
|
}
|
|
}
|
|
if ($item->admin_id) {
|
|
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
|
} else {
|
|
$item->admin_name = '';
|
|
}
|
|
if ($item->warehouse_id) {
|
|
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
|
} else {
|
|
$item->warehouse_name = '';
|
|
}
|
|
if ($item->supplier_id) {
|
|
$item->supplier_name = Supplier::where('id', $item->supplier_id)->value('mer_name');
|
|
}else{
|
|
$item->supplier_name = '';
|
|
}
|
|
if (!empty($item['order_type'])) {
|
|
$item->order_type_name = getOrderTypeName($item->order_type);
|
|
}
|
|
})
|
|
->toArray();
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取仓储商品单数量
|
|
* @return int
|
|
* @author admin
|
|
* @date 2024/08/20 10:50
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return PsiOrder::where($this->searchWhere)->count();
|
|
}
|
|
/**
|
|
* @notes 导出文件名
|
|
* @return string
|
|
* @date 2022/11/24 16:17
|
|
*/
|
|
public function setFileName(): string
|
|
{
|
|
$financial_pm = $this->request->get('financial_pm');
|
|
if ($financial_pm == 0) {
|
|
return '出库单列表';
|
|
} else {
|
|
return '入库单列表';
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 导出字段
|
|
* @return string[]
|
|
* @date 2022/11/24 16:17
|
|
*/
|
|
public function setExcelFields(): array
|
|
{
|
|
$financial_pm = $this->request->get('financial_pm');
|
|
if ($financial_pm == 1) {
|
|
$data = [
|
|
'create_time' => '操作时间',
|
|
'warehouse_name' => '仓库',
|
|
'supplier_name' => '供应商',
|
|
'code' => '单号',
|
|
'financial_pm_name' => '状态',
|
|
'admin_name' => '填写人员',
|
|
'completed_amount' => '已结金额',
|
|
'outstanding_amount' => '未结金额',
|
|
'total_price' => '总金额',
|
|
'mark' => '备注',
|
|
];
|
|
} else {
|
|
$data = [
|
|
'create_time' => '操作时间',
|
|
'warehouse_name' => '仓库',
|
|
'supplier_name' => '供应商',
|
|
'code' => '单号',
|
|
'financial_pm_name' => '状态',
|
|
'admin_name' => '填写人员',
|
|
'total_price' => '总金额',
|
|
'mark' => '备注',
|
|
];
|
|
}
|
|
return $data;
|
|
}
|
|
}
|