@agile-team/wl-skills-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +328 -0
- package/bin/wl-skills.js +104 -0
- package/files/.github/copilot-instructions.md +211 -0
- package/files/.github/docs/SYS_MENU_INFO.md +247 -0
- package/files/.github/docs/menu-sync-design.md +265 -0
- package/files/.github/docs/use-skill.md +379 -0
- package/files/.github/docs/wl-skills-kit.md +266 -0
- package/files/.github/skills/api-contract/SKILL.md +247 -0
- package/files/.github/skills/convention-extract/SKILL.md +355 -0
- package/files/.github/skills/menu-sync/SKILL.md +255 -0
- package/files/.github/skills/menu-sync/env/guide.md +73 -0
- package/files/.github/skills/page-codegen/SKILL.md +825 -0
- package/files/.github/skills/page-codegen/TPL-CHANGE-HISTORY.md +281 -0
- package/files/.github/skills/page-codegen/TPL-DETAIL-TABS.md +1112 -0
- package/files/.github/skills/page-codegen/TPL-DRIVEN.md +124 -0
- package/files/.github/skills/page-codegen/TPL-FORM-ROUTE.md +441 -0
- package/files/.github/skills/page-codegen/TPL-LIST.md +196 -0
- package/files/.github/skills/page-codegen/TPL-MASTER-DETAIL.md +153 -0
- package/files/.github/skills/page-codegen/TPL-OPERATION-STATION.md +442 -0
- package/files/.github/skills/page-codegen/TPL-RECORD-FORM.md +376 -0
- package/files/.github/skills/page-codegen/TPL-TREE-LIST.md +191 -0
- package/files/.github/skills/prototype-scan/SKILL.md +414 -0
- package/files/demo/README.md +44 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add/api.md +54 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add/data.ts +346 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add/index.scss +1 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add/index.vue +28 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add-form/data.ts +115 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add-form/index.scss +44 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-add-form/index.vue +43 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change/data.ts +338 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change/index.scss +1 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change/index.vue +28 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-form/data.ts +115 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-form/index.scss +44 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-form/index.vue +43 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/data.ts +196 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.scss +150 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.vue +79 -0
- package/files/demo/produce/aiflow/mmwr-customer-archive/api.md +88 -0
- package/files/demo/produce/aiflow/mmwr-customer-archive/data.ts +601 -0
- package/files/demo/produce/aiflow/mmwr-customer-archive/index.scss +1 -0
- package/files/demo/produce/aiflow/mmwr-customer-archive/index.vue +64 -0
- package/files/demo/produce/aiflow/mmwr-customer-detail/api.md +67 -0
- package/files/demo/produce/aiflow/mmwr-customer-detail/data.ts +286 -0
- package/files/demo/produce/aiflow/mmwr-customer-detail/index.scss +139 -0
- package/files/demo/produce/aiflow/mmwr-customer-detail/index.vue +318 -0
- package/files/demo/produce/aiflow/mmwr-temp-customer-archive/api.md +98 -0
- package/files/demo/produce/aiflow/mmwr-temp-customer-archive/data.ts +543 -0
- package/files/demo/produce/aiflow/mmwr-temp-customer-archive/index.scss +1 -0
- package/files/demo/produce/aiflow/mmwr-temp-customer-archive/index.vue +52 -0
- package/files/demo/sale/demo/add-demo/data.ts +518 -0
- package/files/demo/sale/demo/add-demo/index.scss +207 -0
- package/files/demo/sale/demo/add-demo/index.vue +167 -0
- package/files/demo/sale/demo/billet-flame-cut-plan/data.ts +524 -0
- package/files/demo/sale/demo/billet-flame-cut-plan/index.scss +155 -0
- package/files/demo/sale/demo/billet-flame-cut-plan/index.vue +117 -0
- package/files/demo/sale/demo/domestic-trade-order/data.ts +308 -0
- package/files/demo/sale/demo/domestic-trade-order/index.scss +99 -0
- package/files/demo/sale/demo/domestic-trade-order/index.vue +77 -0
- package/files/demo/sale/demo/heat-batch-return/data.ts +367 -0
- package/files/demo/sale/demo/heat-batch-return/index.scss +100 -0
- package/files/demo/sale/demo/heat-batch-return/index.vue +170 -0
- package/files/demo/sale/demo/heat-batch-return/meltDialog.vue +320 -0
- package/files/demo/sale/demo/metallurgical-spec/data.ts +825 -0
- package/files/demo/sale/demo/metallurgical-spec/index.scss +264 -0
- package/files/demo/sale/demo/metallurgical-spec/index.vue +309 -0
- package/files/docs/jh-date-range.md +257 -0
- package/files/docs/jh-date.md +222 -0
- package/files/docs/jh-dept-picker.md +190 -0
- package/files/docs/jh-drag-row.md +590 -0
- package/files/docs/jh-file-upload.md +216 -0
- package/files/docs/jh-pagination.md +505 -0
- package/files/docs/jh-picker.md +218 -0
- package/files/docs/jh-select.md +148 -0
- package/files/docs/jh-text.md +248 -0
- package/files/docs/jh-user-picker.md +197 -0
- package/files/docs/page-query-hook-best-practices.md +362 -0
- package/files/docs/request.md +925 -0
- package/files/src/components/global/C_ParentView/index.vue +3 -0
- package/files/src/components/global/C_RightToolbar/index.vue +459 -0
- package/files/src/components/global/C_Splitter/index.vue +195 -0
- package/files/src/components/global/C_SvgIcon/index.vue +61 -0
- package/files/src/components/global/C_SvgIcon/svgicon.js +10 -0
- package/files/src/components/global/C_TagStatus/README.md +264 -0
- package/files/src/components/global/C_TagStatus/config.ts +192 -0
- package/files/src/components/global/C_TagStatus/index.vue +127 -0
- package/files/src/components/global/C_TagStatus/types.ts +64 -0
- package/files/src/components/global/C_Tree/README.md +153 -0
- package/files/src/components/global/C_Tree/index.scss +42 -0
- package/files/src/components/global/C_Tree/index.vue +119 -0
- package/files/src/components/global/C_Tree/types.ts +59 -0
- package/files/src/components/local/c_formModal/README.md +235 -0
- package/files/src/components/local/c_formModal/data.ts +95 -0
- package/files/src/components/local/c_formModal/index.scss +8 -0
- package/files/src/components/local/c_formModal/index.vue +107 -0
- package/files/src/components/local/c_formSections/README.md +496 -0
- package/files/src/components/local/c_formSections/data.ts +175 -0
- package/files/src/components/local/c_formSections/index.scss +280 -0
- package/files/src/components/local/c_formSections/index.vue +429 -0
- package/files/src/components/local/c_listModal/data.ts +41 -0
- package/files/src/components/local/c_listModal/index.vue +136 -0
- package/files/src/components/local/c_spliterTitle/index.scss +25 -0
- package/files/src/components/local/c_spliterTitle/index.vue +21 -0
- package/files/src/components/remote/AGGrid/README.md +530 -0
- package/files/src/components/remote/BaseForm/README.md +508 -0
- package/files/src/components/remote/BaseQuery/README.md +865 -0
- package/files/src/components/remote/BaseTable/README.md +941 -0
- package/files/src/components/remote/BaseToolbar/README.md +496 -0
- package/files/src/types/page.ts +24 -0
- package/package.json +31 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# jh-picker - 通用关联挑选组件
|
|
2
|
+
|
|
3
|
+
> 平台统一的通用数据挑选组件,适用于需要从某一业务数据源中选择一条或多条数据的场景,常用于关联单据、基础资料等
|
|
4
|
+
|
|
5
|
+
## 📦 组件位置
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import "@jhlc/common-core";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
组件已全局注册,可直接在模板中使用 `<jh-picker />`。
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 基本用法
|
|
16
|
+
|
|
17
|
+
### 1️⃣ 单选关联数据(最常用)
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<jh-picker
|
|
22
|
+
v-model="form.customerId"
|
|
23
|
+
picker-type="customer"
|
|
24
|
+
placeholder="请选择客户"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { ref } from "vue";
|
|
30
|
+
|
|
31
|
+
const form = ref({
|
|
32
|
+
customerId: ""
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### 2️⃣ 多选关联数据
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<jh-picker
|
|
43
|
+
v-model="form.productIds"
|
|
44
|
+
picker-type="product"
|
|
45
|
+
multiple
|
|
46
|
+
placeholder="请选择商品"
|
|
47
|
+
/>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Props 属性
|
|
53
|
+
|
|
54
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
55
|
+
| -------------------- | -------------------------------- | ------------------------------------------------------------------------ | --------------------- |
|
|
56
|
+
| modelValue / v-model | 绑定值 | `string \| string[]` | - |
|
|
57
|
+
| pickerType | 选择器类型(业务标识) | `string` | - |
|
|
58
|
+
| single | 是否单选(与 multiple 相反) | `boolean` | `true` |
|
|
59
|
+
| multiple | 是否多选 | `boolean` | `false` |
|
|
60
|
+
| placeholder | 占位提示 | `string` | `"请选择"` |
|
|
61
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
62
|
+
| clearable | 是否可清空 | `boolean` | `true` |
|
|
63
|
+
| dataType | 返回数据类型(多选时) | `"array" \| "string"` | `"array"` |
|
|
64
|
+
| showType | 显示类型 | `"" \| "button"` | `""` |
|
|
65
|
+
| showLabel | 按钮文本(showType="button" 时) | `string` | - |
|
|
66
|
+
| buttonType | 按钮类型 | `"default" \| "primary" \| "success" \| "info" \| "warning" \| "danger"` | `"default"` |
|
|
67
|
+
| buttonIcon | 按钮图标 | `"Search" \| "Edit" \| "Delete" \| "Plus" \| "Refresh"` | - |
|
|
68
|
+
| title | 弹窗标题 | `string` | - |
|
|
69
|
+
| width | 弹窗宽度 | `string` | `"800px"` |
|
|
70
|
+
| listUrl | 列表查询接口 | `string` | - |
|
|
71
|
+
| listByIdsUrl | 根据ID查询接口(回显) | `string` | - |
|
|
72
|
+
| query | 查询条件配置 | `Array` | - |
|
|
73
|
+
| columns | 表格列配置 | `Array` | - |
|
|
74
|
+
| valueAttr | 值字段路径 | `string[] \| string` | `["id"]` |
|
|
75
|
+
| labelAttr | 标签字段路径 | `string[] \| string` | `["name"]` |
|
|
76
|
+
| dataAttr | 数据字段路径 | `string[] \| string` | `["data", "records"]` |
|
|
77
|
+
|
|
78
|
+
> **重点**: `pickerType` 必须是平台配置过的类型,否则需要手动配置 `listUrl`、`query`、`columns` 等参数。
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Events 事件
|
|
83
|
+
|
|
84
|
+
| 事件名 | 说明 | 回调参数 |
|
|
85
|
+
| ----------------- | -------------- | ------------------------------------- |
|
|
86
|
+
| update:modelValue | v-model 更新 | `(value: string \| string[]) => void` |
|
|
87
|
+
| change | 选择变化时触发 | `() => void` |
|
|
88
|
+
| ok | 确认选择时触发 | `() => void` |
|
|
89
|
+
| clear | 清空时触发 | `() => void` |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 常见场景
|
|
94
|
+
|
|
95
|
+
### 场景 1:选择关联客户
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<jh-picker v-model="form.customerId" picker-type="customer" />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### 场景 2:选择关联单据
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<jh-picker v-model="form.orderId" picker-type="order" />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### 场景 3:多选关联基础资料
|
|
112
|
+
|
|
113
|
+
```vue
|
|
114
|
+
<jh-picker v-model="form.materialIds" picker-type="material" multiple />
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### 场景 4:详情页展示(配合 jh-text)
|
|
120
|
+
|
|
121
|
+
```vue
|
|
122
|
+
<jh-text :value="detail.customerName" />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
> ⚠️ `jh-picker` 仅负责选择,展示请使用文本组件
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 与手动实现对比
|
|
130
|
+
|
|
131
|
+
### 使用 jh-picker(推荐)
|
|
132
|
+
|
|
133
|
+
```vue
|
|
134
|
+
<jh-picker v-model="form.customerId" picker-type="customer" />
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 手动实现(不推荐)
|
|
138
|
+
|
|
139
|
+
```vue
|
|
140
|
+
<el-input v-model="form.customerName" @click="openDialog" readonly />
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
❌ 需要自己实现弹窗
|
|
144
|
+
❌ 需要处理列表查询
|
|
145
|
+
❌ 需要维护回填逻辑
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 最佳实践
|
|
150
|
+
|
|
151
|
+
### 1️⃣ pickerType 必须语义清晰
|
|
152
|
+
|
|
153
|
+
```vue
|
|
154
|
+
<jh-picker picker-type="customer" />
|
|
155
|
+
<jh-picker picker-type="product" />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
确保不同业务类型对应不同选择器配置
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### 2️⃣ 编辑 & 展示分离
|
|
163
|
+
|
|
164
|
+
| 场景 | 编辑 | 展示 |
|
|
165
|
+
| -------- | --------- | ------------------ |
|
|
166
|
+
| 关联数据 | jh-picker | jh-text / 普通文本 |
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### 3️⃣ 多选返回值说明
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
// 单选
|
|
174
|
+
customerId: "c001";
|
|
175
|
+
|
|
176
|
+
// 多选
|
|
177
|
+
productIds: ["p001", "p002"];
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 注意事项
|
|
183
|
+
|
|
184
|
+
1. **pickerType 由平台统一配置**
|
|
185
|
+
- 不可随意填写
|
|
186
|
+
- 必须是平台已支持的类型
|
|
187
|
+
|
|
188
|
+
2. **组件仅返回关联 ID**
|
|
189
|
+
- 其他字段需自行处理或由后端返回
|
|
190
|
+
|
|
191
|
+
3. **多选注意字段类型**
|
|
192
|
+
- 必须使用数组接收
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 🎯 真实项目示例
|
|
197
|
+
|
|
198
|
+
### 示例 1:销售订单选择客户
|
|
199
|
+
|
|
200
|
+
```vue
|
|
201
|
+
<jh-picker v-model="form.customerId" picker-type="customer" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 示例 2:采购单选择商品
|
|
205
|
+
|
|
206
|
+
```vue
|
|
207
|
+
<jh-picker v-model="form.productIds" picker-type="product" multiple />
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🚀 快速开始
|
|
213
|
+
|
|
214
|
+
1. 确定业务类型(pickerType)
|
|
215
|
+
2. 使用 v-model 绑定 ID
|
|
216
|
+
3. 展示统一使用文本组件
|
|
217
|
+
|
|
218
|
+
**推荐作为平台统一的通用关联选择组件使用!**
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# jh-select - 字典下拉选择组件
|
|
2
|
+
|
|
3
|
+
> 集成平台数据字典的下拉选择组件,只需传入字典名称即可自动加载选项,统一字典使用方式
|
|
4
|
+
|
|
5
|
+
## 📦 组件位置
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import "@jhlc/common-core";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
组件已全局注册,可直接在模板中使用 `<jh-select />`。
|
|
12
|
+
|
|
13
|
+
## 基本用法
|
|
14
|
+
|
|
15
|
+
### 根据字典名称加载
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<jh-select
|
|
20
|
+
v-model="form.status"
|
|
21
|
+
dict="order_status"
|
|
22
|
+
placeholder="请选择订单状态"
|
|
23
|
+
clearable
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { ref } from "vue";
|
|
29
|
+
|
|
30
|
+
const form = ref({
|
|
31
|
+
status: ""
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Props 属性
|
|
37
|
+
|
|
38
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
39
|
+
| -------------------- | ------------------------- | -------------------------------------------------------- | ---------- |
|
|
40
|
+
| modelValue / v-model | 绑定值 | `string \| number \| Array<string \| number> \| boolean` | - |
|
|
41
|
+
| dict | 字典名称(平台字典 code) | `string` | - |
|
|
42
|
+
| items | 静态数据选项 | `Array<{label: string, value: any}>` | `[]` |
|
|
43
|
+
| placeholder | 占位提示 | `string` | `"请选择"` |
|
|
44
|
+
| clearable | 是否可清空 | `boolean` | `true` |
|
|
45
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
46
|
+
| multiple | 是否多选 | `boolean` | `false` |
|
|
47
|
+
| filterable | 是否可搜索 | `boolean` | `false` |
|
|
48
|
+
| datasourceType | 数据源类型 | `"static" \| "interface"` | `"static"` |
|
|
49
|
+
| multiDataFormat | 多选时的数据格式 | `"string" \| "array"` | `"array"` |
|
|
50
|
+
| collapseTag | 多选时是否折叠 Tag | `boolean` | `false` |
|
|
51
|
+
| teleported | 是否将下拉面板插入 body | `boolean` | `true` |
|
|
52
|
+
|
|
53
|
+
> **重点**: 当 `dict` 属性存在时,组件会自动加载对应字典数据,无需手动设置 `items`。
|
|
54
|
+
|
|
55
|
+
## Events 事件
|
|
56
|
+
|
|
57
|
+
| 事件名 | 说明 | 回调参数 |
|
|
58
|
+
| ----------------- | ------------ | ----------------- |
|
|
59
|
+
| change | 选中值变化 | `(value) => void` |
|
|
60
|
+
| update:modelValue | v-model 更新 | `(value) => void` |
|
|
61
|
+
|
|
62
|
+
## 常见场景
|
|
63
|
+
|
|
64
|
+
### 场景 1:列表查询条件
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<jh-select v-model="query.status" dict="order_status" placeholder="订单状态" />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 场景 2:表单编辑
|
|
71
|
+
|
|
72
|
+
```vue
|
|
73
|
+
<jh-select v-model="form.type" dict="order_type" :disabled="isView" />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 场景 3:多选字典
|
|
77
|
+
|
|
78
|
+
```vue
|
|
79
|
+
<jh-select v-model="form.tags" dict="order_tag" multiple />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 场景 4:BaseQuery 配置式用法(推荐)
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
// data.ts 查询项配置
|
|
86
|
+
export const queryItemsConfig: BaseQueryItemDesc<any>[] = [
|
|
87
|
+
{
|
|
88
|
+
name: "orderStatus",
|
|
89
|
+
label: "操作类型",
|
|
90
|
+
placeholder: "请选择操作类型",
|
|
91
|
+
component: () => {
|
|
92
|
+
return {
|
|
93
|
+
tag: "jh-select",
|
|
94
|
+
// 方式一:静态数据
|
|
95
|
+
items: [
|
|
96
|
+
{ label: "是", value: 1 },
|
|
97
|
+
{ label: "否", value: 0 }
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "status",
|
|
104
|
+
label: "状态",
|
|
105
|
+
logicType: BusLogicDataType.dict,
|
|
106
|
+
logicValue: "order_status" // 字典 code
|
|
107
|
+
// 方式二:使用字典数据(会自动加载)
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 场景 5:静态 items 方式
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<jh-select
|
|
116
|
+
v-model="form.gender"
|
|
117
|
+
:items="[
|
|
118
|
+
{ label: '男', value: 1 },
|
|
119
|
+
{ label: '女', value: 2 }
|
|
120
|
+
]"
|
|
121
|
+
placeholder="请选择性别"
|
|
122
|
+
/>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 最佳实践
|
|
128
|
+
|
|
129
|
+
1. **始终使用 dict 属性**
|
|
130
|
+
- 不要手动写 options
|
|
131
|
+
- 保证字典来源统一
|
|
132
|
+
|
|
133
|
+
2. **配合 jh-text 使用**
|
|
134
|
+
- 列表展示用 `jh-text`
|
|
135
|
+
- 表单编辑用 `jh-select`
|
|
136
|
+
|
|
137
|
+
3. **字典值以字符串为主**
|
|
138
|
+
- 避免 number/string 混用
|
|
139
|
+
|
|
140
|
+
## 注意事项
|
|
141
|
+
|
|
142
|
+
- 字典数据来自平台缓存
|
|
143
|
+
- 字典名称必须是平台已配置的 code
|
|
144
|
+
- 多选时返回数组
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
✅ **推荐作为平台统一的字典下拉组件使用**
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# jh-text - 文本展示组件
|
|
2
|
+
|
|
3
|
+
> 统一的文本展示组件,内置平台字典、用户、部门的自动翻译能力,用于列表、详情等只读场景
|
|
4
|
+
|
|
5
|
+
## 📦 组件位置
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import "@jhlc/common-core";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
组件已全局注册,可直接在模板中使用 `<jh-text />`。
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 基本用法
|
|
16
|
+
|
|
17
|
+
### 1️⃣ 字典文本展示(最常用)
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<jh-text dict="order_status" :value="row.status" />
|
|
22
|
+
</template>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> 根据字典 code + value 自动翻译显示文本
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### 2️⃣ 用户名称展示
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<jh-text type="user" :value="row.createUserId" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### 3️⃣ 部门名称展示
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<jh-text type="dept" :value="row.deptId" />
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### 4️⃣ 普通文本展示
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<jh-text :value="row.remark" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Props 属性
|
|
54
|
+
|
|
55
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
56
|
+
| --- | --- | --- | --- |
|
|
57
|
+
| content | 需要展示的值(优先级高于 value) | `string \| number \| Date \| Array` | `""` |
|
|
58
|
+
| value | 需要展示的值(与Content二选一) | `string \| number \| string[]` | - |
|
|
59
|
+
| dict | 字典名称(平台字典 code) | `string` | - |
|
|
60
|
+
| type | 文本类型 | `"text" \| "dict" \| "user" \| "dept"` | `"text"` |
|
|
61
|
+
| logicType | 逻辑类型(用于自动识别) | `BusLogicDataType` | - |
|
|
62
|
+
| logicValue | 逻辑值(字典code/用户/部门) | `string` | - |
|
|
63
|
+
| separator | 多值分隔符 | `string` | `"、"` |
|
|
64
|
+
| emptyText | 空值显示文本 | `string` | `"-"` |
|
|
65
|
+
| format | 文本格式 | `"default" \| "ellipsis" \| "html"` | `"default"` |
|
|
66
|
+
| rows | 多行显示时的行数 | `number` | `1` |
|
|
67
|
+
| fontSize | 字体大小 | `"extra-small" \| "small" \| "base" \| "medium" \| "large" \| "extra-large"` | - |
|
|
68
|
+
| fontWeight | 字体粗细 | `"light" \| "regular" \| "medium" \| "semi"` | - |
|
|
69
|
+
|
|
70
|
+
> **提示**:
|
|
71
|
+
> - `dict` 传入时,会自动设置 `type="dict"`
|
|
72
|
+
> - 同时使用 `logicType` 和 `logicValue` 可以实现自动翻译
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 支持类型说明
|
|
77
|
+
|
|
78
|
+
| type 值 | 说明 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| text | 普通文本(默认) |
|
|
81
|
+
| dict | 字典翻译 |
|
|
82
|
+
| user | 用户名称 |
|
|
83
|
+
| dept | 部门名称 |
|
|
84
|
+
|
|
85
|
+
> 当传入 `dict` 时,`type` 可省略
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 常见场景
|
|
90
|
+
|
|
91
|
+
### 场景 1:表格字典列展示(推荐)
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<el-table-column label="订单状态">
|
|
95
|
+
<template #default="{ row }">
|
|
96
|
+
<jh-text dict="order_status" :value="row.status" />
|
|
97
|
+
</template>
|
|
98
|
+
</el-table-column>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
✅ **统一字典展示**
|
|
102
|
+
✅ **避免每个页面手动转换**
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 场景 2:用户/部门字段展示
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<jh-text type="user" :value="row.createUserId" />
|
|
110
|
+
<jh-text type="dept" :value="row.deptId" />
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### 场景 3:详情页只读展示
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<el-descriptions-item label="订单状态">
|
|
119
|
+
<jh-text dict="order_status" :value="detail.status" />
|
|
120
|
+
</el-descriptions-item>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 场景 4:多值展示
|
|
126
|
+
|
|
127
|
+
```vue
|
|
128
|
+
<jh-text
|
|
129
|
+
dict="order_tag"
|
|
130
|
+
:value="row.tags"
|
|
131
|
+
separator=" / "
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 场景 5:BaseDetail 配置式用法
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
// data.ts 详情项配置
|
|
139
|
+
export const detailItemsConfig: BaseFormDetailDesc[] = [
|
|
140
|
+
{
|
|
141
|
+
name: "status",
|
|
142
|
+
label: "状态",
|
|
143
|
+
logicType: BusLogicDataType.dict,
|
|
144
|
+
logicValue: "order_status"
|
|
145
|
+
// 会自动渲染为 jh-text 并翻译字典
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "createUserId",
|
|
149
|
+
label: "创建人",
|
|
150
|
+
logicType: BusLogicDataType.user,
|
|
151
|
+
logicValue: "userId"
|
|
152
|
+
// 会自动翻译用户名
|
|
153
|
+
}
|
|
154
|
+
];
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 与手动处理对比
|
|
160
|
+
|
|
161
|
+
### 使用 jh-text(推荐)
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<jh-text dict="order_status" :value="row.status" />
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 手动处理(不推荐)
|
|
168
|
+
|
|
169
|
+
```vue
|
|
170
|
+
{{ getDictLabel("order_status", row.status) }}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
❌ 依赖工具函数
|
|
174
|
+
❌ 每个页面重复实现
|
|
175
|
+
❌ 不利于统一规范
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 最佳实践
|
|
180
|
+
|
|
181
|
+
### 1️⃣ 列表展示统一使用 jh-text
|
|
182
|
+
|
|
183
|
+
- 字典值
|
|
184
|
+
- 用户 / 部门 ID
|
|
185
|
+
- 多选值
|
|
186
|
+
|
|
187
|
+
```vue
|
|
188
|
+
<jh-text ... />
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 2️⃣ 表单编辑 + 展示组件配套使用
|
|
194
|
+
|
|
195
|
+
| 场景 | 编辑 | 展示 |
|
|
196
|
+
| --- | --- | --- |
|
|
197
|
+
| 字典 | jh-select | jh-text |
|
|
198
|
+
| 用户 | jh-user-picker | jh-text |
|
|
199
|
+
| 部门 | jh-dept-picker | jh-text |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### 3️⃣ 空值兜底处理
|
|
204
|
+
|
|
205
|
+
```vue
|
|
206
|
+
<jh-text :value="row.remark" empty-text="暂无" />
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 注意事项
|
|
212
|
+
|
|
213
|
+
1. **仅用于展示**
|
|
214
|
+
- 不支持编辑
|
|
215
|
+
- 不触发任何 change 事件
|
|
216
|
+
|
|
217
|
+
2. **字典值必须合法**
|
|
218
|
+
- value 必须存在于字典中
|
|
219
|
+
- 否则显示 `emptyText`
|
|
220
|
+
|
|
221
|
+
3. **多值类型**
|
|
222
|
+
- value 为数组或逗号分隔字符串均可
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 🎯 真实项目示例
|
|
227
|
+
|
|
228
|
+
### 示例 1:列表页
|
|
229
|
+
|
|
230
|
+
```vue
|
|
231
|
+
<jh-text dict="order_status" :value="row.status" />
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 示例 2:详情页
|
|
235
|
+
|
|
236
|
+
```vue
|
|
237
|
+
<jh-text type="user" :value="detail.createUserId" />
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 🚀 快速开始
|
|
243
|
+
|
|
244
|
+
- **字典展示**:直接传 `dict`
|
|
245
|
+
- **用户/部门**:使用 `type`
|
|
246
|
+
- **空值兜底**:配置 `emptyText`
|
|
247
|
+
|
|
248
|
+
**推荐作为平台统一的文本展示组件使用!**
|