Accept Merge Request #83: (feature/zy -> develop)
Merge Request: feature: 结算按钮 Created By: @zhuyu Accepted By: @zhuyu URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/83
This commit is contained in:
commit
b6b2554fa0
|
|
@ -107,7 +107,7 @@ class Task extends Backend
|
|||
|
||||
$list[$k]['refuse_reason'] = $row['refuse_reason'] ?? '';
|
||||
$list[$k]['fileurl'] = cdnurl($row['prove_file_path']);
|
||||
$list[$k]['filetype'] = pathinfo($list[$k]['url'], PATHINFO_EXTENSION);
|
||||
$list[$k]['filetype'] = pathinfo($list[$k]['fileurl'], PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
|
|
|||
|
|
@ -103,13 +103,24 @@ class Detail extends Backend
|
|||
$queryRes[$targetAdminId][$itemId] = $queryDatum['item_value'];
|
||||
}
|
||||
|
||||
$querySettleData = Db::name('salary_settle')
|
||||
->whereIn('target_admin_id', $adminIds)
|
||||
->where('salary_month', '=', $month)
|
||||
->field('id,target_admin_id,settle_status')
|
||||
->select();
|
||||
$querySettleRes = [];
|
||||
foreach ($querySettleData as $querySettleDatum) {
|
||||
$targetAdminId = $querySettleDatum['target_admin_id'];
|
||||
$querySettleRes[$targetAdminId] = $querySettleDatum['settle_status'];
|
||||
}
|
||||
|
||||
|
||||
foreach ($adminIds as $adminId) {
|
||||
$attrValue = [];
|
||||
$total = 0;
|
||||
foreach ($items as $item) {
|
||||
|
||||
$res[$adminId]['admin_id'] = $adminId;
|
||||
$res[$adminId]['target_admin_id'] = $adminId;
|
||||
$res[$adminId]['name'] = $adminNames[$adminId];
|
||||
$res[$adminId]['month'] = $month;
|
||||
|
||||
|
|
@ -132,6 +143,7 @@ class Detail extends Backend
|
|||
$jxTotal = ($attrValue['ZWJX'] - $attrValue['YYCB']) * $attrValue['TD'] / 100;
|
||||
$res[$adminId]['jx_total'] = $this->clean_number($jxTotal);
|
||||
$res[$adminId]['total'] = $this->clean_number($total + $jxTotal);
|
||||
$res[$adminId]['settle_status'] = $querySettleRes[$adminId] ?? 0;
|
||||
}
|
||||
|
||||
$res = array_values($res);
|
||||
|
|
@ -297,4 +309,38 @@ class Detail extends Backend
|
|||
}
|
||||
|
||||
|
||||
public function settle()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
|
||||
$targetAdminId = $this->request->get('target_admin_id');
|
||||
$month = $this->request->get('month');
|
||||
|
||||
|
||||
$settle = Db::name('salary_settle')
|
||||
->where('salary_month', $month)
|
||||
->where('target_admin_id', $targetAdminId)
|
||||
->field('target_admin_id,salary_month')->find();
|
||||
if (!empty($settle)) {
|
||||
Db::name('salary_settle')
|
||||
->where('salary_month', $month)
|
||||
->where('target_admin_id', $targetAdminId)
|
||||
->save([
|
||||
'settle_status' => 1,
|
||||
]);
|
||||
$this->success();
|
||||
}
|
||||
|
||||
Db::name('salary_settle')->insert([
|
||||
'target_admin_id' => $targetAdminId,
|
||||
'salary_month' => $month,
|
||||
'settle_status' => 1,
|
||||
]);
|
||||
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,15 +87,44 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{
|
||||
name: 'custom_edit',
|
||||
text: '编辑',
|
||||
title: '编辑薪资',
|
||||
title: '编辑',
|
||||
classname: 'btn btn-xs btn-success btn-dialog',
|
||||
icon: 'fa fa-edit',
|
||||
url: function (row) {
|
||||
// 注意这里拼接 admin_id 和 month
|
||||
return 'salary/detail/custom_edit?target_admin_id=' + row.admin_id + '&month=' + row.month;
|
||||
return 'salary/detail/custom_edit?target_admin_id=' + row.target_admin_id + '&month=' + row.month;
|
||||
},
|
||||
extend: 'data-area=\'["800px", "600px"]\'',
|
||||
},
|
||||
{
|
||||
name: 'complete',
|
||||
text:"结算",
|
||||
title:"结算",
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
|
||||
icon: 'fa fa-cny',
|
||||
url: function (row) {
|
||||
// 注意这里拼接 admin_id 和 month
|
||||
return 'salary/detail/settle?target_admin_id=' + row.target_admin_id + '&month=' + row.month;
|
||||
},
|
||||
confirm: '确认结算?',
|
||||
refresh: true,
|
||||
success: function (data, ret) {
|
||||
$("#table").bootstrapTable('refresh');
|
||||
return false;
|
||||
},
|
||||
error: function (data, ret) {
|
||||
Layer.alert(ret.msg);
|
||||
return false;
|
||||
},
|
||||
visible: function (row) {
|
||||
//返回true时按钮显示,返回false隐藏
|
||||
if (row.settle_status != 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
],
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user