Browse Source

运费模板表单删除基本数量,基本费用,续重数量,续重费用字段

antshop
linyaostalker 5 years ago
parent
commit
e73256899b
  1. 141
      backend/modules/shop/views/express-template/_form.php

141
backend/modules/shop/views/express-template/_form.php

@ -2,144 +2,31 @@
use blobt\widgets\Icheck;
use backend\modules\shop\models\ars\ExpressTemplate;
use yii\bootstrap4\ActiveForm;
use yii\bootstrap4\Html;
/* @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">&times;</span></button>
<p style="color: #2e2e2e">必须至少选择一个城市为配送区域</p>
</div>
<?php } ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="order-form">
<?= $form->field($model, 'calculation_type')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculationType, 'type' => "radio"]) ?>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'basic_count')->textInput() ?>
<?= $form->field($model, 'basic_price')->textInput() ?>
<?= $form->field($model, 'extra_count')->textInput() ?>
<?= $form->field($model, 'extra_price')->textInput() ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?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;
if ($isCreate) {
echo $form->field($model, 'calculation_type')->widget(Icheck::className(), ["items" => ExpressTemplate::$calculationType, 'type' => "radio"]);
}
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})?/));
})
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
$("input:radio[name='ExpressTemplate[calculation_type]']").on('ifChecked', function(event){
updateTypeChangeCalType($(this).val()-1)
})
changeCalType(calType)
})
JS;
$this->registerJs($js)
<?php ActiveForm::end(); ?>
?>
</div>
Loading…
Cancel
Save