From 8a39722142bcee6dd74082b050a34390679e4627 Mon Sep 17 00:00:00 2001 From: linda Date: Thu, 15 Oct 2026 15:55:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E5=90=8E=E5=8F=B0=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=AD=97=E6=AE=B5=E6=A0=87=E9=A2=98=E4=B8=8E=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E4=B8=AD=E6=96=87=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一、问题(用户反馈「后台字段内容没用中文」) - 大量字段标题没有中文映射 → __(‘Title’)/__(‘Views’)/__(‘Createtime’) 直接显示英文 key - 枚举取值显示裸数字/英文:is_paid→0/1、audit_status→0/1/2、pay_type→wxpay、 订单 status→paid、提现 status→auditing… - 部分语言包写的是字段注释原文而非标签(如 ‘Audit_status’ => ‘0待审1通过2驳回’) 二、修复(17 个业务模块) - 语言包 application/admin/lang/zh-cn/fc/*.php 全量补齐字段中文标签 (key 与 js 里 __('Key') 严格一致;标签为业务可读文案) - 列表 JS public/assets/js/backend/fc/*.js · 枚举/布尔字段统一加 searchList(筛选下拉也是中文)+ 中文 formatter · 字段顺序调整:业务关键字段靠前;次要字段 visible:false · 长文本用 autocontent、金额加 ¥ 前缀、时间用 datetime 组件 - 取值口径统一(新增 docs/06-后台字段中文化规范.md 沉淀对照表): audit_status 待审核/已通过/已驳回、status(订单) 待支付/已支付/已退款/已关闭、 pay_type 微信支付/余额支付、user_type 个人/商家、level 一级/二级 … 三、回归防护 - 新增 tools/check-admin-i18n.mjs: · 扫描 js+视图里的所有 __('Key'),缺失中文映射即报错 · 校验语言包值含中文(排除照抄英文) · 校验已知枚举字段都带 searchList 口径:全局语言包(zh-cn.php)已覆盖的 Add/Edit/Delete/OK/Operate 等不计缺; key 本身是中文时 __() 原样返回,也不计缺 四、验证 - 中文化校验:错误 0,警告 0(17 模块) - 既有业务按钮全部保留(审核/下架/打款/退款/补单/回复/置顶/举报/余额充值) - userext 的 JOIN 字段(昵称/手机/余额)保留 --- application/admin/lang/zh-cn/fc/area.php | 8 +- application/admin/lang/zh-cn/fc/banner.php | 12 +- application/admin/lang/zh-cn/fc/category.php | 8 +- application/admin/lang/zh-cn/fc/comment.php | 12 ++ .../admin/lang/zh-cn/fc/commission.php | 15 +- .../admin/lang/zh-cn/fc/distrelation.php | 10 +- application/admin/lang/zh-cn/fc/draft.php | 13 +- .../admin/lang/zh-cn/fc/financeflow.php | 12 +- application/admin/lang/zh-cn/fc/merchant.php | 23 ++- application/admin/lang/zh-cn/fc/message.php | 12 +- application/admin/lang/zh-cn/fc/order.php | 16 +- application/admin/lang/zh-cn/fc/payview.php | 8 +- application/admin/lang/zh-cn/fc/plan.php | 13 +- application/admin/lang/zh-cn/fc/post.php | 45 ++++-- application/admin/lang/zh-cn/fc/report.php | 11 +- application/admin/lang/zh-cn/fc/userext.php | 22 ++- application/admin/lang/zh-cn/fc/withdraw.php | 11 +- docs/06-后台字段中文化规范.md | 152 ++++++++++++++++++ public/assets/js/backend/fc/area.js | 11 +- public/assets/js/backend/fc/banner.js | 13 +- public/assets/js/backend/fc/category.js | 17 +- public/assets/js/backend/fc/comment.js | 28 +++- public/assets/js/backend/fc/commission.js | 45 +++++- public/assets/js/backend/fc/distrelation.js | 9 +- public/assets/js/backend/fc/draft.js | 8 +- public/assets/js/backend/fc/financeflow.js | 27 +++- public/assets/js/backend/fc/merchant.js | 24 ++- public/assets/js/backend/fc/message.js | 18 ++- public/assets/js/backend/fc/order.js | 51 ++++-- public/assets/js/backend/fc/payview.js | 20 ++- public/assets/js/backend/fc/plan.js | 25 ++- public/assets/js/backend/fc/post.js | 67 ++++++-- public/assets/js/backend/fc/report.js | 18 ++- public/assets/js/backend/fc/userext.js | 35 ++-- public/assets/js/backend/fc/withdraw.js | 29 +++- tools/check-admin-i18n.mjs | 133 +++++++++++++++ 36 files changed, 846 insertions(+), 135 deletions(-) create mode 100644 docs/06-后台字段中文化规范.md create mode 100644 tools/check-admin-i18n.mjs diff --git a/application/admin/lang/zh-cn/fc/area.php b/application/admin/lang/zh-cn/fc/area.php index ca5d8ed..63bde8a 100644 --- a/application/admin/lang/zh-cn/fc/area.php +++ b/application/admin/lang/zh-cn/fc/area.php @@ -1,5 +1,11 @@ 'ID', + 'Name' => '区域名称', + 'Sort' => '排序', + 'Enabled' => '是否启用', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作', ]; diff --git a/application/admin/lang/zh-cn/fc/banner.php b/application/admin/lang/zh-cn/fc/banner.php index ec4d628..e64dad7 100644 --- a/application/admin/lang/zh-cn/fc/banner.php +++ b/application/admin/lang/zh-cn/fc/banner.php @@ -1,6 +1,14 @@ '图片,空则用渐变占位', - 'Link' => '跳转路径' + 'Id' => 'ID', + 'Title' => '标题', + 'Image' => '图片', + 'Link' => '跳转路径', + 'Color' => '背景色', + 'Sort' => '排序', + 'Enabled' => '是否启用', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作', ]; diff --git a/application/admin/lang/zh-cn/fc/category.php b/application/admin/lang/zh-cn/fc/category.php index fd41fe2..b1b9f8a 100644 --- a/application/admin/lang/zh-cn/fc/category.php +++ b/application/admin/lang/zh-cn/fc/category.php @@ -1,10 +1,14 @@ '分类名', + 'Id' => 'ID', + 'Name' => '分类名称', 'Icon_key' => '图标key', 'Color' => '主题色', 'Sort' => '排序', 'Enabled' => '是否启用', - 'Post_count' => '信息量' + 'Post_count' => '信息量', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作', ]; diff --git a/application/admin/lang/zh-cn/fc/comment.php b/application/admin/lang/zh-cn/fc/comment.php index b07da42..c966339 100644 --- a/application/admin/lang/zh-cn/fc/comment.php +++ b/application/admin/lang/zh-cn/fc/comment.php @@ -1,6 +1,18 @@ 'ID', + 'Post_id' => '信息ID', + 'User_id' => '评价人ID', + 'Score' => '评分', + 'Content' => '评价内容', + 'Images' => '评价图片', + 'Reply' => '商家回复', + 'Replytime' => '回复时间', + 'Top' => '是否置顶', + 'Status' => '状态', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', 'ReplyComment' => '回复', 'TopComment' => '置顶', 'UnTopComment' => '取消置顶' diff --git a/application/admin/lang/zh-cn/fc/commission.php b/application/admin/lang/zh-cn/fc/commission.php index 33aa030..51d54dd 100644 --- a/application/admin/lang/zh-cn/fc/commission.php +++ b/application/admin/lang/zh-cn/fc/commission.php @@ -1,9 +1,16 @@ '获得佣金的人', - 'From_user_id' => '产生佣金的下线', + 'Id' => 'ID', + 'User_id' => '收益人ID', + 'From_user_id' => '来源用户ID', + 'Order_id' => '订单ID', + 'Order_no' => '订单号', + 'Order_type' => '订单类型', 'Amount' => '佣金金额', - 'Rate' => '分佣比例%', - 'Status' => '0未结算1已结算' + 'Rate' => '分佣比例(%)', + 'Level' => '层级', + 'Status' => '结算状态', + 'Settletime' => '结算时间', + 'Createtime' => '创建时间' ]; diff --git a/application/admin/lang/zh-cn/fc/distrelation.php b/application/admin/lang/zh-cn/fc/distrelation.php index 4a092b5..13ec2d4 100644 --- a/application/admin/lang/zh-cn/fc/distrelation.php +++ b/application/admin/lang/zh-cn/fc/distrelation.php @@ -1,7 +1,11 @@ '下线用户', - 'Parent_id' => '上级用户', - 'Level' => '1一级2二级' + 'Id' => 'ID', + 'User_id' => '下线用户ID', + 'Parent_id' => '上级用户ID', + 'Level' => '层级', + 'Createtime' => '绑定时间', + 'Operate' => '操作' ]; + diff --git a/application/admin/lang/zh-cn/fc/draft.php b/application/admin/lang/zh-cn/fc/draft.php index ca5d8ed..2417eeb 100644 --- a/application/admin/lang/zh-cn/fc/draft.php +++ b/application/admin/lang/zh-cn/fc/draft.php @@ -1,5 +1,16 @@ 'ID', + 'User_id' => '用户ID', + 'Category_id' => '分类ID', + 'Title' => '标题', + 'Content' => '内容', + 'Media' => '媒体', + 'Contact' => '联系人', + 'Phone' => '联系电话', + 'Address' => '地址', + 'Savedat' => '保存时间', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间' ]; diff --git a/application/admin/lang/zh-cn/fc/financeflow.php b/application/admin/lang/zh-cn/fc/financeflow.php index 024183f..a1b664f 100644 --- a/application/admin/lang/zh-cn/fc/financeflow.php +++ b/application/admin/lang/zh-cn/fc/financeflow.php @@ -1,7 +1,13 @@ 'income/expense', - 'Scene' => '业务场景', - 'Balance' => '账后余额' + 'Id' => 'ID', + 'Flow_no' => '流水号', + 'Type' => '收支类型', + 'Scene' => '业务场景', + 'Amount' => '金额', + 'Balance' => '账户余额', + 'Related_id' => '关联ID', + 'Remark' => '备注', + 'Createtime' => '创建时间' ]; diff --git a/application/admin/lang/zh-cn/fc/merchant.php b/application/admin/lang/zh-cn/fc/merchant.php index a55484c..5ef9899 100644 --- a/application/admin/lang/zh-cn/fc/merchant.php +++ b/application/admin/lang/zh-cn/fc/merchant.php @@ -1,9 +1,22 @@ '经营类目', - 'License' => '营业执照', - 'Shop_status' => 'normal/pending/banned', - 'AuditPass' => '审核通过', - 'AuditReject' => '审核驳回' + 'Id' => 'ID', + 'User_id' => '用户ID', + 'Name' => '商家名称', + 'Logo' => '商家LOGO', + 'Contact' => '联系电话', + 'Category' => '经营类目', + 'License' => '营业执照', + 'Audit_status' => '审核状态', + 'Audit_reason' => '驳回原因', + 'Shop_status' => '店铺状态', + 'Violations' => '违规次数', + 'Post_count' => '发布数', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作', + 'AuditPass' => '审核通过', + 'AuditReject' => '审核驳回' ]; + diff --git a/application/admin/lang/zh-cn/fc/message.php b/application/admin/lang/zh-cn/fc/message.php index a7ee25a..1cdcd1c 100644 --- a/application/admin/lang/zh-cn/fc/message.php +++ b/application/admin/lang/zh-cn/fc/message.php @@ -1,6 +1,14 @@ '0=全体', - 'Type' => 'system/interact' + 'Id' => 'ID', + 'User_id' => '接收用户ID', + 'Type' => '消息类型', + 'Title' => '标题', + 'Content' => '内容', + 'Isread' => '是否已读', + 'Readtime' => '阅读时间', + 'Createtime' => '发送时间', + 'Operate' => '操作' ]; + diff --git a/application/admin/lang/zh-cn/fc/order.php b/application/admin/lang/zh-cn/fc/order.php index 1a9fc9c..b29ad05 100644 --- a/application/admin/lang/zh-cn/fc/order.php +++ b/application/admin/lang/zh-cn/fc/order.php @@ -1,9 +1,21 @@ 'post/member/recharge', - 'Status' => 'pending/paid/refunded/closed', + 'Id' => 'ID', + 'Order_no' => '订单号', + 'User_id' => '用户ID', + 'Type' => '订单类型', + 'Title' => '订单标题', + 'Amount' => '金额', + 'Pay_type' => '支付方式', + 'Status' => '订单状态', + 'Paytime' => '支付时间', + 'Refund_amount' => '退款金额', + 'Refund_reason' => '退款原因', 'Related_id' => '关联业务ID', + 'Createtime' => '下单时间', + 'Updatetime' => '更新时间', + // 按钮文案 'RefundOrder' => '退款', 'SupplementOrder' => '补单' ]; diff --git a/application/admin/lang/zh-cn/fc/payview.php b/application/admin/lang/zh-cn/fc/payview.php index ca5d8ed..e57264e 100644 --- a/application/admin/lang/zh-cn/fc/payview.php +++ b/application/admin/lang/zh-cn/fc/payview.php @@ -1,5 +1,11 @@ 'ID', + 'User_id' => '用户ID', + 'Post_id' => '信息ID', + 'Pay_type' => '支付方式', + 'Amount' => '金额', + 'Order_id' => '订单ID', + 'Createtime' => '支付时间' ]; diff --git a/application/admin/lang/zh-cn/fc/plan.php b/application/admin/lang/zh-cn/fc/plan.php index 140d9ea..5d2eb5c 100644 --- a/application/admin/lang/zh-cn/fc/plan.php +++ b/application/admin/lang/zh-cn/fc/plan.php @@ -1,5 +1,16 @@ 'M1/M3/M12' + 'Id' => 'ID', + 'Plan_code' => '套餐编码', + 'Name' => '套餐名称', + 'Price' => '售价', + 'Origin_price' => '原价', + 'Days' => '有效天数', + 'Tag' => '标签', + 'Sort' => '排序', + 'Enabled' => '是否启用', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作', ]; diff --git a/application/admin/lang/zh-cn/fc/post.php b/application/admin/lang/zh-cn/fc/post.php index a7e9b98..7cb251b 100644 --- a/application/admin/lang/zh-cn/fc/post.php +++ b/application/admin/lang/zh-cn/fc/post.php @@ -1,17 +1,36 @@ '发布者', - 'Media' => '媒体JSON数组', - 'Contact' => '联系人', - 'Phone' => '联系电话(完整)', - 'Tags' => '标签,逗号分隔', - 'Is_paid' => '是否付费发布', - 'Amount' => '支付金额', - 'Audit_status' => '0待审1通过2驳回', - 'Status' => '1正常0下架', - 'Distance' => '距离(米)', - 'AuditPass' => '审核通过', - 'AuditReject' => '审核驳回', - 'OfflinePost' => '下架' + 'Id' => 'ID', + 'User_id' => '发布者ID', + 'Category_id' => '分类ID', + 'Title' => '标题', + 'Content' => '内容', + 'Cover' => '封面图', + 'Media' => '媒体', + 'Price' => '价格', + 'Price_unit' => '价格单位', + 'Area' => '区域', + 'Address' => '地址', + 'Contact' => '联系人', + 'Phone' => '联系电话', + 'Wechat' => '微信号', + 'Tags' => '标签', + 'Is_paid' => '是否付费', + 'Amount' => '支付金额', + 'Pay_type' => '支付方式', + 'Audit_status' => '审核状态', + 'Audit_reason' => '驳回原因', + 'Views' => '浏览量', + 'Likes' => '点赞数', + 'Comment_count' => '评价数', + 'Status' => '状态', + 'Is_top' => '是否置顶', + 'Distance' => '距离(米)', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Deletetime' => '删除时间', + 'AuditPass' => '审核通过', + 'AuditReject' => '审核驳回', + 'OfflinePost' => '下架' ]; diff --git a/application/admin/lang/zh-cn/fc/report.php b/application/admin/lang/zh-cn/fc/report.php index fee14e4..8d0de57 100644 --- a/application/admin/lang/zh-cn/fc/report.php +++ b/application/admin/lang/zh-cn/fc/report.php @@ -1,7 +1,14 @@ 'post/comment', - 'Status' => 'pending/handled', + 'Id' => 'ID', + 'Target_type' => '举报对象', + 'Target_id' => '对象ID', + 'Reason' => '举报原因', + 'Reporter_id' => '举报人ID', + 'Status' => '处理状态', + 'Remark' => '处理备注', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', 'HandleReport' => '处理' ]; diff --git a/application/admin/lang/zh-cn/fc/userext.php b/application/admin/lang/zh-cn/fc/userext.php index 2c9d657..1403b8b 100644 --- a/application/admin/lang/zh-cn/fc/userext.php +++ b/application/admin/lang/zh-cn/fc/userext.php @@ -1,7 +1,23 @@ '微信openid', - 'User_type' => '1个人2商家', - 'Free_view_date' => '免费查看额度基准日' + 'Id' => 'ID', + 'User_id' => '用户ID', + 'Nickname' => '昵称', + 'Mobile' => '手机号', + 'Money' => '账户余额', + 'Openid' => '微信openid', + 'User_type' => '用户身份', + 'Realname_status' => '实名状态', + 'Is_member' => '是否会员', + 'Member_level' => '会员等级', + 'Member_expiretime' => '会员到期时间', + 'Invite_code' => '邀请码', + 'Inviter_id' => '邀请人ID', + 'Free_view_date' => '免费额度基准日', + 'Free_view_used' => '已用免费额度', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Operate' => '操作' ]; + diff --git a/application/admin/lang/zh-cn/fc/withdraw.php b/application/admin/lang/zh-cn/fc/withdraw.php index d4a5e39..d1737bb 100644 --- a/application/admin/lang/zh-cn/fc/withdraw.php +++ b/application/admin/lang/zh-cn/fc/withdraw.php @@ -1,8 +1,17 @@ 'auditing/paid/rejected', + 'Id' => 'ID', + 'Withdraw_no' => '提现单号', + 'User_id' => '用户ID', + 'Amount' => '提现金额', + 'Channel' => '提现渠道', + 'Status' => '审核状态', 'Reason' => '驳回原因', + 'Paytime' => '打款时间', + 'Createtime' => '申请时间', + 'Updatetime' => '更新时间', + // 按钮文案 'PayWithdraw' => '打款', 'RejectWithdraw' => '驳回' ]; diff --git a/docs/06-后台字段中文化规范.md b/docs/06-后台字段中文化规范.md new file mode 100644 index 0000000..c5704f0 --- /dev/null +++ b/docs/06-后台字段中文化规范.md @@ -0,0 +1,152 @@ +# 后台字段中文化规范(FastAdmin PC) + +> 目标:后台列表/表单里的**字段标题**与**字段取值**全部显示中文,不留英文 key 与裸枚举值。 + +## 一、两条修复原则 + +### 1) 字段标题 → 补全语言包 + +FastAdmin 的列标题写作 `title: __('Xxx')`,若 `application/admin/lang/zh-cn/fc/<控制器>.php` +里没有 `'Xxx' => '中文'`,就会**原样显示英文 key**。 + +要求:把该表**所有字段**都写进语言包,且中文是**业务可读的标签** +(不要写字段注释原文,如 `'Audit_status' => '0待审1通过2驳回'` 是错的,应为 `'审核状态'`)。 + +### 2) 字段取值 → 加 `searchList` + `formatter` + +枚举/布尔字段必须渲染中文,同时给筛选项也是中文下拉: + +```js +{ + field: 'audit_status', title: __('Audit_status'), + searchList: {0: '待审核', 1: '已通过', 2: '已驳回'}, + formatter: function (value) { + var m = {0: '待审核', 1: '已通过', 2: '已驳回'}; + return m[value] !== undefined ? m[value] : (value === '' || value === null ? '-' : value); + } +} +``` + +- 值为 `0` 时必须正常命中(用 `m[value] !== undefined` 判断,不要用 `m[value] || value`) +- 字符串枚举键用引号:`{wxpay: '微信支付', balance: '余额支付'}` + +## 二、统一取值对照表(必须严格照用,保证全站一致) + +| 字段 | 取值 → 中文 | +| --- | --- | +| `audit_status` | 0 待审核 · 1 已通过 · 2 已驳回 | +| `status`(fc_post) | 1 正常 · 0 已下架 | +| `is_paid` / `is_top` / `enabled` / `isread` / `is_member` / `top` | 0 否 · 1 是 | +| `user_type` | 1 个人 · 2 商家 | +| `pay_type` | wxpay 微信支付 · balance 余额支付 | +| `type`(fc_order) | post 发布订单 · member 会员订单 · recharge 充值订单 | +| `status`(fc_order) | pending 待支付 · paid 已支付 · refunded 已退款 · closed 已关闭 | +| `status`(fc_withdraw) | auditing 待审核 · paid 已打款 · rejected 已驳回 | +| `status`(fc_report) | pending 待处理 · handled 已处理 | +| `target_type`(fc_report) | post 信息 · comment 评价 | +| `type`(fc_message) | system 系统通知 · interact 互动消息 | +| `level`(fc_dist_relation / fc_commission) | 1 一级 · 2 二级 | +| `status`(fc_commission) | 0 未结算 · 1 已结算 | +| `realname_status` | 0 未认证 · 1 已认证 | +| `shop_status`(fc_merchant) | normal 正常 · pending 待审核 · banned 已封禁 | +| `gender`(fa_user) | 0 保密 · 1 男 · 2 女 | + +## 三、各模块字段中文标签对照 + +### fc/post(信息) +id→ID,user_id→发布者ID,category_id→分类ID,title→标题,content→内容, +cover→封面图,media→媒体,price→价格,price_unit→价格单位,area→区域, +address→地址,contact→联系人,phone→联系电话,wechat→微信号,tags→标签, +is_paid→是否付费,amount→支付金额,pay_type→支付方式, +audit_status→审核状态,audit_reason→驳回原因,views→浏览量,likes→点赞数, +comment_count→评价数,status→状态,is_top→是否置顶,distance→距离(米), +createtime→创建时间,updatetime→更新时间,deletetime→删除时间 + +### fc/category(分类) +id→ID,name→分类名称,icon_key→图标key,color→主题色,sort→排序, +enabled→是否启用,post_count→信息量,createtime→创建时间,updatetime→更新时间 + +### fc/banner(轮播) +id→ID,title→标题,image→图片,link→跳转路径,color→背景色, +sort→排序,enabled→是否启用,createtime→创建时间,updatetime→更新时间 + +### fc/area(服务区域) +id→ID,name→区域名称,sort→排序,enabled→是否启用,createtime→创建时间,updatetime→更新时间 + +### fc/plan(会员套餐) +id→ID,plan_code→套餐编码,name→套餐名称,price→售价,origin_price→原价, +days→有效天数,tag→标签,sort→排序,enabled→是否启用,createtime→创建时间,updatetime→更新时间 + +### fc/merchant(商家资质) +id→ID,user_id→用户ID,name→商家名称,logo→商家LOGO,contact→联系电话, +category→经营类目,license→营业执照,audit_status→审核状态,audit_reason→驳回原因, +shop_status→店铺状态,violations→违规次数,post_count→发布数, +createtime→创建时间,updatetime→更新时间 + +### fc/comment(评价) +id→ID,post_id→信息ID,user_id→评价人ID,score→评分,content→评价内容, +images→评价图片,reply→商家回复,replytime→回复时间,top→是否置顶, +status→状态,createtime→创建时间,updatetime→更新时间 + +### fc/report(举报) +id→ID,target_type→举报对象,target_id→对象ID,reason→举报原因, +reporter_id→举报人ID,status→处理状态,remark→处理备注, +createtime→创建时间,updatetime→更新时间 + +### fc/order(订单) +id→ID,order_no→订单号,user_id→用户ID,type→订单类型,title→订单标题, +amount→金额,pay_type→支付方式,status→订单状态,paytime→支付时间, +refund_amount→退款金额,refund_reason→退款原因,related_id→关联业务ID, +createtime→下单时间,updatetime→更新时间 + +### fc/withdraw(提现) +id→ID,withdraw_no→提现单号,user_id→用户ID,amount→提现金额,channel→提现渠道, +status→审核状态,reason→驳回原因,paytime→打款时间, +createtime→申请时间,updatetime→更新时间 + +### fc/commission(佣金) +id→ID,user_id→收益人ID,from_user_id→来源用户ID,order_id→订单ID,order_no→订单号, +order_type→订单类型,amount→佣金金额,rate→分佣比例(%),level→层级, +status→结算状态,settletime→结算时间,createtime→创建时间 + +### fc/finance_flow(资金流水) +id→ID,flow_no→流水号,type→收支类型,scene→业务场景,amount→金额, +balance→账户余额,related_id→关联ID,remark→备注,createtime→创建时间 + +### fc/user_ext(会员) +id→ID,user_id→用户ID,openid→微信openid,user_type→用户身份,realname_status→实名状态, +is_member→是否会员,member_level→会员等级,member_expiretime→会员到期时间, +invite_code→邀请码,inviter_id→邀请人ID,free_view_date→免费额度基准日, +free_view_used→已用免费额度,createtime→创建时间,updatetime→更新时间 + +### fc/message(消息) +id→ID,user_id→接收用户ID,type→消息类型,title→标题,content→内容, +isread→是否已读,readtime→阅读时间,createtime→发送时间 + +### fc/pay_view(付费查看记录) +id→ID,user_id→用户ID,post_id→信息ID,pay_type→支付方式,amount→金额, +order_id→订单ID,createtime→支付时间 + +### fc/draft(草稿箱) +id→ID,user_id→用户ID,category_id→分类ID,title→标题,content→内容,media→媒体, +contact→联系人,phone→联系电话,address→地址,savedat→保存时间, +createtime→创建时间,updatetime→更新时间 + +### fc/distrelation(分销关系) +id→ID,user_id→下线用户ID,parent_id→上级用户ID,level→层级,createtime→绑定时间 + +## 四、其它要求 + +- **列表首列位置**:把最关键的 3~5 个业务字段放在前面(如 信息列表按 `title` 优先), + 不重要的字段(`media`/`deletetime`/`updatetime`/`audit_reason`)设 `visible: false` +- `createtime` / `updatetime` / `paytime` / `settletime` / `replytime` / `readtime` / + `savedat` / `member_expiretime` 等时间字段保持 + `operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime` +- 金额字段用 `formatter` 输出 `¥` 前缀(如 `¥19.90`),`operate: false` 或 `'BETWEEN'` +- 长文本(`content`/`audit_reason`)用 `class: 'autocontent', formatter: Table.api.formatter.content` + (弹层查看,不在列里撑开) +- 逗号分隔的 `tags` 用 `formatter: Table.api.formatter.flag` +- 只改 `application/admin/lang/zh-cn/fc/*.php` 与 `public/assets/js/backend/fc/*.js`, + **不要动** PHP 控制器 / 视图 / `application/api/**` +- JS 用 ES5(`var`/`function`),保持 `define(['jquery','bootstrap','backend','table','form']...)` 依赖不变 +- `__('Xxx')` 的 key 必须与语言包键**完全一致**(大小写敏感) diff --git a/public/assets/js/backend/fc/area.js b/public/assets/js/backend/fc/area.js index b00200b..4e648e2 100644 --- a/public/assets/js/backend/fc/area.js +++ b/public/assets/js/backend/fc/area.js @@ -27,10 +27,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, + { + field: 'enabled', title: __('Enabled'), + searchList: {0: '否', 1: '是'}, + formatter: function (value) { + var m = {0: '否', 1: '是'}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'sort', title: __('Sort')}, - {field: 'enabled', title: __('Enabled')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/banner.js b/public/assets/js/backend/fc/banner.js index 9a3e0b0..abc86f6 100644 --- a/public/assets/js/backend/fc/banner.js +++ b/public/assets/js/backend/fc/banner.js @@ -27,13 +27,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'title', title: __('Title'), operate: 'LIKE'}, + { + field: 'enabled', title: __('Enabled'), + searchList: {0: '否', 1: '是'}, + formatter: function (value) { + var m = {0: '否', 1: '是'}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'sort', title: __('Sort')}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'link', title: __('Link'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'color', title: __('Color'), operate: 'LIKE'}, - {field: 'sort', title: __('Sort')}, - {field: 'enabled', title: __('Enabled')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/category.js b/public/assets/js/backend/fc/category.js index b5218aa..b44ac81 100644 --- a/public/assets/js/backend/fc/category.js +++ b/public/assets/js/backend/fc/category.js @@ -27,13 +27,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, - {field: 'icon_key', title: __('Icon_key'), operate: 'LIKE'}, - {field: 'color', title: __('Color'), operate: 'LIKE'}, - {field: 'sort', title: __('Sort')}, - {field: 'enabled', title: __('Enabled'), searchList: {"1":__('Yes'),"0":__('No')}, formatter: Table.api.formatter.normal}, + { + field: 'enabled', title: __('Enabled'), + searchList: {0: '否', 1: '是'}, + formatter: function (value) { + var m = {0: '否', 1: '是'}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'post_count', title: __('Post_count')}, + {field: 'sort', title: __('Sort')}, + {field: 'color', title: __('Color'), operate: 'LIKE'}, + {field: 'icon_key', title: __('Icon_key'), operate: 'LIKE'}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/comment.js b/public/assets/js/backend/fc/comment.js index 695142e..551b6fa 100644 --- a/public/assets/js/backend/fc/comment.js +++ b/public/assets/js/backend/fc/comment.js @@ -30,14 +30,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: __('Id')}, {field: 'post_id', title: __('Post_id')}, {field: 'user_id', title: __('User_id')}, - {field: 'score', title: __('Score')}, + {field: 'score', title: __('Score'), + searchList: {1: '1', 2: '2', 3: '3', 4: '4', 5: '5'}, + formatter: function (value) { + return (value === null || value === '' || value === undefined) ? '-' : value; + } + }, {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'reply', title: __('Reply'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'replytime', title: __('Replytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'top', title: __('Top')}, - {field: 'status', title: __('Status')}, + {field: 'top', title: __('Top'), + searchList: {0: __('否'), 1: __('是')}, + formatter: function (value) { + var m = {0: __('否'), 1: __('是')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'replytime', title: __('Replytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'status', title: __('Status'), + searchList: {1: __('正常'), 0: __('隐藏')}, + formatter: function (value) { + var m = {1: __('正常'), 0: __('隐藏')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'images', title: __('Images'), visible: false}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/commission.js b/public/assets/js/backend/fc/commission.js index 7fbe3cf..b0d47a4 100644 --- a/public/assets/js/backend/fc/commission.js +++ b/public/assets/js/backend/fc/commission.js @@ -27,18 +27,49 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('Id'), visible: false}, {field: 'user_id', title: __('User_id')}, {field: 'from_user_id', title: __('From_user_id')}, + { + field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + { + field: 'rate', title: __('Rate'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : parseFloat(value).toFixed(2) + '%'; + } + }, + { + field: 'level', title: __('Level'), + searchList: {1: __('一级'), 2: __('二级')}, + formatter: function (value) { + var m = {1: __('一级'), 2: __('二级')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + { + field: 'status', title: __('Status'), + searchList: {0: __('未结算'), 1: __('已结算')}, + formatter: function (value) { + var m = {0: __('未结算'), 1: __('已结算')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'order_id', title: __('Order_id')}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, - {field: 'order_type', title: __('Order_type'), operate: 'LIKE'}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'rate', title: __('Rate'), operate:'BETWEEN'}, - {field: 'level', title: __('Level')}, - {field: 'status', title: __('Status')}, + { + field: 'order_type', title: __('Order_type'), + searchList: {post: __('发布订单'), member: __('会员订单'), recharge: __('充值订单')}, + formatter: function (value) { + var m = {post: __('发布订单'), member: __('会员订单'), recharge: __('充值订单')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'settletime', title: __('Settletime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/distrelation.js b/public/assets/js/backend/fc/distrelation.js index 09bb69f..ba9408a 100644 --- a/public/assets/js/backend/fc/distrelation.js +++ b/public/assets/js/backend/fc/distrelation.js @@ -28,7 +28,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: __('Id')}, {field: 'user_id', title: __('User_id')}, {field: 'parent_id', title: __('Parent_id')}, - {field: 'level', title: __('Level')}, + { + field: 'level', title: __('Level'), + searchList: {1: __('一级'), 2: __('二级')}, + formatter: function (value) { + var m = {1: __('一级'), 2: __('二级')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] diff --git a/public/assets/js/backend/fc/draft.js b/public/assets/js/backend/fc/draft.js index 5197366..9471849 100644 --- a/public/assets/js/backend/fc/draft.js +++ b/public/assets/js/backend/fc/draft.js @@ -29,14 +29,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'user_id', title: __('User_id')}, - {field: 'category_id', title: __('Category_id')}, {field: 'title', title: __('Title'), operate: 'LIKE'}, + {field: 'category_id', title: __('Category_id')}, + {field: 'savedat', title: __('Savedat'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, {field: 'phone', title: __('Phone'), operate: 'LIKE'}, {field: 'address', title: __('Address'), operate: 'LIKE'}, - {field: 'savedat', title: __('Savedat')}, + {field: 'media', title: __('Media'), visible: false}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/financeflow.js b/public/assets/js/backend/fc/financeflow.js index a49545e..315b0d4 100644 --- a/public/assets/js/backend/fc/financeflow.js +++ b/public/assets/js/backend/fc/financeflow.js @@ -25,15 +25,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('Id'), visible: false}, {field: 'flow_no', title: __('Flow_no'), operate: 'LIKE'}, - {field: 'type', title: __('Type'), operate: 'LIKE'}, + { + field: 'type', title: __('Type'), + searchList: {income: __('收入'), expense: __('支出')}, + formatter: function (value) { + var m = {income: __('收入'), expense: __('支出')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'scene', title: __('Scene'), operate: 'LIKE'}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'balance', title: __('Balance'), operate:'BETWEEN'}, + { + field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + { + field: 'balance', title: __('Balance'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'related_id', title: __('Related_id')}, {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/merchant.js b/public/assets/js/backend/fc/merchant.js index a7151a1..7741968 100644 --- a/public/assets/js/backend/fc/merchant.js +++ b/public/assets/js/backend/fc/merchant.js @@ -30,17 +30,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: __('Id')}, {field: 'user_id', title: __('User_id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, - {field: 'logo', title: __('Logo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, {field: 'category', title: __('Category'), operate: 'LIKE'}, + { + field: 'audit_status', title: __('Audit_status'), + searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, + formatter: function (value) { + var m = {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + { + field: 'shop_status', title: __('Shop_status'), + searchList: {normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}, + formatter: function (value) { + var m = {normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'license', title: __('License'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'audit_status', title: __('Audit_status')}, - {field: 'audit_reason', title: __('Audit_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'shop_status', title: __('Shop_status'), operate: 'LIKE', formatter: Table.api.formatter.status}, {field: 'violations', title: __('Violations')}, {field: 'post_count', title: __('Post_count')}, + {field: 'audit_reason', title: __('Audit_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'logo', title: __('Logo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content, visible: false}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/message.js b/public/assets/js/backend/fc/message.js index 18bc6ea..1b290c8 100644 --- a/public/assets/js/backend/fc/message.js +++ b/public/assets/js/backend/fc/message.js @@ -27,10 +27,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'user_id', title: __('User_id')}, - {field: 'type', title: __('Type'), operate: 'LIKE'}, + { + field: 'type', title: __('Type'), + searchList: {system: __('系统通知'), interact: __('互动消息')}, + formatter: function (value) { + var m = {system: __('系统通知'), interact: __('互动消息')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'title', title: __('Title'), operate: 'LIKE'}, {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'isread', title: __('Isread')}, + { + field: 'isread', title: __('Isread'), + searchList: {0: __('否'), 1: __('是')}, + formatter: function (value) { + var m = {0: __('否'), 1: __('是')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'readtime', title: __('Readtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} diff --git a/public/assets/js/backend/fc/order.js b/public/assets/js/backend/fc/order.js index f9f286e..79f5241 100644 --- a/public/assets/js/backend/fc/order.js +++ b/public/assets/js/backend/fc/order.js @@ -27,20 +27,51 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('Id'), visible: false}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, - {field: 'user_id', title: __('User_id')}, - {field: 'type', title: __('Type'), operate: 'LIKE'}, + { + field: 'type', title: __('Type'), + searchList: {post: __('发布订单'), member: __('会员订单'), recharge: __('充值订单')}, + formatter: function (value) { + var m = {post: __('发布订单'), member: __('会员订单'), recharge: __('充值订单')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'title', title: __('Title'), operate: 'LIKE'}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'pay_type', title: __('Pay_type'), operate: 'LIKE'}, - {field: 'status', title: __('Status'), searchList: {"16":__('Status 16')}, formatter: Table.api.formatter.status}, + { + field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + { + field: 'pay_type', title: __('Pay_type'), + searchList: {wxpay: __('微信支付'), balance: __('余额支付')}, + formatter: function (value) { + var m = {wxpay: __('微信支付'), balance: __('余额支付')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + { + field: 'status', title: __('Status'), + searchList: {pending: __('待支付'), paid: __('已支付'), refunded: __('已退款'), closed: __('已关闭')}, + formatter: function (value) { + var m = {pending: __('待支付'), paid: __('已支付'), refunded: __('已退款'), closed: __('已关闭')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'user_id', title: __('User_id')}, {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'}, - {field: 'refund_reason', title: __('Refund_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'related_id', title: __('Related_id')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + { + field: 'refund_amount', title: __('Refund_amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + {field: 'refund_reason', title: __('Refund_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'related_id', title: __('Related_id'), visible: false}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/payview.js b/public/assets/js/backend/fc/payview.js index 67186a1..bb49838 100644 --- a/public/assets/js/backend/fc/payview.js +++ b/public/assets/js/backend/fc/payview.js @@ -25,13 +25,25 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('Id'), visible: false}, {field: 'user_id', title: __('User_id')}, {field: 'post_id', title: __('Post_id')}, - {field: 'pay_type', title: __('Pay_type'), operate: 'LIKE'}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'order_id', title: __('Order_id')}, + { + field: 'pay_type', title: __('Pay_type'), + searchList: {wxpay: __('微信支付'), balance: __('余额支付'), free: __('会员免费')}, + formatter: function (value) { + var m = {wxpay: __('微信支付'), balance: __('余额支付'), free: __('会员免费')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + { + field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'order_id', title: __('Order_id')}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/plan.js b/public/assets/js/backend/fc/plan.js index 3bcdbc4..c3462ae 100644 --- a/public/assets/js/backend/fc/plan.js +++ b/public/assets/js/backend/fc/plan.js @@ -30,14 +30,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'id', title: __('Id')}, {field: 'plan_code', title: __('Plan_code'), operate: 'LIKE'}, {field: 'name', title: __('Name'), operate: 'LIKE'}, - {field: 'price', title: __('Price'), operate:'BETWEEN'}, - {field: 'origin_price', title: __('Origin_price'), operate:'BETWEEN'}, + { + field: 'price', title: __('Price'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + { + field: 'origin_price', title: __('Origin_price'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, {field: 'days', title: __('Days')}, {field: 'tag', title: __('Tag'), operate: 'LIKE', formatter: Table.api.formatter.flag}, + { + field: 'enabled', title: __('Enabled'), + searchList: {0: '否', 1: '是'}, + formatter: function (value) { + var m = {0: '否', 1: '是'}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'sort', title: __('Sort')}, - {field: 'enabled', title: __('Enabled')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/post.js b/public/assets/js/backend/fc/post.js index 17c7c0b..6b92b5e 100644 --- a/public/assets/js/backend/fc/post.js +++ b/public/assets/js/backend/fc/post.js @@ -28,31 +28,72 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, - {field: 'category_id', title: __('Category_id')}, {field: 'title', title: __('Title'), operate: 'LIKE'}, - {field: 'cover', title: __('Cover'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'price', title: __('Price'), operate:'BETWEEN'}, + {field: 'category_id', title: __('Category_id')}, + {field: 'price', title: __('Price'), operate: 'BETWEEN', + formatter: function (value) { + return (value === null || value === '' || value === undefined) ? '-' : '¥' + value; + } + }, {field: 'price_unit', title: __('Price_unit'), operate: 'LIKE'}, {field: 'area', title: __('Area'), operate: 'LIKE'}, + {field: 'audit_status', title: __('Audit_status'), + searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, + formatter: function (value) { + var m = {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'views', title: __('Views')}, + {field: 'is_paid', title: __('Is_paid'), + searchList: {0: __('否'), 1: __('是')}, + formatter: function (value) { + var m = {0: __('否'), 1: __('是')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'cover', title: __('Cover'), operate: 'LIKE'}, + {field: 'media', title: __('Media'), visible: false}, + {field: 'user_id', title: __('User_id')}, {field: 'address', title: __('Address'), operate: 'LIKE'}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, {field: 'phone', title: __('Phone'), operate: 'LIKE'}, {field: 'wechat', title: __('Wechat'), operate: 'LIKE'}, {field: 'tags', title: __('Tags'), operate: 'LIKE', formatter: Table.api.formatter.flag}, - {field: 'is_paid', title: __('Is_paid')}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'pay_type', title: __('Pay_type'), operate: 'LIKE'}, - {field: 'audit_status', title: __('Audit_status')}, + {field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return (value === null || value === '' || value === undefined) ? '-' : '¥' + value; + } + }, + {field: 'pay_type', title: __('Pay_type'), + searchList: {wxpay: __('微信支付'), balance: __('余额支付')}, + formatter: function (value) { + var m = {wxpay: __('微信支付'), balance: __('余额支付')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'audit_reason', title: __('Audit_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'views', title: __('Views')}, {field: 'likes', title: __('Likes')}, {field: 'comment_count', title: __('Comment_count')}, - {field: 'status', title: __('Status')}, - {field: 'is_top', title: __('Is_top')}, + {field: 'status', title: __('Status'), + searchList: {1: __('正常'), 0: __('已下架')}, + formatter: function (value) { + var m = {1: __('正常'), 0: __('已下架')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + {field: 'is_top', title: __('Is_top'), + searchList: {0: __('否'), 1: __('是')}, + formatter: function (value) { + var m = {0: __('否'), 1: __('是')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'distance', title: __('Distance')}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, + {field: 'deletetime', title: __('Deletetime'), visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/report.js b/public/assets/js/backend/fc/report.js index 54695b1..ff1c198 100644 --- a/public/assets/js/backend/fc/report.js +++ b/public/assets/js/backend/fc/report.js @@ -26,14 +26,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'target_type', title: __('Target_type'), operate: 'LIKE'}, + {field: 'target_type', title: __('Target_type'), + searchList: {post: __('信息'), comment: __('评价')}, + formatter: function (value) { + var m = {post: __('信息'), comment: __('评价')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'target_id', title: __('Target_id')}, {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'reporter_id', title: __('Reporter_id')}, - {field: 'status', title: __('Status'), searchList: {"16":__('Status 16')}, formatter: Table.api.formatter.status}, + {field: 'status', title: __('Status'), + searchList: {pending: __('待处理'), handled: __('已处理')}, + formatter: function (value) { + var m = {pending: __('待处理'), handled: __('已处理')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/userext.js b/public/assets/js/backend/fc/userext.js index 6ecc5fc..b0780a5 100644 --- a/public/assets/js/backend/fc/userext.js +++ b/public/assets/js/backend/fc/userext.js @@ -28,33 +28,44 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'user_id', title: '用户ID'}, - {field: 'nickname', title: '昵称', operate: 'LIKE'}, - {field: 'mobile', title: '手机号', operate: 'LIKE'}, + {field: 'user_id', title: __('User_id')}, + {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, + {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, { - field: 'money', title: '账户余额', operate: false, + field: 'money', title: __('Money'), operate: false, formatter: function (value) { var n = parseFloat(value || 0); return n > 0 ? '¥' + n.toFixed(2) : '¥0.00'; } }, { - field: 'user_type', title: '身份', searchList: {'1': '个人', '2': '商家'}, + field: 'user_type', title: __('User_type'), + searchList: {'1': __('个人'), '2': __('商家')}, formatter: function (value) { - return value == 2 ? '商家' : '个人'; + var m = {'1': __('个人'), '2': __('商家')}; + return m[value] !== undefined ? m[value] : '-'; } }, { - field: 'is_member', title: '会员', searchList: {'1': '是', '0': '否'}, + field: 'is_member', title: __('Is_member'), + searchList: {'0': __('否'), '1': __('是')}, formatter: function (value) { - return value == 1 ? '是' : '否'; + var m = {'0': __('否'), '1': __('是')}; + return m[value] !== undefined ? m[value] : '-'; } }, - {field: 'member_level', title: '会员等级', operate: 'LIKE'}, - {field: 'member_expiretime', title: '会员到期', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}, - {field: 'invite_code', title: '邀请码', operate: 'LIKE'}, + {field: 'member_level', title: __('Member_level'), operate: 'LIKE'}, + {field: 'member_expiretime', title: __('Member_expiretime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}, + {field: 'invite_code', title: __('Invite_code'), operate: 'LIKE'}, {field: 'openid', title: __('Openid'), operate: 'LIKE', visible: false}, - {field: 'realname_status', title: __('Realname_status'), visible: false}, + { + field: 'realname_status', title: __('Realname_status'), visible: false, + searchList: {'0': __('未认证'), '1': __('已认证')}, + formatter: function (value) { + var m = {'0': __('未认证'), '1': __('已认证')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'inviter_id', title: __('Inviter_id'), visible: false}, {field: 'free_view_date', title: __('Free_view_date'), visible: false}, {field: 'free_view_used', title: __('Free_view_used'), visible: false}, diff --git a/public/assets/js/backend/fc/withdraw.js b/public/assets/js/backend/fc/withdraw.js index 6aefb12..cf52187 100644 --- a/public/assets/js/backend/fc/withdraw.js +++ b/public/assets/js/backend/fc/withdraw.js @@ -27,16 +27,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('Id'), visible: false}, {field: 'withdraw_no', title: __('Withdraw_no'), operate: 'LIKE'}, {field: 'user_id', title: __('User_id')}, - {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, - {field: 'channel', title: __('Channel'), operate: 'LIKE'}, - {field: 'status', title: __('Status'), searchList: {"16":__('Status 16')}, formatter: Table.api.formatter.status}, + { + field: 'amount', title: __('Amount'), operate: 'BETWEEN', + formatter: function (value) { + return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); + } + }, + { + field: 'channel', title: __('Channel'), + searchList: {wxpay: __('微信支付')}, + formatter: function (value) { + var m = {wxpay: __('微信支付')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, + { + field: 'status', title: __('Status'), + searchList: {auditing: __('待审核'), paid: __('已打款'), rejected: __('已驳回')}, + formatter: function (value) { + var m = {auditing: __('待审核'), paid: __('已打款'), rejected: __('已驳回')}; + return m[value] !== undefined ? m[value] : '-'; + } + }, {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/tools/check-admin-i18n.mjs b/tools/check-admin-i18n.mjs new file mode 100644 index 0000000..dcb7df9 --- /dev/null +++ b/tools/check-admin-i18n.mjs @@ -0,0 +1,133 @@ +#!/usr/bin/env node +/** + * 后台字段中文化校验(FastAdmin PC) + * + * 校验目标: + * 1) 列表/表单里所有 `__('Key')` 都能在对应语言包里找到**中文**映射 + * —— 缺失即会在后台显示英文 key(这正是「字段没中文化」的直接原因) + * 2) 语言包的值确实包含中文(排除照抄英文/注释原文的情况) + * 3) 已知枚举字段都加了 searchList + formatter(取值不会是裸数字/英文枚举) + * + * 用法:node tools/check-admin-i18n.mjs + */ +import fs from 'node:fs' +import path from 'node:path' +import url from 'node:url' + +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) +const ROOT = path.resolve(__dirname, '..') +const JS_DIR = path.join(ROOT, 'public/assets/js/backend/fc') +const LANG_DIR = path.join(ROOT, 'application/admin/lang/zh-cn/fc') +const VIEW_DIR = path.join(ROOT, 'application/admin/view/fc') + +let errors = 0 +let warns = 0 +const bad = (m) => { console.log(` ❌ ${m}`); errors++ } +const warn = (m) => { console.log(` ⚠️ ${m}`); warns++ } +const ok = (m) => console.log(` ✅ ${m}`) + +/** 提取源码里所有 __('Key') / __("Key") 的 key */ +function extractKeys(src) { + const keys = new Set() + const re = /__\(\s*['"]([^'"]+)['"]\s*\)/g + let m + while ((m = re.exec(src))) keys.add(m[1]) + return keys +} + +/** 解析语言包 return [ 'Key' => '值', ... ] */ +function parseLang(file) { + const map = new Map() + if (!fs.existsSync(file)) return map + const src = fs.readFileSync(file, 'utf8') + const re = /'([^']+)'\s*=>\s*'((?:[^'\\]|\\.)*)'/g + let m + while ((m = re.exec(src))) map.set(m[1], m[2].replace(/\\'/g, "'")) + return map +} + +const hasCJK = (s) => /[\u4e00-\u9fa5]/.test(s) + +/** 已知枚举字段 → 期望在 js 中同时出现 searchList(取值中文化) */ +const ENUM_FIELDS = { + audit_status: true, status: true, is_paid: true, is_top: true, top: true, + is_member: true, isread: true, enabled: true, user_type: true, pay_type: true, + level: true, realname_status: true, shop_status: true, target_type: true, type: true, + channel: true, order_type: true, +} + +const modules = fs.readdirSync(JS_DIR).filter((f) => f.endsWith('.js')).map((f) => f.replace(/\.js$/, '')).sort() +if (!modules.length) { + console.log('未找到后台模块 JS,路径:' + JS_DIR) + process.exit(1) +} + +// FastAdmin 全局语言包:内置 key(Add/Edit/Delete/OK/Operate/Refresh/Recycle bin…) +// 都在这里有中文映射,因此缺失判定必须「全局 + 模块」都不存在才算错误。 +const GLOBAL_LANG = parseLang(path.join(ROOT, 'application/admin/lang/zh-cn.php')) +// 这些值本身不是中文但完全正确,不计入「不含中文」告警 +const CJK_EXEMPT = new Set(['ID', 'IP', 'URL', 'API', 'VIP', 'LOGO', 'Logo', 'OpenID', 'ok']) + +console.log(`\n后台字段中文化校验(${modules.length} 个模块,全局语言包 ${GLOBAL_LANG.size} 条)\n`) + +for (const name of modules) { + console.log(`[${name}]`) + const lang = parseLang(path.join(LANG_DIR, `${name}.php`)) + if (!lang.size) bad(`${name}.php 语言包为空或不存在`) + + // 1) 收集该模块 js + 视图里用到的所有 __() key + const files = [path.join(JS_DIR, `${name}.js`)] + const viewDir = path.join(VIEW_DIR, name) + if (fs.existsSync(viewDir)) { + for (const v of fs.readdirSync(viewDir)) { + if (v.endsWith('.html')) files.push(path.join(viewDir, v)) + } + } + const keys = new Set() + for (const f of files) { + for (const k of extractKeys(fs.readFileSync(f, 'utf8'))) keys.add(k) + } + + // 2) 缺映射 → 会显示英文 + // 注意:key 本身含中文时(如 __('待审核')),FastAdmin 的 __() 查不到映射会原样 + // 返回 key,显示仍然是中文,因此**不算缺**。只统计「英文 key 且无映射」的情况。 + const missing = [...keys] + .filter((k) => !hasCJK(k) && !lang.has(k) && !GLOBAL_LANG.has(k)) + .sort() + if (missing.length) { + bad(`缺少中文映射 ${missing.length} 个(后台将显示英文):${missing.slice(0, 12).join(', ')}${missing.length > 12 ? ' …' : ''}`) + } else { + ok(`字段标题全部有中文映射(${keys.size} 个 key)`) + } + + // 3) 模块自身语言包的值必须含中文 + const nonCJK = [...lang.entries()] + .filter(([, v]) => !hasCJK(v) && !CJK_EXEMPT.has(v)) + .map(([k, v]) => `${k}=${v}`) + if (nonCJK.length) warn(`这些标签不含中文,请确认:${nonCJK.slice(0, 8).join(', ')}`) + + // 4) 枚举字段应有 searchList(取值中文化) + const js = fs.readFileSync(path.join(JS_DIR, `${name}.js`), 'utf8') + const fieldRe = /field:\s*'([a-zA-Z_]+)'/g + const usedEnums = new Set() + let fm + while ((fm = fieldRe.exec(js))) { + if (ENUM_FIELDS[fm[1]]) usedEnums.add(fm[1]) + } + const noSearch = [...usedEnums].filter((f) => { + // 该字段所在的列对象里是否出现 searchList + const seg = js.split(new RegExp(`field:\\s*'${f}'`))[1] || '' + const block = seg.slice(0, 400) + return !/searchList/.test(block) + }) + if (noSearch.length) { + warn(`枚举字段缺 searchList(取值可能显示为原值):${noSearch.join(', ')}`) + } else if (usedEnums.size) { + ok(`枚举字段取值已中文化(${[...usedEnums].join(', ')})`) + } +} + +console.log('\n------------------------------------------') +console.log(`中文化校验结束:错误 ${errors},警告 ${warns}`) +console.log('------------------------------------------\n') +if (errors) process.exitCode = 1