Compare commits
2 Commits
350d3bec2d
...
0c4063047e
| Author | SHA1 | Date |
|---|---|---|
|
|
0c4063047e | |
|
|
7c316bbead |
|
|
@ -0,0 +1,380 @@
|
||||||
|
# 院校模块(School)后台接口文档
|
||||||
|
|
||||||
|
> 适用范围:后台管理(CRUD / 导入导出 / 聚合详情)。
|
||||||
|
>
|
||||||
|
> 代码位置:`jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/school/controller/*`
|
||||||
|
|
||||||
|
## 1. 基础约定(JEECG-Boot)
|
||||||
|
|
||||||
|
### 1.1 基础地址
|
||||||
|
|
||||||
|
- 默认 `server.servlet.context-path` 为 `/jeecg-boot`
|
||||||
|
- 文档中接口地址以:`/jeecg-boot` + Controller 的 `@RequestMapping` 为准
|
||||||
|
|
||||||
|
示例:
|
||||||
|
|
||||||
|
- `GET /jeecg-boot/school/school/list`
|
||||||
|
|
||||||
|
### 1.2 认证
|
||||||
|
|
||||||
|
- 需要登录后调用(通常前端会在请求头携带 token)
|
||||||
|
- 权限控制使用 `@RequiresPermissions`(文档中会标注权限码)
|
||||||
|
|
||||||
|
### 1.3 统一返回结构
|
||||||
|
|
||||||
|
接口统一返回:`org.jeecg.common.api.vo.Result<T>`。
|
||||||
|
|
||||||
|
成功示例:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "",
|
||||||
|
"code": 200,
|
||||||
|
"result": {},
|
||||||
|
"timestamp": 1700000000000
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
失败示例:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"message": "未找到对应数据",
|
||||||
|
"code": 500,
|
||||||
|
"result": null,
|
||||||
|
"timestamp": 1700000000000
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.4 分页返回结构(MyBatis-Plus IPage)
|
||||||
|
|
||||||
|
分页接口 `result` 为 `IPage<T>`,常见字段示例:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"code": 200,
|
||||||
|
"result": {
|
||||||
|
"records": [],
|
||||||
|
"total": 0,
|
||||||
|
"size": 10,
|
||||||
|
"current": 1,
|
||||||
|
"pages": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.5 导入 / 导出
|
||||||
|
|
||||||
|
- 导出:`GET /exportXls`,返回 Excel 文件流
|
||||||
|
- 导入:`POST /importExcel`,`multipart/form-data`,上传字段名通常为 `file`
|
||||||
|
|
||||||
|
## 2. 数据表与字段说明(摘要)
|
||||||
|
|
||||||
|
> 下面仅列出接口当前代码中实体字段;若你按 `Task2_solution.md` 扩展了更多列,可继续在实体中补字段以支持后台维护。
|
||||||
|
|
||||||
|
### 2.1 学校主表(t_school)
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| mainCode | String | 学校编码(唯一) |
|
||||||
|
| mainName | String | 学校主名称(官方全称) |
|
||||||
|
| shortName | String | 学校简称 |
|
||||||
|
| schoolIcon | String | 院校图标(URL) |
|
||||||
|
| createBy/createTime | String/Date | 创建人/创建时间 |
|
||||||
|
| updateBy/updateTime | String/Date | 更新人/更新时间 |
|
||||||
|
|
||||||
|
### 2.2 学校详情(t_school_detail)
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| schoolId | Long | 学校ID |
|
||||||
|
| introduction | String | 学校简介(大文本) |
|
||||||
|
| address | String | 地址 |
|
||||||
|
| contact | String | 联系电话 |
|
||||||
|
| website | String | 官网 |
|
||||||
|
| updateTime | Date | 更新时间 |
|
||||||
|
|
||||||
|
### 2.3 学校名称(t_school_name)
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| schoolId | Long | 学校ID |
|
||||||
|
| name | String | 名称(别名/曾用名/英文名) |
|
||||||
|
| nameType | Integer | 名称类型:1官方全称/2曾用名/3别名/4英文名称 |
|
||||||
|
|
||||||
|
### 2.4 学校标签(t_school_tag)
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| schoolId | Long | 学校ID |
|
||||||
|
| tagName | String | 标签名(985/211/双一流/…) |
|
||||||
|
|
||||||
|
### 2.5 学院 / 专业(Task2 扩展表)
|
||||||
|
|
||||||
|
- 学院:`t_school_college`
|
||||||
|
- 专业:`t_school_major`
|
||||||
|
- 专业标签:`t_school_major_tag`
|
||||||
|
|
||||||
|
### 2.6 校区 / 宿舍 / 媒体 / 招生计划(Task2 扩展表)
|
||||||
|
|
||||||
|
- 校区:`t_school_campus`
|
||||||
|
- 宿舍:`t_school_dorm`
|
||||||
|
- 媒体:`t_school_media`(biz_type + biz_id)
|
||||||
|
- 招生计划:`t_school_enroll_plan`
|
||||||
|
|
||||||
|
## 3. 接口清单
|
||||||
|
|
||||||
|
> 说明:所有 `/list` 接口均支持 `pageNo` / `pageSize` 分页。
|
||||||
|
>
|
||||||
|
> 对于使用 `QueryGenerator` 的 `/list`:可通过 query 参数传实体字段实现筛选(例如 `schoolId=1`、`majorName=计算机`)。
|
||||||
|
|
||||||
|
### 3.1 学校主表(SchoolController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/school`
|
||||||
|
|
||||||
|
#### 3.1.1 分页列表(通用查询)
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/list`
|
||||||
|
- 权限:无(如需权限可自行加 `@RequiresPermissions`)
|
||||||
|
- Query:
|
||||||
|
- `pageNo`:默认 1
|
||||||
|
- `pageSize`:默认 10
|
||||||
|
- 其他:`t_school` 对应字段(例如 `mainName`、`mainCode` 等)
|
||||||
|
|
||||||
|
#### 3.1.2 关键词搜索(编码/名称/简称/别名)
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/search`
|
||||||
|
- 权限:无
|
||||||
|
- Query:
|
||||||
|
- `keyword`:可空
|
||||||
|
- `pageNo`、`pageSize`
|
||||||
|
|
||||||
|
#### 3.1.3 新增
|
||||||
|
|
||||||
|
- Method: `POST`
|
||||||
|
- Path: `/add`
|
||||||
|
- 权限:`school:school:add`
|
||||||
|
- Body(JSON):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mainCode": "10001",
|
||||||
|
"mainName": "示例大学",
|
||||||
|
"shortName": "示大",
|
||||||
|
"schoolIcon": "https://example.com/icon.png"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3.1.4 修改
|
||||||
|
|
||||||
|
- Method: `PUT` or `POST`
|
||||||
|
- Path: `/edit`
|
||||||
|
- 权限:`school:school:edit`
|
||||||
|
- Body(JSON):必须包含 `id`
|
||||||
|
|
||||||
|
#### 3.1.5 删除
|
||||||
|
|
||||||
|
- Method: `DELETE`
|
||||||
|
- Path: `/delete`
|
||||||
|
- 权限:`school:school:delete`
|
||||||
|
- Query:`id`
|
||||||
|
|
||||||
|
#### 3.1.6 批量删除
|
||||||
|
|
||||||
|
- Method: `DELETE`
|
||||||
|
- Path: `/deleteBatch`
|
||||||
|
- 权限:`school:school:deleteBatch`
|
||||||
|
- Query:`ids`(逗号分隔 Long,例如:`1,2,3`)
|
||||||
|
|
||||||
|
#### 3.1.7 按ID查询
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/queryById`
|
||||||
|
- Query:`id`
|
||||||
|
|
||||||
|
#### 3.1.8 全量聚合详情(按ID)
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/fullById`
|
||||||
|
- Query:`id`
|
||||||
|
- 返回:`SchoolFullVO`(主表 + detail + names + tags + colleges/majors/...)
|
||||||
|
|
||||||
|
#### 3.1.9 全量聚合详情(按mainCode)
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/fullByMainCode`
|
||||||
|
- Query:`mainCode`
|
||||||
|
|
||||||
|
#### 3.1.10 导出
|
||||||
|
|
||||||
|
- Method: `GET`
|
||||||
|
- Path: `/exportXls`
|
||||||
|
- 权限:`school:school:exportXls`
|
||||||
|
- Query:可带筛选条件(同 `/list`)
|
||||||
|
|
||||||
|
#### 3.1.11 导入
|
||||||
|
|
||||||
|
- Method: `POST`
|
||||||
|
- Path: `/importExcel`
|
||||||
|
- 权限:`school:school:importExcel`
|
||||||
|
- Form-Data:`file=@xxx.xlsx`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.2 学校详情(SchoolDetailController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/detail`
|
||||||
|
|
||||||
|
- `GET /list`(QueryGenerator)
|
||||||
|
- `POST /add`(权限:`school:detail:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:detail:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:detail:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:detail:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:detail:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:detail:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.3 学校名称(SchoolNameController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/name`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:name:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:name:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:name:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:name:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:name:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:name:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.4 学校标签(SchoolTagController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/tag`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:tag:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:tag:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:tag:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:tag:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:tag:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:tag:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.5 学院(SchoolCollegeController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/college`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:college:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:college:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:college:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:college:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:college:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:college:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.6 专业(SchoolMajorController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/major`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:major:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:major:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:major:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:major:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:major:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:major:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.7 专业标签(SchoolMajorTagController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/majorTag`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:majorTag:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:majorTag:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:majorTag:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:majorTag:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:majorTag:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:majorTag:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.8 校区(SchoolCampusController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/campus`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:campus:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:campus:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:campus:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:campus:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:campus:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:campus:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.9 宿舍(SchoolDormController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/dorm`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:dorm:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:dorm:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:dorm:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:dorm:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:dorm:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:dorm:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.10 媒体(SchoolMediaController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/media`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:media:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:media:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:media:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:media:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:media:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:media:importExcel`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3.11 招生计划(SchoolEnrollPlanController)
|
||||||
|
|
||||||
|
Base:`/jeecg-boot/school/enrollPlan`
|
||||||
|
|
||||||
|
- `GET /list`
|
||||||
|
- `POST /add`(权限:`school:enrollPlan:add`)
|
||||||
|
- `PUT|POST /edit`(权限:`school:enrollPlan:edit`)
|
||||||
|
- `DELETE /delete`(权限:`school:enrollPlan:delete`)
|
||||||
|
- `DELETE /deleteBatch`(权限:`school:enrollPlan:deleteBatch`)
|
||||||
|
- `GET /queryById`
|
||||||
|
- `GET /exportXls`(权限:`school:enrollPlan:exportXls`)
|
||||||
|
- `POST /importExcel`(权限:`school:enrollPlan:importExcel`)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/campus/list',
|
||||||
|
save = '/school/campus/add',
|
||||||
|
edit = '/school/campus/edit',
|
||||||
|
deleteOne = '/school/campus/delete',
|
||||||
|
deleteBatch = '/school/campus/deleteBatch',
|
||||||
|
queryById = '/school/campus/queryById',
|
||||||
|
importExcel = '/school/campus/importExcel',
|
||||||
|
exportXls = '/school/campus/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '校区名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'campusName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'address',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '校区名称',
|
||||||
|
field: 'campusName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '校区名称',
|
||||||
|
field: 'campusName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '地址',
|
||||||
|
field: 'address',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolCampusModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-campus" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolCampus.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolCampus.api';
|
||||||
|
import SchoolCampusModal from './components/SchoolCampusModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校校区',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校校区',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolCampus.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolCampus.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolCampusForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/campus/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolCampus.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolCampus.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/college/list',
|
||||||
|
save = '/school/college/add',
|
||||||
|
edit = '/school/college/edit',
|
||||||
|
deleteOne = '/school/college/delete',
|
||||||
|
deleteBatch = '/school/college/deleteBatch',
|
||||||
|
queryById = '/school/college/queryById',
|
||||||
|
importExcel = '/school/college/importExcel',
|
||||||
|
exportXls = '/school/college/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学院名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'collegeName',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学院名称',
|
||||||
|
field: 'collegeName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学院名称',
|
||||||
|
field: 'collegeName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolCollegeModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-college" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolCollege.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolCollege.api';
|
||||||
|
import SchoolCollegeModal from './components/SchoolCollegeModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校学院',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校学院',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolCollege.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolCollege.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolCollegeForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/college/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolCollege.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolCollege.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/detail/list',
|
||||||
|
save = '/school/detail/add',
|
||||||
|
edit = '/school/detail/edit',
|
||||||
|
deleteOne = '/school/detail/delete',
|
||||||
|
deleteBatch = '/school/detail/deleteBatch',
|
||||||
|
queryById = '/school/detail/queryById',
|
||||||
|
importExcel = '/school/detail/importExcel',
|
||||||
|
exportXls = '/school/detail/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '简介',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'introduction',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'address',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '联系电话',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'contact',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '官网',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'website',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '简介',
|
||||||
|
field: 'introduction',
|
||||||
|
component: 'InputTextArea',
|
||||||
|
componentProps: {
|
||||||
|
rows: 6,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '地址',
|
||||||
|
field: 'address',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '联系电话',
|
||||||
|
field: 'contact',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '官网',
|
||||||
|
field: 'website',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolDetailModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-detail" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolDetail.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolDetail.api';
|
||||||
|
import SchoolDetailModal from './components/SchoolDetailModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校详情',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校详情',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolDetail.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolDetail.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolDetailForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/detail/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="900"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolDetail.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolDetail.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (data?.record) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/dorm/list',
|
||||||
|
save = '/school/dorm/add',
|
||||||
|
edit = '/school/dorm/edit',
|
||||||
|
deleteOne = '/school/dorm/delete',
|
||||||
|
deleteBatch = '/school/dorm/deleteBatch',
|
||||||
|
queryById = '/school/dorm/queryById',
|
||||||
|
importExcel = '/school/dorm/importExcel',
|
||||||
|
exportXls = '/school/dorm/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '宿舍名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'dormName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '校区ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'campusId',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '宿舍名称',
|
||||||
|
field: 'dormName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '宿舍名称',
|
||||||
|
field: 'dormName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '校区ID',
|
||||||
|
field: 'campusId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolDormModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-dorm" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolDorm.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolDorm.api';
|
||||||
|
import SchoolDormModal from './components/SchoolDormModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校宿舍',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId', 'campusId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校宿舍',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolDorm.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolDorm.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolDormForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/dorm/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolDorm.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolDorm.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/enrollPlan/list',
|
||||||
|
save = '/school/enrollPlan/add',
|
||||||
|
edit = '/school/enrollPlan/edit',
|
||||||
|
deleteOne = '/school/enrollPlan/delete',
|
||||||
|
deleteBatch = '/school/enrollPlan/deleteBatch',
|
||||||
|
queryById = '/school/enrollPlan/queryById',
|
||||||
|
importExcel = '/school/enrollPlan/importExcel',
|
||||||
|
exportXls = '/school/enrollPlan/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '年份',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'year',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '省份',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'province',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '计划内容',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'planContent',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '年份',
|
||||||
|
field: 'year',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '省份',
|
||||||
|
field: 'province',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '年份',
|
||||||
|
field: 'year',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '省份',
|
||||||
|
field: 'province',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '计划内容',
|
||||||
|
field: 'planContent',
|
||||||
|
component: 'InputTextArea',
|
||||||
|
componentProps: {
|
||||||
|
rows: 6,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolEnrollPlanModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-enroll-plan" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolEnrollPlan.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolEnrollPlan.api';
|
||||||
|
import SchoolEnrollPlanModal from './components/SchoolEnrollPlanModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '招生计划',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId', 'year'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '招生计划',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolEnrollPlan.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolEnrollPlan.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolEnrollPlanForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/enrollPlan/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="900"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolEnrollPlan.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolEnrollPlan.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/major/list',
|
||||||
|
save = '/school/major/add',
|
||||||
|
edit = '/school/major/edit',
|
||||||
|
deleteOne = '/school/major/delete',
|
||||||
|
deleteBatch = '/school/major/deleteBatch',
|
||||||
|
queryById = '/school/major/queryById',
|
||||||
|
importExcel = '/school/major/importExcel',
|
||||||
|
exportXls = '/school/major/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '专业编码',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'majorCode',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '专业名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'majorName',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '专业名称',
|
||||||
|
field: 'majorName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '专业编码',
|
||||||
|
field: 'majorCode',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '专业名称',
|
||||||
|
field: 'majorName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolMajorModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-major" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolMajor.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolMajor.api';
|
||||||
|
import SchoolMajorModal from './components/SchoolMajorModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校专业',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校专业',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolMajor.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMajor.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolMajorForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/major/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolMajor.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMajor.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/majorTag/list',
|
||||||
|
save = '/school/majorTag/add',
|
||||||
|
edit = '/school/majorTag/edit',
|
||||||
|
deleteOne = '/school/majorTag/delete',
|
||||||
|
deleteBatch = '/school/majorTag/deleteBatch',
|
||||||
|
queryById = '/school/majorTag/queryById',
|
||||||
|
importExcel = '/school/majorTag/importExcel',
|
||||||
|
exportXls = '/school/majorTag/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '专业ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'majorId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '标签',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'tagName',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '专业ID',
|
||||||
|
field: 'majorId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '标签',
|
||||||
|
field: 'tagName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '专业ID',
|
||||||
|
field: 'majorId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '标签',
|
||||||
|
field: 'tagName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolMajorTagModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-major-tag" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolMajorTag.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolMajorTag.api';
|
||||||
|
import SchoolMajorTagModal from './components/SchoolMajorTagModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '专业标签',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['majorId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '专业标签',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolMajorTag.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMajorTag.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolMajorTagForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/majorTag/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolMajorTag.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMajorTag.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/media/list',
|
||||||
|
save = '/school/media/add',
|
||||||
|
edit = '/school/media/edit',
|
||||||
|
deleteOne = '/school/media/delete',
|
||||||
|
deleteBatch = '/school/media/deleteBatch',
|
||||||
|
queryById = '/school/media/queryById',
|
||||||
|
importExcel = '/school/media/importExcel',
|
||||||
|
exportXls = '/school/media/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
import { render } from '/@/utils/common/renderUtils';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '业务类型',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'bizType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '业务ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'bizId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '媒体类型',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'mediaType',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '媒体地址',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'mediaUrl',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '预览',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'mediaUrl',
|
||||||
|
customRender: render.renderImage,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '业务类型',
|
||||||
|
field: 'bizType',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '业务ID',
|
||||||
|
field: 'bizId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '业务类型',
|
||||||
|
field: 'bizType',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
helpMessage: '例如:school/campus/dorm/major 等,由后端约定',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '业务ID',
|
||||||
|
field: 'bizId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '媒体类型',
|
||||||
|
field: 'mediaType',
|
||||||
|
component: 'Input',
|
||||||
|
helpMessage: '例如:image/video/cover 等,由后端约定',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '媒体地址',
|
||||||
|
field: 'mediaUrl',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolMediaModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-media" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolMedia.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolMedia.api';
|
||||||
|
import SchoolMediaModal from './components/SchoolMediaModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校媒体',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['bizId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校媒体',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolMedia.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMedia.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolMediaForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/media/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="900"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolMedia.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolMedia.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/name/list',
|
||||||
|
save = '/school/name/add',
|
||||||
|
edit = '/school/name/edit',
|
||||||
|
deleteOne = '/school/name/delete',
|
||||||
|
deleteBatch = '/school/name/deleteBatch',
|
||||||
|
queryById = '/school/name/queryById',
|
||||||
|
importExcel = '/school/name/importExcel',
|
||||||
|
exportXls = '/school/name/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
const nameTypeOptions = [
|
||||||
|
{ label: '官方全称', value: 1 },
|
||||||
|
{ label: '曾用名', value: 2 },
|
||||||
|
{ label: '别名', value: 3 },
|
||||||
|
{ label: '英文名称', value: 4 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '名称类型',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'nameType',
|
||||||
|
customRender: ({ text }) => {
|
||||||
|
const found = nameTypeOptions.find((o) => o.value === text || o.value === Number(text));
|
||||||
|
return found?.label || text;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '名称',
|
||||||
|
field: 'name',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '名称类型',
|
||||||
|
field: 'nameType',
|
||||||
|
component: 'Select',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
componentProps: {
|
||||||
|
options: nameTypeOptions,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '名称',
|
||||||
|
field: 'name',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '名称类型',
|
||||||
|
field: 'nameType',
|
||||||
|
component: 'Select',
|
||||||
|
required: true,
|
||||||
|
componentProps: {
|
||||||
|
options: nameTypeOptions,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolNameModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-name" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolName.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolName.api';
|
||||||
|
import SchoolNameModal from './components/SchoolNameModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校名称',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId', 'nameType'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校名称',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolName.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolName.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolNameForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/name/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolName.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolName.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/school/list',
|
||||||
|
search = '/school/school/search',
|
||||||
|
save = '/school/school/add',
|
||||||
|
edit = '/school/school/edit',
|
||||||
|
deleteOne = '/school/school/delete',
|
||||||
|
deleteBatch = '/school/school/deleteBatch',
|
||||||
|
queryById = '/school/school/queryById',
|
||||||
|
fullById = '/school/school/fullById',
|
||||||
|
fullByMainCode = '/school/school/fullByMainCode',
|
||||||
|
importExcel = '/school/school/importExcel',
|
||||||
|
exportXls = '/school/school/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const search = (params) => defHttp.get({ url: Api.search, params });
|
||||||
|
|
||||||
|
export const listOrSearch = (params) => {
|
||||||
|
if (params?.keyword) {
|
||||||
|
return search(params);
|
||||||
|
}
|
||||||
|
// 避免将 keyword 透传给 /list
|
||||||
|
const { keyword: _keyword, ...rest } = params || {};
|
||||||
|
return list(rest);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const fullById = (params) => defHttp.get({ url: Api.fullById, params });
|
||||||
|
|
||||||
|
export const fullByMainCode = (params) => defHttp.get({ url: Api.fullByMainCode, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
import { render } from '/@/utils/common/renderUtils';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校编码',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'mainCode',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学校名称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'mainName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学校简称',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'shortName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学校图标',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolIcon',
|
||||||
|
customRender: render.renderImage,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '关键字',
|
||||||
|
field: 'keyword',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
helpMessage: '走 /school/school/search:支持 编码/名称/简称/别名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校编码',
|
||||||
|
field: 'mainCode',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校名称',
|
||||||
|
field: 'mainName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校简称',
|
||||||
|
field: 'shortName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校编码',
|
||||||
|
field: 'mainCode',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校名称',
|
||||||
|
field: 'mainName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校简称',
|
||||||
|
field: 'shortName',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校图标',
|
||||||
|
field: 'schoolIcon',
|
||||||
|
component: 'Input',
|
||||||
|
helpMessage: '填写图片URL(或后端文件路径)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,353 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
<SchoolFullDrawer @register="registerDrawer" />
|
||||||
|
<SchoolSubManagerDrawer @register="registerSubDrawer" v-bind="$attrs" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-school" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useDrawer } from '/@/components/Drawer';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './School.data';
|
||||||
|
import { listOrSearch, deleteOne, batchDelete, getImportUrl, getExportUrl } from './School.api';
|
||||||
|
import SchoolModal from './components/SchoolModal.vue';
|
||||||
|
import SchoolFullDrawer from './components/SchoolFullDrawer.vue';
|
||||||
|
import SchoolSubManagerDrawer from './components/SchoolSubManagerDrawer.vue';
|
||||||
|
|
||||||
|
import { columns as detailColumns, searchFormSchema as detailSearchSchemas } from '../detail/SchoolDetail.data';
|
||||||
|
import { list as detailList, deleteOne as detailDeleteOne, batchDelete as detailBatchDelete } from '../detail/SchoolDetail.api';
|
||||||
|
import SchoolDetailModal from '../detail/components/SchoolDetailModal.vue';
|
||||||
|
|
||||||
|
import { columns as nameColumns, searchFormSchema as nameSearchSchemas } from '../name/SchoolName.data';
|
||||||
|
import { list as nameList, deleteOne as nameDeleteOne, batchDelete as nameBatchDelete } from '../name/SchoolName.api';
|
||||||
|
import SchoolNameModal from '../name/components/SchoolNameModal.vue';
|
||||||
|
|
||||||
|
import { columns as tagColumns, searchFormSchema as tagSearchSchemas } from '../tag/SchoolTag.data';
|
||||||
|
import { list as tagList, deleteOne as tagDeleteOne, batchDelete as tagBatchDelete } from '../tag/SchoolTag.api';
|
||||||
|
import SchoolTagModal from '../tag/components/SchoolTagModal.vue';
|
||||||
|
|
||||||
|
import { columns as collegeColumns, searchFormSchema as collegeSearchSchemas } from '../college/SchoolCollege.data';
|
||||||
|
import { list as collegeList, deleteOne as collegeDeleteOne, batchDelete as collegeBatchDelete } from '../college/SchoolCollege.api';
|
||||||
|
import SchoolCollegeModal from '../college/components/SchoolCollegeModal.vue';
|
||||||
|
|
||||||
|
import { columns as majorColumns, searchFormSchema as majorSearchSchemas } from '../major/SchoolMajor.data';
|
||||||
|
import { list as majorList, deleteOne as majorDeleteOne, batchDelete as majorBatchDelete } from '../major/SchoolMajor.api';
|
||||||
|
import SchoolMajorModal from '../major/components/SchoolMajorModal.vue';
|
||||||
|
|
||||||
|
import { columns as majorTagColumns, searchFormSchema as majorTagSearchSchemas } from '../majorTag/SchoolMajorTag.data';
|
||||||
|
import { list as majorTagList, deleteOne as majorTagDeleteOne, batchDelete as majorTagBatchDelete } from '../majorTag/SchoolMajorTag.api';
|
||||||
|
import SchoolMajorTagModal from '../majorTag/components/SchoolMajorTagModal.vue';
|
||||||
|
|
||||||
|
import { columns as campusColumns, searchFormSchema as campusSearchSchemas } from '../campus/SchoolCampus.data';
|
||||||
|
import { list as campusList, deleteOne as campusDeleteOne, batchDelete as campusBatchDelete } from '../campus/SchoolCampus.api';
|
||||||
|
import SchoolCampusModal from '../campus/components/SchoolCampusModal.vue';
|
||||||
|
|
||||||
|
import { columns as dormColumns, searchFormSchema as dormSearchSchemas } from '../dorm/SchoolDorm.data';
|
||||||
|
import { list as dormList, deleteOne as dormDeleteOne, batchDelete as dormBatchDelete } from '../dorm/SchoolDorm.api';
|
||||||
|
import SchoolDormModal from '../dorm/components/SchoolDormModal.vue';
|
||||||
|
|
||||||
|
import { columns as mediaColumns, searchFormSchema as mediaSearchSchemas } from '../media/SchoolMedia.data';
|
||||||
|
import { list as mediaList, deleteOne as mediaDeleteOne, batchDelete as mediaBatchDelete } from '../media/SchoolMedia.api';
|
||||||
|
import SchoolMediaModal from '../media/components/SchoolMediaModal.vue';
|
||||||
|
|
||||||
|
import { columns as enrollColumns, searchFormSchema as enrollSearchSchemas } from '../enrollPlan/SchoolEnrollPlan.data';
|
||||||
|
import { list as enrollList, deleteOne as enrollDeleteOne, batchDelete as enrollBatchDelete } from '../enrollPlan/SchoolEnrollPlan.api';
|
||||||
|
import SchoolEnrollPlanModal from '../enrollPlan/components/SchoolEnrollPlanModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||||
|
|
||||||
|
const [registerSubDrawer, { openDrawer: openSubDrawer }] = useDrawer();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校主表',
|
||||||
|
api: listOrSearch,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: [],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校主表',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFullDetail(record: Recordable) {
|
||||||
|
openDrawer(true, { record });
|
||||||
|
}
|
||||||
|
|
||||||
|
function openSubManager(title: string, config: Recordable, record: Recordable) {
|
||||||
|
openSubDrawer(true, Object.assign({ title, record }, config));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '全量详情',
|
||||||
|
onClick: handleFullDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校详情管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'学校详情管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: detailColumns,
|
||||||
|
searchSchemas: detailSearchSchemas,
|
||||||
|
listApi: detailList,
|
||||||
|
deleteOne: detailDeleteOne,
|
||||||
|
batchDelete: detailBatchDelete,
|
||||||
|
modalComponent: SchoolDetailModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校名称管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'学校名称管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: nameColumns,
|
||||||
|
searchSchemas: nameSearchSchemas,
|
||||||
|
listApi: nameList,
|
||||||
|
deleteOne: nameDeleteOne,
|
||||||
|
batchDelete: nameBatchDelete,
|
||||||
|
modalComponent: SchoolNameModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学校标签管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'学校标签管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: tagColumns,
|
||||||
|
searchSchemas: tagSearchSchemas,
|
||||||
|
listApi: tagList,
|
||||||
|
deleteOne: tagDeleteOne,
|
||||||
|
batchDelete: tagBatchDelete,
|
||||||
|
modalComponent: SchoolTagModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学院管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'学院管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: collegeColumns,
|
||||||
|
searchSchemas: collegeSearchSchemas,
|
||||||
|
listApi: collegeList,
|
||||||
|
deleteOne: collegeDeleteOne,
|
||||||
|
batchDelete: collegeBatchDelete,
|
||||||
|
modalComponent: SchoolCollegeModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '专业管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'专业管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: majorColumns,
|
||||||
|
searchSchemas: majorSearchSchemas,
|
||||||
|
listApi: majorList,
|
||||||
|
deleteOne: majorDeleteOne,
|
||||||
|
batchDelete: majorBatchDelete,
|
||||||
|
modalComponent: SchoolMajorModal,
|
||||||
|
getExtraDropDownActions: (r) => [
|
||||||
|
{
|
||||||
|
label: '专业标签管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubDrawer(true, {
|
||||||
|
title: '专业标签管理',
|
||||||
|
majorId: r.id,
|
||||||
|
ownerName: r.majorName || r.majorCode || String(r.id),
|
||||||
|
fixedMode: 'majorId',
|
||||||
|
columns: majorTagColumns,
|
||||||
|
searchSchemas: majorTagSearchSchemas,
|
||||||
|
listApi: majorTagList,
|
||||||
|
deleteOne: majorTagDeleteOne,
|
||||||
|
batchDelete: majorTagBatchDelete,
|
||||||
|
modalComponent: SchoolMajorTagModal,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '校区管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'校区管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: campusColumns,
|
||||||
|
searchSchemas: campusSearchSchemas,
|
||||||
|
listApi: campusList,
|
||||||
|
deleteOne: campusDeleteOne,
|
||||||
|
batchDelete: campusBatchDelete,
|
||||||
|
modalComponent: SchoolCampusModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '宿舍管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'宿舍管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: dormColumns,
|
||||||
|
searchSchemas: dormSearchSchemas,
|
||||||
|
listApi: dormList,
|
||||||
|
deleteOne: dormDeleteOne,
|
||||||
|
batchDelete: dormBatchDelete,
|
||||||
|
modalComponent: SchoolDormModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '媒体管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'媒体管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'bizSchool',
|
||||||
|
bizType: 'school',
|
||||||
|
columns: mediaColumns,
|
||||||
|
searchSchemas: mediaSearchSchemas,
|
||||||
|
listApi: mediaList,
|
||||||
|
deleteOne: mediaDeleteOne,
|
||||||
|
batchDelete: mediaBatchDelete,
|
||||||
|
modalComponent: SchoolMediaModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '招生计划管理',
|
||||||
|
onClick: () =>
|
||||||
|
openSubManager(
|
||||||
|
'招生计划管理',
|
||||||
|
{
|
||||||
|
fixedMode: 'schoolId',
|
||||||
|
columns: enrollColumns,
|
||||||
|
searchSchemas: enrollSearchSchemas,
|
||||||
|
listApi: enrollList,
|
||||||
|
deleteOne: enrollDeleteOne,
|
||||||
|
batchDelete: enrollBatchDelete,
|
||||||
|
modalComponent: SchoolEnrollPlanModal,
|
||||||
|
},
|
||||||
|
record
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../School.data';
|
||||||
|
import { saveOrUpdate } from '../School.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/school/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<template>
|
||||||
|
<BasicDrawer @register="registerDrawer" title="全量详情" :width="900" destroyOnClose>
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-alert
|
||||||
|
type="info"
|
||||||
|
show-icon
|
||||||
|
message="该数据来自接口 /school/school/fullById,展示为原始 JSON。"
|
||||||
|
style="margin-bottom: 12px"
|
||||||
|
/>
|
||||||
|
<pre style="white-space: pre-wrap; word-break: break-word">{{ prettyJson }}</pre>
|
||||||
|
</a-spin>
|
||||||
|
</BasicDrawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||||
|
import { fullById } from '../School.api';
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const data = ref<any>(null);
|
||||||
|
|
||||||
|
const [registerDrawer] = useDrawerInner(async (ctx) => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const id = ctx?.record?.id;
|
||||||
|
data.value = id ? await fullById({ id }) : null;
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const prettyJson = computed(() => {
|
||||||
|
try {
|
||||||
|
return JSON.stringify(data.value ?? {}, null, 2);
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../School.data';
|
||||||
|
import { saveOrUpdate } from '../School.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,246 @@
|
||||||
|
<template>
|
||||||
|
<BasicDrawer @register="registerDrawer" :title="drawerTitle" :width="1000" destroyOnClose>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<component :is="modalComponent" @register="registerModal" @success="handleSuccess" />
|
||||||
|
</BasicDrawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, reactive, ref, unref } from 'vue';
|
||||||
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import type { BasicColumn, BasicTableProps, FormSchema } from '/@/components/Table';
|
||||||
|
import { useTable } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
|
||||||
|
type FixedMode = 'schoolId' | 'bizSchool' | 'majorId';
|
||||||
|
|
||||||
|
type DrawerOpenConfig = {
|
||||||
|
title: string;
|
||||||
|
record?: Recordable;
|
||||||
|
fixedMode?: FixedMode;
|
||||||
|
bizType?: string;
|
||||||
|
columns: BasicColumn[];
|
||||||
|
searchSchemas?: FormSchema[];
|
||||||
|
listApi: (params: any) => Promise<any>;
|
||||||
|
deleteOne: (params: any, handleSuccess: Fn) => Promise<any>;
|
||||||
|
batchDelete: (params: any, handleSuccess: Fn) => Promise<any>;
|
||||||
|
modalComponent: any;
|
||||||
|
getExtraDropDownActions?: (record: any) => any[];
|
||||||
|
majorId?: number | string;
|
||||||
|
ownerName?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const ownerName = ref('');
|
||||||
|
const fixedParams = ref<Recordable>({});
|
||||||
|
|
||||||
|
const title = ref('');
|
||||||
|
const fixedMode = ref<FixedMode>('schoolId');
|
||||||
|
const bizType = ref('school');
|
||||||
|
const columns = ref<BasicColumn[]>([]);
|
||||||
|
const searchSchemas = ref<FormSchema[]>([]);
|
||||||
|
const listApi = ref<(params: any) => Promise<any>>();
|
||||||
|
const deleteOne = ref<(params: any, handleSuccess: Fn) => Promise<any>>();
|
||||||
|
const batchDelete = ref<(params: any, handleSuccess: Fn) => Promise<any>>();
|
||||||
|
const modalComponent = ref<any>();
|
||||||
|
const getExtraDropDownActions = ref<((record: any) => any[]) | undefined>();
|
||||||
|
|
||||||
|
function getDisableFieldsByMode() {
|
||||||
|
if (unref(fixedMode) === 'schoolId') {
|
||||||
|
return ['schoolId'];
|
||||||
|
}
|
||||||
|
if (unref(fixedMode) === 'bizSchool') {
|
||||||
|
return ['bizType', 'bizId'];
|
||||||
|
}
|
||||||
|
if (unref(fixedMode) === 'majorId') {
|
||||||
|
return ['majorId'];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const fixedDisabledFields = reactive<string[]>(getDisableFieldsByMode());
|
||||||
|
const filteredSearchSchemas = computed(() => {
|
||||||
|
return (unref(searchSchemas) || []).filter((s) => !fixedDisabledFields.includes(String(s.field)));
|
||||||
|
});
|
||||||
|
|
||||||
|
const drawerTitle = computed(() => {
|
||||||
|
const name = unref(ownerName);
|
||||||
|
const t = unref(title);
|
||||||
|
return name ? `${t}(${name})` : t;
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectedRowKeys = ref<any[]>([]);
|
||||||
|
const selectedRows = ref<Recordable[]>([]);
|
||||||
|
|
||||||
|
const rowSelection = reactive({
|
||||||
|
type: 'checkbox',
|
||||||
|
selectedRowKeys: selectedRowKeys,
|
||||||
|
selectedRows: selectedRows,
|
||||||
|
onChange(keys, rows) {
|
||||||
|
selectedRowKeys.value = keys;
|
||||||
|
selectedRows.value = rows;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const tableProps = reactive<Partial<BasicTableProps>>({
|
||||||
|
rowKey: 'id',
|
||||||
|
useSearchForm: true,
|
||||||
|
canResize: false,
|
||||||
|
showIndexColumn: false,
|
||||||
|
showTableSetting: true,
|
||||||
|
showActionColumn: true,
|
||||||
|
actionColumn: {
|
||||||
|
width: 160,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
api: (params) => {
|
||||||
|
if (!unref(listApi)) return Promise.resolve({ records: [], total: 0 });
|
||||||
|
return unref(listApi)!(Object.assign({}, params, unref(fixedParams)));
|
||||||
|
},
|
||||||
|
beforeFetch: (params) => {
|
||||||
|
return Object.assign(params, unref(fixedParams));
|
||||||
|
},
|
||||||
|
formConfig: {
|
||||||
|
schemas: [],
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: [],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
columns: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload, setProps }] = useTable(tableProps);
|
||||||
|
|
||||||
|
const [registerDrawer] = useDrawerInner(async (data: DrawerOpenConfig) => {
|
||||||
|
selectedRowKeys.value = [];
|
||||||
|
|
||||||
|
title.value = data?.title || '';
|
||||||
|
fixedMode.value = (data?.fixedMode as FixedMode) || 'schoolId';
|
||||||
|
bizType.value = data?.bizType || 'school';
|
||||||
|
columns.value = data?.columns || [];
|
||||||
|
searchSchemas.value = data?.searchSchemas || [];
|
||||||
|
listApi.value = data?.listApi;
|
||||||
|
deleteOne.value = data?.deleteOne;
|
||||||
|
batchDelete.value = data?.batchDelete;
|
||||||
|
modalComponent.value = data?.modalComponent;
|
||||||
|
getExtraDropDownActions.value = data?.getExtraDropDownActions;
|
||||||
|
|
||||||
|
if (unref(fixedMode) === 'schoolId') {
|
||||||
|
const school = data?.record;
|
||||||
|
fixedParams.value = { schoolId: school?.id };
|
||||||
|
ownerName.value = school?.mainName || school?.shortName || school?.mainCode || String(school?.id || '');
|
||||||
|
} else if (unref(fixedMode) === 'bizSchool') {
|
||||||
|
const school = data?.record;
|
||||||
|
fixedParams.value = { bizType: unref(bizType), bizId: school?.id };
|
||||||
|
ownerName.value = school?.mainName || school?.shortName || school?.mainCode || String(school?.id || '');
|
||||||
|
} else if (unref(fixedMode) === 'majorId') {
|
||||||
|
fixedParams.value = { majorId: data?.majorId };
|
||||||
|
ownerName.value = data?.ownerName || String(data?.majorId || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
fixedDisabledFields.splice(0, fixedDisabledFields.length, ...getDisableFieldsByMode());
|
||||||
|
|
||||||
|
setProps({
|
||||||
|
title: unref(title),
|
||||||
|
columns: unref(columns),
|
||||||
|
formConfig: {
|
||||||
|
...(tableProps.formConfig as any),
|
||||||
|
schemas: unref(filteredSearchSchemas),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, {
|
||||||
|
isUpdate: false,
|
||||||
|
showFooter: true,
|
||||||
|
record: unref(fixedParams),
|
||||||
|
dynamicDisabledFields: fixedDisabledFields,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record: Object.assign({}, record, unref(fixedParams)),
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: true,
|
||||||
|
dynamicDisabledFields: fixedDisabledFields,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record: Object.assign({}, record, unref(fixedParams)),
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: false,
|
||||||
|
dynamicDisabledFields: fixedDisabledFields,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await unref(deleteOne)?.({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await unref(batchDelete)?.({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record) {
|
||||||
|
const extra = unref(getExtraDropDownActions) ? unref(getExtraDropDownActions)!(record) : [];
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
...extra,
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/school/tag/list',
|
||||||
|
save = '/school/tag/add',
|
||||||
|
edit = '/school/tag/edit',
|
||||||
|
deleteOne = '/school/tag/delete',
|
||||||
|
deleteBatch = '/school/tag/deleteBatch',
|
||||||
|
queryById = '/school/tag/queryById',
|
||||||
|
importExcel = '/school/tag/importExcel',
|
||||||
|
exportXls = '/school/tag/exportXls',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '学校ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'schoolId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '标签',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'tagName',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '标签',
|
||||||
|
field: 'tagName',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 6 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '学校ID',
|
||||||
|
field: 'schoolId',
|
||||||
|
component: 'InputNumber',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '标签',
|
||||||
|
field: 'tagName',
|
||||||
|
component: 'Input',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
return formSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||||
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
|
||||||
|
<SchoolTagModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="school-tag" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import { columns, searchFormSchema } from './SchoolTag.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './SchoolTag.api';
|
||||||
|
import SchoolTagModal from './components/SchoolTagModal.vue';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '学校标签',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: ['schoolId'],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '学校标签',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record: Recordable) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../SchoolTag.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolTag.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'SchoolTagForm',
|
||||||
|
components: {
|
||||||
|
BasicForm,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
formData: propTypes.object.def({}),
|
||||||
|
formBpm: propTypes.bool.def(true),
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
|
||||||
|
labelWidth: 150,
|
||||||
|
schemas: getBpmFormSchema(props.formData),
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const formDisabled = computed(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let loadedFormData: Recordable = {};
|
||||||
|
const queryByIdUrl = '/school/tag/queryById';
|
||||||
|
|
||||||
|
async function initFormData() {
|
||||||
|
const params = { id: props.formData.dataId };
|
||||||
|
const data = await defHttp.get({ url: queryByIdUrl, params });
|
||||||
|
loadedFormData = { ...data };
|
||||||
|
await setFieldsValue(loadedFormData);
|
||||||
|
await setProps({ disabled: formDisabled.value });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitForm() {
|
||||||
|
const data = getFieldsValue();
|
||||||
|
const params = Object.assign({}, loadedFormData, data);
|
||||||
|
await saveOrUpdate(params, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
initFormData();
|
||||||
|
|
||||||
|
return {
|
||||||
|
registerForm,
|
||||||
|
formDisabled,
|
||||||
|
submitForm,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal
|
||||||
|
v-bind="$attrs"
|
||||||
|
@register="registerModal"
|
||||||
|
destroyOnClose
|
||||||
|
:title="title"
|
||||||
|
:width="800"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../SchoolTag.data';
|
||||||
|
import { saveOrUpdate } from '../SchoolTag.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
|
||||||
|
const [registerForm, { setProps, resetFields, setFieldsValue, validate, updateSchema }] = useForm({
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
const disabledFields: string[] = data?.dynamicDisabledFields || [];
|
||||||
|
for (const schema of formSchema) {
|
||||||
|
const field = String(schema.field);
|
||||||
|
updateSchema({ field, dynamicDisabled: disabledFields.includes(field) });
|
||||||
|
}
|
||||||
|
setModalProps({
|
||||||
|
confirmLoading: false,
|
||||||
|
showCancelBtn: !!data?.showFooter,
|
||||||
|
showOkBtn: !!data?.showFooter,
|
||||||
|
});
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
await setFieldsValue({ ...data.record });
|
||||||
|
}
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue