Quellcode durchsuchen

图片 excel 统计

chengwl vor 5 Jahren
Ursprung
Commit
5aa9d730c3

+ 2 - 1
composer.json

@@ -19,7 +19,8 @@
         "yiisoft/yii2-bootstrap": "~2.0.0",
         "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
         "phpoffice/phpspreadsheet": "^1.14",
-        "kartik-v/yii2-widget-datetimepicker": "*"
+        "kartik-v/yii2-widget-datetimepicker": "*",
+        "bailangzhan/yii2-webuploader": "dev-master"
     },
     "require-dev": {
         "yiisoft/yii2-debug": "~2.1.0",

+ 46 - 4
composer.lock

@@ -4,14 +4,54 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "bd5e2ccae4851be41ed513f3ec9161c3",
+    "content-hash": "6e6b33d1ba8a1589bf1e3d4b874b53e5",
     "packages": [
+        {
+            "name": "bailangzhan/yii2-webuploader",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/bailangzhan/yii2-webuploader.git",
+                "reference": "988b70baa21d16d477c035de22ae9d4d47aadb59"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/bailangzhan/yii2-webuploader/zipball/988b70baa21d16d477c035de22ae9d4d47aadb59",
+                "reference": "988b70baa21d16d477c035de22ae9d4d47aadb59",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "yiisoft/yii2": ">=2.0.4"
+            },
+            "type": "yii2-extension",
+            "autoload": {
+                "psr-4": {
+                    "manks\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "yii2-webuploader组件",
+            "keywords": [
+                "webuploader",
+                "yii2"
+            ],
+            "time": "2018-01-12T04:02:15+00:00"
+        },
         {
             "name": "bower-asset/bootstrap",
             "version": "v3.4.1",
             "source": {
                 "type": "git",
-                "url": "git@github.com:twbs/bootstrap.git",
+                "url": "https://github.com/twbs/bootstrap.git",
                 "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
             },
             "dist": {
@@ -55,7 +95,7 @@
             "version": "3.5.1",
             "source": {
                 "type": "git",
-                "url": "git@github.com:jquery/jquery-dist.git",
+                "url": "https://github.com/jquery/jquery-dist.git",
                 "reference": "4c0e4becb8263bb5b3e6dadc448d8e7305ef8215"
             },
             "dist": {
@@ -5774,7 +5814,9 @@
     ],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": [],
+    "stability-flags": {
+        "bailangzhan/yii2-webuploader": 20
+    },
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {

+ 18 - 0
config/params.php

@@ -4,4 +4,22 @@ return [
     'adminEmail' => 'admin@example.com',
     'senderEmail' => 'noreply@example.com',
     'senderName' => 'Example.com mailer',
+    'domain' => 'http://mgc.longyilive.com/',  //上传域名
+    'webuploader'=>[
+        'uploadUrl' => 'upload/img',
+	    // 多文件分隔符
+        'delimiter' => ',',
+        'baseConfig' => [
+            'defaultImage' => 'http://img1.imgtn.bdimg.com/it/u=2056478505,162569476&fm=26&gp=0.jpg',
+            'disableGlobalDnd' => true,
+            'accept' => [
+                'title' => 'Images',
+                'extensions' => 'gif,jpg,jpeg,bmp,png',
+                'mimeTypes' => 'image/*',
+            ],
+            'pick' => [
+                'multiple' => false,
+            ],
+        ],
+    ]
 ];

+ 134 - 12
controllers/SiteController.php

@@ -12,7 +12,9 @@ use yii\web\Controller;
 use yii\web\NotFoundHttpException;
 use yii\filters\VerbFilter;
 use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use app\models\LoginForm;
+
 /**
  * SiteController implements the CRUD actions for Orderreturn model.
  */
@@ -46,9 +48,7 @@ class SiteController extends Controller
      */
     public function actionIndex()
     {
-        if (Yii::$app->user->isGuest) {
-            return $this->redirect(['login']);
-        }
+        
         $request = Yii::$app->request;
         $shop=$request->get('shop',1);
         $searchModel = new OrderreturnSearch();
@@ -57,7 +57,129 @@ class SiteController extends Controller
             'searchModel' => $searchModel,
             'dataProvider' => $dataProvider,
             'shop'=>$shop,
+            'dayStatis'=>$dayStatis,
+            'dayCount'=>$dayCount,
+            'monthStatis'=>$monthStatis,
+            'monthCount'=>$monthCount
+        ]);
+    }
+    public function actionStatis(){
+        if (Yii::$app->user->isGuest) {
+            return $this->redirect(['login']);
+        }
+        $request = Yii::$app->request;
+        $shop=$request->get('shop',1);
+        $dayStatis=Orderreturn::find()
+                ->select([ 'usage','count(*) as num'])
+                ->groupBy('usage')
+                ->where(['>','created_at',strtotime(date('Y-m-d'))])
+                ->where(['shop'=>$shop])
+                ->asArray()
+                ->all();
+        $dayCount=array_sum(array_column($dayStatis,'num'));
+        $monthStatis=Orderreturn::find()
+            ->select(['count(*) as num', 'usage'])
+            ->groupBy('usage')
+            ->where(['>','created_at',strtotime(date('Y-m'))])
+            ->where(['shop'=>$shop])
+            ->asArray()
+            ->all();
+        $monthCount=array_sum(array_column($monthStatis,'num'));
+        return $this->render('statis', [
+            'shop'=>$shop,
+            'dayStatis'=>$dayStatis,
+            'dayCount'=>$dayCount,
+            'monthStatis'=>$monthStatis,
+            'monthCount'=>$monthCount
         ]);
+    }
+    public function actionStatisExport(){
+        $request = Yii::$app->request;
+        $shop=$request->get('shop',1);
+        $dayStatis=Orderreturn::find()
+                ->select([ 'usage','count(*) as num'])
+                ->groupBy('usage')
+                ->where(['>','created_at',strtotime(date('Y-m-d'))])
+                ->where(['shop'=>$shop])
+                ->asArray()
+                ->all();
+        $dayCount=array_sum(array_column($dayStatis,'num'));
+        $monthStatis=Orderreturn::find()
+            ->select(['count(*) as num', 'usage'])
+            ->groupBy('usage')
+            ->where(['>','created_at',strtotime(date('Y-m'))])
+            ->where(['shop'=>$shop])
+            ->asArray()
+            ->all();
+        $monthCount=array_sum(array_column($monthStatis,'num'));
+        $spreadsheet = new Spreadsheet();
+        $spreadsheet->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(30);
+        $spreadsheet->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(30);
+        //当日统计
+        $spreadsheet->setActiveSheetIndex(0)->mergeCells('A1:B1');
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('A1','当天退货数量统计 单位:个');
+        $spreadsheet->setActiveSheetIndex(0)->getStyle('A1')->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
+        
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('A2','退货包裹数');
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('B2',$dayCount);
+        $i=3;
+        $usageType=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
+        foreach($dayStatis as $item){
+            if(isset($usageType[$item['usage']])){
+                $spreadsheet->setActiveSheetIndex(0)->setCellValue('A'.$i,$usageType[$item['usage']]);
+                $spreadsheet->setActiveSheetIndex(0)->setCellValue('B'.$i,$item['num']);
+            }
+            $i++;
+        }
+
+        $i+=2;
+        //当月统计
+        $spreadsheet->setActiveSheetIndex(0)->mergeCells('A'.$i.':B'.$i);
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('A'.$i,'当月退货数量统计 单位:个');
+        $spreadsheet->setActiveSheetIndex(0)->getStyle('A'.$i)->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
+        
+        $i++;
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('A'.$i,'退货包裹数');
+        $spreadsheet->setActiveSheetIndex(0)->setCellValue('B'.$i,$dayCount);
+        $i++;
+        foreach($monthStatis as $item){
+            if(isset($usageType[$item['usage']])){
+                $spreadsheet->setActiveSheetIndex(0)->setCellValue('A'.$i,$usageType[$item['usage']]);
+                $spreadsheet->setActiveSheetIndex(0)->setCellValue('B'.$i,$item['num']);
+            }
+            $i++;
+        }
+        $spreadsheet->setActiveSheetIndex(0)->getStyle('B1:B'.$i)->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
+        
+        // Rename worksheet
+        $spreadsheet->getActiveSheet()->setTitle('Simple');
+        
+        // Set active sheet index to the first sheet, so Excel opens this as the first sheet
+        $spreadsheet->setActiveSheetIndex(0);
+        $filename=($shop==1 ? "美国仓":"亚马逊")."退货订单".date("Ymd").".xlsx";
+        // Redirect output to a client’s web browser (Xlsx)
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+        header('Content-Disposition: attachment;filename="'.$filename.'"');
+        header('Cache-Control: max-age=0');
+        // If you're serving to IE 9, then the following may be needed
+        header('Cache-Control: max-age=1');
+        
+        // If you're serving to IE over SSL, then the following may be needed
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
+        header('Pragma: public'); // HTTP/1.0
+        
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
+        $writer->save('php://output');
+        exit;
+
+
+
+
+
+
+
     }
 
     /**
@@ -68,8 +190,15 @@ class SiteController extends Controller
      */
     public function actionView($id)
     {
+        $is_create=false;
+        $headers = Yii::$app->request->headers;
+        $referer = $headers->get('Referer');
+        if(strpos($referer,'site/create')>-1){
+            $is_create=true;
+        }
         return $this->render('view', [
             'model' => $this->findModel($id),
+            'is_create'=>$is_create,
         ]);
     }
 
@@ -83,6 +212,7 @@ class SiteController extends Controller
         $request = Yii::$app->request;
         $shop = $request->getBodyParam('shop')??1;
         $model = new Orderreturn();
+        
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
@@ -106,7 +236,6 @@ class SiteController extends Controller
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
-
         return $this->render('update', [
             'model' => $model,
         ]);
@@ -139,7 +268,7 @@ class SiteController extends Controller
         }
         return $this->redirect(['index']);
     }
-    public function actionExport(){
+    public function actionImport(){
         
         $request = Yii::$app->request;
         $shop = $request->post('shop')??1;
@@ -195,13 +324,6 @@ class SiteController extends Controller
         }else{
             throw new \yii\web\NotFoundHttpException('错误请求');
         }
-
-
-
-
-  
-
-
         return $this->render('upload', ['model' => $model]);
     }
 

+ 37 - 0
controllers/UploadController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use yii\web\UploadedFile;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use app\models\LoginForm;
+use app\models\UploadImg;
+use yii\web\Response;
+
+class UploadController extends Controller
+{
+    public function actionImg(){
+        try {
+            Yii::$app->response->format = Response::FORMAT_JSON;
+            $model = new UploadImg();
+            $model->file = UploadedFile::getInstanceByName('file');
+            if (!$model->file) {
+                return false;
+            }
+            $info = $model->upload();
+            if ($info && is_array($info)) {
+                return $info;
+            } else {
+                return ['code' => 1, 'msg' => 'error'];
+            }
+        } catch (\Exception $e) {
+            return ['code' => 1, 'msg' => $e->getMessage()];
+        }
+
+    }
+   
+}

+ 6 - 1
models/Orderreturn.php

@@ -36,6 +36,8 @@ class Orderreturn extends \yii\db\ActiveRecord
     {
         return [
             [[ 'num','shop'], 'integer'],
+            [['imgs'], 'safe'],
+            [['imgs'], 'string', 'max' => 255],
             [['deliveryid', 'website', 'customer', 'receiptdate','delivery', 'origin_goodsinfo', 'goodsinfo', 'usage', 'mark'], 'string', 'max' => 255],
         ];
     }
@@ -64,6 +66,10 @@ class Orderreturn extends \yii\db\ActiveRecord
         parent::afterFind();
         $this->receiptdate=date('Y-m-d',$this->receiptdate);
     }
+    public function beforeValidate(){
+        is_array($this->imgs) && $this->imgs && $this->imgs = implode(',', $this->imgs);
+        return $this;
+    }
     public function beforeSave($options = array()){
         parent::beforeSave($options);
         $this->receiptdate=strtotime(trim($this->receiptdate));
@@ -71,7 +77,6 @@ class Orderreturn extends \yii\db\ActiveRecord
             $this->created_at=time();
         }
         return $this;
-        // dd($this);
     }
 
     

+ 59 - 0
models/UploadImg.php

@@ -0,0 +1,59 @@
+<?php
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\web\UploadedFile;
+use yii\helpers\FileHelper;
+
+class UploadImg extends Model
+{
+    public $file;
+    private $_appendRules;
+
+
+    public function init ()
+    {
+        parent::init();
+        $extensions = Yii::$app->params['webuploader']['baseConfig']['accept']['extensions'];
+        $this->_appendRules = [
+            [['file'], 'file', 'extensions' => $extensions],
+        ];
+    }
+
+  
+    public function rules()
+    {
+        $baseRules = [];
+        return array_merge($baseRules, $this->_appendRules);
+    }
+    
+    
+    public function upload()
+    {   
+       
+        // $relativePath = $successPath = '';
+        if ($this->validate()) {
+            $relativePath = './uploads/images/';
+            $successPath = '/uploads/images/';
+            $fileName = time().rand(1,100) . '.' . $this->file->extension;
+            if (!is_dir($relativePath)) {
+                FileHelper::createDirectory($relativePath);
+            }
+            $this->file->saveAs($relativePath . $fileName);
+            return [
+                'code' => 0,
+                'url' => Yii::$app->params['domain'] . $successPath . $fileName,
+                'attachment' => $successPath . $fileName
+            ];
+        } else {
+            $errors = $this->errors;
+            return [
+                'code' => 1,
+                'msg' => current($errors)[0]
+            ];
+        }
+
+    }
+
+}

+ 13 - 2
views/site/_form.php

@@ -19,13 +19,13 @@ use kartik\datetime\DateTimePicker;
 
     <?= $form->field($model, 'customer')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'delivery')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'delivery')->dropdownList(['1' =>'USPS','2'=>'UPS','3'=>'FedEx','4'=>'客人到店退货','5'=>'DHL' ]) ?>
 
     <?= $form->field($model, 'origin_goodsinfo')->textInput(['maxlength' => true]) ?>
 
     <?= $form->field($model, 'goodsinfo')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'usage')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'usage')->dropdownList(['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内']) ?>
 
     <?= $form->field($model, 'receiptdate')->widget(DateTimePicker::className(), [
     'pluginOptions' => [
@@ -39,6 +39,17 @@ use kartik\datetime\DateTimePicker;
 
     <?= $form->field($model, 'mark')->textInput(['maxlength' => true]) ?>
     <?= $form->field($model, 'shop')->dropdownList(['1' => "美国仓",'2'=>'亚马逊']) ?>
+    <?= $form->field($model, 'imgs')->widget('manks\FileInput', [
+        'clientOptions' => [
+            'pick' => [
+                'multiple' => true,
+            ],
+            // 'server' => Url::to('upload/u2'),
+            // 'accept' => [
+            // 	'extensions' => 'png',
+            // ],
+        ],
+    ]); ?>
 
     <div class="form-group">
         <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>

+ 31 - 4
views/site/index.php

@@ -6,6 +6,7 @@ use yii\widgets\ActiveForm;
 use yii\bootstrap\Nav;
 use yii\grid\CheckboxColumn;
 use yii\helpers\Url;
+use  yii\data\ArrayDataProvider;
 
 /* @var $this yii\web\View */
 /* @var $searchModel app\models\OrderreturnSearch */
@@ -28,6 +29,9 @@ $this->params['breadcrumbs'][] = $this->title;
 <div class="orderreturn-index">
   
     <h1><?php echo $shop==1?"美国仓":"亚马逊"; ?></h1>
+    <p class="">
+        <?= Html::a('统计数据', ['statis','shop'=>$shop], ['class' => 'btn btn-success ']) ?>
+    </p>
     <p class="order—create">
         <?= Html::a('创建', ['create'], ['class' => 'btn btn-success ']) ?>
     </p>
@@ -36,7 +40,7 @@ $this->params['breadcrumbs'][] = $this->title;
         $model=new app\models\UploadExcel();
         $form=ActiveForm::begin([
             'id' => 'upload-excel',
-            'action'=>'/site/export?shop='.$shop,
+            'action'=>'/site/import?shop='.$shop,
             'method'=>'post',
             'options'=>[
                 "class"=>"upload-excel",
@@ -50,7 +54,8 @@ $this->params['breadcrumbs'][] = $this->title;
     </p>
 
     <?php echo $this->render('_search', ['model' => $searchModel]); ?>
-
+   
+        
     <?= GridView::widget([
         'dataProvider' => $dataProvider,
         'showFooter' => true,
@@ -68,10 +73,32 @@ $this->params['breadcrumbs'][] = $this->title;
             ['attribute' => 'deliveryid', 'footerOptions' => ['class'=>'hide']],
             ['attribute' => 'website', 'footerOptions' => ['class'=>'hide']],
             ['attribute' => 'customer', 'footerOptions' => ['class'=>'hide']],
-            ['attribute' => 'delivery', 'footerOptions' => ['class'=>'hide']],
+            [
+                'attribute' => 'delivery', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' =>'USPS','2'=>'UPS','3'=>'FedEx','4'=>'客人到店退货','5'=>'DHL' ];
+                    if(isset($list[$model->delivery])){
+                        return $list[$model->delivery];
+                    }
+                    return $model->delivery;
+                }
+
+            ],
             ['attribute' => 'origin_goodsinfo', 'footerOptions' => ['class'=>'hide']],
             ['attribute' => 'goodsinfo', 'footerOptions' => ['class'=>'hide']],
-            ['attribute' => 'usage', 'footerOptions' => ['class'=>'hide']],
+            [
+                'attribute' => 'usage', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
+                    if(isset($list[$model->usage])){
+                        return $list[$model->usage];
+                    }
+                    return $model->usage;
+                }
+                
+            ],
             ['attribute' => 'receiptdate', 'footerOptions' => ['class'=>'hide']],
             ['attribute' => 'num', 'footerOptions' => ['class'=>'hide']],
             ['attribute' => 'mark', 'footerOptions' => ['class'=>'hide']],

+ 98 - 0
views/site/statis.php

@@ -0,0 +1,98 @@
+<?php
+
+use yii\helpers\Html;
+use yii\grid\GridView;
+use yii\widgets\ActiveForm;
+use yii\bootstrap\Nav;
+use yii\grid\CheckboxColumn;
+use yii\helpers\Url;
+use  yii\data\ArrayDataProvider;
+
+/* @var $this yii\web\View */
+/* @var $searchModel app\models\OrderreturnSearch */
+/* @var $dataProvider yii\data\ActiveDataProvider */
+
+$this->title = 'Orderreturns';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+ 
+<div class="orderreturn-index">
+  
+    <h1><?php echo $shop==1?"美国仓":"亚马逊"; ?>统计数据</h1>
+        <?= Html::a('导出', ['statis-export'], ['class' => 'btn btn-success ']) ?>
+  
+
+    <?php
+        $dayprovider = new ArrayDataProvider([
+            'allModels' => $dayStatis,
+            'pagination' => [
+                'pageSize' => 10,
+            ],
+            'sort' => [
+                'attributes' => ['usage'],
+            ],
+        ]);
+    ?>
+    <?= GridView::widget([
+        'dataProvider'=>$dayprovider,
+        'summary' => '',
+        'columns'=>[
+            [
+                'header' => '当日退货数量统计',
+                'attribute' => 'usage', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
+                    if(isset($list[$model['usage']])){
+                        return $list[$model['usage']];
+                    }
+                    return $model->usage;
+                }
+                
+            ],
+            [
+                'header'=>$dayCount,
+                'attribute' => 'num', 
+            ]
+        ]
+    ])?>         
+    <?php
+        $monthprovider = new ArrayDataProvider([
+            'allModels' => $monthStatis,
+            // 'pagination' => [
+            //     'pageSize' => 10,
+            // ],
+            'sort' => [
+                'attributes' => ['usage'],
+            ],
+        ]);
+    ?>
+    <?= GridView::widget([
+        'dataProvider'=>$monthprovider,
+        'summary' => '',
+        'columns'=>[
+            [
+                'header' => '当月退货数量统计',
+                'attribute' => 'usage', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
+                    if(isset($list[$model['usage']])){
+                        return $list[$model['usage']];
+                    }
+                    return $model->usage;
+                }
+                
+            ],
+            [
+                'header'=>$monthCount,
+                'attribute' => 'num', 
+            ]
+        ]
+    ])?>         
+        
+
+    
+
+
+</div>

+ 46 - 2
views/site/view.php

@@ -33,14 +33,58 @@ $this->params['breadcrumbs'][] = $this->title;
             'deliveryid',
             'website',
             'customer',
-            'delivery',
+            [
+                'attribute' => 'delivery', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' =>'USPS','2'=>'UPS','3'=>'FedEx','4'=>'客人到店退货','5'=>'DHL' ];
+                    if(isset($list[$model->delivery])){
+                        return $list[$model->delivery];
+                    }
+                    return $model->delivery;
+                }
+
+            ],
             'origin_goodsinfo',
             'goodsinfo',
-            'usage',
+            [
+                'attribute' => 'usage', 
+                'footerOptions' => ['class'=>'hide'],
+                'value'=>function($model){// 形参为此行记录对象
+                    $list=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
+                    if(isset($list[$model->usage])){
+                        return $list[$model->usage];
+                    }
+                    return $model->usage;
+                }
+                
+            ],
             'receiptdate',
             'num',
             'mark',
+            [
+                'attribute'=>'imgs',
+                'value'=>function($model){
+                    $str="";
+                    $imgs=explode(',',$model->imgs);
+                    if(is_array($imgs)&&!empty($imgs)){
+                        foreach($imgs as $img){
+                            $str.=' <img   height="100px" width="100px"  src =' .$img .'>';
+                        }
+                        return $str;
+                    }
+                },
+                'format'=>['html']
+                
+            ]
         ],
     ]) ?>
+    <?php if($is_create):  ?>
+
+     <p>
+        <?= Html::a('继续创建', ['create'], ['class' => 'btn btn-primary']) ?>
+        <?= Html::a('回主页', ['index'], ['class' => 'btn btn-primary']) ?>
+    </p>
+    <?php endif; ?>
 
 </div>