mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: master 商品名称搜索优化
This commit is contained in:
parent
5ea7e26b97
commit
ab9e209910
49
app/Console/Commands/UpdateGoodsSkuName.php
Normal file
49
app/Console/Commands/UpdateGoodsSkuName.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\GoodsSku;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateGoodsSkuName extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:goods_skus:name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '更新goods_sku的完整名称';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
GoodsSku::query()
|
||||
->where('name', '')
|
||||
->where('is_combination', 0)
|
||||
->chunk(500, static function ($skus) {
|
||||
foreach ($skus as $sku) {
|
||||
$sku->name = $sku->goods->title . $sku->title;
|
||||
$sku->save();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,6 @@ namespace App\Filters;
|
||||
|
||||
class GoodsFilter extends Filters
|
||||
{
|
||||
protected function goodsTitle($value)
|
||||
{
|
||||
return $this->builder->where('title', 'like', "%$value%");
|
||||
}
|
||||
|
||||
protected function typeId($value)
|
||||
{
|
||||
if($value){
|
||||
|
||||
@ -61,6 +61,7 @@ class GoodsController extends Controller
|
||||
$item['stock'] = $item['num'];
|
||||
$item['reference_price'] = $item['cost'] * 1.5;
|
||||
$item['external_sku_id'] = $goods->goods_code . '_' . $item['sku_code'];
|
||||
$item['name'] = $goods->goods_code . $item['title'];
|
||||
$goodsSkus[] = $item;
|
||||
}
|
||||
$collection = $goods->skus()->createMany($goodsSkus)->toArray();
|
||||
|
||||
@ -140,10 +140,13 @@ class GoodsSkusController extends Controller
|
||||
->toArray();
|
||||
$builder->whereIn('id', $skuIds);
|
||||
}
|
||||
if ($request->get('goods_title') || $request->get('type_id') || $request->get('brand_id')) {
|
||||
if ($request->get('type_id') || $request->get('brand_id')) {
|
||||
$goodsIds = Goods::query()->filter()->pluck('id')->toArray();
|
||||
$builder->whereIn('goods_id', $goodsIds);
|
||||
}
|
||||
if ($request->get('goods_title')) {
|
||||
$builder->where('name', 'like', '%' . $request->goods_title . '%');
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
@ -185,6 +188,7 @@ class GoodsSkusController extends Controller
|
||||
$this->setBeforeUpdateForLog($sku->toArray());
|
||||
$skuInfo = $request->sku;
|
||||
$skuInfo['external_sku_id'] = $request->goods['goods_code'] . '_' . $request->sku['sku_code'];
|
||||
$skuInfo['name'] = $request->goods['title'] . $request->sku['title'];
|
||||
$sku->update($skuInfo);
|
||||
$this->setAfterUpdateForLog($sku->toArray());
|
||||
$this->addLog($id, 'update');
|
||||
|
||||
@ -10,7 +10,6 @@ class Goods extends Model
|
||||
|
||||
//查询字段
|
||||
public $fieldSearchable = [
|
||||
'goods_title',
|
||||
'type_id',
|
||||
'brand_id',
|
||||
];
|
||||
|
||||
@ -28,7 +28,7 @@ class CreateGroupsTable extends Migration
|
||||
$table->string('activity_no')->nullable()->comment('团号');
|
||||
$table->unsignedTinyInteger('create_status')->default(3)->comment('1-创建成功,2-创建失败,3-创建中');
|
||||
$table->string('error_msg')->nullable()->comment('create_status为2时有,创建团失败原因');
|
||||
$table->text('qr_code_url')->nullable()->comment('create_status为1时有,团小程序二维码图片地址');
|
||||
$table->string('qr_code_url')->default('')->comment('create_status为1时有,团小程序二维码图片地址');
|
||||
$table->unsignedBigInteger('create_time')->nullable();
|
||||
$table->unsignedTinyInteger('is_help_sell')->nullable()->comment('是否帮卖0-我发布的,1-我帮卖的');
|
||||
$table->tinyInteger('status')->default(-10)->comment('团状态(-10:待发布/预览中,-5:未开始,1:跟团中,20:已结束,30:已删除');
|
||||
|
||||
@ -13,6 +13,9 @@ class CreateDailyReportsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('daily_reports')) {
|
||||
return;
|
||||
}
|
||||
Schema::create('daily_reports', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->date('date');
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNameToGoodsSkusTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('goods_skus', 'name')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('goods_skus', function (Blueprint $table) {
|
||||
$table->string('name')->default('')->comment('完整商品名称');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('goods_skus', function (Blueprint $table) {
|
||||
$table->dropColumn('name');
|
||||
});
|
||||
}
|
||||
}
|
||||
2
resources/frontend/src/api/goods.js
vendored
2
resources/frontend/src/api/goods.js
vendored
@ -17,7 +17,7 @@ export function goods(params) {
|
||||
params,
|
||||
});
|
||||
}
|
||||
// 新建商品
|
||||
// 新增商品/规格
|
||||
export function addGoods(data) {
|
||||
return http({
|
||||
url: "/api/goods",
|
||||
|
||||
2
resources/frontend/src/router/list.js
vendored
2
resources/frontend/src/router/list.js
vendored
@ -18,7 +18,7 @@ const list = [
|
||||
},
|
||||
{
|
||||
path: "ADDGOODS",
|
||||
name: "新建商品",
|
||||
name: "新增商品/规格",
|
||||
component: () => import("../views/goods/addgoods/addgoods.vue"),
|
||||
},
|
||||
{
|
||||
|
||||
@ -62,6 +62,7 @@ export default {
|
||||
}
|
||||
|
||||
if (data.token) {
|
||||
localStorage.setItem("userName", this.form.name);
|
||||
this.form = {};
|
||||
localStorage.setItem("token", data.token);
|
||||
this.$message({
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="box-card">
|
||||
<!-- 新建商品进入显示 -->
|
||||
<!-- 新增商品进入显示 -->
|
||||
<el-form ref="form" :inline="true" :model="form">
|
||||
<div>
|
||||
<el-form-item label="商品列表:">
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<div class="goods">
|
||||
<el-form ref="form" :inline="true" :model="form">
|
||||
<el-form-item label="商品名称:">
|
||||
<el-input v-model="form.goods_title" placeholder="商品名称" style="width: 100px">
|
||||
<el-input v-model="form.goods_title" placeholder="商品名称" style="width: 240px">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品种类:">
|
||||
@ -36,7 +36,7 @@
|
||||
<el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-date-picker v-model="value1" type="datetimerange" range-separator="至" start-placeholder="开始时间"
|
||||
<el-date-picker v-model="value1" type="datetimerange" range-separator="-" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss" @change="getSTime"
|
||||
style="width: 300px">
|
||||
</el-date-picker>
|
||||
@ -69,7 +69,7 @@
|
||||
:on-error="inventoryError" style="display:inline-block;margin: 0 10px 0 10px;">
|
||||
<el-button type="primary" plain>盘点导入</el-button>
|
||||
</el-upload>
|
||||
<el-button type="primary" plain @click="addNewgoods">新建商品</el-button>
|
||||
<el-button type="primary" plain @click="addNewgoods">新增商品</el-button>
|
||||
<el-button type="primary" plain @click="handleImport()">导入商品</el-button>
|
||||
<el-button type="primary" plain @click="handleExport()">表格导出</el-button>
|
||||
<el-button type="primary" plain @click="onCount()">库存盘点</el-button>
|
||||
@ -87,7 +87,7 @@
|
||||
<img :src="scope.row.goods.img_url" class="Img" />
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ scope.row.goods.title }} {{ scope.row.title }}</p>
|
||||
<p>{{ scope.row.name }}</p>
|
||||
<p>
|
||||
{{ scope.row.goods.goods_code + "_" + scope.row.sku_code }}
|
||||
</p>
|
||||
@ -104,7 +104,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格" prop="title" width="130"></el-table-column>
|
||||
<el-table-column label="规格" prop="title"></el-table-column>
|
||||
<el-table-column label="品牌">
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
@ -168,7 +168,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column sortable label="订单">
|
||||
<el-table-column sortable label="销量">
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<span>{{ scope.row.order_goods_num }}</span>
|
||||
@ -242,7 +242,7 @@
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="status" label="状态"> </el-table-column>
|
||||
<el-table-column label="操作" width="130">
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="ejectstock(scope.row)">库存</el-button>
|
||||
<el-button type="text" @click="handleEdit(scope.row.id)">编辑</el-button>
|
||||
@ -453,7 +453,7 @@ export default {
|
||||
},
|
||||
Paginationdata: {}, //分页相关数据
|
||||
current_page: 1, //当前页
|
||||
per_page: 100, //每页显示数量
|
||||
per_page: 10, //每页显示数量
|
||||
multipleSelection: [], //多选框选中的id
|
||||
updateType: "", //更新类型,newest-上新, inventory-库存盘点, stock-库存
|
||||
stock: false, //点击库存显示输入框变量
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-container>
|
||||
<el-container>
|
||||
<el-aside :class="show ? 'width' : 'width1'">
|
||||
<el-aside :class="show ? 'aside-show' : 'aside-hide'">
|
||||
<el-menu router background-color="#282c34" text-color="#fff" :default-active="$route.path"
|
||||
:default-openeds="openeds">
|
||||
<div v-for="item in menu" :key="item.id">
|
||||
@ -66,7 +66,7 @@ export default {
|
||||
menu: [], // 侧边栏
|
||||
show: true, // 导航栏折叠
|
||||
levelData: [], // table导航栏
|
||||
titie: [], // 面包线
|
||||
titie: [], // 面包屑
|
||||
head: "", // 路由name
|
||||
onindex: 0, // 索引
|
||||
openeds: ["GOODS_MANAGE"],
|
||||
@ -140,13 +140,13 @@ export default {
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.width {
|
||||
.aside-show {
|
||||
transition: all 0.3s;
|
||||
opacity: 0;
|
||||
width: 0px !important;
|
||||
}
|
||||
|
||||
.width1 {
|
||||
.aside-hide {
|
||||
transition: all 0.3s;
|
||||
opacity: 1;
|
||||
width: 200px !important;
|
||||
|
||||
@ -211,7 +211,7 @@ export default {
|
||||
confirm_at_start: this.form.confirm_at[0],
|
||||
confirm_at_end: this.form.confirm_at[1]
|
||||
});
|
||||
this.initWebSocket();
|
||||
// this.initWebSocket();
|
||||
},
|
||||
mounted() {
|
||||
// 展示店铺列表
|
||||
|
||||
4
resources/frontend/vue.config.js
vendored
4
resources/frontend/vue.config.js
vendored
@ -7,8 +7,8 @@ module.exports = {
|
||||
proxy: {
|
||||
// 配置代理
|
||||
"/api": {
|
||||
// target: "http://erp.test",
|
||||
target: "http://erp.chutang66.com",
|
||||
target: "http://erp.local",
|
||||
// target: "http://erp.chutang66.com",
|
||||
changeOrigin: true, // 开启代理
|
||||
pathRewrite: {
|
||||
// 重命名
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user