feature: auth
This commit is contained in:
parent
32848f79e8
commit
a339bdf316
|
|
@ -72,98 +72,6 @@ class Schedule extends Backend
|
|||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function custom_index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
$this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if ($this->request->isAjax()) {
|
||||
|
||||
|
||||
$filter = $this->request->param('filter');
|
||||
$filter = json_decode($filter, true);
|
||||
|
||||
$startDate = date('Y-m-01');
|
||||
$endDate = date('Y-m-t');
|
||||
|
||||
if (isset($filter['timetype']) && $filter['timetype'] == 2) {
|
||||
$startDate = date('Y-m-d', strtotime('monday this week'));
|
||||
$endDate = date('Y-m-d', strtotime('sunday this week'));
|
||||
}
|
||||
|
||||
$res = [];
|
||||
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
$admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select();
|
||||
} else{
|
||||
$admins = Db::name('admin')->field('id,nickname')->select();
|
||||
}
|
||||
|
||||
$admins = array_column($admins, NULL, 'id');
|
||||
$adminIds = array_keys($admins);
|
||||
|
||||
$adminNames = array_column($admins, 'nickname', 'id');
|
||||
|
||||
$tmpDate = $startDate;
|
||||
$dates = [];
|
||||
while(true) {
|
||||
|
||||
if ($tmpDate > $endDate) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($adminIds as $adminId) {
|
||||
$res[$adminId][$tmpDate] = '无';
|
||||
$res[$adminId]['admin_id'] = $adminId;
|
||||
$res[$adminId]['name'] = $adminNames[$adminId];
|
||||
$res[$adminId]['editable'] = $this->auth->check('oa/schedule/custom_edit') ? 1 : 0;
|
||||
}
|
||||
|
||||
$dates[] = $tmpDate;
|
||||
$tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400);
|
||||
}
|
||||
|
||||
$builder = $this->model
|
||||
->with([
|
||||
'admin'
|
||||
])
|
||||
->where('date', '>=', $startDate)
|
||||
->where('date', '<=', $endDate);
|
||||
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
$builder = $builder->where('exec_admin_id', $this->auth->id);
|
||||
}
|
||||
|
||||
$queryData = $builder->select();
|
||||
foreach ($queryData as $queryDatum) {
|
||||
$queryDatum = $queryDatum->toArray();
|
||||
|
||||
$adminId = $queryDatum['admin']['id'];
|
||||
$date = $queryDatum['date'];
|
||||
$type = $queryDatum['type'];
|
||||
|
||||
if (isset($res[$adminId][$date])) {
|
||||
$res[$adminId][$date] = $this->model->getTypeList()[$type];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$res = array_values($res);
|
||||
|
||||
$result = array("total" => count($res), "rows" => $res);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
$timeType = [
|
||||
1 => '本月排班',
|
||||
2 => '本周排班',
|
||||
];
|
||||
$this->view->assign("timetype", $timeType);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
|
|
@ -262,59 +170,4 @@ class Schedule extends Backend
|
|||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
public function editable()
|
||||
{
|
||||
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
|
||||
|
||||
$date = $params['field'];
|
||||
$adminId = $params['admin_id'];
|
||||
|
||||
$value = $params[$date] ?? '无';
|
||||
$valueMap = [
|
||||
'无' => 0,
|
||||
'早班' => 1,
|
||||
'中班' => 2,
|
||||
'晚班' => 3,
|
||||
'行政班' => 4,
|
||||
];
|
||||
|
||||
if ($value == '无') {
|
||||
$this->model->where('exec_admin_id', $adminId)->delete();
|
||||
$this->success();
|
||||
}
|
||||
|
||||
$dbValue = $valueMap[$value];
|
||||
|
||||
$data = $this->model
|
||||
->where('date', '=', $date)
|
||||
->where('exec_admin_id', '=', $adminId)
|
||||
->find();
|
||||
|
||||
$nowTime = date('Y-m-d H:i:s');
|
||||
if (!empty($data)) {
|
||||
$data->save([
|
||||
"date" => $date,
|
||||
"exec_admin_id" => $adminId,
|
||||
"type" => $dbValue,
|
||||
"update_time" => $nowTime,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->model->insert([
|
||||
"date" => $date,
|
||||
"exec_admin_id" => $adminId,
|
||||
"type" => $dbValue,
|
||||
"create_time" => $nowTime,
|
||||
"update_time" => $nowTime,
|
||||
]);
|
||||
|
||||
$this->success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,130 +36,6 @@ class Detail extends Backend
|
|||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function custom_index()
|
||||
{
|
||||
//当前是否为关联查询
|
||||
$this->relationSearch = true;
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
|
||||
$items = Db::name('salary_item')->field('id,attr,type,name')->select();
|
||||
|
||||
$salaryItem = [];
|
||||
foreach ($items as $item) {
|
||||
$idAttr[$item['id']] = $item['attr'];
|
||||
if ($item['attr'] == 'JXKHJL') {
|
||||
$salaryItem[] = [
|
||||
'id' => 'jx_total',
|
||||
'name' => '绩效提成',
|
||||
];
|
||||
}
|
||||
$salaryItem[] = [
|
||||
'id' => 'item_' . $item['id'],
|
||||
'name' => $item['name'],
|
||||
];
|
||||
}
|
||||
$salaryItem[] = [
|
||||
'id' => 'total',
|
||||
'name' => '总计',
|
||||
];
|
||||
|
||||
$month = date('Y-m-01');
|
||||
|
||||
if ($this->request->isAjax()) {
|
||||
|
||||
|
||||
$filter = $this->request->param('filter');
|
||||
$filter = json_decode($filter, true);
|
||||
|
||||
if (!empty($filter['month'])) {
|
||||
$month = $filter['month'] . '-01';
|
||||
}
|
||||
|
||||
$res = [];
|
||||
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
$admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select();
|
||||
} else{
|
||||
$admins = Db::name('admin')->field('id,nickname')->select();
|
||||
}
|
||||
|
||||
$admins = array_column($admins, NULL, 'id');
|
||||
$adminIds = array_keys($admins);
|
||||
|
||||
$adminNames = array_column($admins, 'nickname', 'id');
|
||||
|
||||
$builder = $this->model
|
||||
->where('salary_month', '=', $month);
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
$builder = $builder->where('target_admin_id', $this->auth->id);
|
||||
}
|
||||
|
||||
$queryData = $builder->select();
|
||||
$queryRes = [];
|
||||
foreach ($queryData as $queryDatum) {
|
||||
$targetAdminId = $queryDatum['target_admin_id'];
|
||||
$itemId = $queryDatum['item_id'];
|
||||
$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]['target_admin_id'] = $adminId;
|
||||
$res[$adminId]['name'] = $adminNames[$adminId];
|
||||
$res[$adminId]['month'] = $month;
|
||||
|
||||
$itemKey = 'item_' . $item['id'];
|
||||
|
||||
$value = 0;
|
||||
|
||||
if (!empty($queryRes[$adminId][$item['id']])) {
|
||||
$value = $this->clean_number($queryRes[$adminId][$item['id']]);
|
||||
$total = $this->calc_total($total, $item['type'], $queryRes[$adminId][$item['id']]);
|
||||
}
|
||||
|
||||
$attrValue[$item['attr']] = $value;
|
||||
if ($item['attr'] == 'TD') {
|
||||
$value = $value . '%';
|
||||
}
|
||||
$res[$adminId][$itemKey] = $value;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
$result = array("total" => count($res), "rows" => $res);
|
||||
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
$this->assignconfig("manage", $this->auth->check('salary/detail/custom_edit'));
|
||||
$this->view->assign("month", $month);
|
||||
$this->view->assign("salaryitem", json_encode($salaryItem));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function calc_total($total, $type, $value){
|
||||
if ($type == 1) {
|
||||
return $total + $value;
|
||||
|
|
@ -175,140 +51,6 @@ class Detail extends Backend
|
|||
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
|
||||
}
|
||||
|
||||
public function custom_add()
|
||||
{
|
||||
|
||||
if (false === $this->request->isPost()) {
|
||||
|
||||
$items = Db::name('salary_item')->field('id,type,name')->select();
|
||||
|
||||
$typeMap = [
|
||||
1 => '应发工资',
|
||||
2 => '应扣款项',
|
||||
3 => '其他'
|
||||
];
|
||||
$groupedItems = [];
|
||||
foreach ($items as $item) {
|
||||
$type = $item['type'];
|
||||
$label = $typeMap[$type];
|
||||
$groupedItems[$label][] = $item;
|
||||
}
|
||||
|
||||
$this->view->assign('groupedItems', $groupedItems);
|
||||
$this->view->assign('items', $items);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
|
||||
|
||||
$month = $params['salary_month'] . '-01';
|
||||
$targetAdminId = $params['target_admin_id'];
|
||||
$salaryDetails = [];
|
||||
|
||||
foreach ($params as $k => $v) {
|
||||
if (!str_contains($k, 'item')) {
|
||||
continue;
|
||||
}
|
||||
$salaryDetails[] = [
|
||||
'target_admin_id' => $targetAdminId,
|
||||
'salary_month' => $month,
|
||||
'item_id' => explode('_', $k)[1],
|
||||
'item_value' => $v,
|
||||
];
|
||||
}
|
||||
|
||||
Db::name('salary_detail')
|
||||
->where('salary_month', $month)
|
||||
->where('target_admin_id', $targetAdminId)
|
||||
->delete();
|
||||
|
||||
Db::name('salary_detail')
|
||||
->insertAll($salaryDetails);
|
||||
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
public function custom_edit()
|
||||
{
|
||||
|
||||
if (false === $this->request->isPost()) {
|
||||
|
||||
|
||||
$targetAdminId = $this->request->get('target_admin_id');
|
||||
$month = $this->request->get('month');
|
||||
|
||||
$row['salary_month'] = $month;
|
||||
$row['target_admin_id'] = $targetAdminId;
|
||||
|
||||
|
||||
$queryData = $this->model
|
||||
->where('salary_month', '=', $month)
|
||||
->where('target_admin_id', $targetAdminId)
|
||||
->select();
|
||||
$items = Db::name('salary_item')->field('id,name,type')->select();
|
||||
$queryData = array_column($queryData, NULL, 'item_id');
|
||||
|
||||
foreach ($items as $item) {
|
||||
$itemKey = 'item_' . $item['id'];
|
||||
$row[$itemKey] = !empty($queryData[$item['id']]) ? $queryData[$item['id']]['item_value'] : 0;
|
||||
}
|
||||
|
||||
$typeMap = [
|
||||
1 => '应发工资',
|
||||
2 => '应扣款项',
|
||||
3 => '其他'
|
||||
];
|
||||
$groupedItems = [];
|
||||
foreach ($items as $item) {
|
||||
$type = $item['type'];
|
||||
$label = $typeMap[$type];
|
||||
$groupedItems[$label][] = $item;
|
||||
}
|
||||
|
||||
$this->view->assign('groupedItems', $groupedItems);
|
||||
$this->view->assign('items', $items);
|
||||
$this->view->assign('row', $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
|
||||
|
||||
$month = $params['salary_month'] . '-01';
|
||||
$targetAdminId = $params['target_admin_id'];
|
||||
$salaryDetails = [];
|
||||
|
||||
foreach ($params as $k => $v) {
|
||||
if (!str_contains($k, 'item')) {
|
||||
continue;
|
||||
}
|
||||
$salaryDetails[] = [
|
||||
'target_admin_id' => $targetAdminId,
|
||||
'salary_month' => $month,
|
||||
'item_id' => explode('_', $k)[1],
|
||||
'item_value' => $v,
|
||||
];
|
||||
}
|
||||
|
||||
Db::name('salary_detail')
|
||||
->where('salary_month', $month)
|
||||
->where('target_admin_id', $targetAdminId)
|
||||
->delete();
|
||||
|
||||
Db::name('salary_detail')
|
||||
->insertAll($salaryDetails);
|
||||
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
public function settle()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script id="customformtpl" type="text/html">
|
||||
<!--form表单必须添加form-commsearch这个类-->
|
||||
<form action="" class="form-commonsearch">
|
||||
<div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:15px 20px;">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6 col-md-3" style="min-height:68px;">
|
||||
<!--这里添加68px是为了避免刷新时出现元素错位闪屏-->
|
||||
<div class="form-group">
|
||||
<label class="control-label">时间范围</label>
|
||||
<input type="hidden" class="operate" data-name="timetype" value="in"/>
|
||||
<div>
|
||||
<select id="c-flag" class="form-control selectpicker" name="timetype" style="height:31px;">
|
||||
{foreach name="timetype" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="" }selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="control-label"></label>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<input type="submit" class="btn btn-success btn-block" value="查询"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</script>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Target_admin_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-target_admin_id" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[target_admin_id]" type="text" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Salary_month')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-salary_month" class="form-control datetimepicker" data-date-format="YYYY-MM" data-use-current="true" name="row[salary_month]" type="text" value="{:date('Y-m-d')}">
|
||||
</div>
|
||||
</div>
|
||||
{foreach $groupedItems as $groupName => $group}
|
||||
<div class="form-group" style="border-top: 1px solid #ddd; padding-top: 10px; margin-top: 20px;">
|
||||
<label class="control-label col-xs-12 col-sm-2 text-left" style="font-weight: bold;">{$groupName}</label>
|
||||
</div>
|
||||
|
||||
{foreach $group as $index => $item}
|
||||
{if $index % 2 == 0}<div class="form-group">{/if}
|
||||
<label class="control-label col-xs-12 col-sm-1">{$item.name}:</label>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<input class="form-control" step="0.01" name="row[item_{$item.id}]" type="number" value="">
|
||||
</div>
|
||||
{if $index % 2 == 1 || $index == count($group) - 1}</div>{/if}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Target_admin_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-target_admin_id" readonly="readonly" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[target_admin_id]" type="text" value="{$row.target_admin_id|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Salary_month')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-salary_month" readonly="readonly" class="form-control datetimepicker" data-date-format="YYYY-MM" data-use-current="true" name="row[salary_month]" type="text" value="{$row.salary_month|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
{foreach $groupedItems as $groupName => $group}
|
||||
<div class="form-group" style="border-top: 1px solid #ddd; padding-top: 10px; margin-top: 20px;">
|
||||
<label class="control-label col-xs-12 col-sm-2 text-left" style="font-weight: bold;">{$groupName}</label>
|
||||
</div>
|
||||
|
||||
{foreach $group as $index => $item}
|
||||
{if $index % 2 == 0}<div class="form-group">{/if}
|
||||
<label class="control-label col-xs-12 col-sm-1">{$item.name}:</label>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<input class="form-control" step="0.01" name="row[item_{$item.id}]" type="number" value="{$row['item_' . $item.id]|htmlentities}">
|
||||
</div>
|
||||
{if $index % 2 == 1 || $index == count($group) - 1}</div>{/if}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
|
||||
<textarea id="salaryitem" name="salaryitem" class="form-control" cols="30" rows="5" style="display:none;">{$salaryitem}</textarea>
|
||||
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('salary/detail/custom_add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script id="customformtpl" type="text/html">
|
||||
<!--form表单必须添加form-commsearch这个类-->
|
||||
<form action="" class="form-commonsearch">
|
||||
<div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:15px 20px;">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6 col-md-3" style="min-height:68px;">
|
||||
<!--这里添加68px是为了避免刷新时出现元素错位闪屏-->
|
||||
<div class="form-group">
|
||||
<label class="control-label">时间范围</label>
|
||||
<!-- 指定这个字段是 month,操作符为 = -->
|
||||
<input type="hidden" class="operate" data-name="month" value="="/>
|
||||
<div>
|
||||
<input id="c-month"
|
||||
class="form-control datetimepicker"
|
||||
data-date-format="YYYY-MM"
|
||||
data-use-current="true"
|
||||
name="month"
|
||||
type="text"
|
||||
value="{:date('Y-m')}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="control-label"></label>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<input type="submit" class="btn btn-success btn-block" value="查询"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
|
|
@ -39,144 +39,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
|
|||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
custom_index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'oa/schedule/custom_index' + location.search,
|
||||
// add_url: 'oa/schedule/add',
|
||||
editable: 'oa/schedule/editable',
|
||||
// del_url: 'oa/schedule/del',
|
||||
// multi_url: 'oa/schedule/multi',
|
||||
// import_url: 'oa/schedule/import',
|
||||
table: 'schedule',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
var defaultColumnArr = [];
|
||||
defaultColumnArr.push({
|
||||
"title":"用户名",
|
||||
"field":"name",
|
||||
},{
|
||||
"title":"用户id",
|
||||
"field":"admin_id",
|
||||
"visible":false
|
||||
});
|
||||
|
||||
const startDate = new Date();
|
||||
startDate.setDate(1);
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0);
|
||||
endDate.setHours(0, 0, 0, 0);
|
||||
|
||||
for (let d = new Date(startDate); d <= endDate; ) {
|
||||
const current = new Date(d); // 深拷贝
|
||||
const tmpDate = current.toLocaleDateString('sv-SE');
|
||||
|
||||
console.log('Current Date:', tmpDate);
|
||||
defaultColumnArr.push({
|
||||
"title": tmpDate,
|
||||
"field": tmpDate,
|
||||
"editable" :{
|
||||
type: 'select',
|
||||
pk: 1,
|
||||
source: [
|
||||
{value: '无', text: '无'},
|
||||
{value: '早班', text: '早班'},
|
||||
{value: '中班', text: '中班'},
|
||||
{value: '晚班', text: '晚班'},
|
||||
{value: '行政班', text: '行政班'},
|
||||
],
|
||||
noeditFormatter: function (value, row, index) {
|
||||
if (row.editable === 1) {
|
||||
return false;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
d.setDate(d.getDate() + 1); // 最后再改 d 的值
|
||||
}
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: defaultColumnArr,
|
||||
searchFormVisible: true,
|
||||
searchFormTemplate: 'customformtpl',
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
$(document).on("click", ".btn-block", function () {
|
||||
|
||||
let selectedValue = $('#c-flag').val();
|
||||
|
||||
let changeColumn = [];
|
||||
if (selectedValue == 2) {
|
||||
changeColumn = [{
|
||||
"title":"用户名",
|
||||
"field":"name",
|
||||
},{
|
||||
"title":"用户id",
|
||||
"field":"admin_id",
|
||||
"visible":false
|
||||
}];
|
||||
|
||||
const today = new Date();
|
||||
const startDate = new Date(today.setDate(today.getDate() - today.getDay() + 1)); // 星期一
|
||||
const endDate = new Date(today.setDate(today.getDate() - today.getDay() + 7)); // 星期天
|
||||
|
||||
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
|
||||
let tmpDate = d.toISOString().split('T')[0]; // 使用 d,而不是 date
|
||||
changeColumn.push({
|
||||
"title": tmpDate,
|
||||
"field": tmpDate,
|
||||
"editable" :{
|
||||
type: 'select',
|
||||
pk: 1,
|
||||
source: [
|
||||
{value: '无', text: '无'},
|
||||
{value: '早班', text: '早班'},
|
||||
{value: '中班', text: '中班'},
|
||||
{value: '晚班', text: '晚班'},
|
||||
{value: '行政班', text: '行政班'},
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
changeColumn = defaultColumnArr;
|
||||
}
|
||||
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var queryParams = options.queryParams;
|
||||
options.queryParams = function (params) {
|
||||
//这一行必须要存在,否则在点击下一页时会丢失搜索栏数据
|
||||
params = queryParams(params);
|
||||
|
||||
var filter = params.filter ? JSON.parse(params.filter) : {};
|
||||
filter.timetype = selectedValue;
|
||||
|
||||
params.filter = JSON.stringify(filter);
|
||||
return params;
|
||||
};
|
||||
|
||||
table.bootstrapTable('refreshOptions', {
|
||||
columns: changeColumn,
|
||||
});
|
||||
|
||||
$('#c-flag').val(selectedValue).change();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -41,125 +41,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
custom_index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'salary/detail/custom_index' + location.search,
|
||||
add_url: 'salary/detail/custom_add',
|
||||
// del_url: 'oa/schedule/del',
|
||||
// multi_url: 'oa/schedule/multi',
|
||||
// import_url: 'oa/schedule/import',
|
||||
table: 'salary',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
var defaultColumnArr = [];
|
||||
defaultColumnArr.push({
|
||||
"title":"用户名",
|
||||
"field":"name",
|
||||
},{
|
||||
"title":"用户id",
|
||||
"field":"target_admin_id",
|
||||
"visible":false
|
||||
});
|
||||
|
||||
|
||||
// 获取后端传入的字段定义(JSON 字符串)
|
||||
|
||||
var columnJson = $('#salaryitem').val();
|
||||
var rawColumns = JSON.parse(columnJson);
|
||||
rawColumns.forEach(function (item) {
|
||||
// 可以加入格式化、样式控制等逻辑
|
||||
defaultColumnArr.push({
|
||||
field: item.id,
|
||||
title: item.name,
|
||||
});
|
||||
});
|
||||
|
||||
defaultColumnArr.push({
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
buttons: [
|
||||
{
|
||||
name: 'custom_edit',
|
||||
text: '编辑',
|
||||
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.target_admin_id + '&month=' + row.month;
|
||||
},
|
||||
extend: 'data-area=\'["800px", "600px"]\'',
|
||||
visible:function(row){
|
||||
if (!Config.manage) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
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) {
|
||||
if (!Config.manage) {
|
||||
return false;
|
||||
}
|
||||
//返回true时按钮显示,返回false隐藏
|
||||
if (row.settle_status != 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
],
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
});
|
||||
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: defaultColumnArr,
|
||||
searchFormVisible: true,
|
||||
searchFormTemplate: 'customformtpl',
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
custom_add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
custom_edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user