diff --git a/backend/controllers/TakingSiteController.php b/backend/controllers/TakingSiteController.php index e192756..d83fe6a 100644 --- a/backend/controllers/TakingSiteController.php +++ b/backend/controllers/TakingSiteController.php @@ -68,7 +68,6 @@ 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'); @@ -161,7 +160,7 @@ class TakingSiteController extends Controller 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']; + return ['output' => $data, 'selected' => '']; } else { return ['output' => '', 'selected' => '']; } diff --git a/backend/views/express-template/_form.php b/backend/views/express-template/_form.php index 113b190..544c632 100644 --- a/backend/views/express-template/_form.php +++ b/backend/views/express-template/_form.php @@ -1,46 +1,21 @@ -
+field($model, 'name')->textInput(['maxlength' => true]) ?> - +field($model, 'calculation')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculation, 'type' => "radio"]) ?> - field($model, 'name')->textInput(['maxlength' => true]) ?> +field($model, 'basic_amount')->textInput() ?> - field($model, 'province')->textarea(['rows' => 6]) ?> +field($model, 'basic_price')->textInput() ?> - field($model, 'city')->textarea(['rows' => 6]) ?> +field($model, 'extra_amount')->textInput() ?> - field($model, 'area')->textarea(['rows' => 6]) ?> - - field($model, 'billing_type')->textInput() ?> - - field($model, 'extra_weight_type')->textInput() ?> - - field($model, 'exemption_type')->textInput() ?> - - field($model, 'basic_price')->textInput() ?> - - field($model, 'extra_price')->textInput() ?> - - field($model, 'exemption_amount')->textInput() ?> - - field($model, 'support_taking')->textInput() ?> - - field($model, 'taking_site')->textarea(['rows' => 6]) ?> - -
- 'btn btn-success']) ?> - 'btn btn-info']) ?> -
- - - -
+field($model, 'extra_price')->textInput() ?> diff --git a/backend/views/express-template/create.php b/backend/views/express-template/create.php index 25d22cc..f939012 100644 --- a/backend/views/express-template/create.php +++ b/backend/views/express-template/create.php @@ -1,6 +1,8 @@ title = '创建 Express Template'; $this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; +Yii::$app->params['bsVersion'] = '4.x'; ?>
+
- render('_form', [ - 'model' => $model, - ]) ?> + ['class' => 'container-fluid']]); + echo TabsX::widget([ + 'bordered' => true, + 'items' => [ + [ + 'label' => ' 基本信息', + 'content' => $this->render('_form', [ + 'model' => $model, + 'form' => $form, + ]), + ], + ], + 'position' => TabsX::POS_ABOVE, + 'encodeLabels' => false + ]); + ?> + +
+ 'btn btn-success']) ?> + 'btn btn-info']) ?> +
+ + + +
diff --git a/backend/views/express-template/view.php b/backend/views/express-template/view.php index 5f7fcd0..5fd222f 100644 --- a/backend/views/express-template/view.php +++ b/backend/views/express-template/view.php @@ -25,14 +25,11 @@ $this->params['breadcrumbs'][] = $this->title; 'province:ntext', 'city:ntext', 'area:ntext', - 'billing_type', - 'extra_weight_type', - 'exemption_type', + 'calculation', 'basic_price', + 'basic_amount', 'extra_price', - 'exemption_amount', - 'support_taking', - 'taking_site:ntext', + 'extra_amount', 'updated_at', 'created_at', ], diff --git a/backend/views/taking-site/_form.php b/backend/views/taking-site/_form.php index c115e02..814c8d5 100644 --- a/backend/views/taking-site/_form.php +++ b/backend/views/taking-site/_form.php @@ -1,11 +1,19 @@ select('province_id as id,name')->asArray()->all(); +$data = ArrayHelper::map($provinces, 'id', 'name'); +Yii::$app->params['bsVersion'] = '4.x'; ?>
@@ -14,15 +22,40 @@ use yii\bootstrap4\ActiveForm; field($model, 'name')->textInput(['maxlength' => true]) ?> - field($model, 'province')->textInput(['maxlength' => true]) ?> +
+
+ field($model, 'province')->dropDownList($data, ['id' => 'province-id', 'prompt' => '请选择']); ?> +
+
+ field($model, 'city')->widget(DepDrop::classname(), [ + 'options' => ['id' => 'city-id', 'prompt' => $model->city], + 'data' => $cityList, + 'pluginOptions' => [ + 'depends' => ['province-id'], + 'placeholder' => '请选择成市', + 'url' => Url::to(['/taking-site/city']) + ], + 'pluginEvents' => [ + "depdrop:change" => "function(event, id, value, count) { log(id); log(value); log(count); }", + ] - field($model, 'city')->textInput(['maxlength' => true]) ?> + ]) ?> +
+
+ field($model, 'area')->widget(DepDrop::classname(), [ + 'options' => ['prompt' => $model->area], + 'data' => $areaList, + 'pluginOptions' => [ + 'depends' => ['city-id'], + 'placeholder' => '请选择县区', + 'url' => Url::to(['/taking-site/area']) - field($model, 'area')->textInput(['maxlength' => true]) ?> - - field($model, 'address')->textarea(['rows' => 6]) ?> + ] + ]) ?> +
+
- field($model, 'is_default')->textInput() ?> + field($model, 'address')->textarea(['rows' => 2]) ?>
'btn btn-success']) ?> diff --git a/backend/views/taking-site/create.php b/backend/views/taking-site/create.php index e3725b6..e29a8c0 100644 --- a/backend/views/taking-site/create.php +++ b/backend/views/taking-site/create.php @@ -1,6 +1,6 @@ params['breadcrumbs'][] = $this->title; render('_form', [ 'model' => $model, + 'cityList'=>[], + 'areaList'=>[] ]) ?>
diff --git a/backend/views/taking-site/index.php b/backend/views/taking-site/index.php index 5efb74c..44af872 100644 --- a/backend/views/taking-site/index.php +++ b/backend/views/taking-site/index.php @@ -7,7 +7,7 @@ use iron\grid\GridView; /* @var $searchModel common\models\searchs\TakingSiteSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -$this->title = 'Taking Sites'; +$this->title = '上门自提'; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/backend/views/taking-site/update.php b/backend/views/taking-site/update.php index 2940c34..7b0136a 100644 --- a/backend/views/taking-site/update.php +++ b/backend/views/taking-site/update.php @@ -1,19 +1,28 @@ title = '编辑 Taking Site: ' . $model->name; +$this->title = '编辑: ' . $model->name; $this->params['breadcrumbs'][] = ['label' => 'Taking Sites', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update '; + +$cities = City::find()->select('city_id as id,name')->where(['province_id' => $model->province])->asArray()->all(); +$cityList = \yii\helpers\ArrayHelper::map($cities, 'id', 'name'); +$areas = Area::find()->select('area_id as id,name')->where(['city_id' => $model->city])->asArray()->all(); +$areaList = \yii\helpers\ArrayHelper::map($areas, 'id', 'name'); ?>
render('_form', [ 'model' => $model, + 'cityList' => $cityList, + 'areaList' => $areaList ]) ?>
diff --git a/backend/views/taking-site/view.php b/backend/views/taking-site/view.php index 576709a..dd5add5 100644 --- a/backend/views/taking-site/view.php +++ b/backend/views/taking-site/view.php @@ -26,7 +26,6 @@ $this->params['breadcrumbs'][] = $this->title; 'city', 'area', 'address:ntext', - 'is_default', 'updated_at', 'created_at', ], diff --git a/common/models/ars/ExpressTemplate.php b/common/models/ars/ExpressTemplate.php index e3e6b81..d21f833 100644 --- a/common/models/ars/ExpressTemplate.php +++ b/common/models/ars/ExpressTemplate.php @@ -13,19 +13,24 @@ use yii\behaviors\TimestampBehavior; * @property string $province 省份 * @property string $city 城市 * @property string $area 区域 - * @property int $billing_type 账单类型 - * @property int $extra_weight_type 续重重量类型 - * @property int $exemption_type 包邮类型 + * @property int $calculation 计算方式 * @property int $basic_price 基本运费 + * @property int $basic_amount 基本数量 * @property int $extra_price 续重运费 - * @property int $exemption_amount 包邮金额 - * @property int $support_taking 是否支持自提,1为不支持 - * @property string $taking_site 自提地点 + * @property int $extra_amount 续重运费 * @property int $updated_at 更新时间 * @property int $created_at 创建时间 */ class ExpressTemplate extends \yii\db\ActiveRecord { + //计算方式calculation + const CALCULATION_WEIGHT = 1; //按重量 + const CALCULATION_NUMBER = 2; //按件数 + + public static $calculation = [ + self::CALCULATION_WEIGHT => '按重量', + self::CALCULATION_NUMBER => '按件数' + ]; /** * {@inheritdoc} */ @@ -41,8 +46,8 @@ class ExpressTemplate extends \yii\db\ActiveRecord { return [ [['name'], 'required'], - [['province', 'city', 'area', 'taking_site'], 'string'], - [['billing_type', 'extra_weight_type', 'exemption_type', 'basic_price', 'extra_price', 'exemption_amount', 'support_taking'], 'integer'], + [['province', 'city', 'area'], 'string'], + [['calculation', 'basic_price', 'basic_amount', 'extra_price', 'extra_amount'], 'integer'], [['name'], 'string', 'max' => 255], ]; } @@ -58,14 +63,11 @@ class ExpressTemplate extends \yii\db\ActiveRecord 'province' => '省份', 'city' => '城市', 'area' => '区域', - 'billing_type' => '账单类型', - 'extra_weight_type' => '续重重量类型', - 'exemption_type' => '包邮类型', + 'calculation' => '计算方式', 'basic_price' => '基本运费', + 'basic_amount' => '基本数量', 'extra_price' => '续重运费', - 'exemption_amount' => '包邮金额', - 'support_taking' => '是否支持自提,1为不支持', - 'taking_site' => '自提地点', + 'extra_amount' => '续重运费', 'updated_at' => '更新时间', 'created_at' => '创建时间', ]; diff --git a/common/models/ars/TakingSite.php b/common/models/ars/TakingSite.php new file mode 100644 index 0000000..a4acf48 --- /dev/null +++ b/common/models/ars/TakingSite.php @@ -0,0 +1,81 @@ + 120], + [['province', 'city', 'area'], 'string', 'max' => 64], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'id', + 'name' => '名称', + 'updated_at' => '更新时间', + 'created_at' => '创建时间', + 'province' => '省份', + 'city' => '城市', + 'area' => '区域', + 'address' => '地址', + ]; + } + + + /** + * @author linyao + * @email 602604991@qq.com + * @created Nov 8, 2019 + * + * 行为存储创建时间和更新时间 + */ + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => function() { + return time(); + }, + ], + ]; + } +} diff --git a/common/models/searchs/ExpressTemplateSearch.php b/common/models/searchs/ExpressTemplateSearch.php index 947d731..bd233d3 100644 --- a/common/models/searchs/ExpressTemplateSearch.php +++ b/common/models/searchs/ExpressTemplateSearch.php @@ -26,8 +26,8 @@ class ExpressTemplateSearch extends ExpressTemplate 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'], + [['id', 'calculation', 'basic_price', 'basic_amount', 'extra_price', 'extra_amount', 'updated_at', 'created_at'], 'integer'], + [['name', 'province', 'city', 'area'], 'safe'], ['created_at_range','safe'], ]; } @@ -54,19 +54,6 @@ class ExpressTemplateSearch extends ExpressTemplate ], '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', @@ -134,13 +121,11 @@ class ExpressTemplateSearch extends ExpressTemplate // 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, + 'calculation' => $this->calculation, 'basic_price' => $this->basic_price, + 'basic_amount' => $this->basic_amount, 'extra_price' => $this->extra_price, - 'exemption_amount' => $this->exemption_amount, - 'support_taking' => $this->support_taking, + 'extra_amount' => $this->extra_amount, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, ]); @@ -148,8 +133,7 @@ class ExpressTemplateSearch extends ExpressTemplate $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]); + ->andFilterWhere(['like', 'area', $this->area]); if ($this->created_at_range) { $arr = explode(' ~ ', $this->created_at_range); $start = strtotime($arr[0]); diff --git a/common/models/searchs/TakingSiteSearch.php b/common/models/searchs/TakingSiteSearch.php index b41646f..ce91a75 100644 --- a/common/models/searchs/TakingSiteSearch.php +++ b/common/models/searchs/TakingSiteSearch.php @@ -26,7 +26,7 @@ class TakingSiteSearch extends TakingSite public function rules() { return [ - [['id', 'is_default', 'updated_at', 'created_at'], 'integer'], + [['id', 'updated_at', 'created_at'], 'integer'], [['name', 'province', 'city', 'area', 'address'], 'safe'], ['created_at_range','safe'], ]; @@ -58,7 +58,6 @@ class TakingSiteSearch extends TakingSite 'city', 'area', //'address', - //'is_default', //'updated_at', //'created_at', [ @@ -128,7 +127,6 @@ class TakingSiteSearch extends TakingSite // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, - 'is_default' => $this->is_default, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at, ]); diff --git a/console/migrations/m191203_031446_drop_column_is_default_in_table_ats_taking_site.php b/console/migrations/m191203_031446_drop_column_is_default_in_table_ats_taking_site.php new file mode 100644 index 0000000..7c43851 --- /dev/null +++ b/console/migrations/m191203_031446_drop_column_is_default_in_table_ats_taking_site.php @@ -0,0 +1,20 @@ +dropColumn('ats_taking_site', 'is_default'); + } + + public function down() + { + $this->addColumn('ats_taking_site', 'is_default', $this->tinyInteger(1)->defaultValue(0)->comment('是否为默认,1为默认')); + return true; + } +}