Merge remote-tracking branch 'origin/develop' into feature/hant

# Conflicts:
#	application/common/Logic/NoticeLogic.php
This commit is contained in:
todaywindy 2025-06-04 10:49:13 +08:00
commit f0806e7cfc
20 changed files with 1061 additions and 681 deletions

View File

@ -30,6 +30,8 @@ class Admin extends Backend
protected $childrenGroupIds = [];
protected $childrenAdminIds = [];
protected $noNeedRight = ['norightselectpage'];
public function _initialize()
{
parent::_initialize();
@ -358,4 +360,10 @@ class Admin extends Backend
}
$this->success();
}
public function norightselectpage()
{
$this->dataLimit = null;
return parent::selectpage();
}
}

View File

@ -0,0 +1,289 @@
<?php
namespace app\admin\controller\oa;
use app\common\controller\Backend;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 排班
*
* @icon fa fa-circle-o
*/
class CustomSchedule extends Backend
{
/**
* Schedule模型对象
* @var \app\admin\model\oa\Schedule
*/
protected $model = null;
protected $noNeedRight = ['editable'];
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\oa\Schedule;
$this->view->assign("typeList", $this->model->getTypeList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
public function 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->check('oa/custom_schedule/edit')) {
$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/custom_schedule/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->check('oa/custom_schedule/edit')) {
$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();
}
/**
* 添加
*
* @return string
* @throws \think\Exception
*/
public function add()
{
if (false === $this->request->isPost()) {
return $this->view->fetch();
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$params['create_time'] = date('Y-m-d H:i:s');
$params['update_time'] = date('Y-m-d H:i:s');
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
/**
* 编辑
*
* @param $ids
* @return string
* @throws DbException
* @throws \think\Exception
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
if (false === $this->request->isPost()) {
$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', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException()->validate($validate);
}
$params['update_time'] = date('Y-m-d H:i:s');
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if (false === $result) {
$this->error(__('No rows were updated'));
}
$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();
}
}

View File

@ -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->isSuperAdmin() ? 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();
}
}

View File

@ -0,0 +1,347 @@
<?php
namespace app\admin\controller\salary;
use app\common\controller\Backend;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 工资详情
*
* @icon fa fa-circle-o
*/
class CustomDetail extends Backend
{
/**
* Detail模型对象
* @var \app\admin\model\salary\Detail
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\salary\Detail;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
public function 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->check('salary/custom_detail/edit')) {
$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->check('salary/custom_detail/edit')) {
$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/custom_detail/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;
}
if ($type == 2) {
return $total - $value;
}
return $total;
}
public function clean_number($num): string {
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
}
public function 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 edit($ids = null)
{
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()
{
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();
}
}

View File

@ -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->isSuperAdmin());
$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()
{

View File

@ -0,0 +1,30 @@
<?php
return [
'Id' => 'ID',
'Admin_id' => '创建人',
'Exec_admin_id' => '执行人',
'Type' => '任务类型',
'Type 1' => '早班',
'Type 2' => '中班',
'Type 3' => '晚班',
'Type 4' => '行政班',
'Date' => '日期',
'Create_time' => '创建时间',
'Update_time' => '编辑时间',
'Admin.id' => 'ID',
'Admin.username' => '用户名',
'Admin.nickname' => '昵称',
'Admin.password' => '密码',
'Admin.salt' => '密码盐',
'Admin.avatar' => '头像',
'Admin.email' => '电子邮箱',
'Admin.mobile' => '手机号码',
'Admin.loginfailure' => '失败次数',
'Admin.logintime' => '登录时间',
'Admin.loginip' => '登录IP',
'Admin.createtime' => '创建时间',
'Admin.updatetime' => '更新时间',
'Admin.token' => 'Session标识',
'Admin.status' => '状态'
];

View File

@ -0,0 +1,12 @@
<?php
return [
'Id' => 'ID',
'Admin_id' => '创建人',
'Target_admin_id' => '工资归属人',
'Item_id' => '指标id',
'Item_value' => '值',
'Salary_month' => '工资月份',
'Create_time' => '创建时间',
'Update_time' => '编辑时间'
];

View File

@ -0,0 +1,33 @@
<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">{:__('Exec_admin_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/norightselectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Date')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-date" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[date]" type="text" value="{:date('Y-m-d')}">
</div>
</div>
<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>

View File

@ -0,0 +1,33 @@
<form id="edit-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">{:__('Exec_admin_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/norightselectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="{$row.exec_admin_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Date')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-date" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[date]" type="text" value="{$row.date}">
</div>
</div>
<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>

View File

@ -3,7 +3,7 @@
<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="">
<input id="c-target_admin_id" data-rule="required" data-source="auth/admin/norightselectpage" data-field="nickname" class="form-control selectpage" name="row[target_admin_id]" type="text" value="">
</div>
</div>
<div class="form-group">

View File

@ -3,7 +3,7 @@
<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}">
<input id="c-target_admin_id" readonly="readonly" data-rule="required" data-source="auth/admin/norightselectpage" 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">

View File

@ -11,7 +11,7 @@
<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>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('salary/custom_detail/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>

View File

@ -22,8 +22,11 @@ return [
'app\admin\command\ImportServiceItems',
'app\admin\command\Test',
'app\common\command\UpdateWorkerManCommand', //更新师傅评分
'app\common\command\CheckOrderDispatchCommand', //检测超时的任务
'app\common\command\CheckOrderDispatchGotCommand', //dispatch未接单通知
'app\common\command\CheckOrdeRecordCommand', //跟进记录
'app\common\command\UpdateWorkerManCommand',
'app\common\command\CheckOrderDispatchCommand',
'app\common\command\CheckOrdeRecordCommand',
'app\common\command\CheckSmsPlantCommand',
'app\common\command\CheckTTSOverTimeCommand',
'app\common\command\CheckTTSTaskCommand',
'app\common\command\UpdateWorkerManCommand',
];

View File

@ -51,24 +51,25 @@ class NoticeLogic
$log->status = -1;
$log->content = 'TTSID为空';
$log->save();
return;
}
$log->status = 1;
$log->save();
return;
$status = config('alibaba_dyvms.status');
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
if($status){
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){
$log->status = 1;
$log->callId = $reponse->body->callId;
$log->save();
if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){
$log->status = 1;
$log->callId = $reponse->body->callId;
$log->save();
}else{
$log->status = -1;
$log->content = $reponse->body->message;
$log->save();
}
}else{
$log->status = -1;
$log->content = $reponse->body->message;
$log->save();
throw new Exception('语音通知服务未开启');
}
}catch (Exception $exception){
$log->status = -1;

View File

@ -23,7 +23,6 @@ class CheckOrdeRecordCommand extends Command
protected function execute(Input $input, Output $output){
$Model = new OrderDispatchRecord();
$now = date('Y-m-d H:i:s');
$Model->where('notice_time','<=',$now)
->where('status',0)
->chunk(100, function ($list) {
@ -44,7 +43,9 @@ class CheckOrdeRecordCommand extends Command
}
}
OrderDispatchRecord::whereIn('id',$ids)->where('status',0)->update(['status'=>1]);
OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
$count = OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
echo 'count:'.$count.PHP_EOL;
});
$output->info('OVER');

View File

@ -0,0 +1,155 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'oa/custom_schedule/index' + location.search,
// add_url: 'oa/schedule/add',
editable: 'oa/custom_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();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});

View File

@ -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();
},

View File

@ -0,0 +1,127 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'salary/custom_detail/index' + location.search,
add_url: 'salary/custom_detail/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: 'myedit',
text: '编辑',
title: '编辑',
classname: 'btn btn-xs btn-success btn-dialog',
icon: 'fa fa-edit',
url: function (row) {
// 注意这里拼接 admin_id 和 month
return 'salary/custom_detail/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();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});

View File

@ -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();
},