Browse Source

完成创建商品时商品表单tabx改造,完成接通商品规格样式

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
9c4ae59470
  1. 50
      vendor/antgoods/goods/src/assets/custom/sku.99cb07c4f1a205e0a84a.js
  2. 1
      vendor/antgoods/goods/src/assets/custom/sku.html
  3. 9210
      vendor/antgoods/goods/src/assets/js/jquery.js
  4. 8
      vendor/antgoods/goods/src/models/ars/Attribute.php
  5. 22
      vendor/antgoods/goods/src/views/goods/attribute.php
  6. 49
      vendor/antgoods/goods/src/views/goods/create.php
  7. 62
      vendor/antgoods/goods/src/views/goods/goods.php
  8. 6
      vendor/antgoods/goods/src/views/goods/picture.php
  9. 25
      vendor/antgoods/goods/src/web/GoodsAttributeAsset.php

50
vendor/antgoods/goods/src/assets/custom/sku.99cb07c4f1a205e0a84a.js
File diff suppressed because it is too large
View File

1
vendor/antgoods/goods/src/assets/custom/sku.html

@ -0,0 +1 @@
<script type="text/javascript" src="sku.99cb07c4f1a205e0a84a.js"></script>

9210
vendor/antgoods/goods/src/assets/js/jquery.js
File diff suppressed because it is too large
View File

8
vendor/antgoods/goods/src/models/ars/Attribute.php

@ -92,4 +92,12 @@ class Attribute extends \yii\db\ActiveRecord
{ {
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
} }
public function beforeSave($insert)
{
if(!$this->type){
$this->type = self::TYPE_ATTR;
}
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
}
} }

22
vendor/antgoods/goods/src/views/goods/attribute.php

@ -0,0 +1,22 @@
<?php
use antgoods\goods\models\ars\Attribute;
use antgoods\goods\web\GoodsAttributeAsset;
$param = [];
$value = [];
$attrId = [];
$allAttr = Attribute::find()->where(['type' => Attribute::TYPE_ATTR])->asArray()->all();
GoodsAttributeAsset::register($this);
?>
<div class="content-box">
<input type="hidden" id="attribute" name="attribute"/>
<div id="sku-choose"></div>
</div>
<script>
var csrf = "<?= Yii::$app->request->csrfToken ?>";
var allAttr = <?= isset($allAttr) ? json_encode($allAttr) : [] ?>; // 所有数据
var currentAttr = <?= isset($model) ? json_encode($model) : [] ?>; // 默认数据(之前已选择的数据)
var canNotDeleteAttr =<?=isset($attrValue) ? json_encode($attrValue) : [] ?>; // 已设置sku的值,不可删除
</script>

49
vendor/antgoods/goods/src/views/goods/create.php

@ -1,7 +1,7 @@
<?php <?php
use kartik\tabs\TabsX; use kartik\tabs\TabsX;
use yii\widgets\ActiveForm;
use yii\bootstrap4\ActiveForm;
use yii\bootstrap4\Html; use yii\bootstrap4\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
@ -15,10 +15,49 @@ Yii::$app->params['bsVersion'] = '4.x';
<div class="goods-create"> <div class="goods-create">
<div class="goods-form"> <div class="goods-form">
<?=
$this->render('_form', [
'model' => $model,
])
<?php
$form = ActiveForm::begin(['options' => ['class' => 'container-fluid']]);
echo TabsX::widget([
'bordered' => true,
'items' => [
[
'label' => '<i class="fas fa-user"></i> 基本信息',
'content' => $this->render('goods', ['model' => $model,
'form' => $form
]),
],
[
'label' => '<i class="fas fa-list-alt"></i> 商品规格',
'content' => $this->render('attribute', [
'model' => [],
'attrValue' => [],
]),
],
[
'label' => '<i class="fas fa-picture-o"></i> 图片上传',
'content' => $this->render('picture', [
'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(); ?>
<?php
// $this->render('_form', [
// 'model' => $model,
// ])
?> ?>
</div> </div>

62
vendor/antgoods/goods/src/views/goods/goods.php

@ -0,0 +1,62 @@
<?php
use antgoods\goods\models\ars\Category;
use antgoods\goods\models\ars\Brand;
use antgoods\goods\models\ars\ShopCategory;
use antgoods\goods\models\ars\Supplier;
/* @var $this yii\web\View */
/* @var $model antgoods\goods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<?= $form->field($model, 'cat_id')->dropDownList(Category::modelColumn(), ['prompt' => '请选择']) ?>
<?= $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, 'description')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'model_id')->textInput() ?>
<?= $form->field($model, 'is_sale')->radioList($model::$isSale) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'bouns_points')->textInput() ?>
<?= $form->field($model, 'experience_points')->textInput() ?>
<?= $form->field($model, 'express_template')->textInput() ?>

6
vendor/antgoods/goods/src/views/goods/picture.php

@ -1,11 +1,5 @@
<?php <?php
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use antgoods\goods\models\ars\Category;
use antgoods\goods\models\ars\Brand;
use antgoods\goods\models\ars\ShopCategory;
use antgoods\goods\models\ars\Supplier;
use yii\helpers\Url; use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */

25
vendor/antgoods/goods/src/web/GoodsAttributeAsset.php

@ -0,0 +1,25 @@
<?php
namespace antgoods\goods\web;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class GoodsAttributeAsset extends AssetBundle
{
public $sourcePath = "@antgoods/goods/src/assets";
public $css = [
];
public $js = [
'custom/sku.99cb07c4f1a205e0a84a.js'
];
public $depends = [
'yii\web\YiiAsset',
];
public static function addJs($view, $jsfile)
{
$view->registerJsFile($jsfile);
}
}
Loading…
Cancel
Save