Jelajahi Sumber

导出产品

afa 9 bulan lalu
induk
melakukan
ff4a437e18

+ 64 - 25
application/admin/command/Task.php

@@ -4,7 +4,7 @@ namespace app\admin\command;
 
 use think\console\Command;
 use think\console\Input;
-use think\console\input\Option;
+use app\admin\model\Importregion;
 use think\console\Output;
 use think\Exception;
 use app\common\model\Region;
@@ -19,46 +19,85 @@ class Task extends Command
             $this->setName('task')->setDescription('Compress js and css file');
       }
 
-      protected function execute(Input $input, Output $output)
+   
+      protected function execute1(Input $input, Output $output)
       {
             $reg  =  new Region();
-            $list = $reg::where('level', '=', 1)->field('id,name,ext_id')->select();
-            $arr = array();
-           
-            foreach ($list as  $i=>$item) {
-
-                  $arr[$i]['label'] = $item->name;
-                  $arr[$i]['id']    = $item->ext_id;
-                  $list1  =$reg::where('parent_id', '=', $item->id)->field('id,name,ext_id')->select();
-           
-                  foreach ($list1 as $j => $item1) {
+            $list = $reg::where('level', '=', 1)->column('id,name');
 
-                        $arr[$i]['children'][$j]['label'] = $item1->name;
-                        $arr[$i]['children'][$j]['id']    = $item1->ext_id;
-                        $list2  =$reg::where('parent_id', '=', $item1->id)->field('id,name,ext_id')->select();
+            $arr = array();
+            $i = 0;
+            foreach ($list as $key => $item) {
 
-                        foreach ($list2 as $s => $item2) {
-                              $arr[$i]['children'][$j]['children'][$s]['label'] = $item2->name;
-                              $arr[$i]['children'][$j]['children'][$s]['id']    = $item2->ext_id;
-                              $list3  =$reg::where('parent_id', '=', $item2->id)->field('id,name,ext_id')->select();
+                  $arr[$i]['label'] = $item;
+                  $arr[$i]['id'] = $key;
+                  $list1  =$reg::where('parent_id', '=', $key)->column('id,name');
+                  $j = 0;
+                  foreach ($list1 as $key1 => $item1) {
+                        $arr[$i]['children'][$j]['label'] = $item1;
+                        $arr[$i]['children'][$j]['id'] = $key1;
+                        $list2  =$reg::where('parent_id', '=', $key1)->column('id,name');
+                        $s = 0;
+                       
+                        foreach ($list2 as $key2 => $item2) {
+                              $arr[$i]['children'][$j]['children'][$s]['label'] = $item2;
+                              $arr[$i]['children'][$j]['children'][$s]['id'] = $key2;
+                              $list3  =$reg::where('parent_id', '=', $key2)->column('id,name');
 
-                              foreach ($list3 as $d => $item3) {
+                              $d = 0;
+                              foreach ($list3 as $key3 => $item3) {
                                     if(!empty($item3)){
-                                          $arr[$i]['children'][$j]['children'][$s]['children'][$d]['label'] = $item3->name;
-                                          $arr[$i]['children'][$j]['children'][$s]['children'][$d]['id']    = $item3->ext_id;
+                                          $arr[$i]['children'][$j]['children'][$s]['children'][$d]['label'] = $item3;
+                                          $arr[$i]['children'][$j]['children'][$s]['children'][$d]['id'] = $key3;
+                                          $d += 1;
                                     }
                                
                               }
-                             
+                              $s +=1;
                         }
-                       
+                        $j +=1;
                   }
-                 
+                  $i +=1;
             }
 
             file_put_contents('./11.txt', json_encode($arr, JSON_UNESCAPED_UNICODE));
             $output->info("Ok Successed!");
       }
+      
+      //地区导出格式
+      public function execute(Input $input, Output $output){
+            $reg  =  new Region();
+            $imreg=  new Importregion();
+            $list = $reg::where('ext_id', '>', 0)->chunk(1000, function($users) use($reg, $imreg) {
+                  foreach ($users as $user) {
+
+                        switch ($user->level) {
+                              case 2:
+                                  $one = $reg::where('id',  $user->parent_id)->find(); 
+                                  $imreg::insert(['name'=> $one->name.'-'.$user->name, 'com_id'=>$one->id.'-'.$user->id, 'level'=>2]);  
+                                  break;
+                              case 3:
+                                  $two = $reg::where('id',  $user->parent_id)->find();
+                                  $one = $reg::where('id',  $two->parent_id)->find(); 
+                                  $imreg::insert(['name'=> $one->name.'-'.$two->name.'-'.$user->name, 'com_id'=>$one->id.'-'.$two->id.'-'.$user->id, 'level'=>3]);  
+                                  break;
+                              case 4:
+                                    $san = $reg::where('id',  $user->parent_id)->find();
+                                    $two = $reg::where('id',  $san->parent_id)->find();
+                                    $one = $reg::where('id',  $two->parent_id)->find(); 
+                                    $imreg::insert(['name'=> $one->name.'-'.$two->name.'-'.$san->name.'-'.$user->name, 'com_id'=>$one->id.'-'.$two->id.'-'.$san->id.'-'.$user->id, 'level'=>4]);
+                                    break;
+                              // 更多的 case 语句
+                              default:
+                                    $imreg::insert([ 'name'=> $user->name, 'com_id'=>$user->id, 'level'=>1]);
+
+                          }
+                        //
+                  };
+
+            });
+
+      }
 
 
 }

+ 8 - 1
application/admin/controller/Ajax.php

@@ -117,7 +117,6 @@ class Ajax extends Backend
                     'Bucket'    => \think\Env::get('oss.bucket'),
                     'Directory' => \think\Env::get('oss.directory'),
                 ];
-
                 //获取oss实例
                 $ossClient = new OssClient($config['KeyId'],$config['KeySecret'],$config['Endpoint']);
                 $bucket = $config['Bucket']; //创建的项目
@@ -125,6 +124,14 @@ class Ajax extends Backend
                 $res = $ossClient->uploadFile($bucket,$object,$file->getRealPath());
                 $url = str_replace("http://", "https://", $res['info']['url']);
                 $this->success(__('Uploaded successful'), '', ['url' => $url, 'fullurl' => $url]);
+            }elseif($type == 'export'){
+                    try {
+                        $upload = new Upload($file);
+                        $attachment = $upload->upload();
+                    } catch (UploadException $e) {
+                        $this->error($e->getMessage());
+                    }
+                    $this->success(__('Uploaded successful'),  '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
             }else{
                 try {
                     $upload = new Upload($file);

+ 66 - 0
application/admin/controller/ledger/Importlog.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace app\admin\controller\ledger;
+
+use app\common\controller\Backend;
+
+/**
+ * 产品导入记录
+ *
+ * @icon fa fa-circle-o
+ */
+class Importlog extends Backend
+{
+
+    /**
+     * Importlog模型对象
+     * @var \app\admin\model\ledger\Importlog
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Importlog;
+        $this->assignconfig('ids', $this->request->param('ids'));
+
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+     /**
+     * 查看
+     *
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
+     */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $ids = $this->request->param('ids');
+        $list = $this->model//->with('product')
+            ->where($where)->where('product_id', $ids)
+            ->order($sort, $order)
+            ->paginate($limit);
+      
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+
+}

+ 106 - 2
application/admin/controller/product/Lists.php

@@ -5,9 +5,15 @@ namespace app\admin\controller\product;
 use app\common\controller\Backend;
 use Exception;
 use think\Db;
+use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
+use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
+use PhpOffice\PhpSpreadsheet\Reader\Xls;
+use PhpOffice\PhpSpreadsheet\Reader\Csv;
 use app\common\model\ProductArea;
 use think\exception\DbException;
 use think\exception\PDOException;
+use app\admin\model\Importregion;
+use app\admin\model\Importlog;
 use think\exception\ValidateException;
 
 /**
@@ -102,7 +108,7 @@ class Lists extends Backend
             unset($params['product_area'], $params['product_area_txt']);
             //商品
             $add   = $this->model->create($params);
-            $result= $this->setEqualArea($add->id, $areaArr, $areaArrTxt, 0);
+            $result= self::setEqualArea($add->id, $areaArr, $areaArrTxt, 0);
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
             Db::rollback();
@@ -182,7 +188,7 @@ class Lists extends Backend
             unset($params['product_area'], $params['product_area_txt']);
             $row->allowField(true)->save($params);
             //$this->productArea::where('product_id', $ids)->where('status', 1)->delete();
-            $result= $this->setEqualArea($ids, $areaArr, $areaArrTxt, 1);
+            $result= self::setEqualArea($ids, $areaArr, $areaArrTxt, 1);
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
             Db::rollback();
@@ -194,6 +200,104 @@ class Lists extends Backend
         $this->success();
     }
 
+    /**
+     * 导入产品地区
+     * @param $ids
+     * @return string
+     * @throws DbException
+     * @throws \think\Exception
+     */
+    public function exports(Importregion $importregion, Importlog $Importlog){
+        if (false === $this->request->isPost()) { 
+            $this->assignconfig('areaData', []);
+            return $this->view->fetch();
+        }
+        $params = $this->request->post('row/a');
+        if (empty($params)) {
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        $params = $this->preExcludeFields($params);
+        if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+            $params[$this->dataLimitField] = $this->auth->id;
+        }
+        $file = $params['export'];
+        $filePath = ROOT_PATH . DS . 'public' . DS . $file;
+        if (!is_file($filePath)) {
+            $this->error(__('No results were found'));
+        }
+        //实例化reader
+        $ext = pathinfo($filePath, PATHINFO_EXTENSION);
+        if (!in_array($ext, ['csv', 'xls', 'xlsx'])) {
+            $this->error(__('Unknown data format'));
+        }
+        $reader = ($ext === 'xls')? new Xls(): new Xlsx();
+        $result = false;
+        Db::startTrans();
+        try {
+            if (!$PHPExcel = $reader->load($filePath)) {
+                $this->error(__('Unknown data format'));
+            }
+            $PHPExcel = $reader->load($filePath);
+            $currentSheet = $PHPExcel->getSheet(0);  //读取文件中的第一个工作表
+            $allRow = $currentSheet->getHighestRow(); //取得一共有多少行
+            //读取第二行字段名
+            $data = [];
+            $fields = [];
+            $k = 0;
+            $i = 0;
+            $time = time();
+            for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
+                $values = [];
+                //列字段
+                for ($currentColumn = 2; $currentColumn <= 5; $currentColumn++) {
+                    $val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
+                    $values[] = is_null($val) ? '' : $val;
+                }
+                $field =  implode('-', $values);
+                $row = $importregion::where('name', $field)->find();
+                if(!empty($row)){
+                        if($this->productArea::where('product_id',$params['product_id'])->where('address',$row['name'])->count() > 0) continue;
+                        $data = self::importData($data, $k, $params['product_id'], $row->com_id, $time);
+                        $data[$k]['address']     = $row['name'];
+                        $k +=1;
+                }else{
+                        $fields = self::importData($fields, $i, $params['product_id'], $field, $time);
+                        $i += 1;
+                }
+            }
+            if(!empty($data)) $result= $this->productArea::insertAll($data);
+            //错误日志
+            if(!empty($fields)) $Importlog::insertAll($fields);
+            Db::commit();
+        } catch (ValidateException|PDOException|Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if ($result === false) {
+            $this->error(__('No rows were inserted'));
+        }
+        $this->success();
+
+    }
+
+
+     /**
+     * 导入数据
+     * @return array
+     */
+    private static function importData(array $data, int $k, int $product_id, string $ids,  $time): array
+    {   
+        //$data = array();
+        $arr = explode('-', $ids); //分割ID
+        $data[$k]['product_id']  = $product_id;
+        $data[$k]['province']    = $arr[0]??0;
+        $data[$k]['city']        = $arr[1]??0 ; 
+        $data[$k]['area']        = $arr[2]??0;
+        $data[$k]['county']      = $arr[3]??0;
+        $data[$k]['create_time'] = $time;
+        return $data;
+    }
+
 
     //判断是否存在相同元素
     private function setEqualArea(int $product_id,array $areaArr, array $areaArrTxt, int $type): bool

+ 11 - 0
application/admin/lang/zh-cn/ledger/importlog.php

@@ -0,0 +1,11 @@
+<?php
+
+return [
+    'Type_id'     => '任务ID',
+    'Product_id'  => '产品id',
+    'Total_num'   => '总数',
+    'Succes_num'  => '成功数量',
+    'Remark'      => '备注',
+    'Create_time' => '开始时间',
+    'Update_time' => '更新时间'
+];

+ 64 - 0
application/admin/model/Importlog.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Importlog extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $table = 'import_log';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'update_time_text'
+    ];
+    
+
+    
+    public function product()
+    {
+        return $this->hasOne('\app\common\model\ProductLists', 'id', 'product_id', [], 'LEFT')->setEagerlyType(0);
+    }
+
+
+    public function getCreateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getUpdateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setUpdateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+}

+ 55 - 0
application/admin/model/Importregion.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Importregion extends Model
+{
+
+
+    // 表名
+    protected $table = 'import_region';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'update_time_text'
+    ];
+    
+
+
+    public function getCreateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getUpdateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setUpdateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+}

+ 0 - 27
application/admin/validate/offline/Offline_recharge.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace app\admin\validate\offline;
-
-use think\Validate;
-
-class Offline_recharge extends Validate
-{
-    /**
-     * 验证规则
-     */
-    protected $rule = [
-    ];
-    /**
-     * 提示消息
-     */
-    protected $message = [
-    ];
-    /**
-     * 验证场景
-     */
-    protected $scene = [
-        'add'  => [],
-        'edit' => [],
-    ];
-    
-}

+ 52 - 0
application/admin/view/ledger/importlog/add.html

@@ -0,0 +1,52 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-type_id" data-rule="required" data-source="type/index" class="form-control selectpage" name="row[type_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-product_id" data-rule="required" data-source="product/index" class="form-control selectpage" name="row[product_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Total_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-total_num" data-rule="required" class="form-control" name="row[total_num]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Succes_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-succes_num" data-rule="required" class="form-control" name="row[succes_num]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-remark" data-rule="required" class="form-control " rows="5" name="row[remark]" cols="50"></textarea>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:date('Y-m-d H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 52 - 0
application/admin/view/ledger/importlog/edit.html

@@ -0,0 +1,52 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-type_id" data-rule="required" data-source="type/index" class="form-control selectpage" name="row[type_id]" type="text" value="{$row.type_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Product_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-product_id" data-rule="required" data-source="product/index" class="form-control selectpage" name="row[product_id]" type="text" value="{$row.product_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Total_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-total_num" data-rule="required" class="form-control" name="row[total_num]" type="number" value="{$row.total_num|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Succes_num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-succes_num" data-rule="required" class="form-control" name="row[succes_num]" type="number" value="{$row.succes_num|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-remark" data-rule="required" class="form-control " rows="5" name="row[remark]" cols="50">{$row.remark|htmlentities}</textarea>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:$row.update_time?datetime($row.update_time):''}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 19 - 0
application/admin/view/ledger/importlog/index.html

@@ -0,0 +1,19 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 33 - 0
application/admin/view/product/lists/exports.html

@@ -0,0 +1,33 @@
+<form id="edit-form" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-horizontal">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('产品')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-product_id" data-rule="required" data-source="product/lists/index" data-field="zh_name" class="form-control selectpage" name="row[product_id]" type="text" value="{$row.product_id|htmlentities}">
+        </div>
+    </div>
+   
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('导入文件')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-export" data-rule="required" class="form-control" size="50" name="row[export]" type="text" value="">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-export" class="btn btn-danger faupload" data-input-id="c-export" data-params='{"category":"export"}' data-mimetype="xls,xlsx" data-multiple="false" data-preview-id="p-export"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-export" class="btn btn-primary fachoose" data-input-id="c-export" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-export"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-export"></ul>
+        </div>
+    </div>
+     
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div></div>
+</form>

+ 3 - 0
application/admin/view/product/lists/index.html

@@ -9,10 +9,13 @@
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('product/lists/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('product/lists/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-info btn-exports {:$auth->check('product/lists/exports')?'':'hide'}" title="{:__('import')}" id="btn-export-file"><i class="fa fa-download"></i> {:__('import')}</a>
+
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('product/lists/edit')}"
                            data-operate-del="{:$auth->check('product/lists/del')}"
+                           data-operate-del="{:$auth->check('product/lists/exports')}"
                            width="100%">
                     </table>
                 </div>

+ 1 - 1
application/extra/upload.php

@@ -21,7 +21,7 @@ return [
     /**
      * 可上传的文件类型
      */
-    'mimetype'  => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm',
+    'mimetype'  => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm,xls,xlsx,csv',
     /**
      * 是否支持批量上传
      */

File diff ditekan karena terlalu besar
+ 0 - 0
area.js


+ 60 - 0
public/assets/js/backend/ledger/importlog.js

@@ -0,0 +1,60 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'ledger/importlog/index' + location.search+'&ids='+Config.ids,
+                    multi_url: 'ledger/importlog/multi',
+                    import_url: 'ledger/importlog/import',
+                    table: 'import_log',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                search: true,
+                showSearchButton: true,
+                searchFormVisible: true,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'), operate: false},
+                        //{field: 'product.zh_name', title: __('产品'), operate:'LIKE'},
+                        {field: 'province', title: __('省份'), operate: false},
+                        {field: 'city', title: __('城市'), operate: false},
+                        {field: 'area', title: __('区域'), operate: false},
+                        {field: 'county', title: __('街道'), operate: false},
+                        //width: '120',//限制最小宽度,不是固定宽度
+                        {field: 'create_time',title: __('Create_time'), operate:'RANGE', addclass:'datetimerange',autocomplete:false, formatter: Table.api.formatter.datetime}
+                        
+                   
+                        //{field: 'update_time', title: __('Update_time'), operate: false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 32 - 1
public/assets/js/backend/product/lists.js

@@ -70,7 +70,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
                         { field: 'status', title: __('Status'), searchList: { "1": __('上架'), "0": __('下架') }, formatter: Table.api.formatter.toggle },
                         { field: 'create_time', title: __('Create_time'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                         { field: 'update_time', title: __('Update_time'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
-                        { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }
+                        { field: 'importlog', title: __('Operate'),
+                            buttons:[
+                                {
+                                   name:'importlog',//名称开始按钮 classname: 'btn btn-xs btn-primary btn-dialog',
+                                   text:'导入日志',//文本
+                                   classname:'btn btn-xs btn-info btn-primary btn-dialog',//按钮样式
+                                   icon:'fa fa-play',//图标
+                                   url:'ledger/importlog/index',//请求的方法
+                                   extend:'data-area=["75%","85%"]',
+                                   refresh:true,//一开始界面需要刷新
+                                 },
+                              ],
+                            table: table, events: Table.api.events.operate,
+                            formatter: Table.api.formatter.operate 
+                        }
                     ]
                 ]
             });
@@ -82,13 +96,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area', 'vue', 'ELEME
             table.on('post-body.bs.table', function () {
                 $('.btn-editone').data("area", ["100%", "100%"]);
             });
+            //导入地区
+            $(document).on("click",".btn-exports",function(){
+                Fast.api.open('product/lists/exports', '导入地区',{
+                    //接收产品弹窗Fast.api.close传过来的参数
+                    callback:function(data){
+                        
+                    }
+                });
+            })
         },
+
         add: function () {
             Controller.api.bindevent();
         },
         edit: function () {
             Controller.api.bindevent();
         },
+        exports: function () {
+            Form.api.bindevent($("form[role=form]"));
+        },
+        importlog: function () {
+
+            Form.api.bindevent($("form[role=form]"));
+        },
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));

+ 1 - 1
public/assets/js/require-form.js

@@ -195,7 +195,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                         ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
                         ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
                         var options = {
-                            timePicker: false,
+                            timePicker: true,
                             autoUpdateInput: false,
                             timePickerSeconds: true,
                             timePicker24Hour: true,

File diff ditekan karena terlalu besar
+ 0 - 0
public/assets/libs/area/area.js


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini