290 lines
5.5 KiB
Markdown
290 lines
5.5 KiB
Markdown
# 特殊功能示例
|
||
|
||
> 甘特图、订单、邮件等复杂业务功能
|
||
> 源码分析时间:2026-04-01
|
||
|
||
---
|
||
|
||
## 一、销售订单(saleOrder)
|
||
|
||
### 1.1 功能特点
|
||
|
||
- 主子表结构(订单 + 明细)
|
||
- 右侧产品选择弹窗
|
||
- 订单状态管理
|
||
|
||
### 1.2 前端实现
|
||
|
||
```vue
|
||
<script lang="ts" setup>
|
||
// 主表
|
||
const [registerTable, { reload, getSelectRows }] = useVxeTable({
|
||
api: getOrderList,
|
||
columns: mainColumns,
|
||
rowClick: ({ record }) => {
|
||
// 点击主表行加载子表
|
||
state.activeId = record.id;
|
||
getProductEntry(record.id).then(res => {
|
||
state.productList = res.data.list;
|
||
});
|
||
}
|
||
});
|
||
|
||
// 子表
|
||
const [registerProductTable] = useVxeTable({
|
||
columns: productColumns,
|
||
useSearchForm: false,
|
||
pagination: false,
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<div class="h-full">
|
||
<!-- 主表 -->
|
||
<BasicVxeTable @register="registerTable" />
|
||
<!-- 子表 -->
|
||
<div class="footer">
|
||
<BasicVxeTable @register="registerProductTable" :data-source="productList" />
|
||
</div>
|
||
</div>
|
||
</template>
|
||
```
|
||
|
||
### 1.3 后端 API
|
||
|
||
```typescript
|
||
// saleOrder.ts
|
||
export function getOrderList(data) {
|
||
return defHttp.get({ url: '/api/extend/saleOrder/Product', data });
|
||
}
|
||
export function getProductEntry(id) {
|
||
return defHttp.get({ url: `/api/extend/saleOrder/Product/ProductEntry/${id}` });
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 二、项目甘特图(projectGantt)
|
||
|
||
### 2.1 功能特点
|
||
|
||
- 树形任务结构
|
||
- 甘特图时间轴
|
||
- 任务依赖关系
|
||
|
||
### 2.2 前端组件
|
||
|
||
```
|
||
projectGantt/
|
||
├── index.vue # 主页面
|
||
├── Task.vue # 任务组件
|
||
├── TaskForm.vue # 任务表单
|
||
└── Form.vue # 甘特图配置
|
||
```
|
||
|
||
### 2.3 后端 Controller
|
||
|
||
```java
|
||
// ProjectGanttController
|
||
@GetMapping
|
||
public ActionResult<ListVO<ProjectGanttListVO>> list() { }
|
||
|
||
@GetMapping("/{id}")
|
||
public ActionResult<ProjectGanttInfoVO> info(@PathVariable("id") String id) { }
|
||
|
||
@PostMapping
|
||
public ActionResult create(@RequestBody @Valid ProjectGanttCrForm form) { }
|
||
|
||
@PutMapping("/{id}")
|
||
public ActionResult update(@PathVariable("id") String id, @RequestBody ProjectGanttUpForm form) { }
|
||
```
|
||
|
||
---
|
||
|
||
## 三、邮件功能(email)
|
||
|
||
### 3.1 功能模块
|
||
|
||
- 邮件发送(EmailSend)
|
||
- 邮件接收(EmailReceive)
|
||
- 邮件配置(EmailConfig)
|
||
|
||
### 3.2 前端结构
|
||
|
||
```
|
||
email/
|
||
├── index.vue # 邮件列表
|
||
├── Form.vue # 发送表单
|
||
├── Detail.vue # 邮件详情
|
||
├── Config.vue # 配置页面
|
||
├── DetailPage.vue # 详情页面
|
||
└── DetailMain.vue # 详情主体
|
||
```
|
||
|
||
### 3.3 后端 Controller
|
||
|
||
```java
|
||
// EmailController
|
||
@GetMapping
|
||
public ActionResult list() { }
|
||
|
||
@PostMapping
|
||
public ActionResult create(@RequestBody EmailSendEntity entity) { }
|
||
|
||
@GetMapping("/{id}")
|
||
public ActionResult info(@PathVariable("id") String id) { }
|
||
```
|
||
|
||
---
|
||
|
||
## 四、大数据表格(bigData)
|
||
|
||
### 4.1 特点
|
||
|
||
- 虚拟滚动
|
||
- 分页加载
|
||
- 大量数据处理
|
||
|
||
### 4.2 实现参考
|
||
|
||
```vue
|
||
<script lang="ts" setup>
|
||
const [registerTable] = useVxeTable({
|
||
api: getBigDataList,
|
||
columns,
|
||
pagination: { pageSize: 100, showSizeChanger: true },
|
||
scroll: { y: 600 },
|
||
});
|
||
</script>
|
||
```
|
||
|
||
---
|
||
|
||
## 五、条形码(barCode)
|
||
|
||
### 5.1 前端实现
|
||
|
||
```vue
|
||
<script lang="ts" setup>
|
||
import { barcode } from '@jnpf/utils';
|
||
|
||
const generateBarcode = () => {
|
||
barcode(document.getElementById('barcode'), '123456789', {
|
||
displayValue: true,
|
||
fontSize: 14,
|
||
height: 60
|
||
});
|
||
};
|
||
</script>
|
||
|
||
<template>
|
||
<div id="barcode"></div>
|
||
</template>
|
||
```
|
||
|
||
### 5.2 后端 Controller
|
||
|
||
```java
|
||
@GetMapping("/{content}")
|
||
public ActionResult<String> generate(@PathVariable("content") String content) {
|
||
// 返回条形码图片
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 六、文档预览(documentPreview)
|
||
|
||
### 6.1 支持格式
|
||
|
||
- PDF
|
||
- Office 文档(Word、Excel、PPT)
|
||
- 图片
|
||
- 文本文件
|
||
|
||
### 6.2 实现方式
|
||
|
||
```vue
|
||
<script lang="ts" setup>
|
||
import { previewFile } from '@jnpf/utils';
|
||
|
||
function handlePreview(file) {
|
||
previewFile(file.url, file.name);
|
||
}
|
||
</script>
|
||
```
|
||
|
||
---
|
||
|
||
## 七、源码位置
|
||
|
||
| 功能 | 前端路径 | 后端 Controller |
|
||
|------|----------|-----------------|
|
||
| 销售订单 | `saleOrder/` | `SalesOrderController` |
|
||
| 项目甘特图 | `projectGantt/` | `ProjectGanttController` |
|
||
| 邮件 | `email/` | `EmailController` |
|
||
| 大数据 | `bigData/` | `BigDataController` |
|
||
| 条形码 | `barCode/` | `BarCodeController` |
|
||
| 文档预览 | `documentPreview/` | `DocumentPreviewController` |
|
||
|
||
---
|
||
|
||
## 八、主子表开发模板
|
||
|
||
### 8.1 前端主子表
|
||
|
||
```vue
|
||
<template>
|
||
<div>
|
||
<!-- 主表 -->
|
||
<BasicVxeTable
|
||
@register="registerMainTable"
|
||
@row-click="handleRowClick"
|
||
/>
|
||
|
||
<!-- 子表 -->
|
||
<BasicVxeTable
|
||
@register="registerSubTable"
|
||
:data-source="subList"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
const [registerMainTable, { reload }] = useVxeTable({
|
||
api: getMainList,
|
||
columns: mainColumns,
|
||
});
|
||
|
||
const [registerSubTable] = useVxeTable({
|
||
columns: subColumns,
|
||
useSearchForm: false,
|
||
pagination: false,
|
||
});
|
||
|
||
function handleRowClick({ record }) {
|
||
getSubList(record.id).then(res => {
|
||
subList.value = res.data;
|
||
});
|
||
}
|
||
</script>
|
||
```
|
||
|
||
### 8.2 后端主子表
|
||
|
||
```java
|
||
// 主表查询
|
||
@GetMapping
|
||
public ActionResult list(Pagination pagination) {
|
||
List<MainEntity> list = mainService.getList(pagination);
|
||
return ActionResult.page(list, pagination);
|
||
}
|
||
|
||
// 子表查询
|
||
@GetMapping("/{id}/Entries")
|
||
public ActionResult<ListVO<SubEntity>> getEntries(@PathVariable("id") String id) {
|
||
List<SubEntity> list = subService.getListByMainId(id);
|
||
return ActionResult.success(list);
|
||
}
|
||
```
|