【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -52,6 +52,7 @@ def load_and_clean(sql_file: str) -> str:
|
|||||||
REPLACE_PAIR_LIST = (
|
REPLACE_PAIR_LIST = (
|
||||||
(")\nVALUES ", ") VALUES "),
|
(")\nVALUES ", ") VALUES "),
|
||||||
(" CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ", " "),
|
(" CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ", " "),
|
||||||
|
(" CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ", " "),
|
||||||
(" KEY `", " INDEX `"),
|
(" KEY `", " INDEX `"),
|
||||||
("UNIQUE INDEX", "UNIQUE KEY"),
|
("UNIQUE INDEX", "UNIQUE KEY"),
|
||||||
("b'0'", "'0'"),
|
("b'0'", "'0'"),
|
||||||
@@ -61,6 +62,11 @@ def load_and_clean(sql_file: str) -> str:
|
|||||||
content = open(sql_file, encoding="utf-8").read()
|
content = open(sql_file, encoding="utf-8").read()
|
||||||
for replace_pair in REPLACE_PAIR_LIST:
|
for replace_pair in REPLACE_PAIR_LIST:
|
||||||
content = content.replace(*replace_pair)
|
content = content.replace(*replace_pair)
|
||||||
|
# 移除索引字段的前缀长度定义,例如: `name`(32) -> `name`
|
||||||
|
# 移除索引定义上的 USING BTREE COMMENT 部分
|
||||||
|
# 相关 issue:https://t.zsxq.com/96IFc 、https://t.zsxq.com/rC3A3
|
||||||
|
content = re.sub(r'`([^`]+)`\(\d+\)', r'`\1`', content)
|
||||||
|
content = re.sub(r'\s+USING\s+BTREE\s+COMMENT\s+\'[^\']+\'', '', content)
|
||||||
content = re.sub(r"ENGINE.*COMMENT", "COMMENT", content)
|
content = re.sub(r"ENGINE.*COMMENT", "COMMENT", content)
|
||||||
content = re.sub(r"ENGINE.*;", ";", content)
|
content = re.sub(r"ENGINE.*;", ";", content)
|
||||||
return content
|
return content
|
||||||
@@ -262,10 +268,10 @@ class Convertor(ABC):
|
|||||||
# 解析注释
|
# 解析注释
|
||||||
for column in table_ddl["columns"]:
|
for column in table_ddl["columns"]:
|
||||||
column["comment"] = bytes(column["comment"], "utf-8").decode(
|
column["comment"] = bytes(column["comment"], "utf-8").decode(
|
||||||
"unicode_escape"
|
r"unicode_escape"
|
||||||
)[1:-1]
|
)[1:-1]
|
||||||
table_ddl["comment"] = bytes(table_ddl["comment"], "utf-8").decode(
|
table_ddl["comment"] = bytes(table_ddl["comment"], "utf-8").decode(
|
||||||
"unicode_escape"
|
r"unicode_escape"
|
||||||
)[1:-1]
|
)[1:-1]
|
||||||
|
|
||||||
# 为每个表生成个6个基本部分
|
# 为每个表生成个6个基本部分
|
||||||
|
|||||||
@@ -779,8 +779,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
*/
|
*/
|
||||||
private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) {
|
private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) {
|
||||||
// 1. 添加审批意见
|
// 1. 添加审批意见
|
||||||
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()).getCheckedData();
|
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId());
|
||||||
AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); // 发起委托的用户
|
AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); // 发起委托的用户
|
||||||
Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据");
|
Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据");
|
||||||
taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(),
|
taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(),
|
||||||
BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason()));
|
BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason()));
|
||||||
@@ -949,11 +949,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
|
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
|
||||||
|
|
||||||
// 4. 执行驳回
|
// 4. 执行驳回
|
||||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
// ① 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId。原因:当多实例任务回退的时候有问题。
|
||||||
// 当多实例任务回退的时候有问题。相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
// 相关 issue: https://github.com/flowable/flowable-engine/issues/3944
|
||||||
|
// ② flowable 7.2.0 版本后,继续使用 moveActivityIdsToSingleActivityId 方法。原因:flowable 7.2.0 版本修复了该问题。
|
||||||
|
// 相关 issue:https://github.com/YunaiV/ruoyi-vue-pro/issues/1018
|
||||||
runtimeService.createChangeActivityStateBuilder()
|
runtimeService.createChangeActivityStateBuilder()
|
||||||
.processInstanceId(currentTask.getProcessInstanceId())
|
.processInstanceId(currentTask.getProcessInstanceId())
|
||||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
.moveActivityIdsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||||
// 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
// 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
||||||
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
||||||
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
||||||
@@ -1000,13 +1002,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
throw exception(TASK_DELEGATE_FAIL_USER_REPEAT);
|
throw exception(TASK_DELEGATE_FAIL_USER_REPEAT);
|
||||||
}
|
}
|
||||||
// 1.2 校验目标用户存在
|
// 1.2 校验目标用户存在
|
||||||
AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()).getCheckedData();
|
AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId());
|
||||||
if (delegateUser == null) {
|
if (delegateUser == null) {
|
||||||
throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS);
|
throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 添加委托意见
|
// 2. 添加委托意见
|
||||||
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
|
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
|
||||||
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(),
|
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(),
|
||||||
BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason()));
|
BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason()));
|
||||||
|
|
||||||
@@ -1031,13 +1033,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
throw exception(TASK_TRANSFER_FAIL_USER_REPEAT);
|
throw exception(TASK_TRANSFER_FAIL_USER_REPEAT);
|
||||||
}
|
}
|
||||||
// 1.2 校验目标用户存在
|
// 1.2 校验目标用户存在
|
||||||
AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()).getCheckedData();
|
AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId());
|
||||||
if (assigneeUser == null) {
|
if (assigneeUser == null) {
|
||||||
throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS);
|
throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 添加委托意见
|
// 2. 添加委托意见
|
||||||
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
|
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
|
||||||
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(),
|
taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(),
|
||||||
BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason()));
|
BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason()));
|
||||||
|
|
||||||
@@ -1096,7 +1098,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) {
|
public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) {
|
||||||
// 1. 获取和校验任务
|
// 1. 获取和校验任务
|
||||||
TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO);
|
TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO);
|
||||||
List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIds()).getCheckedData();
|
List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIds());
|
||||||
if (CollUtil.isEmpty(userList)) {
|
if (CollUtil.isEmpty(userList)) {
|
||||||
throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST);
|
throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST);
|
||||||
}
|
}
|
||||||
@@ -1123,7 +1125,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity);
|
createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity);
|
||||||
|
|
||||||
// 4. 记录加签的评论到 task 任务
|
// 4. 记录加签的评论到 task 任务
|
||||||
AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData();
|
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
|
||||||
String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(),
|
String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(),
|
||||||
currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()),
|
currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()),
|
||||||
String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason());
|
String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason());
|
||||||
@@ -1155,7 +1157,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
List<Long> currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况,因为向后加签时,它暂时没 assignee 而是 owner
|
List<Long> currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况,因为向后加签时,它暂时没 assignee 而是 owner
|
||||||
Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner())));
|
Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner())));
|
||||||
if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) {
|
if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) {
|
||||||
List<AdminUserRespDTO> userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())).getCheckedData();
|
List<AdminUserRespDTO> userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds()));
|
||||||
throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname)));
|
throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname)));
|
||||||
}
|
}
|
||||||
return taskEntity;
|
return taskEntity;
|
||||||
@@ -1217,10 +1219,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
// 1.2 校验取消人存在
|
// 1.2 校验取消人存在
|
||||||
AdminUserRespDTO cancelUser = null;
|
AdminUserRespDTO cancelUser = null;
|
||||||
if (StrUtil.isNotBlank(task.getAssignee())) {
|
if (StrUtil.isNotBlank(task.getAssignee())) {
|
||||||
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())).getCheckedData();
|
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee()));
|
||||||
}
|
}
|
||||||
if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) {
|
if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) {
|
||||||
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData();
|
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner()));
|
||||||
}
|
}
|
||||||
Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误");
|
Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误");
|
||||||
|
|
||||||
@@ -1234,7 +1236,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
taskService.deleteTasks(convertList(childTaskList, Task::getId));
|
taskService.deleteTasks(convertList(childTaskList, Task::getId));
|
||||||
|
|
||||||
// 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录
|
// 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录
|
||||||
AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData();
|
AdminUserRespDTO user = adminUserApi.getUser(userId);
|
||||||
taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(),
|
taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(),
|
||||||
StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname()));
|
StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname()));
|
||||||
|
|
||||||
@@ -1536,9 +1538,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
// 情况二:转交给部门负责人审批
|
// 情况二:转交给部门负责人审批
|
||||||
if (ObjectUtils.equalsAny(assignStartUserHandlerType,
|
if (ObjectUtils.equalsAny(assignStartUserHandlerType,
|
||||||
BpmUserTaskAssignStartUserHandlerTypeEnum.TRANSFER_DEPT_LEADER.getType())) {
|
BpmUserTaskAssignStartUserHandlerTypeEnum.TRANSFER_DEPT_LEADER.getType())) {
|
||||||
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
|
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
|
||||||
Assert.notNull(startUser, "提交人({})信息为空", processInstance.getStartUserId());
|
Assert.notNull(startUser, "提交人({})信息为空", processInstance.getStartUserId());
|
||||||
DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()).getCheckedData() : null;
|
DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()) : null;
|
||||||
Assert.notNull(dept, "提交人({})部门({})信息为空", processInstance.getStartUserId(), startUser.getDeptId());
|
Assert.notNull(dept, "提交人({})部门({})信息为空", processInstance.getStartUserId(), startUser.getDeptId());
|
||||||
// 找不到部门负责人的情况下,自动审批通过
|
// 找不到部门负责人的情况下,自动审批通过
|
||||||
// noinspection DataFlowIssue
|
// noinspection DataFlowIssue
|
||||||
@@ -1560,7 +1562,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
}
|
}
|
||||||
// 注意:需要基于 instance 设置租户编号,避免 Flowable 内部异步时,丢失租户编号
|
// 注意:需要基于 instance 设置租户编号,避免 Flowable 内部异步时,丢失租户编号
|
||||||
FlowableUtils.execute(processInstance.getTenantId(), () -> {
|
FlowableUtils.execute(processInstance.getTenantId(), () -> {
|
||||||
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData();
|
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
|
||||||
messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
|
messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,8 @@ public class FileTypeUtils {
|
|||||||
}
|
}
|
||||||
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
|
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题
|
||||||
if (StrUtil.containsIgnoreCase(mineType, "video")) {
|
if (StrUtil.containsIgnoreCase(mineType, "video")) {
|
||||||
response.setHeader("Content-Length", String.valueOf(content.length));
|
|
||||||
response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length);
|
|
||||||
response.setHeader("Accept-Ranges", "bytes");
|
response.setHeader("Accept-Ranges", "bytes");
|
||||||
|
response.setHeader("Content-Length", String.valueOf(content.length));
|
||||||
}
|
}
|
||||||
// 输出附件
|
// 输出附件
|
||||||
IoUtil.write(response.getOutputStream(), false, content);
|
IoUtil.write(response.getOutputStream(), false, content);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Rule } from 'ant-design-vue/es/form';
|
import type { Rule } from 'ant-design-vue/es/form';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import { Tinymce as RichTextarea } from '#/components/tinymce';
|
|||||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||||
#if($table.templateType == 2)## 树表需要导入这些
|
#if($table.templateType == 2)## 树表需要导入这些
|
||||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { handleTree } from '@vben/utils'
|
import { handleTree } from '@vben/utils'
|
||||||
#end
|
#end
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
@@ -24,7 +24,7 @@ import { handleTree } from '@vben/utils'
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { ref, h, reactive, onMounted, nextTick } from 'vue';
|
import { ref, h, reactive, onMounted, nextTick } from 'vue';
|
||||||
|
|
||||||
@@ -7,12 +7,13 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
|||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
|
import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
|
||||||
import { cloneDeep, downloadFileFromBlobPart, formatDateTime } from '@vben/utils';
|
import { cloneDeep, downloadFileFromBlobPart, formatDateTime, isEmpty } from '@vben/utils';
|
||||||
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
|
import { Button, Card, message, Tabs, Pagination, Form, RangePicker, DatePicker, Select, Input } from 'ant-design-vue';
|
||||||
import ${simpleClassName}Form from './modules/form.vue';
|
import ${simpleClassName}Form from './modules/form.vue';
|
||||||
import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons';
|
import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons';
|
||||||
import { ContentWrap } from '#/components/content-wrap';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
|
||||||
|
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
||||||
@@ -25,13 +26,11 @@ import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
|||||||
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
#if (${table.templateType} == 2)## 树表接口
|
#if (${table.templateType} == 2)## 树表接口
|
||||||
import { handleTree,isEmpty } from '@vben/utils'
|
import { handleTree } from '@vben/utils'
|
||||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else## 标准表接口
|
#else## 标准表接口
|
||||||
import { isEmpty } from '@vben/utils';
|
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}List,#end export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
#end
|
#end
|
||||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
|
||||||
|
|
||||||
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
|
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
|
||||||
/** 子表的列表 */
|
/** 子表的列表 */
|
||||||
@@ -211,7 +210,7 @@ onMounted(() => {
|
|||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="getList" />
|
<FormModal @success="getList" />
|
||||||
|
|
||||||
<ContentWrap v-if="!hiddenSearchBar">
|
<Card v-if="!hiddenSearchBar" class="mb-4">
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<Form
|
<Form
|
||||||
:model="queryParams"
|
:model="queryParams"
|
||||||
@@ -292,10 +291,10 @@ onMounted(() => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</ContentWrap>
|
</Card>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap title="${table.classComment}">
|
<Card title="${table.classComment}">
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<VbenVxeTableToolbar
|
<VbenVxeTableToolbar
|
||||||
ref="tableToolbarRef"
|
ref="tableToolbarRef"
|
||||||
@@ -338,9 +337,9 @@ onMounted(() => {
|
|||||||
批量删除
|
批量删除
|
||||||
</Button>
|
</Button>
|
||||||
#end
|
#end
|
||||||
</TableToolbar>
|
</VbenVxeTableToolbar>
|
||||||
</template>
|
</template>
|
||||||
<vxe-table
|
<VxeTable
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data="list"
|
:data="list"
|
||||||
#if ( $table.templateType == 2 )
|
#if ( $table.templateType == 2 )
|
||||||
@@ -368,12 +367,12 @@ onMounted(() => {
|
|||||||
#end
|
#end
|
||||||
>
|
>
|
||||||
#if ($table.templateType != 2 && $deleteBatchEnable)
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
<vxe-column type="checkbox" width="40"></vxe-column>
|
<VxeColumn type="checkbox" width="40" />
|
||||||
#end
|
#end
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||||
<!-- 子表的列表 -->
|
<!-- 子表的列表 -->
|
||||||
<vxe-column type="expand" width="60">
|
<VxeColumn type="expand" width="60">
|
||||||
<template #content="{ row }">
|
<template #content="{ row }">
|
||||||
<!-- 子表的表单 -->
|
<!-- 子表的表单 -->
|
||||||
<Tabs v-model:active-key="subTabsName" class="mx-8">
|
<Tabs v-model:active-key="subTabsName" class="mx-8">
|
||||||
@@ -388,7 +387,7 @@ onMounted(() => {
|
|||||||
#end
|
#end
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#end
|
#end
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.listOperationResult)
|
#if ($column.listOperationResult)
|
||||||
@@ -397,31 +396,31 @@ onMounted(() => {
|
|||||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#set ($comment=$column.columnComment)
|
#set ($comment=$column.columnComment)
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
{{formatDateTime(row.${javaField})}}
|
{{formatDateTime(row.${javaField})}}
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
|
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||||
#else
|
#else
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<vxe-column field="operation" title="操作" align="center">
|
<VxeColumn field="operation" title="操作" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
#if ( $table.templateType == 2 )
|
#if ( $table.templateType == 2 )
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
@click="handleAppend(row as any)"
|
@click="handleAppend(row)"
|
||||||
v-access:code="['${permissionPrefix}:create']"
|
v-access:code="['${permissionPrefix}:create']"
|
||||||
>
|
>
|
||||||
新增下级
|
新增下级
|
||||||
@@ -430,7 +429,7 @@ onMounted(() => {
|
|||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
@click="handleEdit(row as any)"
|
@click="handleEdit(row)"
|
||||||
v-access:code="['${permissionPrefix}:update']"
|
v-access:code="['${permissionPrefix}:update']"
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.edit') }}
|
{{ $t('ui.actionTitle.edit') }}
|
||||||
@@ -443,14 +442,14 @@ onMounted(() => {
|
|||||||
#if ( $table.templateType == 2 )
|
#if ( $table.templateType == 2 )
|
||||||
:disabled="!isEmpty(row?.children)"
|
:disabled="!isEmpty(row?.children)"
|
||||||
#end
|
#end
|
||||||
@click="handleDelete(row as any)"
|
@click="handleDelete(row)"
|
||||||
v-access:code="['${permissionPrefix}:delete']"
|
v-access:code="['${permissionPrefix}:delete']"
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.delete') }}
|
{{ $t('ui.actionTitle.delete') }}
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
</vxe-table>
|
</VxeTable>
|
||||||
#if ( $table.templateType != 2 )
|
#if ( $table.templateType != 2 )
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<div class="mt-2 flex justify-end">
|
<div class="mt-2 flex justify-end">
|
||||||
@@ -463,9 +462,9 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
#end
|
#end
|
||||||
</ContentWrap>
|
</Card>
|
||||||
#if ($table.templateType == 11) ## erp情况
|
#if ($table.templateType == 11) ## erp情况
|
||||||
<ContentWrap>
|
<Card>
|
||||||
<!-- 子表的表单 -->
|
<!-- 子表的表单 -->
|
||||||
<Tabs v-model:active-key="subTabsName">
|
<Tabs v-model:active-key="subTabsName">
|
||||||
#foreach ($subTable in $subTables)
|
#foreach ($subTable in $subTables)
|
||||||
@@ -478,7 +477,7 @@ onMounted(() => {
|
|||||||
</Tabs.TabPane>
|
</Tabs.TabPane>
|
||||||
#end
|
#end
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</ContentWrap>
|
</Card>
|
||||||
#end
|
#end
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,21 +4,20 @@
|
|||||||
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Rule } from 'ant-design-vue/es/form';
|
import type { Rule } from 'ant-design-vue/es/form';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { cloneDeep, formatDateTime } from '@vben/utils';
|
|
||||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
|
|||||||
@@ -5,25 +5,27 @@
|
|||||||
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { message, Tabs, Form, Input, Textarea,Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
|
import { message, Tabs, Form, Input, Textarea, Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||||
import { Plus } from "@vben/icons";
|
import { Plus } from "@vben/icons";
|
||||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else
|
#else
|
||||||
import type { Rule } from 'ant-design-vue/es/form';
|
import type { Rule } from 'ant-design-vue/es/form';
|
||||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -55,6 +57,7 @@ defineExpose({
|
|||||||
(row) => !removeRecords.some((removed) => removed.id === row.id),
|
(row) => !removeRecords.some((removed) => removed.id === row.id),
|
||||||
),
|
),
|
||||||
...insertRecords.map((row: any) => ({ ...row, id: undefined })),
|
...insertRecords.map((row: any) => ({ ...row, id: undefined })),
|
||||||
|
];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -113,7 +116,7 @@ watch(
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
<vxe-table ref="tableRef" :data="list" show-overflow class="mx-4">
|
<VxeTable ref="tableRef" :data="list" show-overflow class="mx-4">
|
||||||
#foreach($column in $subColumns)
|
#foreach($column in $subColumns)
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
#set ($comment = $column.columnComment)
|
#set ($comment = $column.columnComment)
|
||||||
@@ -128,25 +131,25 @@ watch(
|
|||||||
#end
|
#end
|
||||||
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
||||||
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<Input v-model:value="row.${javaField}" />
|
<Input v-model:value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<ImageUpload v-model:value="row.${javaField}" />
|
<ImageUpload v-model:value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<FileUpload v-model:value="row.${javaField}" />
|
<FileUpload v-model:value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<Select v-model:value="row.${javaField}" placeholder="请选择${comment}">
|
<Select v-model:value="row.${javaField}" placeholder="请选择${comment}">
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
@@ -162,9 +165,9 @@ watch(
|
|||||||
#end
|
#end
|
||||||
</Select>
|
</Select>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
#elseif($column.htmlType == "checkbox")## 多选框
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<CheckboxGroup v-model:value="row.${javaField}">
|
<CheckboxGroup v-model:value="row.${javaField}">
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
@@ -180,9 +183,9 @@ watch(
|
|||||||
#end
|
#end
|
||||||
</CheckboxGroup>
|
</CheckboxGroup>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "radio")## 单选框
|
#elseif($column.htmlType == "radio")## 单选框
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<RadioGroup v-model:value="row.${javaField}">
|
<RadioGroup v-model:value="row.${javaField}">
|
||||||
#if ("" != $dictType)## 有数据字典
|
#if ("" != $dictType)## 有数据字典
|
||||||
@@ -198,9 +201,9 @@ watch(
|
|||||||
#end
|
#end
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "datetime")## 时间框
|
#elseif($column.htmlType == "datetime")## 时间框
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
v-model:value="row.${javaField}"
|
v-model:value="row.${javaField}"
|
||||||
@@ -209,30 +212,30 @@ watch(
|
|||||||
valueFormat='x'
|
valueFormat='x'
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.htmlType == "textarea" || $column.htmlType == "editor")## 文本框
|
#elseif($column.htmlType == "textarea" || $column.htmlType == "editor")## 文本框
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<Textarea v-model:value="row.${javaField}" />
|
<Textarea v-model:value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<vxe-column field="operation" title="操作" align="center">
|
<VxeColumn field="operation" title="操作" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
danger
|
danger
|
||||||
@click="handleDelect(row)"
|
@click="handleDelete(row)"
|
||||||
v-access:code="['${permissionPrefix}:delete']"
|
v-access:code="['${permissionPrefix}:delete']"
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.delete') }}
|
{{ $t('ui.actionTitle.delete') }}
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
</vxe-table>
|
</VxeTable>
|
||||||
<div class="flex justify-center mt-4">
|
<div class="flex justify-center mt-4">
|
||||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${permissionPrefix}:create']">
|
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${permissionPrefix}:create']">
|
||||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
|
import { reactive, ref, h, nextTick, watch, onMounted } from 'vue';
|
||||||
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils/rangePickerProps';
|
||||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||||
import { ContentWrap } from '#/components/content-wrap';
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
@@ -25,19 +25,19 @@ import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table';
|
|||||||
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
import { message, Button, Card, Tabs, Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||||
import { Plus, Trash2 } from '@vben/icons';
|
import { Plus, Trash2 } from '@vben/icons';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
import { isEmpty } from '@vben/utils';
|
import { isEmpty, cloneDeep } from '@vben/utils';
|
||||||
#else
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#else
|
#else
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ onMounted(() => {
|
|||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
<FormModal @success="getList" />
|
<FormModal @success="getList" />
|
||||||
<div class="h-[600px]">
|
<div class="h-[600px]">
|
||||||
<ContentWrap v-if="!hiddenSearchBar">
|
<Card v-if="!hiddenSearchBar" class="mb-4">
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<Form
|
<Form
|
||||||
:model="queryParams"
|
:model="queryParams"
|
||||||
@@ -284,10 +284,10 @@ onMounted(() => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</ContentWrap>
|
</Card>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap title="${table.classComment}">
|
<Card title="${table.classComment}">
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<VbenVxeTableToolbar
|
<VbenVxeTableToolbar
|
||||||
ref="tableToolbarRef"
|
ref="tableToolbarRef"
|
||||||
@@ -315,9 +315,9 @@ onMounted(() => {
|
|||||||
批量删除
|
批量删除
|
||||||
</Button>
|
</Button>
|
||||||
#end
|
#end
|
||||||
</TableToolbar>
|
</VbenVxeTableToolbar>
|
||||||
</template>
|
</template>
|
||||||
<vxe-table
|
<VxeTable
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:data="list"
|
:data="list"
|
||||||
show-overflow
|
show-overflow
|
||||||
@@ -328,7 +328,7 @@ onMounted(() => {
|
|||||||
#end
|
#end
|
||||||
>
|
>
|
||||||
#if ($deleteBatchEnable)
|
#if ($deleteBatchEnable)
|
||||||
<vxe-column type="checkbox" width="40"></vxe-column>
|
<VxeColumn type="checkbox" width="40" />
|
||||||
#end
|
#end
|
||||||
#foreach($column in $subColumns)
|
#foreach($column in $subColumns)
|
||||||
#if ($column.listOperationResult)
|
#if ($column.listOperationResult)
|
||||||
@@ -336,30 +336,30 @@ onMounted(() => {
|
|||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
#set ($comment=$column.columnComment)
|
#set ($comment=$column.columnComment)
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
{{formatDateTime(row.${javaField})}}
|
{{formatDateTime(row.${javaField})}}
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
#elseif ($table.templateType == 2 && $javaField == $treeNameColumn.javaField)
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center" tree-node/>
|
<VxeColumn field="${javaField}" title="${comment}" align="center" tree-node/>
|
||||||
#else
|
#else
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<vxe-column field="operation" title="操作" align="center">
|
<VxeColumn field="operation" title="操作" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
@click="handleEdit(row as any)"
|
@click="handleEdit(row)"
|
||||||
v-access:code="['${permissionPrefix}:update']"
|
v-access:code="['${permissionPrefix}:update']"
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.edit') }}
|
{{ $t('ui.actionTitle.edit') }}
|
||||||
@@ -369,14 +369,14 @@ onMounted(() => {
|
|||||||
type="link"
|
type="link"
|
||||||
danger
|
danger
|
||||||
class="ml-2"
|
class="ml-2"
|
||||||
@click="handleDelete(row as any)"
|
@click="handleDelete(row)"
|
||||||
v-access:code="['${permissionPrefix}:delete']"
|
v-access:code="['${permissionPrefix}:delete']"
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.delete') }}
|
{{ $t('ui.actionTitle.delete') }}
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
</vxe-table>
|
</VxeTable>
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<div class="mt-2 flex justify-end">
|
<div class="mt-2 flex justify-end">
|
||||||
<Pagination
|
<Pagination
|
||||||
@@ -387,11 +387,11 @@ onMounted(() => {
|
|||||||
@change="getList"
|
@change="getList"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ContentWrap>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
#else
|
#else
|
||||||
<ContentWrap title="${subTable.classComment}列表">
|
<Card title="${subTable.classComment}列表">
|
||||||
<vxe-table
|
<VxeTable
|
||||||
:data="list"
|
:data="list"
|
||||||
show-overflow
|
show-overflow
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@@ -402,23 +402,23 @@ onMounted(() => {
|
|||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
#set ($comment=$column.columnComment)
|
#set ($comment=$column.columnComment)
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
{{formatDateTime(row.${javaField})}}
|
{{formatDateTime(row.${javaField})}}
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center">
|
<VxeColumn field="${javaField}" title="${comment}" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</VxeColumn>
|
||||||
#else
|
#else
|
||||||
<vxe-column field="${javaField}" title="${comment}" align="center" />
|
<VxeColumn field="${javaField}" title="${comment}" align="center" />
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</vxe-table>
|
</VxeTable>
|
||||||
</ContentWrap>
|
</Card>
|
||||||
#end
|
#end
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}';
|
import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
|
||||||
import { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
import { computed, ref, h, onMounted, watch, nextTick } from 'vue';
|
||||||
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
import { Plus } from "@vben/icons";
|
import { Plus } from "@vben/icons";
|
||||||
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
||||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
import { use${subSimpleClassName}GridEditColumns } from '../data';
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
@@ -31,22 +30,9 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'delete': {
|
|
||||||
handleDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
|
columns: use${subSimpleClassName}GridEditColumns(),
|
||||||
border: true,
|
border: true,
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
autoResize: true,
|
autoResize: true,
|
||||||
@@ -186,6 +172,17 @@ watch(
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
@click="handleDelete(row)"
|
||||||
|
v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:delete']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.delete') }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
<div class="flex justify-center -mt-4">
|
<div class="flex justify-center -mt-4">
|
||||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ async function handleDeleteBatch() {
|
|||||||
try {
|
try {
|
||||||
await delete${subSimpleClassName}List(checkedIds.value);
|
await delete${subSimpleClassName}List(checkedIds.value);
|
||||||
checkedIds.value = [];
|
checkedIds.value = [];
|
||||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
handleRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
@@ -134,7 +134,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
#else
|
#else
|
||||||
columns: use${subSimpleClassName}GridColumns(),
|
columns: use${subSimpleClassName}GridColumns(),
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
nabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class IotProductController {
|
|||||||
public CommonResult<List<IotProductRespVO>> getProductSimpleList() {
|
public CommonResult<List<IotProductRespVO>> getProductSimpleList() {
|
||||||
List<IotProductDO> list = productService.getProductList();
|
List<IotProductDO> list = productService.getProductList();
|
||||||
return success(convertList(list, product -> // 只返回 id、name 字段
|
return success(convertList(list, product -> // 只返回 id、name 字段
|
||||||
new IotProductRespVO().setId(product.getId()).setName(product.getName())
|
new IotProductRespVO().setId(product.getId()).setName(product.getName()).setStatus(product.getStatus())
|
||||||
.setDeviceType(product.getDeviceType()).setLocationType(product.getLocationType())));
|
.setDeviceType(product.getDeviceType()).setLocationType(product.getLocationType())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,13 +241,13 @@ public class IotSceneRuleServiceImpl implements IotSceneRuleService {
|
|||||||
*/
|
*/
|
||||||
private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
|
private List<IotSceneRuleDO> getMatchedSceneRuleListByMessage(IotDeviceMessage message) {
|
||||||
// 1.1 通过 deviceId 获取设备信息
|
// 1.1 通过 deviceId 获取设备信息
|
||||||
IotDeviceDO device = getSelf().deviceService.getDeviceFromCache(message.getDeviceId());
|
IotDeviceDO device = deviceService.getDeviceFromCache(message.getDeviceId());
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
|
log.warn("[getMatchedSceneRuleListByMessage][设备({}) 不存在]", message.getDeviceId());
|
||||||
return ListUtil.of();
|
return ListUtil.of();
|
||||||
}
|
}
|
||||||
// 1.2 通过 productId 获取产品信息
|
// 1.2 通过 productId 获取产品信息
|
||||||
IotProductDO product = getSelf().productService.getProductFromCache(device.getProductId());
|
IotProductDO product = productService.getProductFromCache(device.getProductId());
|
||||||
if (product == null) {
|
if (product == null) {
|
||||||
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
|
log.warn("[getMatchedSceneRuleListByMessage][产品({}) 不存在]", device.getProductId());
|
||||||
return ListUtil.of();
|
return ListUtil.of();
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ public class IotDeviceEventPostTriggerMatcher implements IotSceneRuleTriggerMatc
|
|||||||
// 2. 对于事件触发器,通常不需要检查操作符和值,只要事件发生即匹配
|
// 2. 对于事件触发器,通常不需要检查操作符和值,只要事件发生即匹配
|
||||||
// 但如果配置了操作符和值,则需要进行条件匹配
|
// 但如果配置了操作符和值,则需要进行条件匹配
|
||||||
if (StrUtil.isNotBlank(trigger.getOperator()) && StrUtil.isNotBlank(trigger.getValue())) {
|
if (StrUtil.isNotBlank(trigger.getOperator()) && StrUtil.isNotBlank(trigger.getValue())) {
|
||||||
Object eventData = message.getData();
|
Object eventParams = message.getParams();
|
||||||
if (eventData == null) {
|
if (eventParams == null) {
|
||||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件数据为空");
|
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "消息中事件参数为空");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventData, trigger.getOperator(), trigger.getValue());
|
boolean matched = IotSceneRuleMatcherHelper.evaluateCondition(eventParams, trigger.getOperator(), trigger.getValue());
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "事件数据条件不匹配");
|
IotSceneRuleMatcherHelper.logTriggerMatchFailure(message, trigger, "事件数据条件不匹配");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user