linyaostalker
5 years ago
4 changed files with 323 additions and 2 deletions
-
79backend/modules/shop/controllers/ExpressTemplateController.php
-
50backend/modules/shop/views/express-template/express_area_create.php
-
145backend/modules/shop/views/express-template/express_area_form.php
-
51backend/modules/shop/views/express-template/express_area_update.php
@ -0,0 +1,50 @@ |
|||
<?php |
|||
|
|||
use yii\bootstrap4\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use kartik\tabs\TabsX; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\shop\models\ars\ExpressTemplate */ |
|||
|
|||
$this->title = '创建运费模板'; |
|||
$this->params['breadcrumbs'][] = ['label' => '运费模板', 'url' => ['index']]; |
|||
$this->params['breadcrumbs'][] = $this->title; |
|||
Yii::$app->params['bsVersion'] = '4.x'; |
|||
?>
|
|||
<div class="express-template-create"> |
|||
<div class="express-template-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, |
|||
]), |
|||
], |
|||
[ |
|||
'label' => '<i class="fas fa-globe"></i> 选择配送区域', |
|||
'content' => $this->render('area', ['data' => $data, 'form' => $form, 'cities' => [] |
|||
]), |
|||
], |
|||
], |
|||
'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> |
@ -0,0 +1,145 @@ |
|||
<?php |
|||
|
|||
use blobt\widgets\Icheck; |
|||
use backend\modules\shop\models\ars\ExpressTemplate; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\shop\models\ars\ExpressTemplate */ |
|||
/* @var $form yii\widgets\ActiveForm */ |
|||
?>
|
|||
|
|||
<?php |
|||
$status = Yii::$app->request->get('status'); |
|||
if ($status == 1) { |
|||
?>
|
|||
<div class="alert alert-warning alert-dismissible" role="alert"> |
|||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span |
|||
aria-hidden="true">×</span></button> |
|||
<p style="color: #2e2e2e">必须至少选择一个城市为配送区域</p> |
|||
</div> |
|||
<?php } ?>
|
|||
|
|||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
|||
|
|||
<?= $form->field($model, 'calculation_type')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculationType, 'type' => "radio"]) ?>
|
|||
|
|||
<?= $form->field($model, 'basic_count')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'basic_price')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'extra_count')->textInput() ?>
|
|||
|
|||
<?= $form->field($model, 'extra_price')->textInput() ?>
|
|||
|
|||
<?php |
|||
$js=<<<JS |
|||
const formList = [//切换时,class对应的标题
|
|||
{ |
|||
"field-expresstemplate-basic_count":"基本重量(KG)", |
|||
"field-expresstemplate-basic_price":"基本运费(元)", |
|||
"field-expresstemplate-extra_count":"续重重量(KG)", |
|||
"field-expresstemplate-extra_price":"续重运费(元)" |
|||
|
|||
}, |
|||
|
|||
{ |
|||
"field-expresstemplate-basic_count":"基本数量(件)", |
|||
"field-expresstemplate-basic_price":"基本运费(元)", |
|||
"field-expresstemplate-extra_count":"续重数量(件)", |
|||
"field-expresstemplate-extra_price":"续重运费(元)" |
|||
|
|||
} |
|||
] |
|||
const udfVal = [//初始值
|
|||
[0.1,"0.00"], |
|||
[1,"0.00"] |
|||
] |
|||
var calType = 1;//初始的计算方式0:计重 1:计件
|
|||
|
|||
function updateTypeChangeCalType(type){//当切换计算方式
|
|||
|
|||
$.each(formList[type],function(index,value){ //更改文字标题
|
|||
$("." + index).children("label").html(value) |
|||
}); |
|||
|
|||
$("#expresstemplate-basic_count").val(udfVal[type][0])//重置初始值
|
|||
$("#expresstemplate-basic_price").val(udfVal[type][1]) |
|||
$("#expresstemplate-extra_count").val(0) |
|||
$("#expresstemplate-extra_price").val(udfVal[type][1]) |
|||
calType = type; |
|||
} |
|||
function changeCalType(type){//当切换计算方式
|
|||
|
|||
$.each(formList[type],function(index,value){ //更改文字标题
|
|||
$("." + index).children("label").html(value) |
|||
}); |
|||
|
|||
if(!$("#expresstemplate-basic_count").val()){ |
|||
$("#expresstemplate-basic_count").val(udfVal[type][0])//重置初始值
|
|||
} |
|||
if(!$("#expresstemplate-basic_price").val()){ |
|||
$("#expresstemplate-basic_price").val(udfVal[type][1]) |
|||
} |
|||
if(!$("#expresstemplate-extra_count").val()){ |
|||
$("#expresstemplate-extra_count").val(0) |
|||
} |
|||
if(!$("#expresstemplate-extra_price").val()){ |
|||
$("#expresstemplate-extra_price").val(udfVal[type][1]) |
|||
} |
|||
calType = type; |
|||
} |
|||
$(document).ready(function(){ |
|||
$("#expresstemplate-basic_count").blur(function(){ |
|||
if (calType == 0) { |
|||
if($(this).val() < 0.1){ |
|||
$(this).val(0.1) |
|||
} |
|||
var basiccount = $(this).val(); |
|||
$(this).val(Math.floor(basiccount * 10) / 10); |
|||
} else{ |
|||
if($(this).val() < 1){ |
|||
$(this).val(1) |
|||
} |
|||
var basiccount = $(this).val(); |
|||
$(this).val(Math.floor(basiccount * 1) / 1); |
|||
} |
|||
}) |
|||
$("#expresstemplate-basic_price").blur(function(){ |
|||
if($(this).val().indexOf('-') != -1){ |
|||
$(this).val("0.00") |
|||
} |
|||
var basicPrice = $(this).val(); |
|||
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/)); |
|||
}) |
|||
$("#expresstemplate-extra_count").blur(function(){ |
|||
if (calType == 0) { |
|||
if($(this).val() < 0){ |
|||
$(this).val(0) |
|||
} |
|||
var basiccount = $(this).val(); |
|||
$(this).val(Math.floor(basiccount * 10) / 10); |
|||
} else{ |
|||
if($(this).val() < 0){ |
|||
$(this).val(0) |
|||
} |
|||
var basiccount = $(this).val(); |
|||
$(this).val(Math.floor(basiccount * 1) / 1); |
|||
} |
|||
}) |
|||
$("#expresstemplate-extra_price").blur(function(){ |
|||
if($(this).val().indexOf('-') != -1){ |
|||
$(this).val("0.00") |
|||
} |
|||
var basicPrice = $(this).val(); |
|||
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/)); |
|||
}) |
|||
|
|||
$("input:radio[name='ExpressTemplate[calculation_type]']").on('ifChecked', function(event){ |
|||
updateTypeChangeCalType($(this).val()-1) |
|||
}) |
|||
changeCalType(calType) |
|||
}) |
|||
JS; |
|||
$this->registerJs($js) |
|||
|
|||
?>
|
@ -0,0 +1,51 @@ |
|||
<?php |
|||
|
|||
use yii\bootstrap4\Html; |
|||
use yii\bootstrap4\ActiveForm; |
|||
use kartik\tabs\TabsX; |
|||
|
|||
/* @var $this yii\web\View */ |
|||
/* @var $model backend\modules\shop\models\ars\ExpressTemplate */ |
|||
|
|||
$this->title = '编辑运费模板: ' . $model->name; |
|||
$this->params['breadcrumbs'][] = ['label' => '运费模板', 'url' => ['index']]; |
|||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; |
|||
$this->params['breadcrumbs'][] = 'Update '; |
|||
Yii::$app->params['bsVersion'] = '4.x'; |
|||
?>
|
|||
<div class="express-template-update"> |
|||
<div class="express-template-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, |
|||
]), |
|||
], |
|||
[ |
|||
'label' => '<i class="fas fa-globe"></i> 选择配送区域', |
|||
'content' => $this->render('area', ['data' => $data, 'form' => $form, 'cities' => $cities |
|||
]), |
|||
], |
|||
], |
|||
'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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue