Kirin 4 yıl önce
ebeveyn
işleme
ce2814c6de

+ 2 - 0
app/admin/controller/vote/Vote.php

@@ -169,7 +169,9 @@ class Vote extends AuthController
         $where = UtilService::getMore([
             ['page', 1],
             ['limit', 20],
+            ['export', 0],
         ]);
+
 //        $where['vid'] = $id;
         JsonService::successlayui(VoteJoin::getList($id, $where));
     }

+ 27 - 2
app/admin/model/vote/VoteJoin.php

@@ -8,6 +8,7 @@
 namespace app\admin\model\vote;
 
 use crmeb\basic\BaseModel;
+use crmeb\services\PHPExcelService;
 use crmeb\traits\ModelTrait;
 use http\Client\Curl\User;
 
@@ -46,8 +47,32 @@ class VoteJoin extends BaseModel
             ->where('a.vid', $id)
             ->join('user u', 'u.uid = a.uid', 'left')
             ->field('a.*,u.nickname,u.uid')
-            ->order('a.status asc,a.id desc')
-            ->page((int)$where['page'], (int)$where['limit'])
+            ->order('a.status asc,a.id desc');
+        if (isset($where['export']) && $where['export'] == 1) {
+            $list = $data->order('vote', 'desc')->select()->toArray();
+            $export = [];
+            foreach ($list as $index => $item) {
+                $user = \app\admin\model\user\User::get($item['uid']);
+                $export[] = [
+                    $index + 1,
+                    $item['sub_id'],
+                    $item['name'] . "【" . $item['company'] . "】",
+                    $item['type'] == 1 ? '个人' : '企业',
+                    $user['nickname'] . '【' . $item['uid'] . '】',
+                    $item['phone'],
+                    $item['address'],
+                    $item['job'],
+                    $item['detail'],
+                    $item['status'] == 1 ? '正常' : '未过审',
+                    date('Y-m-d H:i:s', $item['add_time']),
+                ];
+            }
+            PHPExcelService::setExcelHeader(['排名', '参赛号', '姓名【所属企业】', '参赛类型', '用户昵称【ID】', '联系方式', '地址', '职业', '详情', '状态', '报名时间'])
+                ->setExcelTile('参赛名单导出', '参赛名单信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+                ->setExcelContent($export)
+                ->ExcelSave();
+        }
+        $data = $data->page((int)$where['page'], (int)$where['limit'])
             ->select()
             ->each(function ($item) use ($id) {
                 $user = \app\admin\model\user\User::get($item['uid']);

+ 12 - 6
app/admin/view/vote/vote/index.php

@@ -29,6 +29,9 @@
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='join'>
                             参加名单
                         </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='join_export'>
+                            导出名单
+                        </button>
                     </script>
                     <script type="text/html" id="status">
                         {{# if(d.status == 1){ }}
@@ -49,13 +52,13 @@
     layList.tableList('List', "{:Url('groupList')}", function () {
         return [
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%'},
-            {field: 'title', title: '活动标题', width: '20%'},
-            {field: '_start_time', title: '开始时间', width: '15%'},
-            {field: '_end_time', title: '结束时间', width: '15%'},
-            {field: '_add_time', title: '添加时间', width: '15%'},
-            {field: 'status', toolbar: '#status', title: '状态', width: '5%'},
+            {field: 'title', title: '活动标题', width: '25%'},
+            {field: '_start_time', title: '开始时间', width: '12%'},
+            {field: '_end_time', title: '结束时间', width: '12%'},
+            {field: '_add_time', title: '添加时间', width: '12%'},
+            {field: 'status', toolbar: '#status', title: '状态', width: '9%'},
             {field: 'visit', title: '访问量', width: '5%'},
-            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '20%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '25%'},
         ];
     });
     //点击事件绑定
@@ -100,6 +103,9 @@
                     w: 1250
                 });
                 break;
+            case 'export':
+                window.location = layList.U({a: 'joinList', q: {id: data.id, export: 1}})
+                break;
         }
     })
 </script>