文件
huaqiapp/server/application/admin/library/ManageConfig.php
linda 56f5f60aa5 feat(admin): 后台登录页品牌化 + 26 个业务模块与前端对齐 + 数据同步打通
一、登录页重构(暖色调品牌版)
- 左右分栏卡片:44% 品牌面板(花红渐变 + 光斑 + 内联 SVG 花瓣 Logo + 花期字标/口号)
  + 56% 表单面板(52px 输入框、内嵌矢量图标、聚焦暖色光晕、渐变主按钮)
- 与前台同一套设计令牌(#E8604C / #F58C7C / #FFF9F5 / #3E2C27),响应式适配
- 完整保留 #login-form/#pd-form-username/#profile-img/#errtips/token/验证码/保持登录等结构,后台登录 JS 零改动

二、后台业务模块(26 个,与前端 M1–M9 一一对应)
- 新增通用 Manage 控制器(列表/搜索/排序/新增/编辑/软删除/批量/列元数据)
- 新增 ManageConfig(26 张表的字段标签/类型/枚举/搜索配置)与 FormBuilder(表单控件渲染)
- 新增通用视图 manage/{index,add,edit,style}.html + public/assets/js/backend/manage.js
- 新增 26 个薄控制器(各 8 行,仅声明 )
- db/05_admin_menu.sql:花期运营菜单树 + 6 个通用操作权限,含站点名品牌化

三、品牌一致性
- site.php 站点名改为「花期运营中心」,顶栏 Logo 增加矢量花瓣
- 业务页暖色表头、渐变按钮、圆角输入、品牌色开关

四、验证(全绿)
- 后台自检 31 项:登录页品牌、框架菜单、26 模块页面 200 + 列表数据、后台编辑写库、
  后台改动 → 前台 API 同步读取、数据还原
- 前台接口 82 项断言、契约 84 接口、Vue 20/20、SCSS 19/19、无 emoji 均通过
- 修复 5 个真实问题:方法签名不兼容致 500、菜单缓存、SQL 字符集乱码、
  snake_case URL 与权限规则命名、会话文件属主导致的自检 500
2026-11-06 11:10:19 +08:00

497 行
30 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace app\admin\library;
/**
* 运营后台业务模块注册表
*
* 与前端 M1–M9 功能模块一一对应,统一由 Manage 控制器提供列表/新增/编辑/删除能力。
* 字段定义支持:type(text/textarea/number/decimal/date/datetime/select/bool/json/user)、
* label、options、search、readonly、form(是否出现在表单)。
*/
class ManageConfig
{
/** 常用枚举 */
public static $enums = [
'status' => ['normal' => '正常', 'hidden' => '隐藏'],
'access' => ['free' => '免费', 'member' => '会员', 'pay' => '付费'],
'verify' => ['pending' => '待审核', 'passed' => '已通过', 'rejected' => '已驳回'],
'pay_status' => ['unpaid' => '待支付', 'paid' => '已支付', 'refunded' => '已退款'],
'scope' => ['prepare' => '备孕任务', 'family' => '家庭共育', 'relation' => '双人任务', 'parenting' => '育儿任务'],
'mood' => ['happy' => '开心', 'calm' => '平静', 'anxious' => '焦虑', 'low' => '低落', 'angry' => '烦躁'],
'mode' => ['cycle' => '经期模式', 'prepare' => '备孕模式', 'pregnant' => '孕期模式'],
'source' => ['user' => '用户记录', 'algorithm' => '算法生成'],
'result' => ['negative' => '阴性', 'weak' => '弱阳', 'positive' => '阳性', 'strong' => '强阳', 'unknown' => '未识别'],
'level' => ['basic' => '基础版', 'pro' => '专业版'],
'repeat_rule' => ['daily' => '每天', 'once' => '单次', 'weekly' => '每周'],
'app_lock' => ['none' => '关闭', 'password' => '数字密码', 'biometric' => '生物识别'],
'cert_verify' => ['pending' => '待审核', 'passed' => '已认证', 'expired' => '已过期'],
'consult_status' => ['pending' => '待开始', 'ongoing' => '进行中', 'finished' => '已完成', 'canceled' => '已取消'],
'onoff' => ['on' => '上架', 'off' => '下架'],
'relation' => ['partner' => '伴侣', 'parent' => '父母', 'friend' => '朋友'],
'test_type' => ['lh' => '排卵试纸', 'hcg' => '早孕试纸'],
'type_content' => [
'jijing' => '每日心语', 'mood' => '情绪科普', 'knowledge' => '知识库', 'advice' => '健康建议',
'meditation' => '正念冥想', 'care' => '暖心话术', 'card' => '沟通引导卡', 'conflict' => '冲突工具',
'firstaid' => '情绪急救包', 'guide' => '同房指导', 'course' => '系列课程', 'activity' => '亲子活动',
'emotion' => '育儿情绪',
],
'category_type' => [
'jijing' => '心语', 'mood' => '情绪科普', 'knowledge' => '知识库', 'advice' => '健康建议',
'meditation' => '冥想', 'care' => '话术', 'card' => '引导卡', 'conflict' => '冲突工具',
'firstaid' => '急救包', 'guide' => '同房指导', 'course' => '课程', 'activity' => '亲子活动', 'emotion' => '育儿情绪',
],
'action' => ['care_daily' => '每日关怀', 'prepare_task' => '备孕任务', 'exchange' => '积分兑换'],
'category' => ['check' => '检查', 'folic' => '叶酸', 'nutrition' => '营养', 'partner' => '伴侣', 'daily' => '日常', 'care' => '照护'],
'memory_type' => ['anniversary' => '纪念日', 'milestone' => '里程碑', 'daily' => '日常记录'],
'vaccine_type' => ['vaccine' => '疫苗', 'checkup' => '儿保体检'],
'gender' => ['0' => '未知', '1' => '男', '2' => '女'],
'advice_key' => [],
];
/**
* 所有受管业务表
*/
public static function all()
{
return [
/* ================= M1 周期管理 ================= */
'fa_cycle' => [
'title' => '周期档案',
'group' => '周期管理',
'sort' => 'start_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'start_date' => ['label' => '经期开始日', 'type' => 'date', 'search' => true],
'end_date' => ['label' => '经期结束日', 'type' => 'date'],
'period_length' => ['label' => '经期天数', 'type' => 'number'],
'cycle_length' => ['label' => '周期天数', 'type' => 'number'],
'ovulation_date' => ['label' => '排卵日', 'type' => 'date'],
'mode' => ['label' => '模式', 'type' => 'select', 'options' => 'mode'],
'source' => ['label' => '来源', 'type' => 'select', 'options' => 'source'],
],
],
'fa_cycle_log' => [
'title' => '每日症状记录',
'group' => '周期管理',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'flow' => ['label' => '经血量', 'type' => 'select', 'options' => ['0' => '无', '1' => '少', '2' => '中', '3' => '多']],
'pain_level' => ['label' => '痛经程度', 'type' => 'select', 'options' => ['0' => '无', '1' => '轻微', '2' => '可忍', '3' => '明显', '4' => '较重', '5' => '难忍']],
'symptom_ids' => ['label' => '症状标签ID', 'type' => 'text'],
'mood' => ['label' => '情绪分值', 'type' => 'number'],
'sleep_hours' => ['label' => '睡眠(小时)', 'type' => 'decimal'],
'sex' => ['label' => '性生活', 'type' => 'select', 'options' => ['0' => '无', '1' => '有保护', '2' => '无保护']],
'note' => ['label' => '备注', 'type' => 'textarea'],
],
],
'fa_symptom_tag' => [
'title' => '症状标签',
'group' => '周期管理',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '标签名', 'type' => 'text', 'search' => true],
'icon' => ['label' => '图标', 'type' => 'text'],
'category' => ['label' => '分类', 'type' => 'select', 'options' => ['body' => '身体', 'mood' => '情绪', 'flow' => '经血']],
'is_preset' => ['label' => '预设标签', 'type' => 'bool'],
'user_id' => ['label' => '归属用户', 'type' => 'user'],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_reminder' => [
'title' => '智能提醒',
'group' => '周期管理',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'title' => ['label' => '提醒内容', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => ['period' => '经期', 'ovulation' => '排卵', 'record' => '记录', 'medication' => '用药', 'custom' => '自定义']],
'remind_time' => ['label' => '提醒时间', 'type' => 'text'],
'repeat_rule' => ['label' => '重复', 'type' => 'select', 'options' => 'repeat_rule'],
'remind_date' => ['label' => '提醒日期', 'type' => 'date'],
'enabled' => ['label' => '启用', 'type' => 'bool'],
],
],
/* ================= M2 情绪疗愈 ================= */
'fa_mood_log' => [
'title' => '情绪日记',
'group' => '情绪疗愈',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'mood' => ['label' => '情绪', 'type' => 'select', 'options' => 'mood'],
'intensity' => ['label' => '强度', 'type' => 'number'],
'triggers' => ['label' => '触发事件', 'type' => 'text'],
'content' => ['label' => '内容', 'type' => 'textarea'],
],
],
/* ================= 内容中心 ================= */
'fa_content' => [
'title' => '内容库',
'group' => '内容中心',
'sort' => 'weigh desc, id desc',
'fields' => [
'type' => ['label' => '内容类型', 'type' => 'select', 'options' => 'type_content', 'search' => true],
'category_id' => ['label' => '分类ID', 'type' => 'number'],
'title' => ['label' => '标题', 'type' => 'text', 'search' => true],
'summary' => ['label' => '摘要', 'type' => 'text'],
'body' => ['label' => '正文', 'type' => 'textarea'],
'cover_emoji' => ['label' => '图标字符', 'type' => 'text'],
'media_type' => ['label' => '媒体类型', 'type' => 'select', 'options' => ['text' => '图文', 'audio' => '音频', 'video' => '视频']],
'duration' => ['label' => '时长(秒)', 'type' => 'number'],
'phase' => ['label' => '适用阶段', 'type' => 'text'],
'mood_tag' => ['label' => '适用情绪', 'type' => 'text'],
'extra' => ['label' => '扩展信息', 'type' => 'textarea'],
'access' => ['label' => '访问权限', 'type' => 'select', 'options' => 'access', 'search' => true],
'verify' => ['label' => '审核状态', 'type' => 'select', 'options' => 'verify', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status', 'search' => true],
],
],
'fa_content_category' => [
'title' => '内容分类',
'group' => '内容中心',
'sort' => 'weigh desc, id asc',
'fields' => [
'pid' => ['label' => '父级ID', 'type' => 'number'],
'name' => ['label' => '分类名', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'category_type', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
/* ================= M3 科学备孕 ================= */
'fa_bbt_record' => [
'title' => '基础体温',
'group' => '科学备孕',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'log_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'temperature' => ['label' => '体温(℃)', 'type' => 'decimal'],
'measure_time' => ['label' => '测量时间', 'type' => 'text'],
'device' => ['label' => '设备来源', 'type' => 'select', 'options' => ['manual' => '手动', 'bluetooth' => '蓝牙']],
],
],
'fa_lh_test' => [
'title' => '试纸识别记录',
'group' => '科学备孕',
'sort' => 'log_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'test_type' => ['label' => '试纸类型', 'type' => 'select', 'options' => 'test_type'],
'log_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'result' => ['label' => '识别结果', 'type' => 'select', 'options' => 'result'],
'confidence' => ['label' => '置信度', 'type' => 'decimal'],
'algo' => ['label' => '算法', 'type' => 'select', 'options' => ['rule' => '规则引擎', 'cnn' => 'CNN 模型']],
'image' => ['label' => '试纸图片', 'type' => 'text'],
],
],
'fa_task' => [
'title' => '任务(备孕/双人/共育)',
'group' => '科学备孕',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'scope' => ['label' => '归属模块', 'type' => 'select', 'options' => 'scope', 'search' => true],
'title' => ['label' => '任务内容', 'type' => 'text', 'search' => true],
'category' => ['label' => '分类', 'type' => 'select', 'options' => 'category'],
'due_date' => ['label' => '截止日期', 'type' => 'date'],
'done' => ['label' => '已完成', 'type' => 'bool'],
'share_partner' => ['label' => '同步伴侣', 'type' => 'bool'],
],
],
/* ================= M4 家人共护 ================= */
'fa_family_bind' => [
'title' => '家人绑定',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '主账号', 'type' => 'user', 'search' => true],
'member_user_id' => ['label' => '家人账号', 'type' => 'user'],
'member_name' => ['label' => '家人称呼', 'type' => 'text', 'search' => true],
'relation' => ['label' => '关系', 'type' => 'select', 'options' => 'relation'],
'scope' => ['label' => '可见范围', 'type' => 'text'],
'invite_code' => ['label' => '邀请码', 'type' => 'text', 'search' => true],
'status' => ['label' => '状态', 'type' => 'select', 'options' => ['pending' => '待接受', 'normal' => '已绑定', 'removed' => '已解绑'], 'search' => true],
],
],
'fa_care_message' => [
'title' => '沟通空间留言',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'bind_id' => ['label' => '绑定ID', 'type' => 'number', 'search' => true],
'user_id' => ['label' => '发送人', 'type' => 'user', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => ['text' => '文字', 'voice' => '语音', 'gift' => '礼物']],
'content' => ['label' => '留言内容', 'type' => 'textarea'],
],
],
'fa_point_log' => [
'title' => '爱心积分流水',
'group' => '家人共护',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'action' => ['label' => '积分动作', 'type' => 'select', 'options' => 'action', 'search' => true],
'point' => ['label' => '积分', 'type' => 'number'],
'ref_id' => ['label' => '关联ID', 'type' => 'number'],
'remark' => ['label' => '备注', 'type' => 'text'],
],
],
/* ================= M7 两性关系 ================= */
'fa_memory' => [
'title' => '纪念日与回忆',
'group' => '两性关系',
'sort' => 'memory_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'title' => ['label' => '标题', 'type' => 'text', 'search' => true],
'memory_date' => ['label' => '日期', 'type' => 'date', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'memory_type'],
'content' => ['label' => '内容', 'type' => 'textarea'],
'remind' => ['label' => '提醒', 'type' => 'bool'],
],
],
'fa_course_order' => [
'title' => '课程订单',
'group' => '两性关系',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'content_id' => ['label' => '课程ID', 'type' => 'number'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
],
],
/* ================= M8 亲子教育 ================= */
'fa_baby' => [
'title' => '宝宝档案',
'group' => '亲子教育',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'nickname' => ['label' => '小名', 'type' => 'text', 'search' => true],
'gender' => ['label' => '性别', 'type' => 'select', 'options' => ['0' => '未知', '1' => '男', '2' => '女']],
'birthday' => ['label' => '生日', 'type' => 'date'],
'due_date' => ['label' => '预产期', 'type' => 'date'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_growth_record' => [
'title' => '成长记录',
'group' => '亲子教育',
'sort' => 'record_date desc, id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'baby_id' => ['label' => '宝宝ID', 'type' => 'number'],
'record_date' => ['label' => '记录日期', 'type' => 'date', 'search' => true],
'height' => ['label' => '身高(cm)', 'type' => 'decimal'],
'weight' => ['label' => '体重(kg)', 'type' => 'decimal'],
'milestone' => ['label' => '里程碑', 'type' => 'text'],
'note' => ['label' => '备注', 'type' => 'textarea'],
],
],
'fa_vaccine' => [
'title' => '疫苗与儿保',
'group' => '亲子教育',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '项目名称', 'type' => 'text', 'search' => true],
'type' => ['label' => '类型', 'type' => 'select', 'options' => 'vaccine_type', 'search' => true],
'month_from' => ['label' => '起始月龄', 'type' => 'number'],
'month_to' => ['label' => '结束月龄', 'type' => 'number'],
'note' => ['label' => '说明', 'type' => 'text'],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
/* ================= M9 心理服务 ================= */
'fa_counselor' => [
'title' => '咨询师',
'group' => '心理服务',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '姓名', 'type' => 'text', 'search' => true],
'avatar_emoji' => ['label' => '头像图标', 'type' => 'text'],
'title' => ['label' => '职称', 'type' => 'text'],
'cert_no' => ['label' => '资质编号', 'type' => 'text', 'search' => true],
'cert_verify' => ['label' => '资质审核', 'type' => 'select', 'options' => 'cert_verify', 'search' => true],
'price_text' => ['label' => '文字咨询价', 'type' => 'decimal'],
'price_voice' => ['label' => '语音咨询价', 'type' => 'decimal'],
'price_video' => ['label' => '视频咨询价', 'type' => 'decimal'],
'rate' => ['label' => '平台分成', 'type' => 'decimal'],
'intro' => ['label' => '简介', 'type' => 'textarea'],
'tags' => ['label' => '擅长标签', 'type' => 'text'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'onoff', 'search' => true],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
'fa_consult_order' => [
'title' => '咨询订单',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'counselor_id' => ['label' => '咨询师ID', 'type' => 'number'],
'mode' => ['label' => '方式', 'type' => 'select', 'options' => ['text' => '文字', 'voice' => '语音', 'video' => '视频']],
'start_time' => ['label' => '预约时间', 'type' => 'datetime'],
'duration' => ['label' => '时长(分钟)', 'type' => 'number'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
'consult_status' => ['label' => '咨询状态', 'type' => 'select', 'options' => 'consult_status', 'search' => true],
'rate_amount' => ['label' => '分成金额', 'type' => 'decimal'],
],
],
'fa_assessment' => [
'title' => '量表管理',
'group' => '心理服务',
'sort' => 'weigh desc, id asc',
'fields' => [
'code' => ['label' => '量表编码', 'type' => 'text', 'search' => true],
'title' => ['label' => '量表名称', 'type' => 'text', 'search' => true],
'intro' => ['label' => '引导语', 'type' => 'textarea'],
'questions' => ['label' => '题目(JSON数组)', 'type' => 'textarea'],
'scoring' => ['label' => '分级规则(JSON)', 'type' => 'textarea'],
'level' => ['label' => '版本', 'type' => 'select', 'options' => 'level'],
'scope' => ['label' => '归属', 'type' => 'select', 'options' => ['mood' => '情绪', 'relation' => '关系', 'parenting' => '育儿']],
'access' => ['label' => '访问权限', 'type' => 'select', 'options' => 'access'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
'weigh' => ['label' => '权重', 'type' => 'number'],
],
],
'fa_assessment_record' => [
'title' => '测评记录',
'group' => '心理服务',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'assessment_id' => ['label' => '量表ID', 'type' => 'number', 'search' => true],
'score' => ['label' => '得分', 'type' => 'decimal'],
'result' => ['label' => '结果分级', 'type' => 'text'],
'risk_flag' => ['label' => '风险标记', 'type' => 'bool'],
'answers' => ['label' => '作答(JSON)', 'type' => 'textarea', 'readonly' => true],
'report' => ['label' => '解读', 'type' => 'textarea', 'readonly' => true],
],
],
/* ================= M6 会员与用户 ================= */
'fa_member_plan' => [
'title' => '会员套餐',
'group' => '会员中心',
'sort' => 'weigh desc, id asc',
'fields' => [
'name' => ['label' => '套餐名', 'type' => 'text', 'search' => true],
'code' => ['label' => '编码', 'type' => 'text', 'search' => true],
'subtitle' => ['label' => '副标题', 'type' => 'text'],
'price' => ['label' => '售价', 'type' => 'decimal'],
'origin_price' => ['label' => '原价', 'type' => 'decimal'],
'duration_days' => ['label' => '有效天数', 'type' => 'number'],
'benefits' => ['label' => '权益(JSON)', 'type' => 'textarea'],
'badge' => ['label' => '角标', 'type' => 'text'],
'weigh' => ['label' => '权重', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => 'status'],
],
],
'fa_member_order' => [
'title' => '会员订单',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'order_no' => ['label' => '订单号', 'type' => 'text', 'search' => true],
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'plan_code' => ['label' => '套餐编码', 'type' => 'text'],
'amount' => ['label' => '金额', 'type' => 'decimal'],
'pay_type' => ['label' => '支付方式', 'type' => 'select', 'options' => ['wechat' => '微信', 'alipay' => '支付宝']],
'pay_status' => ['label' => '支付状态', 'type' => 'select', 'options' => 'pay_status', 'search' => true],
'trade_no' => ['label' => '第三方流水', 'type' => 'text'],
'start_time' => ['label' => '生效时间', 'type' => 'datetime'],
'expire_time' => ['label' => '到期时间', 'type' => 'datetime'],
],
],
'fa_user_setting' => [
'title' => '隐私与提醒设置',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'app_lock' => ['label' => '应用锁', 'type' => 'select', 'options' => 'app_lock'],
'local_only' => ['label' => '仅本地存储', 'type' => 'bool'],
'remind_json' => ['label' => '提醒配置(JSON)', 'type' => 'textarea'],
],
],
'fa_user_backup' => [
'title' => '数据备份',
'group' => '会员中心',
'sort' => 'id desc',
'fields' => [
'user_id' => ['label' => '用户', 'type' => 'user', 'search' => true],
'name' => ['label' => '备份名称', 'type' => 'text'],
'size' => ['label' => '大小(字节)', 'type' => 'number', 'readonly' => true],
'payload' => ['label' => '备份内容', 'type' => 'textarea', 'readonly' => true],
],
],
'fa_user' => [
'title' => '会员用户',
'group' => '会员中心',
'sort' => 'id desc',
'readonly_table' => true,
'fields' => [
'username' => ['label' => '账号', 'type' => 'text', 'search' => true],
'nickname' => ['label' => '昵称', 'type' => 'text', 'search' => true],
'mobile' => ['label' => '手机号', 'type' => 'text', 'search' => true],
'gender' => ['label' => '性别', 'type' => 'select', 'options' => ['0' => '未知', '1' => '男', '2' => '女']],
'birthday' => ['label' => '生日', 'type' => 'date'],
'bio' => ['label' => '签名', 'type' => 'text'],
'score' => ['label' => '积分', 'type' => 'number'],
'status' => ['label' => '状态', 'type' => 'select', 'options' => ['normal' => '正常', 'hidden' => '禁用']],
],
],
];
}
/**
* 取单个表的配置,并补齐通用字段
*/
public static function get($table)
{
$all = self::all();
if (!isset($all[$table])) {
return null;
}
$config = $all[$table];
if (!isset($config['fields']['createtime'])) {
$config['fields']['createtime'] = ['label' => '创建时间', 'type' => 'datetime', 'readonly' => true];
}
if (!isset($config['fields']['updatetime'])) {
$config['fields']['updatetime'] = ['label' => '更新时间', 'type' => 'datetime', 'readonly' => true];
}
if (!isset($config['fields']['deletetime'])) {
$config['fields']['deletetime'] = ['label' => '删除时间', 'type' => 'datetime', 'readonly' => true, 'form' => false];
}
return $config;
}
/** 分组(用于菜单生成与文档) */
public static function groups()
{
$groups = [];
foreach (self::all() as $table => $config) {
$groups[$config['group']][] = ['table' => $table, 'title' => $config['title']];
}
return $groups;
}
}