Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

孙龙 / note-library

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Find file
BlameHistoryPermalink
Switch branch/tag
  • note-library
  • app
  • Http
  • Controllers
  • WebController.php
  • 孙龙's avatar
    up · a88a7a4d
    孙龙 committed 5 years ago
    a88a7a4d
WebController.php 4.97 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
<?php
namespace App\Http\Controllers;


use App\Model\TmplRelationsModel;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use App\Model\TemplateListModel;
use App\Model\NodesModel;
use DNS1D;
use DNS2D;
use Sunra\PhpSimple\HtmlDomParser;

class WebController extends Controller
{
    // 获取页面信息
    public function getPageInfo($request)
    {
        $uri = '/' . $request->path();

        $username = $request->user->email;
        $useremail= $request->user->email;

        // 菜单
        $menuconfig = DB::table('config')->where('config_title', '标签管理系统')->first();
        $menus = [];
        if ($menuconfig && !($menus = json_decode($menuconfig->config_data)))
            $menus = [];

        $perm = new PermController;

        // 用户角色
        $role = $perm->getUserRole($request);

        // 获取权限菜单
        if ($role != 1) {
            $menus = $perm->getPermMenu($menus, $request->user->userId);
        }

        $userPerms = $perm->getUserAllPerms($request->user->userId, $role); // 用户权限

        $data = [
            'header'    => $request->user->header,
            'uri'       => $uri,
            'username'  => $username,
            'useremail' => $useremail,
            'menus'     => $menus,
            'userPerms' => $userPerms,
        ];

        return $data;
    }

    // 首页
    public function index(Request $request)
    {
//        $JobsModel = new JobsModel();

        $info = $this->getPageInfo($request);

        return view('index', $info);
    }

    public function entrance(Request $request, $id='')
    {
        $info = $this->getPageInfo($request);
        $info['id'] = $id;
        return $this->$id($request, $info);
    }

    // 模板列表
    public function labelList($request, $info)
    {
        $info['title'] = '我的标签模板列表';
        return view('web', $info);
    }

    // 模板列表
    public function systemlabelList($request, $info)
    {
        $info['title'] = '系统内置标签模板列表';
        $info['id']= "labelList";
        $info["labelListSystem"] = 1;
        return view('web', $info);
    }



    // 标签使用记录
    public function record($request, $info)
    {
        $info['title'] = '标签使用记录';
        return view('web', $info);
    }

    /*
     * 设计
     */
    public function design($request,$info){
        $info['title'] = '标签设计';
        return view('web', $info);
    }
    /*
     * 标签预览
     */
    public function showPage($request,$info){
        $info['title'] = '预览';
        $id = $request->input("tmpl_relation_id",0);
        $html = (new \App\Services\LabelService)->getLabelHtml($id);
        $info["html"] = $html;
        return view('web', $info);
    }

    /*
     * 标签预览
     */
    public function showTemplate($request,$info){
        $info['title'] = '预览';
        $id = $request->input("t_id",0);
//        $count = TemplateListModel::where("id",intval($id))->where("create_userid",$request->user->userId)->count("id");
//        if($count <= 0){
//            return back()->with('showTemplateerror', '没找到属于您的模板信息');
//        }
        $templateInfo = TemplateListModel::where("id",intval($id))->select("id","template_name","status")->first();
//        if($templateInfo->status <= 0){
//            return back()->with('showTemplateerror', '该模板已经被主人禁用了');
//        }
//        dump($templateInfo->template_extend);

        $html = $templateInfo->template_extend;
        $info["html"] = $html->html;
        return view('web', $info);
    }

    /*
     * 打印标签
     */
    public function prints($request,$info){
        $tmpl_relationids = $request->input("tmpl_relationids",'');
        $tmpl_relationid_arr = explode(",",$tmpl_relationids);
        if(empty($tmpl_relationids)){
            die("没有要打印的数据");
        }
        if(!empty($tmpl_relationid_arr)){
            $tmpl_relationid_arr = array_unique($tmpl_relationid_arr);
            $tmpl_relationid_arr = array_map("intval",$tmpl_relationid_arr);
            $tmpl_relationid_arr = array_filter($tmpl_relationid_arr,function($val){
                if ($val > 0) {
                    return true;
                } else {
                    return false;
                }
            });
        }
//        dump($tmpl_relationid_arr);
        $info['title'] = '打印';

        $templateRelation = TmplRelationsModel::where("create_userid",$request->user->userId)->whereIn("id",$tmpl_relationid_arr)
            ->get();
        if(!$templateRelation){
            die("没有要打印的数据");
        }
        $html = [];
        foreach($templateRelation as $item){
            $createHtml = (new \App\Services\LabelService)->getLabelHtml($item->id);
            if($createHtml){
                array_push($html,$createHtml);
            }
        }

        $info["html"] = $html;
        return view('web.prints', $info);
    }


    
}