Browse Source

增加运费区域表单

antshop
linyaostalker 5 years ago
parent
commit
61808a7cb6
  1. 76
      backend/modules/shop/views/express-template/express_area_form.php

76
backend/modules/shop/views/express-template/express_area_form.php

@ -19,9 +19,7 @@ if ($status == 1) {
</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, 'express_template')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'basic_count')->textInput() ?>
@ -35,18 +33,18 @@ if ($status == 1) {
$js=<<<JS
const formList = [//切换时,class对应的标题
{
"field-expresstemplate-basic_count":"基本重量(KG)",
"field-expresstemplate-basic_price":"基本运费(元)",
"field-expresstemplate-extra_count":"续重重量(KG)",
"field-expresstemplate-extra_price":"续重运费(元)"
"field-expressarea-basic_count":"基本重量(KG)",
"field-expressarea-basic_price":"基本运费(元)",
"field-expressarea-extra_count":"续重重量(KG)",
"field-expressarea-extra_price":"续重运费(元)"
},
{
"field-expresstemplate-basic_count":"基本数量(件)",
"field-expresstemplate-basic_price":"基本运费(元)",
"field-expresstemplate-extra_count":"续重数量(件)",
"field-expresstemplate-extra_price":"续重运费(元)"
"field-expressarea-basic_count":"基本数量(件)",
"field-expressarea-basic_price":"基本运费(元)",
"field-expressarea-extra_count":"续重数量(件)",
"field-expressarea-extra_price":"续重运费(元)"
}
]
@ -54,7 +52,7 @@ const udfVal = [//初始值
[0.1,"0.00"],
[1,"0.00"]
]
var calType = 1;//初始的计算方式0:计重 1:计件
var calType = {$expressTemplateModel->calculation_type}-1;//初始的计算方式0:计重 1:计件
function updateTypeChangeCalType(type){//当切换计算方式
@ -62,10 +60,10 @@ function updateTypeChangeCalType(type){//当切换计算方式
$("." + 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])
$("#expressarea-basic_count").val(udfVal[type][0])//重置初始值
$("#expressarea-basic_price").val(udfVal[type][1])
$("#expressarea-extra_count").val(0)
$("#expressarea-extra_price").val(udfVal[type][1])
calType = type;
}
function changeCalType(type){//当切换计算方式
@ -74,44 +72,55 @@ function changeCalType(type){//当切换计算方式
$("." + index).children("label").html(value)
});
if(!$("#expresstemplate-basic_count").val()){
$("#expresstemplate-basic_count").val(udfVal[type][0])//重置初始值
if(!$("#expressarea-basic_count").val()){
$("#expressarea-basic_count").val(udfVal[type][0])//重置初始值
}
if(!$("#expresstemplate-basic_price").val()){
$("#expresstemplate-basic_price").val(udfVal[type][1])
if(!$("#expressarea-basic_price").val()){
$("#expressarea-basic_price").val(udfVal[type][1])
}
if(!$("#expresstemplate-extra_count").val()){
$("#expresstemplate-extra_count").val(0)
if(!$("#expressarea-extra_count").val()){
$("#expressarea-extra_count").val(0)
}
if(!$("#expresstemplate-extra_price").val()){
$("#expresstemplate-extra_price").val(udfVal[type][1])
if(!$("#expressarea-extra_price").val()){
$("#expressarea-extra_price").val(udfVal[type][1])
}
calType = type;
}
$(document).ready(function(){
$("#expresstemplate-basic_count").blur(function(){
$("#expressarea-basic_count").blur(function(){
if(isNaN($(this).val())){
$(this).val(1)
}
if (calType == 0) {
if($(this).val() < 0.1){
$(this).val(0.1)
$(this).val(1)
}
var basiccount = $(this).val();
$(this).val(Math.floor(basiccount * 10) / 10);
// $(this).val(Math.floor(basiccount * 10) / 10);
$(this).val(basiccount.toString().match(/^\d+(?:\.\d{0,1})?/));
} else{
if($(this).val() < 1){
$(this).val(1)
}
var basiccount = $(this).val();
$(this).val(Math.floor(basiccount * 1) / 1);
// $(this).val(Math.floor(basiccount * 1) / 1);
$(this).val(basiccount.toString().match(/^\d+(?:\.\d{0,0})?/));
}
})
$("#expresstemplate-basic_price").blur(function(){
$("#expressarea-basic_price").blur(function(){
if(isNaN($(this).val())){
$(this).val("0.00")
}
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(){
$("#expressarea-extra_count").blur(function(){
if(isNaN($(this).val())){
$(this).val(0)
}
if (calType == 0) {
if($(this).val() < 0){
$(this).val(0)
@ -126,7 +135,10 @@ $(document).ready(function(){
$(this).val(Math.floor(basiccount * 1) / 1);
}
})
$("#expresstemplate-extra_price").blur(function(){
$("#expressarea-extra_price").blur(function(){
if(isNaN($(this).val())){
$(this).val("0.00")
}
if($(this).val().indexOf('-') != -1){
$(this).val("0.00")
}
@ -134,7 +146,7 @@ $(document).ready(function(){
$(this).val(basicPrice.toString().match(/^\d+(?:\.\d{0,2})?/));
})
$("input:radio[name='ExpressTemplate[calculation_type]']").on('ifChecked', function(event){
$("input:radio[name='ExpressArea[calculation_type]']").on('ifChecked', function(event){
updateTypeChangeCalType($(this).val()-1)
})
changeCalType(calType)

Loading…
Cancel
Save