商品添加是否是新品选择状态

This commit is contained in:
wangxiaowei 2024-12-23 14:10:22 +08:00
parent f0745812fc
commit 455cae1b3d
4 changed files with 54 additions and 3 deletions

@ -255,7 +255,6 @@ class Goods extends ShopBase
$goods_id = $this->request->get('goods_id');
$a = MallCategoryLogic::getAllTree();
$b = GoodsLogic::info($goods_id);
$second_pid = array();
$arr = $arr1 = array();
if ($b['base']['second_cate_id'] != 0) {
@ -280,12 +279,10 @@ class Goods extends ShopBase
$b['base']['first_cate_id'] = explode(",", $b['base']['first_cate_id']);
$b['base']['second_cate_id'] = explode(",", $b['base']['second_cate_id']);
$b['base']['third_cate_id'] = explode(",", $b['base']['third_cate_id']);
$subsidy = [];
if ($b['base']['subsidy_id']) {
$subsidy = (new GoodsSubsidy())->getSubsidyById($b['base']['subsidy_id']);
}
return view('goods/goods/add', [
'category_lists_new' => $a,
'category_first' => $b['base']['first_cate_id'],

@ -843,6 +843,7 @@
var goods_info= {$info|raw|default=''};
// 商品类型
$("input[name=is_new_goods]").prop("checked", goods_info['base']['is_new_goods'] == 1);
$("input[name=type]").prop("disabled",true);
$("input[name=type][value="+goods_info['base']['type']+"]").prop("checked",true);
switchGoodsType(goods_info['base']['type']);

@ -24,6 +24,15 @@
class="layui-input">
</div>
</div>
<!--新品-->
<div class="layui-form-item">
<label class="layui-form-label">新品</label>
<div class="layui-input-block">
<input type="checkbox" name="is_new_goods" lay-skin="switch">
</div>
</div>
<!--商品编码-->
<div class="layui-form-item">
<label class="layui-form-label">商品编码:</label>

@ -0,0 +1,44 @@
<?php
use think\migration\Migrator;
use think\migration\db\Column;
class AddIsNewGoodsFieldsToGoods extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('goods');
$table->addColumn('is_new_goods', 'tinyinteger', [
'limit' => 1, 'default' => 0, 'null' => false, 'comment' => '是否是新品:0不是 1是;'
])->update(); // 更新表结构
}
public function down()
{
// 回滚操作删除添加的字段
$table = $this->table('goods_subsidy');
$table->removeColumn('store_subsidy')
->update();
}
}