# *Bind、插槽与分端字段

## 1. `*Bind` 协议（组件 props，通用）

**任意** `pageContent` / `actionContent` 节点的 **`props`** 均支持：

| 配置键 | 生成 | plain 键 |
|--------|------|----------|
| **`<prop>Bind`** | `:<kebab-prop>="expr"` | `<prop>` 静态 |

示例：`titleBind` → `:title`；`activeDisplayBind` → `:active-display`；`maxBodyHeightBind` → `:max-body-height`。

规则：

- 值是 **一整段 Vue 表达式**，不是模板字符串（不要写 `{{ }}`）。
- 同时写 `*Bind` 与 plain 时，**丢弃 plain**。
- **不**适用于：`**Binding`（如 `headersBinding`）、component descriptor 固定绑定（如 FormSheet `v-model`）、PageHeader/SearchSheet 的 plain 变量名 props（`keyword: 'keyword'`）。

```js
props: {
  titleBind: "bindGroupItem.duoxingRoomId ? '已绑定' : '尚未绑定'",
  label: '组织',
  activeDisplayBind: 'currentOrgInfo.orgName',
}
```

## 2. `active-display` 插槽（富文本第二行）

组件：**`jh-mobile-filter-btn`**（Schema：`MobileFilterBtn`）。

```js
{
  component: 'MobileFilterBtn',
  props: { label: '组织', showActive: true },
  children: [
    `<template v-slot:active-display>
      {{ currentOrgInfo.orgName }}
      <span class="bg-green-500 text-white rounded px-0.5">
        {{ constant.showOrgMemberSimpleType.find(e => e.value == showOrgMemberType)?.text || showOrgMemberType }}
      </span>
    </template>`,
  ],
  attrs: { '@click': 'isOrgFilterShown = true' },
}
```

- 与 **Table/List** 相同：`children` 为 **`string[]`**，每项是完整 `<template v-slot:…>`。
- 有插槽时可 **不写** `activeDisplayBind`。
- **`showActive: true`** 且（插槽 **或** `activeDisplay` 有值）才显示双行块。

## 3. CRUD 插槽（`slots`）

| 路径 | 挂载到 |
|------|--------|
| **`slots.list.pc.children`** | PC Table |
| **`slots.list.mobile.children`** | Mobile List |
| **`slots.create.pc.children`** | CreateDrawer / FormSheet |
| **`slots.update.pc.children`** | UpdateDrawer / FormSheet |
| **`slots.update.{tabKey}.pc.children`** | 多 Tab 按 tab 追加 |

### 3.1 Tab 级插槽 `tab-{tabKey}`

CreateDrawer / UpdateDrawer / FormSheet 支持 **整 Tab 自定义 body**（类似 List 的 `body`）：

| 插槽名 | 作用 |
|--------|------|
| **`tab-{tabKey}`** | 接管该 Tab 整块内容（不再渲染 `jh-form`） |
| **`field-{key}`** | 单字段插槽（经 `jh-form` 转发） |
| **`tab-default`** | 无 `tabList` 时的单表单 Tab |

```js
views: {
  update: {
    tabList: [
      { key: 'basic', title: '基本信息', fieldList: ['name'] },
      { key: 'class', title: '班级绑定' }, // 无 fieldList，纯 tab body
    ],
  },
},
slots: {
  update: {
    class: {
      mobile: {
        children: [/*html*/ `
          <template v-slot:tab-class="{ tab, item }">
            <!-- 整 Tab 内容，item 即 initialData -->
          </template>
        `],
      },
    },
  },
},
```

- 存在 `tab-{key}` 时，该 Tab **跳过** `jh-form` 与内置校验（`validate()` 返回 true）。
- 仍可与同 Tab 的 `field-*` 混用：有 `tab-*` 时以 Tab body 为准。

## 4. `page.targets` vs `includeList[].targets`

| 字段 | 层级 | 含义 |
|------|------|------|
| **`page.targets`** | 整份配置 | 编译产出几端：`pc` / `mobile` / `both` |
| **`includeList[].targets`** | 单条资源 | 在某次 `buildPage('pc'|'mobile')` 中是否包含该项 |

```js
page: { id: 'x', targets: 'both' },
includeList: [
  { type: 'html', path: 'all.html' },
  { type: 'html', path: 'pc.html', targets: 'pc' },
  { type: 'html', path: 'm.html', targets: 'mobile' },
],
```

**不要**把 include 的 `target` 改成 `targets`（除非未来做别名）；页面级用复数 **`targets`**，条目级用单数 **`target`** 是刻意区分。

## 5. 字段 attrs 分端

```js
fields: {
  remark: {
    label: '备注',
    type: 'textarea',
    attrs: { rows: 3 },
    pc: { rows: 6 },
    mobile: { rows: 4 },
  },
},
```

编译时 merge：`pc` 覆盖用于 PC 编译，`mobile` 用于 mobile 编译。

## 6. Mobile `views.list.search.keyword`（与 PC 对齐）

配置：

```js
search: {
  keyword: { fields: ['projectName', 'projectId'], placeholder: '搜索' },
  fieldList: ['status'],
},
```

- **PC**：`jh-search` 用 `props.keyword.fields` 固定 OR 列。
- **Mobile**：`SearchSheet` 用 **`keywordConfig.fields`**，与 PC 共用同一语义来源。
- 页面初值：`standardConfig.features.keywordFieldList` bake 进 `jh-mobile-page-v7` 的 `data.keywordFieldList`。

## 7. `interaction` 条件

```js
interaction: {
  status: {
    visibleWhen: 'isOutsource',
    readonlyWhen: { or: ['isFinished', { field: 'type', op: 'eq', value: 'A' }] },
    disabledWhen: "status === '已归档'",
  },
},
```

写入 **`fieldList[]`** 的 `visibleWhen` / `readonlyWhen` / `disabledWhen`（表达式包装为 `__expr__` 供 NJK 输出）。

按钮 **`actionList[]` / `headActionList[]` / `rowActionList[]`** 均支持 **`visibleWhen` / `disabledWhen` / `loadingWhen`**。

- **`loadingWhen`** 为 true 时按钮显示 loading（`v-btn` 转圈 / 行文字按钮 spinner），并阻止重复点击
- 表单 / 工具栏：上下文为 page `$data` + `initialData`
- **行操作**：上下文额外包含 **`item`**（当前行），例如 `visibleWhen: 'item.id !== -1'`

**标准 uiAction**（编译期 **1:1 输出**；运行时 `resolveDoUiActionId` → `doUiAction(...)`）：

| 位置 | 常用 uiAction |
|------|---------------|
| `headActionList` | `create` / `delete` / `batchDelete` / 自定义 doUiAction 名 |
| `rowActionList` | `update` / `delete` / `detail` / 自定义 doUiAction 名 |
| `create.actionList` | `createItem` / `save` / `cancel` / 自定义 doUiAction 名 |
| `update.actionList` | `updateItem` / `save` / `cancel` / 自定义 doUiAction 名 |

自定义：`uiAction` 直接写 camelCase doUiAction 方法名。旧 **`intent` / `id` / `actionId`** 仅作生成兼容读取；**语法校验**（`validate-examples` / VSCode schema）强制 **`label` + `uiAction`**。
