Browse Source

创建express-template模块的curl

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
7cf55d8d49
  1. 37
      backend/controllers/TakingSiteController.php
  2. 46
      backend/views/express-template/_form.php
  3. 49
      backend/views/express-template/_search.php
  4. 18
      backend/views/express-template/create.php
  5. 28
      backend/views/express-template/index.php
  6. 19
      backend/views/express-template/update.php
  7. 41
      backend/views/express-template/view.php
  8. 161
      common/models/searchs/ExpressTemplateSearch.php

37
backend/controllers/TakingSiteController.php

@ -2,6 +2,8 @@
namespace backend\controllers; namespace backend\controllers;
use common\models\ars\Area;
use common\models\ars\City;
use Yii; use Yii;
use common\models\ars\TakingSite; use common\models\ars\TakingSite;
use common\models\searchs\TakingSiteSearch; use common\models\searchs\TakingSiteSearch;
@ -66,6 +68,7 @@ class TakingSiteController extends Controller
public function actionCreate() public function actionCreate()
{ {
$model = new TakingSite(); $model = new TakingSite();
$model->is_default = TakingSite::IS_DEFAULT_NO;
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index'); return $this->redirect('index');
@ -146,4 +149,38 @@ class TakingSiteController extends Controller
'columns' => $searchModel->columns() 'columns' => $searchModel->columns()
]); ]);
} }
/**
* @return array
* 根据省获取市数据
*/
public function actionCity()
{
Yii::$app->response->format = 'json';
$parents = Yii::$app->request->post('depdrop_parents');
if ($parents != null) {
$provinceId = $parents[0];
$data = City::find()->select('city_id as id,name')->where(['province_id' => $provinceId])->asArray()->all();
return ['output' => $data, 'selected' => '441904'];
} else {
return ['output' => '', 'selected' => ''];
}
}
/**
* @return array
* 根据市数据获取区域数据
*/
public function actionArea()
{
Yii::$app->response->format = 'json';
$parents = Yii::$app->request->post('depdrop_parents');
if ($parents != null) {
$cityId = $parents[0];
$data = Area::find()->select('area_id as id,name')->where(['city_id' => $cityId])->asArray()->all();
return ['output' => $data, 'selected' => ''];
} else {
return ['output' => '', 'selected' => ''];
}
}
} }

46
backend/views/express-template/_form.php

@ -0,0 +1,46 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="express-template-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'province')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'city')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'area')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'billing_type')->textInput() ?>
<?= $form->field($model, 'extra_weight_type')->textInput() ?>
<?= $form->field($model, 'exemption_type')->textInput() ?>
<?= $form->field($model, 'basic_price')->textInput() ?>
<?= $form->field($model, 'extra_price')->textInput() ?>
<?= $form->field($model, 'exemption_amount')->textInput() ?>
<?= $form->field($model, 'support_taking')->textInput() ?>
<?= $form->field($model, 'taking_site')->textarea(['rows' => 6]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

49
backend/views/express-template/_search.php

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use \blobt\widgets\DateRangePicker;
/* @var $this yii\web\View */
/* @var $model common\models\searchs\ExpressTemplateSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
'validateOnType' => true,
]);
?>
<div class="row">
<div class="col">
<?= $form->field($model, 'id', [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "检索ID",
"class" => "form-control",
],
"errorOptions" => [
"class" => "error-tips"
]
])
?>
</div>
<div class="col">
<?= $form->field($model, "created_at_range", [
"template" => "{input}{error}",
"inputOptions" => [
"placeholder" => "创建时间",
],
"errorOptions" => [
"class" => "error-tips"
]
])->widget(DateRangePicker::className());
?>
</div>
<div class="form-group">
<?= Html::submitButton('<i class="fa fa-filter"></i>', ['class' => 'btn btn-default']) ?>
<?= Html::resetButton('<i class="fa fa-eraser"></i>', ['class' => 'btn btn-default']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>

18
backend/views/express-template/create.php

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
$this->title = '创建 Express Template';
$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="express-template-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

28
backend/views/express-template/index.php

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use iron\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\ExpressTemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '运费模板';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-12">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filter' => $this->render("_search", ['model' => $searchModel]),
'batch' => [
[
"label" => "删除",
"url" => "express-template/deletes"
],
],
'columns' => $columns
]);
?>
</div>
</div>

19
backend/views/express-template/update.php

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
$this->title = '编辑 Express Template: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update ';
?>
<div class="express-template-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

41
backend/views/express-template/view.php

@ -0,0 +1,41 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="express-template-view">
<p>
<?= Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'province:ntext',
'city:ntext',
'area:ntext',
'billing_type',
'extra_weight_type',
'exemption_type',
'basic_price',
'extra_price',
'exemption_amount',
'support_taking',
'taking_site:ntext',
'updated_at',
'created_at',
],
]) ?>
</div>

161
common/models/searchs/ExpressTemplateSearch.php

@ -0,0 +1,161 @@
<?php
namespace common\models\searchs;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use common\models\ars\ExpressTemplate;
/**
* ExpressTemplateSearch represents the model behind the search form of `common\models\ars\ExpressTemplate`.
*/
class ExpressTemplateSearch extends ExpressTemplate
{
/**
* @return array
* 增加创建时间查询字段
*/
public function attributes()
{
return ArrayHelper::merge(['created_at_range'], parent::attributes());
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking', 'updated_at', 'created_at'], 'integer'],
[['name', 'province', 'city', 'area', 'taking_site'], 'safe'],
['created_at_range','safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* @return array
* 列格式
*/
public function columns()
{
return [
[
'class' => 'blobt\grid\CheckboxColumn',
'width' => '2%',
'align' => 'center'
],
'id',
'name',
'province',
'city',
'area',
//'billing_type',
//'extra_weight_type',
//'exemption_type',
//'basic_price',
//'extra_price',
//'exemption_amount',
//'support_taking',
//'taking_site',
//'updated_at',
//'created_at',
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',
],
];
}
/**
* @param $params
* @return ActiveDataProvider
* 不分页的所有数据
*/
public function allData($params)
{
$query = ExpressTemplate::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => false,
'sort' => false
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = ExpressTemplate::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSizeLimit' => [1, 200]
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
]
],
]);
$this->load($params);
return $this->filter($query, $dataProvider);
}
/**
* @param $query
* @param $dataProvider
* @return ActiveDataProvider
* 条件筛选
*/
private function filter($query, $dataProvider){
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'billing_type' => $this->billing_type,
'extra_weight_type' => $this->extra_weight_type,
'exemption_type' => $this->exemption_type,
'basic_price' => $this->basic_price,
'extra_price' => $this->extra_price,
'exemption_amount' => $this->exemption_amount,
'support_taking' => $this->support_taking,
'updated_at' => $this->updated_at,
'created_at' => $this->created_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'province', $this->province])
->andFilterWhere(['like', 'city', $this->city])
->andFilterWhere(['like', 'area', $this->area])
->andFilterWhere(['like', 'taking_site', $this->taking_site]);
if ($this->created_at_range) {
$arr = explode(' ~ ', $this->created_at_range);
$start = strtotime($arr[0]);
$end = strtotime($arr[1]) + 3600 * 24;
$query->andFilterWhere(['between', 'created_at', $start, $end]);
}
return $dataProvider;
}
}
Loading…
Cancel
Save