You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

126 lines
3.6 KiB

<?php
use backend\modules\goods\models\ars\Category;
use backend\modules\goods\models\ars\Brand;
use backend\modules\goods\models\ars\ShopCategory;
use backend\modules\goods\models\ars\Supplier;
use linyao\widgets\Select2;
use yii\bootstrap4\Html;
use backend\modules\goods\models\ars\Goods;
/* @var $this yii\web\View */
/* @var $model backend\modules\goods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<?= $form->field($model, 'cat_id')->dropDownList(Category::modelColumn(), ['prompt' => '请选择', 'disabled' => $judgeGoodsCategory]) ?>
<?= $form->field($model, 'brand_id')->dropDownList(Brand::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'shop_cat_id')->dropDownList(ShopCategory::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'sn')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'supplier_id')->dropDownList(Supplier::modelColumn(), ['prompt' => '请选择']) ?>
<?= $form->field($model, 'weight')->textInput() ?>
<?= $form->field($model, 'length')->textInput() ?>
<?= $form->field($model, 'width')->textInput() ?>
<?= $form->field($model, 'height')->textInput() ?>
<?= $form->field($model, 'diameter')->textInput() ?>
<?= $form->field($model, 'unit')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'limit_count')->textInput() ?>
<?= $form->field($model, 'stock')->textInput() ?>
<?= $form->field($model, 'stock_warn')->textInput() ?>
<?= $form->field($model, 'market_price')->textInput() ?>
<?= $form->field($model, 'price')->textInput() ?>
<?= $form->field($model, 'brief')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'is_sale')->radioList(Goods::$isSale) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'bouns_points')->textInput() ?>
<?= $form->field($model, 'experience_points')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>
</div>
<?php
$js =<<<JS
$(document).ready(function(){
if(!$("#goods-market_price").val()){
$("#goods-market_price").val("0.00")
}else{
$("#goods-market_price").val(toFixeds($("#goods-market_price").val(), 2));
}
if(!$("#goods-price").val()){
$("#goods-price").val("0.00")
}else{
$("#goods-price").val(toFixeds($("#goods-price").val(), 2));
}
$("#goods-market_price").blur(function(){
if(!$(this).val()){
$(this).val("0.00")
}
if(isNaN($(this).val())){
$(this).val("0.00")
}
if($(this).val().indexOf('-') != -1){
$(this).val("0.00")
}
$(this).val(toFixeds($(this).val(), 2));
})
$("#goods-price").blur(function(){
if(!$(this).val()){
$(this).val("0.00")
}
if(isNaN($(this).val())){
$(this).val("0.00")
}
if($(this).val().indexOf('-') != -1){
$(this).val("0.00")
}
$(this).val(toFixeds($(this).val(), 2));
})
//金额补全
function toFixeds(val, pre) {
const num = parseFloat(val);
// eslint-disable-next-line no-restricted-globals
if (isNaN(num)) {
return false;
}
const p = 10 ** pre;
const value = num * p;
let f = (Math.round(value) / p).toString();
let rs = f.indexOf('.');
if (rs < 0) {
rs = f.length;
f += '.';
}
while (f.length <= rs + pre) {
f += '0';
}
return f;
}
})
JS;
$this->registerJs($js);
?>