diff --git a/backend/controllers/TakingSiteController.php b/backend/controllers/TakingSiteController.php
index 01ef5d7..e192756 100644
--- a/backend/controllers/TakingSiteController.php
+++ b/backend/controllers/TakingSiteController.php
@@ -2,6 +2,8 @@
namespace backend\controllers;
+use common\models\ars\Area;
+use common\models\ars\City;
use Yii;
use common\models\ars\TakingSite;
use common\models\searchs\TakingSiteSearch;
@@ -66,6 +68,7 @@ class TakingSiteController extends Controller
public function actionCreate()
{
$model = new TakingSite();
+ $model->is_default = TakingSite::IS_DEFAULT_NO;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');
@@ -146,4 +149,38 @@ class TakingSiteController extends Controller
'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' => ''];
+ }
+ }
}
diff --git a/backend/views/express-template/_form.php b/backend/views/express-template/_form.php
new file mode 100644
index 0000000..113b190
--- /dev/null
+++ b/backend/views/express-template/_form.php
@@ -0,0 +1,46 @@
+
+
+
diff --git a/backend/views/express-template/_search.php b/backend/views/express-template/_search.php
new file mode 100644
index 0000000..803dbd1
--- /dev/null
+++ b/backend/views/express-template/_search.php
@@ -0,0 +1,49 @@
+
+
+ ['index'],
+ 'method' => 'get',
+ 'validateOnType' => true,
+ ]);
+?>
+
+
+ = $form->field($model, 'id', [
+ "template" => "{input}{error}",
+ "inputOptions" => [
+ "placeholder" => "检索ID",
+ "class" => "form-control",
+ ],
+ "errorOptions" => [
+ "class" => "error-tips"
+ ]
+ ])
+ ?>
+
+
+ = $form->field($model, "created_at_range", [
+ "template" => "{input}{error}",
+ "inputOptions" => [
+ "placeholder" => "创建时间",
+ ],
+ "errorOptions" => [
+ "class" => "error-tips"
+ ]
+ ])->widget(DateRangePicker::className());
+ ?>
+
+
+ = Html::submitButton('', ['class' => 'btn btn-default']) ?>
+ = Html::resetButton('', ['class' => 'btn btn-default']) ?>
+
+
+
\ No newline at end of file
diff --git a/backend/views/express-template/create.php b/backend/views/express-template/create.php
new file mode 100644
index 0000000..25d22cc
--- /dev/null
+++ b/backend/views/express-template/create.php
@@ -0,0 +1,18 @@
+title = '创建 Express Template';
+$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/views/express-template/index.php b/backend/views/express-template/index.php
new file mode 100644
index 0000000..0e83051
--- /dev/null
+++ b/backend/views/express-template/index.php
@@ -0,0 +1,28 @@
+title = '运费模板';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filter' => $this->render("_search", ['model' => $searchModel]),
+ 'batch' => [
+ [
+ "label" => "删除",
+ "url" => "express-template/deletes"
+ ],
+ ],
+ 'columns' => $columns
+ ]);
+ ?>
+
+
\ No newline at end of file
diff --git a/backend/views/express-template/update.php b/backend/views/express-template/update.php
new file mode 100644
index 0000000..20c70fd
--- /dev/null
+++ b/backend/views/express-template/update.php
@@ -0,0 +1,19 @@
+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 ';
+?>
+
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/views/express-template/view.php b/backend/views/express-template/view.php
new file mode 100644
index 0000000..5f7fcd0
--- /dev/null
+++ b/backend/views/express-template/view.php
@@ -0,0 +1,41 @@
+title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+
+
+
+ = Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?>
+
+
+ = 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',
+ ],
+ ]) ?>
+
+
diff --git a/common/models/searchs/ExpressTemplateSearch.php b/common/models/searchs/ExpressTemplateSearch.php
new file mode 100644
index 0000000..947d731
--- /dev/null
+++ b/common/models/searchs/ExpressTemplateSearch.php
@@ -0,0 +1,161 @@
+ '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;
+ }
+}