Browse Source

im聊天记录自动拉取

lizhen_gitee 8 months ago
parent
commit
7672a7bf1e
2 changed files with 35 additions and 11 deletions
  1. 6 8
      application/admin/controller/Imlogc2c.php
  2. 29 3
      public/assets/js/backend/imlogc2c.js

+ 6 - 8
application/admin/controller/Imlogc2c.php

@@ -23,6 +23,11 @@ class Imlogc2c extends Backend
         parent::_initialize();
         $this->model = new \app\admin\model\Imlogc2c;
 
+        $typeList = [
+            'typeList' => $this->type_arr(),
+        ];
+        $this->view->assign($typeList);
+        $this->assignconfig($typeList);
     }
 
     public function import()
@@ -65,14 +70,7 @@ class Imlogc2c extends Backend
 				$row->getRelation('touser')->visible(['nickname']);
             }
 
-            $list2 = collection($list->items())->toArray();
-
-            $type_arr = $this->type_arr();
-            foreach($list2 as $key => &$val){
-                $val['MsgType'] = isset($type_arr[$val['MsgType']]) ? $type_arr[$val['MsgType']] : '其他';
-            }
-
-            $result = array("total" => $list->total(), "rows" => $list2);
+            $result = array("total" => $list->total(), "rows" => $list->items());
 
             return json($result);
         }

+ 29 - 3
public/assets/js/backend/imlogc2c.js

@@ -35,8 +35,34 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'MsgTimestamp', title: __('Msgtimestamp'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'To_Account', title: __('To_account')},
                         {field: 'touser.nickname', title: __('touser.nickname'), operate: 'LIKE'},
-                        {field: 'MsgType', title: '类型'},
-                        {field: 'operate', title: __('Operate'),
+
+                        {field: 'MsgType', title: '类型', searchList: Config.typeList, formatter: Table.api.formatter.status},
+
+                        {field: 'MsgInfo', title: __('MsgInfo'), operate: false,events: Table.api.events.image,formatter: function (value,row,index){
+                            if (row.MsgType == 'TIMTextElem'){
+                                return value;
+                            }
+                            if (row.MsgType == 'TIMSoundElem'){
+                                return Table.api.formatter.audio(value,row,index);
+                            }
+                            if (row.MsgType == 'TIMImageElem'){
+                                return Table.api.formatter.image(value,row,index);
+                            }
+                            if (row.MsgType == 'TIMVideoFileElem'){
+                                return Table.api.formatter.video(value,row,index);
+                            }
+                            return value;
+                        },
+                            cellStyle:  {css: {
+                                "white-space": "break-spaces",
+                                "max-width": "200px",
+                                "min-width": "200px",
+                                "line-height": "24px",
+                                "text-align": "left !important"
+                            }
+                            }
+                        },
+                        /*{field: 'operate', title: __('Operate'),
                             buttons:[
                                 {
                                     name:'showbody',
@@ -49,7 +75,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     extend: 'data-area=["90%","90%"]'
                                 },
                             ],
-                            table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                            table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}*/
                     ]
                 ]
             });