From 0c51e4f8ec04c6348064b46cb32844b3debd2260 Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Thu, 19 Mar 2026 16:13:22 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E]=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=AE=A1=E7=90=86-=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/mall/Item.php | 14 +--- app/common/model/MallItem.php | 8 +-- web/src/lang/backend/en/mall/item.ts | 10 +-- web/src/lang/backend/zh-cn/mall/item.ts | 15 +++-- web/src/views/backend/mall/item/index.vue | 64 +++++++++++++++++-- web/src/views/backend/mall/item/popupForm.vue | 20 ++++-- 6 files changed, 95 insertions(+), 36 deletions(-) diff --git a/app/admin/controller/mall/Item.php b/app/admin/controller/mall/Item.php index 4eeb006..7ac6d48 100644 --- a/app/admin/controller/mall/Item.php +++ b/app/admin/controller/mall/Item.php @@ -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 中对应的方法至此进行重写 - */ } \ No newline at end of file diff --git a/app/common/model/MallItem.php b/app/common/model/MallItem.php index 9cf1066..895b96f 100644 --- a/app/common/model/MallItem.php +++ b/app/common/model/MallItem.php @@ -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 { diff --git a/web/src/lang/backend/en/mall/item.ts b/web/src/lang/backend/en/mall/item.ts index 059f152..c99901e 100644 --- a/web/src/lang/backend/en/mall/item.ts +++ b/web/src/lang/backend/en/mall/item.ts @@ -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', diff --git a/web/src/lang/backend/zh-cn/mall/item.ts b/web/src/lang/backend/zh-cn/mall/item.ts index cfb997d..eca916c 100644 --- a/web/src/lang/backend/zh-cn/mall/item.ts +++ b/web/src/lang/backend/zh-cn/mall/item.ts @@ -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', diff --git a/web/src/views/backend/mall/item/index.vue b/web/src/views/backend/mall/item/index.vue index 7c2d555..324f193 100644 --- a/web/src/views/backend/mall/item/index.vue +++ b/web/src/views/backend/mall/item/index.vue @@ -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, + }, } ) diff --git a/web/src/views/backend/mall/item/popupForm.vue b/web/src/views/backend/mall/item/popupForm.vue index 829dea6..16a3887 100644 --- a/web/src/views/backend/mall/item/popupForm.vue +++ b/web/src/views/backend/mall/item/popupForm.vue @@ -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') })" /> + +