This commit is contained in:
weiz 2024-03-28 10:41:27 +08:00
parent 2feda57f3c
commit ab005f90c1
3 changed files with 125 additions and 104 deletions

View File

@ -1,77 +1,83 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\financial;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\financial\FinancialExpenseReimbursementDetail;
use app\common\lists\ListsSearchInterface;
/**
* 财务管理--费用报销单--报销明细列表
* Class FinancialExpenseReimbursementDetailLists
* @package app\adminapi\listsfinancial
*/
class FinancialExpenseReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function setSearch(): array
{
return [
'=' => ['expense_reimbursement_id'],
];
}
/**
* @notes 获取财务管理--费用报销单--报销明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function lists(): array
{
return FinancialExpenseReimbursementDetail::where($this->searchWhere)
->field(['id', 'expense_reimbursement_id', 'dept_id', 'date', 'subject_name', 'amount', 'abstract'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取财务管理--费用报销单--报销明细数量
* @return int
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function count(): int
{
return FinancialExpenseReimbursementDetail::where($this->searchWhere)->count();
}
}
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\financial;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\dept\Dept;
use app\common\model\financial\FinancialExpenseReimbursementDetail;
/**
* 财务管理--费用报销单--报销明细列表
* Class FinancialExpenseReimbursementDetailLists
* @package app\adminapi\listsfinancial
*/
class FinancialExpenseReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function setSearch(): array
{
return [
'=' => ['expense_reimbursement_id'],
];
}
/**
* @notes 获取财务管理--费用报销单--报销明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function lists(): array
{
return FinancialExpenseReimbursementDetail::where($this->searchWhere)
->field(['id', 'expense_reimbursement_id', 'dept_id', 'date', 'subject_name', 'amount', 'abstract'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($data) {
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
$data['dept_name'] = $dept['name'];
$data['subject_name_text'] = $data->subject_name_text;
})
->toArray();
}
/**
* @notes 获取财务管理--费用报销单--报销明细数量
* @return int
* @author likeadmin
* @date 2024/03/28 09:26
*/
public function count(): int
{
return FinancialExpenseReimbursementDetail::where($this->searchWhere)->count();
}
}

View File

@ -16,6 +16,7 @@
use app\common\logic\BaseLogic;
use app\common\model\dept\Dept;
use app\common\model\financial\FinancialExpenseReimbursementDetail;
use think\facade\Db;
@ -46,9 +47,8 @@
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'subject_name' => $params['subject_name'],
'amount' => $params['amount'],
'abstract' => $params['abstract'],
'abstract' => $params['abstract'] ?? '',
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -73,12 +73,12 @@
FinancialExpenseReimbursementDetail::where('id', $params['id'])->update([
'expense_reimbursement_id' => $params['expense_reimbursement_id'],
'dept_id' => $params['dept_id'],
'date' => $params['date'],
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'subject_name' => $params['subject_name'],
'amount' => $params['amount'],
'abstract' => $params['abstract'],
'abstract' => $params['abstract'] ?? '',
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
@ -111,6 +111,10 @@
*/
public static function detail($params): array
{
return FinancialExpenseReimbursementDetail::findOrEmpty($params['id'])->toArray();
$data = FinancialExpenseReimbursementDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
$data['dept_name'] = $dept['name'];
$data['subject_name_text'] = $data->subject_name_text;
return $data->toArray();
}
}

View File

@ -11,24 +11,35 @@
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\financial;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 财务管理--费用报销单--报销明细模型
* Class FinancialExpenseReimbursementDetail
* @package app\common\model\financial
*/
class FinancialExpenseReimbursementDetail extends BaseModel
{
use SoftDelete;
protected $name = 'financial_expense_reimbursement_detail';
protected $deleteTime = 'delete_time';
}
namespace app\common\model\financial;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 财务管理--费用报销单--报销明细模型
* Class FinancialExpenseReimbursementDetail
* @package app\common\model\financial
*/
class FinancialExpenseReimbursementDetail extends BaseModel
{
use SoftDelete;
protected $name = 'financial_expense_reimbursement_detail';
protected $deleteTime = 'delete_time';
public function getDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getSubjectNameTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'subject_category')->column('name', 'value');
return !empty($data['subject_name']) ? $dict[$data['subject_name']] : '';
}
}