网站留言

This commit is contained in:
qinzexin 2025-05-22 17:53:57 +08:00
parent 03c19a0c31
commit 6bc3a32e79
45 changed files with 1647 additions and 622 deletions

View File

@ -18,6 +18,8 @@ class Encyclopedia extends Backend
*/
protected $model = null;
protected $searchFields = ["id","title","subtitle","source"];
public function _initialize()
{
parent::_initialize();

View File

@ -17,6 +17,7 @@ class Information extends Backend
* @var \app\admin\model\home\Information
*/
protected $model = null;
protected $searchFields = ["id","title","subtitle","source"];
public function _initialize()
{

View File

@ -3,6 +3,10 @@
namespace app\admin\controller\home;
use app\common\controller\Backend;
use think\Db;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 网站留言
@ -23,6 +27,7 @@ class LeaveWord extends Backend
parent::_initialize();
$this->model = new \app\admin\model\home\LeaveWord;
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("showList", $this->model->getShowList());
}
@ -34,4 +39,105 @@ class LeaveWord extends Backend
*/
/**
* 添加
*
* @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);
}
if($params["status"]=='2' && !$params["answer"]) {
$this->error("已处理,请填写回复内容!");
}
$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);
}
if($params["status"]=='2' && !$params["answer"]) {
$this->error("已处理,请填写回复内容!");
}
$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();
}
}

View File

@ -2,7 +2,15 @@
namespace app\admin\controller\home;
use app\admin\library\Auth;
use app\common\controller\Backend;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use think\db\exception\BindParamException;
use think\Exception;
use think\exception\PDOException;
/**
* 新闻
@ -44,6 +52,9 @@ class News extends Backend
{
//当前是否为关联查询
$this->relationSearch = true;
$this->searchFields = ["id","title","subtitle","source","cate.name","cate.flag"];
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
@ -71,4 +82,230 @@ class News extends Backend
return $this->view->fetch();
}
/**
* 导入
*/
public function import()
{
$file = $this->request->request('file');
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error(__('No results were found'));
}
//实例化reader
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
$this->error(__('Unknown data format'));
}
if ($ext === 'csv') {
$file = fopen($filePath, 'r');
$filePath = tempnam(sys_get_temp_dir(), 'import_csv');
$fp = fopen($filePath, "w");
$n = 0;
while ($line = fgets($file)) {
$line = rtrim($line, "\n\r\0");
$encoding = mb_detect_encoding($line, ['utf-8', 'gbk', 'latin1', 'big5']);
if ($encoding != 'utf-8') {
$line = mb_convert_encoding($line, 'utf-8', $encoding);
}
if ($n == 0 || preg_match('/^".*"$/', $line)) {
fwrite($fp, $line . "\n");
} else {
fwrite($fp, '"' . str_replace(['"', ','], ['""', '","'], $line) . "\"\n");
}
$n++;
}
fclose($file) || fclose($fp);
$reader = new Csv();
} elseif ($ext === 'xls') {
$reader = new Xls();
} else {
$reader = new Xlsx();
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
$table = $this->model->getQuery()->getTable();
$database = \think\Config::get('database.database');
// $fieldArr = [];
// $list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
// foreach ($list as $k => $v) {
// if ($importHeadType == 'comment') {
// $fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
// } else {
// $fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
// }
// }
//加载文件
$insert = [];
try {
if (!$PHPExcel = $reader->load($filePath)) {
$this->error(__('Unknown data format'));
}
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = []; //遍历得到第一行的字段内容
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$fields[] = $val;
}
}
//遍历余下所有行(具体数据)
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
$values = []; //得到当前行数据
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
$values[] = is_null($val) ? '' : $val;
}
if(!$values[0] && !$values[0])continue;
$row = [];
$temp = array_combine($fields, $values);
//拼接提交参数
foreach ($temp as $k => $v) {
if(!$k)throw new Exception("异常的格式或存在空列,请检查!");
//保留原始数据
$raw_v = $v;
$v = str_replace('"','',trim(strip_tags(htmlspecialchars_decode($v))));
switch ($k)
{
case "新闻标题":
case "文章标题":
case "标题":
if (!$v)throw new Exception("{$k}项有的行并未填写内容请检查!");
$row['title'] = $v;
break;
case "新闻副标题":
case "文章副标题":
case "副标题":
$row['subtitle'] = $v;
break;
case "发布时间":
case "时间":
$row['release_time'] = $v;
//转换时间2025/5/20 成时间戳
$row['release_time'] = strtotime($row['release_time']);
break;
case "内容" :
case "文章内容" :
// var_dump($v);die;
$row['content'] = $raw_v;
break;
case "新闻类目" :
case "类目" :
case "分类" :
case "分类ID" :
case "分类id" :
//根据name查询分类表id
if($v){
$cate = \app\admin\model\home\NewsCate::where('name',$v)->find();
if ($cate) {
$row['cate_id'] = $cate['id'];
}else{
//创建分类
$cate = \app\admin\model\home\NewsCate::create([
'name' => $v,
'status' => 1,
'weigh' => 0,
]);
$row['cate_id'] = $cate['id'];
}
}else{
//无分类默认第一个
$row['cate_id'] = \app\admin\model\home\NewsCate::where('status',1)->order('weigh desc')->value('id');
}
break;
case "来源" :
$row['source'] = $v; // 来源
break;
case "浏览量" :
case "点击数" :
$row['views'] = $v; // 来源
break;
case "来源复合数据" :
//$v = "来源新华社 发布日期2025-05-20 点击数15";
if (!$v)throw new Exception("{$k}项有的行并未填写内容请检查!");
// 转换编码为 UTF-8
$v = mb_convert_encoding($v, 'UTF-8', 'UTF-8,GBK,GB2312,ASCII');
if (preg_match('/来源:(.+?)[\\s ]+发布日期:(\d{4}-\d{2}-\d{2})[\\s ]+点击数:(\d+)/is', $v, $matches)) {
$source = isset($matches[1]) ? trim(mb_convert_encoding($matches[1], 'UTF-8', 'auto')) : '';
$releaseDate = isset($matches[2]) ? strtotime(trim($matches[2])) : null;
$clicks = isset($matches[3]) ? intval(trim($matches[3])) : 0;
$row['source'] = $source; // 来源
$row['release_time'] = $releaseDate ?: time(); // 默认当前时间
$row['views'] = $clicks; // 点击数
// var_dump($row);die;
} else {
$this->error("来源复合数据格式异常,请检查字段内容: {$v}");
}
break;
}
}
if ($row) {
//查询是否存在一样的,如果存在,忽略
$where = [
'title' => $row['title'],
];
// unset($where['title']);
if(! \app\admin\model\home\News::where($where)->find()){
$row["weigh"] = 0;
$insert[] = $row;
}
}
}
// var_dump($values);die;
} catch (Exception $exception) {
$this->error($exception->getMessage());
}
if (!$insert) {
$this->error(__('No rows were updated'));
}
try {
//$insert倒序插入
$insert = array_reverse($insert);
$this->model->saveAll($insert);
} catch (PDOException $exception) {
$msg = $exception->getMessage();
if (preg_match("/.+Integrity constraint violation: 1062 Duplicate entry '(.+)' for key '(.+)'/is", $msg, $matches)) {
$msg = "导入失败,包含【{$matches[1]}】的记录已存在";
};
var_dump($exception->getData());
$this->error($msg);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
}

View File

@ -4,12 +4,18 @@ return [
'Name' => '提交者姓名',
'Mobile' => '联系电话',
'Emil' => '邮箱地址',
'Message' => '留言内容',
'Question' => '问题',
'Message' => '描述',
'Status' => '状态',
'Status 1' => '未处理',
'Set status to 1'=> '设为未处理',
'Status 2' => '已处理',
'Set status to 2'=> '设为已处理',
'Answer' => '回复',
'Show' => '精选展示',
'Show 0' => '否',
'Show 1' => '是',
'Weigh' => '权重',
'Createtime' => '创建时间',
'Updatetime' => '修改时间'
];

View File

@ -25,16 +25,32 @@ class LeaveWord extends Model
// 追加属性
protected $append = [
'status_text'
'status_text',
'show_text'
];
protected static function init()
{
self::afterInsert(function ($row) {
if (!$row['weigh']) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
}
});
}
public function getStatusList()
{
return ['1' => __('Status 1'), '2' => __('Status 2')];
}
public function getShowList()
{
return ['0' => __('Show 0'), '1' => __('Show 1')];
}
public function getStatusTextAttr($value, $data)
{
@ -44,6 +60,14 @@ class LeaveWord extends Model
}
public function getShowTextAttr($value, $data)
{
$value = $value ?: ($data['show'] ?? '');
$list = $this->getShowList();
return $list[$value] ?? '';
}
}

View File

@ -18,10 +18,16 @@
<input id="c-emil" class="form-control" name="row[emil]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Question')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-question" class="form-control" name="row[question]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Message')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-message" class="form-control" name="row[message]" type="text">
<textarea id="c-message" class="form-control " rows="5" name="row[message]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
@ -36,6 +42,30 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Answer')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-answer" class="form-control " rows="5" name="row[answer]" cols="50"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Show')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-show" data-rule="required" class="form-control selectpicker" name="row[show]">
{foreach name="showList" 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">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="0">
</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">

View File

@ -18,10 +18,16 @@
<input id="c-emil" class="form-control" name="row[emil]" type="text" value="{$row.emil|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Question')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-question" class="form-control" name="row[question]" type="text" value="{$row.question|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Message')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-message" class="form-control" name="row[message]" type="text" value="{$row.message|htmlentities}">
<textarea id="c-message" class="form-control " rows="5" name="row[message]" cols="50">{$row.message|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
@ -36,6 +42,30 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Answer')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-answer" class="form-control " rows="5" name="row[answer]" cols="50">{$row.answer|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Show')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-show" data-rule="required" class="form-control selectpicker" name="row[show]">
{foreach name="showList" item="vo"}
<option value="{$key}" {in name="key" value="$row.show"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</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">

View File

@ -10,11 +10,10 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('home/news/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('home/news/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('home/news/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('home/news/recyclebin')?'':'hide'}" href="home/news/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('home/news/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('xlsx数据导入')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('home/news/edit')}"

View File

@ -0,0 +1,114 @@
<?php
namespace app\api\controller\home;
use app\common\model\home\LeaveWord as LeaveWordModel;
/**
* 网站留言
*/
class LeaveWord extends Base
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* @var \app\common\model\home\LeaveWord
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new LeaveWordModel;
}
/**
* @ApiTitle( 发网站留言)
* @ApiSummary(发网站留言)
* @ApiMethod(POST)
* @ApiParams(name = "name", type = "string",required=true,description = "提交者姓名")
* @ApiParams(name = "mobile", type = "string",required=true,description = "联系电话")
* @ApiParams(name = "emil", type = "string",required=false,description = "邮箱地址")
* @ApiParams(name = "question", type = "string",required=true,description = "问题")
* @ApiParams(name = "message", type = "string",required=true,description = "描述")
* @ApiReturn({
*
*})
*/
public function add()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$params=[];
$params["name"] = $this->request->post('name/s', ''); //页数
$params["mobile"] = $this->request->post('mobile/s', ''); //条数
$params["emil"] = $this->request->post('emil/s', ''); //搜索关键字
$params["question"] = $this->request->post('question/s', ''); //搜索关键字
$params["message"] = $this->request->post('message/s', ''); //搜索关键字
try{
//当前申请状态
$res = $this->model->add($params,true);
// var_dump($this->model->getLastSql());
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('添加成功', $res);
}
/**
* @ApiTitle(留言列表)
* @ApiSummary(留言列表)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "状态:1=未处理,2=已处理")
* @ApiParams(name = "show", type = "string",required=false,description = "精选展示:0=否,1=是")
* @ApiReturn({
*
*})
*/
public function index()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$params =[];
$show = $this->request->get('show/s', ''); //搜索关键字
// $params["flag"] = $this->request->get('flag/s', ''); //搜索关键字
// $params["hot"] = $this->request->get('hot/s', ''); //搜索关键字
// $params["fine"] = $this->request->get('fine/s', ''); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::allList($page, $limit,$keywords,$status,$show,$params);
// var_dump($this->model->getLastSql());
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}

View File

@ -3,10 +3,11 @@
namespace app\common\model\home;
use app\common\model\Attachment;
use app\common\model\BaseModel;
use think\Model;
use traits\model\SoftDelete;
class Encyclopedia extends Model
class Encyclopedia extends BaseModel
{
use SoftDelete;
@ -87,6 +88,11 @@ class Encyclopedia extends Model
if (!empty($value)) return cdnurl($value, true);
}
public function getFileAttr($value, $data)
{
if (!empty($value)) return cdnurl($value, true);
}
public function attachment()
{

View File

@ -3,10 +3,11 @@
namespace app\common\model\home;
use app\common\model\Attachment;
use app\common\model\BaseModel;
use think\Model;
use traits\model\SoftDelete;
class Information extends Model
class Information extends BaseModel
{
use SoftDelete;
@ -87,6 +88,11 @@ class Information extends Model
if (!empty($value)) return cdnurl($value, true);
}
public function getFileAttr($value, $data)
{
if (!empty($value)) return cdnurl($value, true);
}
public function attachment()
{

View File

@ -93,4 +93,99 @@ class LeaveWord extends BaseModel
/**得到基础条件
* @param $status
* @param null $model
* @param string $alisa
*/
public static function getBaseWhere($whereData = [], $model = null, $alisa = '',$with = false)
{
if (!$model) {
$model = new static;
if ($alisa&&!$with) $model = $model->alias($alisa);
}
if ($alisa) $alisa = $alisa . '.';
$tableFields = (new static)->getTableFields();
foreach ($tableFields as $fields)
{
if(in_array($fields, ["status","show"]))continue;
// if (isset($whereData[$fields]) && $whereData[$fields]) $model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
if (isset($whereData[$fields]) && $whereData[$fields]){
if(is_array($whereData[$fields])){
$model = $model->where("{$alisa}{$fields}", $whereData[$fields][0], $whereData[$fields][1]);
}else{
$model = $model->where("{$alisa}{$fields}", '=', $whereData[$fields]);
}
}
}
if (isset($whereData['status']) && $whereData['status']!=="" && $whereData['status']!==null){
$model = $model->where("{$alisa}status", 'in', $whereData['status'] );
}
if (isset($whereData['show']) && $whereData['show']!=="" && $whereData['show']!==null){
$model = $model->where("{$alisa}show", 'in', $whereData['show'] );
}
if (isset($whereData['keywords'])&&$whereData['keywords']){
$model = $model->where("{$alisa}name|{$alisa}mobile|{$alisa}emil|{$alisa}question|{$alisa}message|{$alisa}answer", 'LIKE', "%{$whereData['keywords']}%" );
}
if (isset($whereData['time'])&&$whereData['time']){
$model = $model->time(["{$alisa}createtime",$whereData['time']]);
}
// if (isset($whereData['has_evaluate'])&&$whereData['has_evaluate']){
// //1查已评价 2查未评价
// if($whereData['has_evaluate'] == 1){
// //1查已评价
// $model = $model->where("{$alisa}classes_evaluate_id", '<>', 0);
// }else{
// //2查未评价
// $model = $model->whereExists(function ($query) use ($alisa) {
// $order_table_name = (new \app\common\model\school\classes\hourorder\Order())->getQuery()->getTable();
// $query->table($order_table_name)->where($order_table_name . '.classes_order_id=' . $alisa . 'id')->where('status', '=', '3');
// })->where("{$alisa}classes_evaluate_id", '=', 0);
//
// }
// }
return $model;
}
public static function allList($page, $limit,$keywords,$status="",$show="",$params=[]){
$with_field = [
// 'cate'=>['image','name'],
// 'attachment'=>['*'],
'base'=>['*'],
];
// $alisa = (new self)->getWithAlisaName();
// $sort = "{$alisa}.weigh desc,{$alisa}.id desc";
$sort = "weigh desc,id desc";
$serch_where = ['status'=>$status,'show'=>$show,'keywords'=>$keywords];
return (new self)->getBaseList(array_merge($serch_where,$params), $page, $limit,$sort,$with_field);
}
}

View File

@ -39,6 +39,14 @@ class News extends BaseModel
}
public function getFileAttr($value, $data)
{
if (!empty($value)) return cdnurl($value, true);
}
protected static function init()
{
self::afterInsert(function ($row) {

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
sortName: 'weigh',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{checkbox: true},
@ -29,8 +31,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'emil', title: __('Emil'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'message', title: __('Message'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'question', title: __('Question'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'show', title: __('Show'), searchList: {"0":__('Show 0'),"1":__('Show 1')}, formatter: Table.api.formatter.normal},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}