lizhen 2 days ago
parent
commit
0cf4f380ec

+ 13 - 0
application/admin/controller/Jiuyezixun.php

@@ -3,6 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
+use think\Db;
 
 /**
  * 就业咨询
@@ -34,5 +35,17 @@ class Jiuyezixun extends Backend
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
 
+    /**
+     * 预览
+     */
+    public function yulan($id){
+        $info = Db::name('jiuyezixun')->where('id',$id)->find();
+        $this->assign('info',$info);
+
+        $this->layout = false;
+
+        return $this->fetch();
+    }
+
 
 }

+ 1 - 0
application/admin/view/jiuyezixun/index.html

@@ -36,6 +36,7 @@
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('jiuyezixun/edit')}"
                            data-operate-del="{:$auth->check('jiuyezixun/del')}"
+                           data-operate-yulan="{:$auth->check('jiuyezixun/yulan')}"
                            width="100%">
                     </table>
                 </div>

+ 69 - 0
application/admin/view/jiuyezixun/yulan.html

@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>政策解读</title>
+    <style>
+        html, body, div, span, applet, object, iframe,
+        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+        a, abbr, acronym, address, big, cite, code,
+        del, dfn, em, img, ins, kbd, q, s, samp,
+        small, strike, strong, sub, sup, tt, var,
+        b, u, i, center,
+        dl, dt, dd, ol, ul, li,
+        fieldset, form, label, legend,
+        table, caption, tbody, tfoot, thead, tr, th, td,
+        article, aside, canvas, details, embed, 
+        figure, figcaption, footer, header, hgroup, 
+        menu, nav, output, ruby, section, summary,
+        time, mark, audio, video {
+            margin: 0;
+            padding: 0;
+            border: 0;
+            font-size: 100%;
+            font: inherit;
+            vertical-align: baseline;
+            box-sizing: border-box;
+            font-family: Source Han Sans CN;
+        }
+        .page{
+            padding: 15px;
+            font-size: 14px;
+            line-height: 16px;
+            color:#333;
+        }
+    </style>
+</head>
+<body>
+    {$info.title}
+    <br/>
+    {$info.updatetime|date="Y-m-d H:i:s",###}
+
+
+
+    <div class="page">
+        {$info.content}
+    </div>
+</body>
+</html>
+<script src="/assets/js/jquery-3.1.1.min.js"></script>
+<script>
+
+    function replaceDetail(){
+        var details = $('.page').html();
+	   //newContent仅是details替换后内容;
+        let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
+            match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
+            match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
+            match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
+            return match;
+        });
+        newContent = newContent.replace(/<br[^>]*\/>/gi, '');
+        newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
+        $('.page').html('');
+        $('.page').html(newContent);
+    }
+    replaceDetail();
+</script>

+ 6 - 3
application/admin/view/zhengcejiedu/yulan.html

@@ -38,15 +38,18 @@
 </head>
 <body>
     {$info.title}
-
+    <br/>
     {$info.updatetime|date="Y-m-d H:i:s",###}
+    <br/>
+    <br/>
 
     <?php if(!empty($info['video_file'])){ ?>
-    <video width="100" height="100" controls><source src="{$info.video_file}" type="video/ogg"></video>
+    <video width="400" height="300" controls style="margin: 0 auto;display: block;"><source src="{$info.video_file}" type="video/ogg"></video>
+    <br/>
     <?php } ?>
 
     <?php if(!empty($info['audio_file'])){ ?>
-    <audio controls="controls" src="{$info.audio_file}" /></audio>
+    <audio controls="controls" src="{$info.audio_file}" style="margin: 0 auto;display: block;" /></audio>
     <?php } ?>
 
     <div class="page">

+ 21 - 2
public/assets/js/backend/jiuyezixun.js

@@ -36,9 +36,25 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
                         {field: 'weigh', title: __('Weigh'), operate: false},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'), table: table,
+                            buttons:[
+                                {
+                                    name:'yulan',
+                                    text:'预览',
+                                    title:'预览',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-yulan btn-dialog',
+                                    url:'jiuyezixun/yulan/id/{ids}?dialog=1',
+                                    target:'_self',
+                                },
+                            ],
+                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
-                ]
+                ],
+                onLoadSuccess:function(){
+                    // 这里就是数据渲染结束后的回调函数
+                    $(".btn-yulan").data("area", ['25%','80%']);
+                }
             });
 
             // 为表格绑定事件
@@ -50,6 +66,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        yulan: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));

+ 9 - 2
public/assets/js/backend/zhengcejiedu.js

@@ -47,14 +47,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     text:'预览',
                                     title:'预览',
                                     icon:'fa fa-exclamation-circle',
-                                    classname:'btn btn-xs btn-info btn-orderpro btn-dialog',
+                                    classname:'btn btn-xs btn-info btn-yulan btn-dialog',
                                     url:'zhengcejiedu/yulan/id/{ids}?dialog=1',
                                     target:'_self',
                                 },
                             ],
                             events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
-                ]
+                ],
+                onLoadSuccess:function(){
+                    // 这里就是数据渲染结束后的回调函数
+                    $(".btn-yulan").data("area", ['25%','80%']);
+                }
             });
 
             // 为表格绑定事件
@@ -66,6 +70,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         edit: function () {
             Controller.api.bindevent();
         },
+        yulan: function () {
+            Controller.api.bindevent();
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));