一、问题(用户反馈「后台字段内容没用中文」)
- 大量字段标题没有中文映射 → __(‘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 字段(昵称/手机/余额)保留
127 行
5.8 KiB
JavaScript
127 行
5.8 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'fc/comment/index' + location.search,
|
|
add_url: 'fc/comment/add',
|
|
edit_url: 'fc/comment/edit',
|
|
del_url: 'fc/comment/del',
|
|
multi_url: 'fc/comment/multi',
|
|
import_url: 'fc/comment/import',
|
|
table: 'fc_comment',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
fixedColumns: true,
|
|
fixedRightNumber: 1,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'post_id', title: __('Post_id')},
|
|
{field: 'user_id', title: __('User_id')},
|
|
{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: '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: '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}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
// 回复
|
|
$(document).on('click', '.btn-reply', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
Layer.prompt({title: __('请输入回复内容'), formType: 2}, function (value, index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/comment/reply',
|
|
data: {ids: ids.join(','), reply: value}
|
|
}, function (data) {
|
|
table.bootstrapTable('refresh');
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 置顶
|
|
$(document).on('click', '.btn-top', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
Layer.confirm(__('确认置顶选中的评价?'), {icon: 3, title: __('提示')}, function (index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/comment/top',
|
|
data: {ids: ids.join(','), top: 1}
|
|
}, function (data) {
|
|
table.bootstrapTable('refresh');
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
// 取消置顶
|
|
$(document).on('click', '.btn-untop', function () {
|
|
var ids = Table.api.selectedids(table);
|
|
Layer.confirm(__('确认取消置顶选中的评价?'), {icon: 3, title: __('提示')}, function (index) {
|
|
Fast.api.ajax({
|
|
url: 'fc/comment/top',
|
|
data: {ids: ids.join(','), top: 0}
|
|
}, function (data) {
|
|
table.bootstrapTable('refresh');
|
|
return false;
|
|
});
|
|
Layer.close(index);
|
|
});
|
|
});
|
|
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|