[积分商城]商品管理-优化

This commit is contained in:
2026-03-19 16:13:22 +08:00
parent a02eb8465c
commit 0c51e4f8ec
6 changed files with 95 additions and 36 deletions

View File

@@ -2,7 +2,6 @@
namespace app\admin\controller\mall;
use Throwable;
use app\common\controller\Backend;
/**
@@ -23,6 +22,9 @@ class Item extends Backend
protected string|array $quickSearchField = ['id'];
/** 添加时自动填充 admin_id */
protected bool $autoFillAdminId = true;
public function initialize(): void
{
parent::initialize();
@@ -31,7 +33,6 @@ class Item extends Backend
/**
* 查看
* @throws Throwable
*/
public function index(\Webman\Http\Request $request): \support\Response
{
@@ -45,11 +46,6 @@ class Item extends Backend
return $this->success();
}
/**
* 1. withJoin 不可使用 alias 方法设置表别名,别名将自动使用关联模型名称(小写下划线命名规则)
* 2. 以下的别名设置了主表别名,同时便于拼接查询参数等
* 3. paginate 数据集可使用链式操作 each(function($item, $key) {}) 遍历处理
*/
list($where, $alias, $limit, $order) = $this->queryBuilder();
$res = $this->model
->withJoin($this->withJoinTable, $this->withJoinType)
@@ -65,8 +61,4 @@ class Item extends Backend
'remark' => get_route_remark(),
]);
}
/**
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
*/
}

View File

@@ -2,6 +2,7 @@
namespace app\common\model;
use app\common\model\traits\TimestampInteger;
use support\think\Model;
/**
@@ -9,12 +10,11 @@ use support\think\Model;
*/
class MallItem extends Model
{
// 表名
use TimestampInteger;
protected $name = 'mall_item';
// 自动写入时间戳字段
protected $autoWriteTimestamp = true;
protected bool $autoWriteTimestamp = true;
public function admin(): \think\model\relation\BelongsTo
{

View File

@@ -4,12 +4,14 @@ export default {
description: 'description',
remark: 'remark',
score: 'score',
'类型': '类型',
'类型 1': '类型 1',
'类型 2': '类型 2',
'类型 3': '类型 3',
type: 'type',
'type 1': 'type 1',
'type 2': 'type 2',
'type 3': 'type 3',
admin_id: 'admin_id',
admin__username: 'username',
image: 'show image',
stock: 'stock',
sort: 'sort',
create_time: 'create_time',
update_time: 'update_time',

View File

@@ -4,13 +4,18 @@ export default {
description: '描述',
remark: '备注',
score: '兑换积分',
'类型': '类型',
'类型 1': '奖励',
'类型 2': '充值',
'类型 3': '实物',
type: '类型',
'type 1': '奖励',
'type 2': '充值',
'type 3': '实物',
admin_id: '创建管理员',
admin__username: '用户名',
admin__username: '创建管理员',
image: '展示图',
stock: '库存',
sort: '排序',
status: '状态',
'status 0': '禁用',
'status 1': '启用',
create_time: '创建时间',
update_time: '修改时间',
'quick Search Fields': 'ID',

View File

@@ -48,20 +48,69 @@ const baTable = new baTableClass(
{ type: 'selection', align: 'center', operator: false },
{ label: t('mall.item.id'), prop: 'id', align: 'center', width: 70, operator: 'RANGE', sortable: 'custom' },
{ label: t('mall.item.title'), prop: 'title', align: 'center', operatorPlaceholder: t('Fuzzy query'), sortable: false, operator: 'LIKE' },
{ label: t('mall.item.score'), prop: 'score', align: 'center', sortable: false, operator: 'RANGE' },
{
label: t('mall.item.类型'),
prop: '类型',
label: t('mall.item.description'),
prop: 'description',
align: 'center',
operatorPlaceholder: t('Fuzzy query'),
sortable: false,
operator: 'LIKE',
},
{
label: t('mall.item.score'),
prop: 'score',
align: 'center',
sortable: false,
operator: 'RANGE',
},
{
label: t('mall.item.type'),
prop: 'type',
align: 'center',
effect: 'dark',
custom: { 1: 'success', 2: 'primary', 3: 'info' },
operator: 'eq',
sortable: false,
render: 'tag',
replaceValue: { '1': t('mall.item.类型 1'), '2': t('mall.item.类型 2'), '3': t('mall.item.类型 3') },
replaceValue: { '1': t('mall.item.type 1'), '2': t('mall.item.type 2'), '3': t('mall.item.type 3') },
},
{
label: t('mall.item.status'),
prop: 'status',
align: 'center',
operator: 'eq',
sortable: false,
render: 'switch',
replaceValue: { '0': t('mall.item.status 0'), '1': t('mall.item.status 1') },
},
{
label: t('mall.item.remark'),
prop: 'remark',
align: 'center',
showOverflowTooltip: true,
operatorPlaceholder: t('Fuzzy query'),
sortable: false,
operator: 'LIKE',
},
{
label: t('mall.item.image'),
prop: 'image',
align: 'center',
render: 'image',
operator: false,
},
{
label: t('mall.item.stock'),
prop: 'stock',
align: 'center',
sortable: false,
operator: 'RANGE',
},
{
label: t('mall.item.admin__username'),
prop: 'admin.username',
align: 'center',
minWidth: 100,
operatorPlaceholder: t('Fuzzy query'),
render: 'tags',
operator: 'LIKE',
@@ -92,10 +141,13 @@ const baTable = new baTableClass(
},
{ label: t('Operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
],
dblClickNotEditColumn: [undefined],
dblClickNotEditColumn: [undefined, 'status'],
},
{
defaultItems: {},
defaultItems: {
stock: 0,
sort: 100,
},
}
)

View File

@@ -72,13 +72,14 @@
:input-attr="{ content: { '1': t('mall.item.type 1'), '2': t('mall.item.type 2'), '3': t('mall.item.type 3') } }"
:placeholder="t('Please select field', { field: t('mall.item.type') })"
/>
<FormItem :label="t('mall.item.image')" type="image" v-model="baTable.form.items!.image" />
<FormItem
:label="t('mall.item.admin_id')"
type="remoteSelect"
v-model="baTable.form.items!.admin_id"
prop="admin_id"
:input-attr="{ pk: 'admin.id', field: 'username', remoteUrl: '/admin/auth.Admin/index' }"
:placeholder="t('Please select field', { field: t('mall.item.admin_id') })"
:label="t('mall.item.stock')"
type="number"
v-model="baTable.form.items!.stock"
prop="stock"
:input-attr="{ step: 1 }"
:placeholder="t('Please input field', { field: t('mall.item.stock') })"
/>
<FormItem
:label="t('mall.item.sort')"
@@ -88,6 +89,13 @@
:input-attr="{ step: 1 }"
:placeholder="t('Please input field', { field: t('mall.item.sort') })"
/>
<FormItem
:label="t('mall.item.status')"
type="switch"
v-model="baTable.form.items!.status"
prop="status"
:input-attr="{ content: { '0': t('mall.item.status 0'), '1': t('mall.item.status 1') } }"
/>
</el-form>
</div>
</el-scrollbar>