index.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use yii\widgets\ActiveForm;
  5. use yii\bootstrap\Nav;
  6. use yii\grid\CheckboxColumn;
  7. use yii\helpers\Url;
  8. use yii\data\ArrayDataProvider;
  9. /* @var $this yii\web\View */
  10. /* @var $searchModel app\models\OrderreturnSearch */
  11. /* @var $dataProvider yii\data\ActiveDataProvider */
  12. $this->title = 'Orderreturns';
  13. $this->params['breadcrumbs'][] = $this->title;
  14. ?>
  15. <div style="display:inline-block;">
  16. <?php
  17. echo Nav::widget([
  18. 'options' => ['class' => 'navbar-nav navbar-left'],
  19. 'items' => [
  20. ['label' => '美国仓', 'url' => ['/site/index','shop'=>1]],
  21. ['label' => '亚马逊', 'url' => ['/site/index','shop'=>2]],
  22. ],
  23. ]);
  24. ?>
  25. </div>
  26. <div class="orderreturn-index">
  27. <h1><?php echo $shop==1?"美国仓":"亚马逊"; ?></h1><br/>
  28. <p class="order—create">
  29. <?= Html::a('统计数据', ['statis','shop'=>$shop], ['class' => 'btn btn-info ']) ?>
  30. <?= Html::a('创建', ['create'], ['class' => 'btn btn-success ']) ?>
  31. </p>
  32. <p>
  33. <?php
  34. $model=new app\models\UploadExcel();
  35. $form=ActiveForm::begin([
  36. 'id' => 'upload-excel',
  37. 'action'=>'/site/import?shop='.$shop,
  38. 'method'=>'post',
  39. 'options'=>[
  40. "class"=>"upload-excel",
  41. 'enctype'=>'multipart/form-data',
  42. ]
  43. ]);
  44. ?>
  45. <?= Html::activeFileInput($model, 'excel', $options = []) ?>
  46. <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
  47. <?php ActiveForm::end() ?>
  48. </p>
  49. <br/>
  50. <?php echo $this->render('_search', ['model' => $searchModel]); ?>
  51. <?= GridView::widget([
  52. 'dataProvider' => $dataProvider,
  53. 'showFooter' => true,
  54. // 'filterModel' => $searchModel,
  55. 'id' => 'grid',
  56. 'columns' => [
  57. [
  58. 'class'=>CheckboxColumn::className(),
  59. 'name'=>'id',
  60. 'headerOptions' => ['width'=>'30'],
  61. 'footer' => '<button href="#" class="btn btn-default btn-xs btn-delete" url="'. Url::toRoute('site/delete-all') .'">批量删除</button>
  62. <button href="#" class="btn btn-default btn-xs btn-export" style="margin: 0px 20px;" url="'. Url::toRoute('site/order-export') .'">批量导出</button>',
  63. 'footerOptions' => ['colspan' => 5],
  64. ],
  65. ['attribute' => 'id', 'footerOptions' => ['class'=>'hide']],
  66. ['attribute' => 'deliveryid', 'footerOptions' => ['class'=>'hide']],
  67. ['attribute' => 'website', 'footerOptions' => ['class'=>'hide']],
  68. ['attribute' => 'customer', 'footerOptions' => ['class'=>'hide']],
  69. [
  70. 'attribute' => 'delivery',
  71. 'footerOptions' => ['class'=>'hide'],
  72. 'value'=>function($model){// 形参为此行记录对象
  73. $list=['1' =>'USPS','2'=>'UPS','3'=>'FedEx','4'=>'客人到店退货','5'=>'DHL' ];
  74. if(isset($list[$model->delivery])){
  75. return $list[$model->delivery];
  76. }
  77. return $model->delivery;
  78. }
  79. ],
  80. ['attribute' => 'origin_goodsinfo', 'footerOptions' => ['class'=>'hide']],
  81. ['attribute' => 'goodsinfo', 'footerOptions' => ['class'=>'hide']],
  82. [
  83. 'attribute' => 'usage',
  84. 'footerOptions' => ['class'=>'hide'],
  85. 'value'=>function($model){// 形参为此行记录对象
  86. $list=['1' => "可用-请加库存",'2'=>'不可用-退回工厂','3'=>'精打理-退回国内','4'=>'精打理-留美仓','5'=>'泡发-发回国内'];
  87. if(isset($list[$model->usage])){
  88. return $list[$model->usage];
  89. }
  90. return $model->usage;
  91. }
  92. ],
  93. ['attribute' => 'receiptdate', 'footerOptions' => ['class'=>'hide']],
  94. ['attribute' => 'num', 'footerOptions' => ['class'=>'hide']],
  95. ['attribute' => 'mark', 'footerOptions' => ['class'=>'hide']],
  96. ['class' => 'yii\grid\ActionColumn', 'header' => '管理操作', 'footerOptions' => ['class'=>'hide']],
  97. // ['class' => 'yii\grid\ActionColumn'],
  98. ],
  99. ]); ?>
  100. </div>
  101. <?php
  102. $script = <<< js
  103. $(".btn-delete").on("click", function(){
  104. var ids = $("#grid").yiiGridView("getSelectedRows");
  105. var self = $(this);
  106. if(ids.length == 0) return false;
  107. $.ajax({
  108. url:self.attr("url"),
  109. type:"post",
  110. data:{id:ids},
  111. success:function(res){
  112. }
  113. });
  114. });
  115. $(".btn-export").on("click", function(){
  116. var ids = $("#grid").yiiGridView("getSelectedRows");
  117. var self = $(this);
  118. if(ids.length == 0) return false;
  119. $.ajax({
  120. url:self.attr("url"),
  121. type:"post",
  122. data:{id:ids},
  123. dataType:'json',
  124. success:function(res){
  125. var a = document.createElement("a");
  126. a.href = res.file;
  127. a.download = '美国店退货订单.xlsx';
  128. document.body.appendChild(a);
  129. a.click();
  130. a.remove();
  131. }
  132. });
  133. });
  134. js;
  135. $this->registerJs($script);
  136. ?>