You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
4.3 KiB
171 lines
4.3 KiB
<?php
|
|
|
|
namespace app\calculator\controller\admin;
|
|
|
|
use app\calculator\model\CalculatorCategoryPlace;
|
|
use app\calculator\model\CalculatorPlace;
|
|
use think\facade\View;
|
|
|
|
class Calculator extends Base
|
|
{
|
|
|
|
/**
|
|
* 场所列表
|
|
* @return array|mixed|string
|
|
*/
|
|
public function place()
|
|
{
|
|
$search = input('get.');
|
|
|
|
$place_model = new CalculatorCategoryPlace();
|
|
|
|
autoSearch(['time', 'keyword', 'category_id', 'is_publish'], $search);
|
|
View::assign('search', $search);
|
|
|
|
$where = [
|
|
['uid', '=', UID],
|
|
];
|
|
if ($search['time']) {
|
|
$time = explode('-', $search['time']);
|
|
$where[] = ['create_time', 'between time', [$time[0], $time[1]]];
|
|
}
|
|
if ($search['keyword']) {
|
|
$where[] = ['name', 'like', '%' . $search['keyword'] . '%'];
|
|
}
|
|
if ($search['category_id'] != "") {
|
|
$where[] = ['category_id', '=', $search['category_id']];
|
|
}
|
|
if ($search['is_publish'] != "") {
|
|
$where[] = ['is_publish', '=', $search['is_publish']];
|
|
}
|
|
|
|
$page = array_key_exists("page", $search) ? (string)$search['page'] : "1";
|
|
|
|
|
|
$dataList = $place_model
|
|
->where($where)->order('id asc')
|
|
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item, $key) {
|
|
return $item;
|
|
});
|
|
View::assign('dataList', $dataList);
|
|
|
|
$attach = [
|
|
'total_html' => [['场所总数', $dataList->total()]]
|
|
];
|
|
View::assign('attach', $attach);
|
|
|
|
return View::fetch();
|
|
}
|
|
|
|
/**
|
|
* 场所添加
|
|
* @return array|mixed|string
|
|
*/
|
|
public function placeAdd()
|
|
{
|
|
$place_model = new CalculatorCategoryPlace();
|
|
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$data['is_publish'] = array_key_exists('is_publish', $data) ? $data['is_publish'] : 0;
|
|
$data['publish_time'] = time();
|
|
$res = $place_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $place_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
|
|
return View::fetch('placeadd');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 场所修改
|
|
* @return array|mixed|string
|
|
*/
|
|
public function placeUpdate()
|
|
{
|
|
return $this->placeAdd();
|
|
}
|
|
|
|
/**
|
|
* 场所备注
|
|
* @return array|mixed|string
|
|
*/
|
|
public function remark()
|
|
{
|
|
$search = input('get.');
|
|
|
|
$place_model = new CalculatorPlace();
|
|
|
|
autoSearch(['keyword'], $search);
|
|
View::assign('search', $search);
|
|
|
|
$where = [
|
|
['uid', '=', UID],
|
|
];
|
|
|
|
if ($search['keyword']) {
|
|
$where[] = ['name', 'like', '%' . $search['keyword'] . '%'];
|
|
}
|
|
|
|
|
|
$page = array_key_exists("page", $search) ? (string)$search['page'] : "1";
|
|
|
|
|
|
$dataList = $place_model
|
|
->where($where)->order('id asc')
|
|
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item, $key) {
|
|
return $item;
|
|
});
|
|
View::assign('dataList', $dataList);
|
|
|
|
$attach = [
|
|
'total_html' => [['场所总数', $dataList->total()]]
|
|
];
|
|
View::assign('attach', $attach);
|
|
|
|
return View::fetch();
|
|
}
|
|
|
|
/**
|
|
* 场所备注添加
|
|
* @return array|mixed|string
|
|
*/
|
|
public function remarkAdd()
|
|
{
|
|
$place_model = new CalculatorPlace();
|
|
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
|
|
$res = $place_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $place_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
|
|
return View::fetch('remarkadd');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 场所备注修改
|
|
* @return array|mixed|string
|
|
*/
|
|
public function remarkUpdate()
|
|
{
|
|
return $this->remarkAdd();
|
|
}
|
|
|
|
} |