feat(后台): 工资部分发放
parent
36a61f46b6
commit
f4f6f431ac
|
@ -29,7 +29,7 @@ use think\response\View;
|
||||||
*/
|
*/
|
||||||
class Pay extends Base
|
class Pay extends Base
|
||||||
{
|
{
|
||||||
protected $noNeedLogin = ['getAccountList', 'list'];
|
protected $noNeedLogin = ['getAccountList', 'list', 'listModify', 'payAll'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详情
|
* 详情
|
||||||
|
@ -144,6 +144,65 @@ class Pay extends Base
|
||||||
return $this->json(4000, '非法请求');
|
return $this->json(4000, '非法请求');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工资详情中的单个字段编辑
|
||||||
|
*
|
||||||
|
* @return Json
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function listModify(): Json
|
||||||
|
{
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
$item = input('post.');
|
||||||
|
$validate = $this->validateByApi($item, [
|
||||||
|
'field' => 'require',
|
||||||
|
'value' => 'require',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validate !== true) {
|
||||||
|
return $validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$info = PayMonthLog::findById($item['id'])) {
|
||||||
|
return $this->json(4001, '记录不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item['field'] != 'paid_amount') {
|
||||||
|
return $this->json(4001, '该项不支持修改');
|
||||||
|
}
|
||||||
|
|
||||||
|
$update = [$item['field'] => (float) $item['value']];
|
||||||
|
|
||||||
|
if ($item['field'] == 'paid_amount') {
|
||||||
|
if ($item['value'] < 0) {
|
||||||
|
return $this->json(4001, '发放工资不能小于0');
|
||||||
|
}
|
||||||
|
if ($item['value'] > $info['amount']) {
|
||||||
|
return $this->json(4001, '发放工资不能大于总工资');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item['value'] == $info['amount']) {
|
||||||
|
$update['status'] = 1;//全部发放
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item['value'] < $info['amount']) {
|
||||||
|
$update['status'] = 2;//部分发放
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$info->save($update);
|
||||||
|
return $this->json();
|
||||||
|
} catch (ValidateException $e) {
|
||||||
|
return $this->json(4001, $e->getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->json(4000, '非法请求');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*
|
*
|
||||||
|
@ -380,4 +439,25 @@ class Pay extends Base
|
||||||
$this->data['positionList'] = $position;
|
$this->data['positionList'] = $position;
|
||||||
return $this->view();
|
return $this->view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全部发放
|
||||||
|
public function payAll(): Json
|
||||||
|
{
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
$time = input('time/d', 0);
|
||||||
|
$accountId = input('user_id/d', 0);
|
||||||
|
if (!$time) {
|
||||||
|
return $this->json(4004, '参数错误');
|
||||||
|
}
|
||||||
|
|
||||||
|
PayMonthLog::where('time', $time)->where('account_id', $accountId)->update([
|
||||||
|
'status' => 1,
|
||||||
|
'paid_amount' => Db::raw('`amount`'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json(4001, '操作错误');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -254,7 +254,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect', 'laydate'
|
||||||
let listUrl = $('#table-container').data('url');
|
let listUrl = $('#table-container').data('url');
|
||||||
let insTb = table.render({
|
let insTb = table.render({
|
||||||
elem: '#table-container',
|
elem: '#table-container',
|
||||||
toolbar: '#toolbar-tpl',
|
toolbar: '#toolbar-tpl1',
|
||||||
defaultToolbar: ['filter', 'exports', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
|
defaultToolbar: ['filter', 'exports', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
|
||||||
title: '搜索'
|
title: '搜索'
|
||||||
, layEvent: 'search'
|
, layEvent: 'search'
|
||||||
|
@ -289,13 +289,59 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect', 'laydate'
|
||||||
{field: 'amount', minWidth: 100, title: '总计'},
|
{field: 'amount', minWidth: 100, title: '总计'},
|
||||||
{field: 'base_amount', minWidth: 100, title: '基本工资'},
|
{field: 'base_amount', minWidth: 100, title: '基本工资'},
|
||||||
{field: 'overtime_amount', minWidth: 100, title: '加班工资'},
|
{field: 'overtime_amount', minWidth: 100, title: '加班工资'},
|
||||||
{field: 'paid_amount', minWidth: 100, title: '已发工资'},
|
{field: 'paid_amount', minWidth: 100, title: '已发工资', edit: 'text'},
|
||||||
{field: 'status_text', minWidth: 100, title: '状态'},
|
// {field: 'status_text', minWidth: 100, title: '状态'},
|
||||||
]],
|
]],
|
||||||
done: function () {
|
done: function () {
|
||||||
Tools.setInsTb(insTb);
|
Tools.setInsTb(insTb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
table.on('toolbar(table-container-filter)', function (obj) {
|
||||||
|
let layEvent = obj.event;
|
||||||
|
let insTb = Tools.getInsTb();
|
||||||
|
let url = $($(this).context).data('href')
|
||||||
|
|
||||||
|
// debugger;
|
||||||
|
switch (layEvent) {
|
||||||
|
// toolbar 刷新
|
||||||
|
case 'pay-all':
|
||||||
|
let index = layer.confirm('确认一件全部发放吗?此操作将下列所有工地工资全部发放', {
|
||||||
|
btn: ['确认', '取消'], //按钮
|
||||||
|
title: '操作提示',
|
||||||
|
}, function () {
|
||||||
|
$.post(url, function (res) {
|
||||||
|
layer.close(index)
|
||||||
|
layer.msg(res.msg)
|
||||||
|
if (res.code === 0) {
|
||||||
|
insTb.reload();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, function () {
|
||||||
|
layer.close(index)
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
case 'refresh':
|
||||||
|
refreshTab(insTb);
|
||||||
|
return false;
|
||||||
|
// toolbar 搜索
|
||||||
|
case 'search':
|
||||||
|
let search = $('.table-search-fieldset');
|
||||||
|
if (search.hasClass('div-show')) {
|
||||||
|
search.css('display', 'none').removeClass('div-show');
|
||||||
|
} else {
|
||||||
|
search.css('display', 'block').addClass('div-show');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
// 其他 默认为打开弹出层
|
||||||
|
default:
|
||||||
|
if (layEvent !== 'LAYTABLE_COLS' && layEvent !== 'LAYTABLE_EXPORT') {
|
||||||
|
openLayer(url, title, width, height);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
|
@ -33,9 +33,9 @@
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">状态</label>
|
<label class="layui-form-label">状态</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<!-- <input type="radio" name="status" value="0" title="待发放" {if $item.status == '0'} checked {/if}>-->
|
<input type="text" readonly class="layui-input" value="{if $item.amount == $item.paid_amount}全部发放{/if}
|
||||||
<!-- <input type="radio" name="status" value="1" title="全部发放" {if $item.status == '1'} checked {/if}>-->
|
{if $item.paid_amount <= 0}待发放{/if}
|
||||||
<!-- <input type="radio" name="status" value="2" title="部分发放" {if $item.status == '2'} checked {/if}>-->
|
{if $item.paid_amount > 0 && $item.paid_amount < $item.amount}部分发放{/if}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,4 +62,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 隐藏列 -->
|
||||||
|
<!-- 编辑单元格提交url -->
|
||||||
|
<input type="hidden" id="row-modify" data-url="/manager/pay/list-modify">
|
||||||
|
|
||||||
|
<!-- toolbar -->
|
||||||
|
<script type="text/html" id="toolbar-tpl1">
|
||||||
|
<a class="layui-btn layui-btn-primary layui-btn-sm" data-table-refresh lay-event="refresh"><i class="fa fa-refresh"></i></a>
|
||||||
|
<a class="layui-btn layui-btn-normal layui-btn-sm" data-href="/manager/pay/pay-all.html?time={$item.time ?? 0}&user_id={$item.account_id}" data-title="一键发放" lay-event="pay-all">全部发放</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="__MANAGER__/js/pay/pay.js?v={:mt_rand()}"></script>
|
<script src="__MANAGER__/js/pay/pay.js?v={:mt_rand()}"></script>
|
Loading…
Reference in New Issue