Operatelog.php 2.5 KB
<?php

namespace app\admin\controller\facrm;

use app\common\controller\Backend;
use think\Db;
use think\Exception;
use think\exception\PDOException;


/**
 * 操作记录
 */
class Operatelog extends Backend
{

    protected $model = null;
    protected $noNeedRight = [];
    /**
     * 快速搜索时执行查找的字段
     */
    protected $searchFields = 'content';
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('\app\admin\model\facrm\Operatelog');
        $this->request->filter(['strip_tags']);
    }

    /**
     * 查看
     */
    public function index($customer_id = null,$contract_id=null,$receivable_id=null)
    {

        if ($this->request->isAjax()) {
            $filter_w=[];
            if ($customer_id) {
                $filter_w['customer_id'] = $customer_id;
            }
            if ($contract_id) {
                $filter_w['contract_id'] = $contract_id;
            }
            if ($receivable_id) {
                $filter_w['receivable_id'] = $receivable_id;
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $total = $this->model
                ->where($where)
                ->where($filter_w)
                ->order($sort, $order)->fetchSql(false)
                ->count();
            $list = $this->model
                ->where($filter_w)
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)->fetchSql(false)
                ->select();
            foreach ($list as $row){
                $row->hidden(['content']);
            }
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

    /**
     * 详情
     */
    public function detail($ids)
    {
        $row = $this->model->get(['id' => $ids]);
        if (!$row) {
            $this->error(__('No Results were found'));
        }

        $this->view->assign("row", $row->toArray());
        return $this->view->fetch();
    }

    /**
     * 修改
     * @Internal
     * @return mixed
     */
    public function edit($key = null){
        $this->error();
    }

    /**
     * 添加
     * @Internal
     * @return mixed
     */
    public function add()
    {
        $this->error();
    }


    /**
     * @Internal
     * @return mixed
     */
    public function multi($ids = "")
    {
        $this->error();
    }

}