[积分商城]商品管理-优化
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace app\admin\controller\mall;
|
namespace app\admin\controller\mall;
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +22,9 @@ class Item extends Backend
|
|||||||
|
|
||||||
protected string|array $quickSearchField = ['id'];
|
protected string|array $quickSearchField = ['id'];
|
||||||
|
|
||||||
|
/** 添加时自动填充 admin_id */
|
||||||
|
protected bool $autoFillAdminId = true;
|
||||||
|
|
||||||
public function initialize(): void
|
public function initialize(): void
|
||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
@@ -31,7 +33,6 @@ class Item extends Backend
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看
|
* 查看
|
||||||
* @throws Throwable
|
|
||||||
*/
|
*/
|
||||||
public function index(\Webman\Http\Request $request): \support\Response
|
public function index(\Webman\Http\Request $request): \support\Response
|
||||||
{
|
{
|
||||||
@@ -45,11 +46,6 @@ class Item extends Backend
|
|||||||
return $this->success();
|
return $this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. withJoin 不可使用 alias 方法设置表别名,别名将自动使用关联模型名称(小写下划线命名规则)
|
|
||||||
* 2. 以下的别名设置了主表别名,同时便于拼接查询参数等
|
|
||||||
* 3. paginate 数据集可使用链式操作 each(function($item, $key) {}) 遍历处理
|
|
||||||
*/
|
|
||||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||||
$res = $this->model
|
$res = $this->model
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
@@ -65,8 +61,4 @@ class Item extends Backend
|
|||||||
'remark' => get_route_remark(),
|
'remark' => get_route_remark(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 若需重写查看、编辑、删除等方法,请复制 @see \app\admin\library\traits\Backend 中对应的方法至此进行重写
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\common\model;
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\common\model\traits\TimestampInteger;
|
||||||
use support\think\Model;
|
use support\think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,12 +10,11 @@ use support\think\Model;
|
|||||||
*/
|
*/
|
||||||
class MallItem extends Model
|
class MallItem extends Model
|
||||||
{
|
{
|
||||||
// 表名
|
use TimestampInteger;
|
||||||
|
|
||||||
protected $name = 'mall_item';
|
protected $name = 'mall_item';
|
||||||
|
|
||||||
// 自动写入时间戳字段
|
protected bool $autoWriteTimestamp = true;
|
||||||
protected $autoWriteTimestamp = true;
|
|
||||||
|
|
||||||
|
|
||||||
public function admin(): \think\model\relation\BelongsTo
|
public function admin(): \think\model\relation\BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ export default {
|
|||||||
description: 'description',
|
description: 'description',
|
||||||
remark: 'remark',
|
remark: 'remark',
|
||||||
score: 'score',
|
score: 'score',
|
||||||
'类型': '类型',
|
type: 'type',
|
||||||
'类型 1': '类型 1',
|
'type 1': 'type 1',
|
||||||
'类型 2': '类型 2',
|
'type 2': 'type 2',
|
||||||
'类型 3': '类型 3',
|
'type 3': 'type 3',
|
||||||
admin_id: 'admin_id',
|
admin_id: 'admin_id',
|
||||||
admin__username: 'username',
|
admin__username: 'username',
|
||||||
|
image: 'show image',
|
||||||
|
stock: 'stock',
|
||||||
sort: 'sort',
|
sort: 'sort',
|
||||||
create_time: 'create_time',
|
create_time: 'create_time',
|
||||||
update_time: 'update_time',
|
update_time: 'update_time',
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ export default {
|
|||||||
description: '描述',
|
description: '描述',
|
||||||
remark: '备注',
|
remark: '备注',
|
||||||
score: '兑换积分',
|
score: '兑换积分',
|
||||||
'类型': '类型',
|
type: '类型',
|
||||||
'类型 1': '奖励',
|
'type 1': '奖励',
|
||||||
'类型 2': '充值',
|
'type 2': '充值',
|
||||||
'类型 3': '实物',
|
'type 3': '实物',
|
||||||
admin_id: '创建管理员',
|
admin_id: '创建管理员',
|
||||||
admin__username: '用户名',
|
admin__username: '创建管理员',
|
||||||
|
image: '展示图',
|
||||||
|
stock: '库存',
|
||||||
sort: '排序',
|
sort: '排序',
|
||||||
|
status: '状态',
|
||||||
|
'status 0': '禁用',
|
||||||
|
'status 1': '启用',
|
||||||
create_time: '创建时间',
|
create_time: '创建时间',
|
||||||
update_time: '修改时间',
|
update_time: '修改时间',
|
||||||
'quick Search Fields': 'ID',
|
'quick Search Fields': 'ID',
|
||||||
|
|||||||
@@ -48,20 +48,69 @@ const baTable = new baTableClass(
|
|||||||
{ type: 'selection', align: 'center', operator: false },
|
{ 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.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.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.类型'),
|
label: t('mall.item.description'),
|
||||||
prop: '类型',
|
prop: 'description',
|
||||||
align: 'center',
|
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',
|
operator: 'eq',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
render: 'tag',
|
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'),
|
label: t('mall.item.admin__username'),
|
||||||
prop: 'admin.username',
|
prop: 'admin.username',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
|
minWidth: 100,
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
operatorPlaceholder: t('Fuzzy query'),
|
||||||
render: 'tags',
|
render: 'tags',
|
||||||
operator: 'LIKE',
|
operator: 'LIKE',
|
||||||
@@ -92,10 +141,13 @@ const baTable = new baTableClass(
|
|||||||
},
|
},
|
||||||
{ label: t('Operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
|
{ label: t('Operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
|
||||||
],
|
],
|
||||||
dblClickNotEditColumn: [undefined],
|
dblClickNotEditColumn: [undefined, 'status'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
defaultItems: {},
|
defaultItems: {
|
||||||
|
stock: 0,
|
||||||
|
sort: 100,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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') } }"
|
: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') })"
|
: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
|
<FormItem
|
||||||
:label="t('mall.item.admin_id')"
|
:label="t('mall.item.stock')"
|
||||||
type="remoteSelect"
|
type="number"
|
||||||
v-model="baTable.form.items!.admin_id"
|
v-model="baTable.form.items!.stock"
|
||||||
prop="admin_id"
|
prop="stock"
|
||||||
:input-attr="{ pk: 'admin.id', field: 'username', remoteUrl: '/admin/auth.Admin/index' }"
|
:input-attr="{ step: 1 }"
|
||||||
:placeholder="t('Please select field', { field: t('mall.item.admin_id') })"
|
:placeholder="t('Please input field', { field: t('mall.item.stock') })"
|
||||||
/>
|
/>
|
||||||
<FormItem
|
<FormItem
|
||||||
:label="t('mall.item.sort')"
|
:label="t('mall.item.sort')"
|
||||||
@@ -88,6 +89,13 @@
|
|||||||
:input-attr="{ step: 1 }"
|
:input-attr="{ step: 1 }"
|
||||||
:placeholder="t('Please input field', { field: t('mall.item.sort') })"
|
: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>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
|
|||||||
Reference in New Issue
Block a user