Browse Source

重新设计修改运费模板数据表字段,重新生成运费模板模型和curd文件,删除自提数据表is_default字段,修改相应的自提curd文件和model文件

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
b4cdea200b
  1. 3
      backend/controllers/TakingSiteController.php
  2. 41
      backend/views/express-template/_form.php
  3. 33
      backend/views/express-template/create.php
  4. 9
      backend/views/express-template/view.php
  5. 47
      backend/views/taking-site/_form.php
  6. 4
      backend/views/taking-site/create.php
  7. 2
      backend/views/taking-site/index.php
  8. 11
      backend/views/taking-site/update.php
  9. 1
      backend/views/taking-site/view.php
  10. 30
      common/models/ars/ExpressTemplate.php
  11. 81
      common/models/ars/TakingSite.php
  12. 28
      common/models/searchs/ExpressTemplateSearch.php
  13. 4
      common/models/searchs/TakingSiteSearch.php
  14. 20
      console/migrations/m191203_031446_drop_column_is_default_in_table_ats_taking_site.php

3
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' => ''];
}

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

@ -1,46 +1,21 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use blobt\widgets\Icheck;
use common\models\ars\ExpressTemplate;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="express-template-form">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'calculation')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculation, 'type' => "radio"]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'basic_amount')->textInput() ?>
<?= $form->field($model, 'province')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'basic_price')->textInput() ?>
<?= $form->field($model, 'city')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'extra_amount')->textInput() ?>
<?= $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>
<?= $form->field($model, 'extra_price')->textInput() ?>

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

@ -1,6 +1,8 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\Html;
use yii\bootstrap4\ActiveForm;
use kartik\tabs\TabsX;
/* @var $this yii\web\View */
/* @var $model common\models\ars\ExpressTemplate */
@ -8,11 +10,36 @@ use yii\helpers\Html;
$this->title = '创建 Express Template';
$this->params['breadcrumbs'][] = ['label' => 'Express Templates', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Yii::$app->params['bsVersion'] = '4.x';
?>
<div class="express-template-create">
<div class="express-template-form">
<?= $this->render('_form', [
<?php
$form = ActiveForm::begin(['options' => ['class' => 'container-fluid']]);
echo TabsX::widget([
'bordered' => true,
'items' => [
[
'label' => '<i class="fas fa-user"></i> 基本信息',
'content' => $this->render('_form', [
'model' => $model,
]) ?>
'form' => $form,
]),
],
],
'position' => TabsX::POS_ABOVE,
'encodeLabels' => false
]);
?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>

9
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',
],

47
backend/views/taking-site/_form.php

@ -1,11 +1,19 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\Html;
use yii\bootstrap4\ActiveForm;
use blobt\widgets\Icheck;
use kartik\depdrop\DepDrop;
use common\models\ars\Province;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\ars\TakingSite */
/* @var $form yii\widgets\ActiveForm */
$provinces = Province::find()->select('province_id as id,name')->asArray()->all();
$data = ArrayHelper::map($provinces, 'id', 'name');
Yii::$app->params['bsVersion'] = '4.x';
?>
<div class="taking-site-form">
@ -14,15 +22,40 @@ use yii\bootstrap4\ActiveForm;
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'province')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>
<div class="row">
<div class="col-lg-4">
<?= $form->field($model, 'province')->dropDownList($data, ['id' => 'province-id', 'prompt' => '请选择']); ?>
</div>
<div class="col-lg-4">
<?= $form->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); }",
]
<?= $form->field($model, 'area')->textInput(['maxlength' => true]) ?>
]) ?>
</div>
<div class="col-lg-4">
<?= $form->field($model, 'area')->widget(DepDrop::classname(), [
'options' => ['prompt' => $model->area],
'data' => $areaList,
'pluginOptions' => [
'depends' => ['city-id'],
'placeholder' => '请选择县区',
'url' => Url::to(['/taking-site/area'])
<?= $form->field($model, 'address')->textarea(['rows' => 6]) ?>
]
]) ?>
</div>
</div>
<?= $form->field($model, 'is_default')->textInput() ?>
<?= $form->field($model, 'address')->textarea(['rows' => 2]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>

4
backend/views/taking-site/create.php

@ -1,6 +1,6 @@
<?php
use yii\helpers\Html;
use yii\bootstrap4\Html;
/* @var $this yii\web\View */
/* @var $model common\models\ars\TakingSite */
@ -13,6 +13,8 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'cityList'=>[],
'areaList'=>[]
]) ?>
</div>

2
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;
?>
<div class="row">

11
backend/views/taking-site/update.php

@ -1,19 +1,28 @@
<?php
use yii\helpers\Html;
use common\models\ars\City;
use common\models\ars\Area;
/* @var $this yii\web\View */
/* @var $model common\models\ars\TakingSite */
$this->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');
?>
<div class="taking-site-update">
<?= $this->render('_form', [
'model' => $model,
'cityList' => $cityList,
'areaList' => $areaList
]) ?>
</div>

1
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',
],

30
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' => '创建时间',
];

81
common/models/ars/TakingSite.php

@ -0,0 +1,81 @@
<?php
namespace common\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "ats_taking_site".
*
* @property int $id
* @property string $name 名称
* @property int $updated_at 更新时间
* @property int $created_at 创建时间
* @property string $province 省份
* @property string $city 城市
* @property string $area 区域
* @property string $address 地址
*/
class TakingSite extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'ats_taking_site';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'province', 'city', 'area', 'address'], 'required'],
[['address'], 'string'],
[['name'], 'string', 'max' => 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();
},
],
];
}
}

28
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]);

4
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,
]);

20
console/migrations/m191203_031446_drop_column_is_default_in_table_ats_taking_site.php

@ -0,0 +1,20 @@
<?php
use yii\db\Migration;
/**
* Class m191203_031446_drop_column_is_default_in_table_ats_taking_site
*/
class m191203_031446_drop_column_is_default_in_table_ats_taking_site extends Migration
{
public function up()
{
$this->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;
}
}
Loading…
Cancel
Save