hrjy 2 years ago
parent
commit
38c78ade34

+ 1 - 0
app/admin/controller/user/User.php

@@ -312,6 +312,7 @@ class User extends AuthController
             ['level', ''],
             ['group_id', ''],
             ['excel', ''],
+            ['sort', ''],
         ]);
         return Json::successlayui(UserModel::getUserList($where));
     }

+ 1 - 0
app/admin/controller/water/WaterQuery.php

@@ -49,6 +49,7 @@ class WaterQuery extends AuthController
             ['card', ''],
             ['order_id', ''],
             ['uid', ''],
+            ['excel', 0],
         ]);
 
         return Json::successlayui(model::list($where));

+ 4 - 0
app/admin/model/user/User.php

@@ -99,6 +99,10 @@ class User extends BaseModel
         } else {
             $model = self::order('u.uid desc');
         }
+
+        if ($where['sort'] == 1){
+            $model = self::order('u.calculation DESC');
+        }
         if ($where['user_time_type'] == 'visitno' && $where['user_time'] != '') {
             list($startTime, $endTime) = explode(' - ', $where['user_time']);
             $endTime = strtotime($endTime) + 24 * 3600;

+ 43 - 0
app/admin/model/water/WaterQuery.php

@@ -6,6 +6,7 @@
 
 namespace app\admin\model\water;
 
+use crmeb\services\PHPExcelService;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use think\model\concern\SoftDelete;
@@ -41,6 +42,12 @@ class WaterQuery extends BaseModel
 
         if ($where['name'])$model->where('u.uid|u.nickname' , 'like', '%'.$where['name'].'%');
         if ($where['uid'])$model->where('u.uid' , $where['uid']);
+
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            $list = $model->select()->toArray();
+            self::SaveExcel($list);
+        }
+
         $data['count'] = $model->count();
         if ($where['page'] && $where['limit']){
             $model->page($where['page'], $where['limit']);
@@ -53,5 +60,41 @@ class WaterQuery extends BaseModel
 
     }
 
+    /**
+     * excel
+     * @param $list
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function SaveExcel($list)
+    {
+        $export = [];
+        foreach ($list as $index => $item) {
+
+            $export[] = [
+                $item['uid'],
+                $item['nickname'],
+                $item['long'],
+                $item['wide'],
+                $item['high'],
+                $item['is_warm'] ? '保温' : '不保温',
+                $item['is_channel'] ? '需要' : '不需要',
+                $item['is_ladder'] ? '需要' : '不需要',
+                $item['is_gc'] ? '大公差' : '正常公差',
+                $item['price'],
+                $item['weight'],
+                $item['create_time'],
+
+            ];
+        }
+        PHPExcelService::setExcelHeader(['UID', '昵称', '长','宽', '高', '是否保温', '槽钢','人梯', '公差',
+            '总价','重量','计算时间'])
+            ->setExcelTile('计算导出' . date('YmdHis', time()), '计算信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+            ->setExcelContent($export)
+            ->ExcelSave();
+    }
+
 
 }

+ 9 - 0
app/admin/view/user/user/index.php

@@ -89,6 +89,15 @@
                                 </select>
                             </div>
                         </div>
+                        <div class="layui-inline">
+                            <label class="layui-form-label">排  序:</label>
+                            <div class="layui-input-inline">
+                                <select name="sort" lay-verify="status">
+                                    <option value="">正常排序</option>
+                                    <option value="1">次数排序</option>
+                                </select>
+                            </div>
+                        </div>
                         <div class="layui-inline">
                             <label class="layui-form-label">性  别:</label>
                             <div class="layui-input-inline">

+ 94 - 0
app/admin/view/water/water_query/index.php

@@ -49,6 +49,12 @@
 <!--                                        <input type="text" id="order_id" name="order_id" class="layui-input" placeholder="输入订单号">-->
 <!--                                    </div>-->
                                 </div>
+                                <div class="layui-col-lg12" id="app1">
+                                    <button @click="excel" type="button"
+                                            class="layui-btn layui-btn-warm layui-btn-sm export" type="button">
+                                        <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                                    </button>
+                                </div>
                                 <div class="layui-inline">
                                     <div class="layui-input-inline">
                                         <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
@@ -212,5 +218,93 @@
             });
         }
     });
+
+    require(['vue'], function (Vue) {
+        new Vue({
+            el: "#app1",
+            data: {
+                badge: [],
+                where: {
+                    nickname: '',
+                    group: '',
+                    excel: 0,
+                },
+                showtime: false,
+            },
+            watch: {
+                'where.status': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.data': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.type': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.pay_type': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                }
+            },
+            methods: {
+                setData: function (item) {
+                    var that = this;
+                    if (item.is_zd == true) {
+                        that.showtime = true;
+                        this.where.data = this.$refs.date_time.innerText;
+                    } else {
+                        this.showtime = false;
+                        this.where.data = item.value;
+                    }
+                },
+                getBadge: function () {
+                    var that = this;
+                    layList.basePost(layList.Url({c: 'order.store_order', a: 'getBadge'}), this.where, function (rem) {
+                        that.badge = rem.data;
+                    });
+                },
+                search: function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                refresh: function () {
+                    layList.reload();
+                    this.getBadge();
+                },
+                excel: function () {
+
+                    var name = $('#name').val();
+
+
+                    this.where['name'] = name;
+                    this.where.excel = 1;
+                    location.href = layList.U({c: 'water.water_query', a: 'list', q: this.where});
+                    this.where.excel = 0;
+                }
+            },
+            mounted: function () {
+                var that = this;
+                that.getBadge();
+                window.formReload = this.search;
+                layList.laydate.render({
+                    elem: this.$refs.date_time,
+                    trigger: 'click',
+                    eventElem: this.$refs.time,
+                    range: true,
+                    change: function (value) {
+                        that.where.data = value;
+                    }
+                });
+            }
+        })
+    });
 </script>
 {/block}

+ 1 - 0
app/api/controller/water/WaterQueryController.php

@@ -78,6 +78,7 @@ class WaterQueryController
                 //今天计算超过设置次数提醒
                 $amount['remind'] = '你今日计算次数已超过'.sys_config('remind').'次';
             }
+            User::where('uid', $request->uid())->inc('calculation', 1)->update();
 //            if ($user['member'] == 0){
 //                if ($user['free'] > 0){
 //                    User::where('uid', $request->uid())->dec('free', 1)->update();