diff --git a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java new file mode 100644 index 00000000..0d922edd --- /dev/null +++ b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/ValidConst.java @@ -0,0 +1,20 @@ +package com.orion.ops.framework.common.constant; + +/** + * 验证常量 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023/10/20 11:45 + */ +public interface ValidConst { + + String CHAR_NUMBER_2_32_PATTERN = "^[a-zA-Z0-9]{2,32}$"; + + String CHAR_NUMBER_2_32_MESSAGE = "只能为 2-32 位的数字或字母"; + + String CHAR_NUMBER_4_32_PATTERN = "^[a-zA-Z0-9]{4,32}$"; + + String CHAR_NUMBER_4_32_MESSAGE = "只能为 4-32 位的数字或字母"; + +} diff --git a/orion-ops-launch/src/main/resources/templates/orion-vue-views-components-card-list.vue.vm b/orion-ops-launch/src/main/resources/templates/orion-vue-views-components-card-list.vue.vm index ff8fd242..585c360e 100644 --- a/orion-ops-launch/src/main/resources/templates/orion-vue-views-components-card-list.vue.vm +++ b/orion-ops-launch/src/main/resources/templates/orion-vue-views-components-card-list.vue.vm @@ -112,6 +112,13 @@ import fieldConfig from '../types/card.fields'; import { delete${vue.featureEntity}, get${vue.featureEntity}Page, ${vue.featureEntity}QueryRequest, ${vue.featureEntity}QueryResponse } from '@/api/${vue.module}/${vue.feature}'; import { Message, Modal } from '@arco-design/web-vue'; + import {} from '../types/const'; + #if($vue.enums.isEmpty()) + import {} from '../types/enum.types'; + #else + import { #foreach($entry in ${vue.enums.entrySet()})${entry.value.className}#if($foreach.hasNext), #end#end } from '../types/enum.types'; + #end + import { toOptions, getEnumValue } from '@/utils/enum'; const { loading, setLoading } = useLoading(); const cardColLayout = useColLayout(); diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictKeyController.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictKeyController.java index 09e29872..e402cdc3 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictKeyController.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/DictKeyController.java @@ -1,11 +1,13 @@ package com.orion.ops.module.infra.controller; +import com.orion.lang.define.wrapper.DataGrid; import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog; import com.orion.ops.framework.log.core.annotation.IgnoreLog; import com.orion.ops.framework.log.core.enums.IgnoreLogMode; import com.orion.ops.framework.web.core.annotation.RestWrapper; import com.orion.ops.module.infra.define.operator.DictKeyOperatorType; import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest; +import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest; import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest; import com.orion.ops.module.infra.entity.vo.DictKeyVO; import com.orion.ops.module.infra.service.DictKeyService; @@ -62,6 +64,14 @@ public class DictKeyController { return dictKeyService.getDictKeyList(); } + @IgnoreLog(IgnoreLogMode.RET) + @PostMapping("/query") + @Operation(summary = "分页查询全部字典配置项") + @PreAuthorize("@ss.hasPermission('infra:dict-key:query')") + public DataGrid getDictKeyPage(@Validated @RequestBody DictKeyQueryRequest request) { + return dictKeyService.getDictKeyPage(request); + } + @OperatorLog(DictKeyOperatorType.DELETE) @DeleteMapping("/delete") @Operation(summary = "删除字典配置项") diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java index 26be0f37..4fbc0208 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyCreateRequest.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.entity.request.dict; +import com.orion.ops.framework.common.constant.ValidConst; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -27,7 +28,7 @@ public class DictKeyCreateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") + @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) @Schema(description = "配置项") private String keyName; @@ -36,11 +37,9 @@ public class DictKeyCreateRequest implements Serializable { @Schema(description = "配置值定义") private String valueType; - @NotBlank @Schema(description = "额外配置定义") private String extraSchema; - @NotBlank @Size(max = 64) @Schema(description = "配置描述") private String description; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyQueryRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyQueryRequest.java new file mode 100644 index 00000000..ce407460 --- /dev/null +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyQueryRequest.java @@ -0,0 +1,38 @@ +package com.orion.ops.module.infra.entity.request.dict; + +import com.orion.ops.framework.common.entity.PageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.Size; + +/** + * 字典配置项 查询请求对象 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2023-10-19 10:25 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Schema(name = "DictKeyQueryRequest", description = "字典配置项 查询请求对象") +public class DictKeyQueryRequest extends PageRequest { + + @Schema(description = "搜索") + private String searchValue; + + @Schema(description = "id") + private Long id; + + @Size(max = 32) + @Schema(description = "配置项") + private String keyName; + + @Size(max = 64) + @Schema(description = "配置描述") + private String description; + +} diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java index 51e0fbe0..3059e6c6 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictKeyUpdateRequest.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.entity.request.dict; +import com.orion.ops.framework.common.constant.ValidConst; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -32,7 +33,7 @@ public class DictKeyUpdateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") + @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) @Schema(description = "配置项") private String keyName; @@ -41,11 +42,9 @@ public class DictKeyUpdateRequest implements Serializable { @Schema(description = "配置值定义") private String valueType; - @NotBlank @Schema(description = "额外配置定义") private String extraSchema; - @NotBlank @Size(max = 64) @Schema(description = "配置描述") private String description; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java index 282be4d2..cabab672 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueCreateRequest.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.entity.request.dict; +import com.orion.ops.framework.common.constant.ValidConst; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -32,7 +33,7 @@ public class DictValueCreateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") + @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) @Schema(description = "配置名称") private String name; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java index fd64f25f..b7b7654a 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/dict/DictValueUpdateRequest.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.entity.request.dict; +import com.orion.ops.framework.common.constant.ValidConst; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -36,7 +37,7 @@ public class DictValueUpdateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") + @Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE) @Schema(description = "配置名称") private String name; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/SystemUserCreateRequest.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/SystemUserCreateRequest.java index 1edab3d5..8b8d8b6c 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/SystemUserCreateRequest.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/entity/request/user/SystemUserCreateRequest.java @@ -1,5 +1,6 @@ package com.orion.ops.module.infra.entity.request.user; +import com.orion.ops.framework.common.constant.ValidConst; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; @@ -27,7 +28,7 @@ public class SystemUserCreateRequest implements Serializable { @NotBlank @Size(max = 32) - @Pattern(regexp = "^[a-zA-Z0-9]{4,32}$") + @Pattern(regexp = ValidConst.CHAR_NUMBER_4_32_PATTERN, message = ValidConst.CHAR_NUMBER_4_32_MESSAGE) @Schema(description = "用户名") private String username; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java index 616acb33..cf929560 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/DictKeyService.java @@ -1,6 +1,8 @@ package com.orion.ops.module.infra.service; +import com.orion.lang.define.wrapper.DataGrid; import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest; +import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest; import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest; import com.orion.ops.module.infra.entity.vo.DictKeyVO; @@ -39,6 +41,14 @@ public interface DictKeyService { */ List getDictKeyList(); + /** + * 分页 查询字典配置项 + * + * @param request request + * @return rows + */ + DataGrid getDictKeyPage(DictKeyQueryRequest request); + /** * 查询字典配置项 schema * diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java index cecff44d..3ee5b999 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictKeyServiceImpl.java @@ -3,7 +3,9 @@ package com.orion.ops.module.infra.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.orion.lang.define.wrapper.DataGrid; import com.orion.lang.utils.Objects1; +import com.orion.lang.utils.Strings; import com.orion.lang.utils.collect.Maps; import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs; import com.orion.ops.framework.common.constant.Const; @@ -17,6 +19,7 @@ import com.orion.ops.module.infra.define.cache.DictCacheKeyDefine; import com.orion.ops.module.infra.entity.domain.DictKeyDO; import com.orion.ops.module.infra.entity.dto.DictKeyCacheDTO; import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest; +import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest; import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest; import com.orion.ops.module.infra.entity.vo.DictKeyVO; import com.orion.ops.module.infra.enums.DictValueTypeEnum; @@ -118,6 +121,16 @@ public class DictKeyServiceImpl implements DictKeyService { .collect(Collectors.toList()); } + @Override + public DataGrid getDictKeyPage(DictKeyQueryRequest request) { + // 条件 + LambdaQueryWrapper wrapper = this.buildQueryWrapper(request); + // 查询 + return dictKeyDAO.of(wrapper) + .page(request) + .dataGrid(DictKeyConvert.MAPPER::to); + } + @Override public Map getDictSchema(String key) { // 查询缓存 @@ -210,4 +223,22 @@ public class DictKeyServiceImpl implements DictKeyService { Valid.isFalse(present, ErrorMessage.DATA_PRESENT); } + /** + * 构建查询 wrapper + * + * @param request request + * @return wrapper + */ + private LambdaQueryWrapper buildQueryWrapper(DictKeyQueryRequest request) { + String searchValue = request.getSearchValue(); + return dictKeyDAO.wrapper() + .eq(DictKeyDO::getId, request.getId()) + .like(DictKeyDO::getKeyName, request.getKeyName()) + .like(DictKeyDO::getDescription, request.getDescription()) + .and(Strings.isNotEmpty(searchValue), c -> c + .like(DictKeyDO::getKeyName, searchValue).or() + .like(DictKeyDO::getDescription, searchValue) + ); + } + } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java index 28624bac..725db9c7 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DictValueServiceImpl.java @@ -182,6 +182,7 @@ public class DictValueServiceImpl implements DictValueService { Map> result = Maps.newLinkedMap(); for (DictValueVO value : values) { Map item = Maps.newMap(); + item.put(Const.NAME, value.getName()); item.put(Const.LABEL, value.getLabel()); item.put(Const.VALUE, DictValueTypeEnum.of(schema.get(Const.VALUE)).parse(value.getValue())); // 额外值 @@ -213,7 +214,7 @@ public class DictValueServiceImpl implements DictValueService { DictValueDO updateRecord = new DictValueDO(); updateRecord.setKeyName(newKey); LambdaQueryWrapper wrapper = dictValueDAO.lambda() - .eq(DictValueDO::getKeyId, beforeKey); + .eq(DictValueDO::getKeyId, keyId); int effect = dictValueDAO.update(updateRecord, wrapper); // 删除缓存 String beforeCacheKey = DictCacheKeyDefine.DICT_VALUE.format(beforeKey); diff --git a/orion-ops-ui/src/api/system/dict-key.ts b/orion-ops-ui/src/api/system/dict-key.ts index e290bb95..ee93241a 100644 --- a/orion-ops-ui/src/api/system/dict-key.ts +++ b/orion-ops-ui/src/api/system/dict-key.ts @@ -1,5 +1,6 @@ import axios from 'axios'; import qs from 'query-string'; +import { DataGrid, Pagination } from '@/types/global'; import { TableData } from '@arco-design/web-vue/es/table/interface'; /** @@ -19,6 +20,16 @@ export interface DictKeyUpdateRequest extends DictKeyCreateRequest { id?: number; } +/** + * 字典配置项查询请求 + */ +export interface DictKeyQueryRequest extends Pagination { + searchValue?: string; + id?: number; + keyName?: string; + description?: string; +} + /** * 字典配置项查询响应 */ @@ -51,6 +62,13 @@ export function getDictKeyList() { return axios.post>('/infra/dict-key/list'); } +/** + * 分页查询字典配置项 + */ +export function getDictKeyPage(request: DictKeyQueryRequest) { + return axios.post>('/infra/dict-key/query', request); +} + /** * 删除字典配置项 */ diff --git a/orion-ops-ui/src/router/routes/modules/system.ts b/orion-ops-ui/src/router/routes/modules/system.ts index f58fadd2..5b74d766 100644 --- a/orion-ops-ui/src/router/routes/modules/system.ts +++ b/orion-ops-ui/src/router/routes/modules/system.ts @@ -12,9 +12,14 @@ const SYSTEM: AppRouteRecordRaw = { component: () => import('@/views/system/menu/index.vue'), }, { - name: 'systemDict', - path: '/system/dict', - component: () => import('@/views/system/dict/index.vue'), + name: 'systemDictKey', + path: '/system/dict-key', + component: () => import('@/views/system/dict-key/index.vue'), + }, + { + name: 'systemDictValue', + path: '/system/dict-value', + component: () => import('@/views/system/dict-value/index.vue'), }, ], }; diff --git a/orion-ops-ui/src/views/system/dict-key/components/dict-key-form-modal.vue b/orion-ops-ui/src/views/system/dict-key/components/dict-key-form-modal.vue new file mode 100644 index 00000000..9c35dc4b --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-key/components/dict-key-form-modal.vue @@ -0,0 +1,263 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict-key/components/dict-key-table.vue b/orion-ops-ui/src/views/system/dict-key/components/dict-key-table.vue new file mode 100644 index 00000000..187fadd8 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-key/components/dict-key-table.vue @@ -0,0 +1,190 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict-key/index.vue b/orion-ops-ui/src/views/system/dict-key/index.vue new file mode 100644 index 00000000..0ded5463 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-key/index.vue @@ -0,0 +1,43 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict-key/types/const.ts b/orion-ops-ui/src/views/system/dict-key/types/const.ts new file mode 100644 index 00000000..033a4b5d --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-key/types/const.ts @@ -0,0 +1,17 @@ +/** + * 快捷定义字段 + */ +export const definedExtraKeys = ['status', 'type', 'color']; + +/** + * 内置字段 + */ +export const innerKeys = ['name', 'value', 'label']; + +/** + * 额外参数类型 + */ +export interface ExtraParamType { + name?: string; + type?: string; +} diff --git a/orion-ops-ui/src/views/system/dict/types/enum.types.ts b/orion-ops-ui/src/views/system/dict-key/types/enum.types.ts similarity index 76% rename from orion-ops-ui/src/views/system/dict/types/enum.types.ts rename to orion-ops-ui/src/views/system/dict-key/types/enum.types.ts index 4da3740e..f12fa2e0 100644 --- a/orion-ops-ui/src/views/system/dict/types/enum.types.ts +++ b/orion-ops-ui/src/views/system/dict-key/types/enum.types.ts @@ -5,22 +5,27 @@ export const ValueTypeEnum = { STRING: { label: '字符串', value: 'STRING', + color: 'blue', }, INTEGER: { label: '整数', value: 'INTEGER', + color: 'arcoblue', }, DECIMAL: { label: '小数', value: 'DECIMAL', + color: 'purple', }, BOOLEAN: { label: '布尔值', value: 'BOOLEAN', + color: 'pinkpurple', }, COLOR: { label: '颜色', value: 'COLOR', + color: 'magenta', }, -} +}; diff --git a/orion-ops-ui/src/views/system/dict/types/dict-key.form.rules.ts b/orion-ops-ui/src/views/system/dict-key/types/form.rules.ts similarity index 57% rename from orion-ops-ui/src/views/system/dict/types/dict-key.form.rules.ts rename to orion-ops-ui/src/views/system/dict-key/types/form.rules.ts index 927d8511..880ac041 100644 --- a/orion-ops-ui/src/views/system/dict/types/dict-key.form.rules.ts +++ b/orion-ops-ui/src/views/system/dict-key/types/form.rules.ts @@ -4,27 +4,19 @@ export const keyName = [{ required: true, message: '请输入配置项' }, { - maxLength: 32, - message: '配置项长度不能大于32位' + match: /^[a-zA-Z0-9]{2,32}$/, + message: '配置项需要为 2-32 位的数字以及字母' }] as FieldRule[]; export const valueType = [{ required: true, - message: '请输入配置值定义' + message: '请输入配置值类型' }, { maxLength: 12, - message: '配置值定义长度不能大于12位' -}] as FieldRule[]; - -export const extraSchema = [{ - required: true, - message: '请输入额外配置定义' + message: '配置值类型长度不能大于12位' }] as FieldRule[]; export const description = [{ - required: true, - message: '请输入配置描述' -}, { maxLength: 64, message: '配置描述长度不能大于64位' }] as FieldRule[]; @@ -32,6 +24,5 @@ export const description = [{ export default { keyName, valueType, - extraSchema, description, } as Record; diff --git a/orion-ops-ui/src/views/system/dict-key/types/table.columns.ts b/orion-ops-ui/src/views/system/dict-key/types/table.columns.ts new file mode 100644 index 00000000..f7aabce0 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-key/types/table.columns.ts @@ -0,0 +1,45 @@ +import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; + +const columns = [ + { + title: 'id', + dataIndex: 'id', + slotName: 'id', + width: 70, + align: 'left', + fixed: 'left', + }, { + title: '配置项', + dataIndex: 'keyName', + slotName: 'keyName', + align: 'left', + ellipsis: true, + tooltip: true, + }, { + title: '配置值类型', + dataIndex: 'valueType', + slotName: 'valueType', + align: 'left', + width: 150 + }, { + title: '配置描述', + dataIndex: 'description', + slotName: 'description', + align: 'left', + ellipsis: true, + tooltip: true, + }, { + title: '额外配置类型', + dataIndex: 'extraSchema', + slotName: 'extraSchema', + align: 'left', + }, { + title: '操作', + slotName: 'handle', + width: 130, + align: 'center', + fixed: 'right', + }, +] as TableColumnData[]; + +export default columns; diff --git a/orion-ops-ui/src/views/system/dict-value/components/dict-value-card-list.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-card-list.vue new file mode 100644 index 00000000..26f55e3e --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-card-list.vue @@ -0,0 +1,223 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict/components/dict-key-form-modal.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-drawer.vue similarity index 51% rename from orion-ops-ui/src/views/system/dict/components/dict-key-form-modal.vue rename to orion-ops-ui/src/views/system/dict-value/components/dict-value-form-drawer.vue index 152c494b..cd95b96a 100644 --- a/orion-ops-ui/src/views/system/dict/components/dict-key-form-modal.vue +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-drawer.vue @@ -1,51 +1,61 @@ @@ -53,11 +63,11 @@ import { ref } from 'vue'; import useLoading from '@/hooks/loading'; import useVisible from '@/hooks/visible'; - import formRules from '../types/dict-key.form.rules'; - import { createDictKey, updateDictKey, DictKeyUpdateRequest } from '@/api/system/dict-key'; + import formRules from '../types/form.rules'; + import { createDictValue, updateDictValue, DictValueUpdateRequest } from '@/api/system/dict-value'; import { Message } from '@arco-design/web-vue'; import {} from '../types/const'; - import { ValueTypeEnum } from '../types/enum.types'; + import {} from '../types/enum.types'; import { toOptions } from '@/utils/enum'; const { visible, setVisible } = useVisible(); @@ -66,24 +76,27 @@ const title = ref(); const isAddHandle = ref(true); - const defaultForm = (): DictKeyUpdateRequest => { + const defaultForm = (): DictValueUpdateRequest => { return { id: undefined, + keyId: undefined, keyName: undefined, - valueType: undefined, - extraSchema: undefined, - description: undefined, + name: undefined, + value: undefined, + label: undefined, + extra: undefined, + sort: undefined, }; }; const formRef = ref(); - const formModel = ref({}); + const formModel = ref({}); const emits = defineEmits(['added', 'updated']); // 打开新增 const openAdd = () => { - title.value = '添加字典配置项'; + title.value = '添加字典配置值'; isAddHandle.value = true; renderForm({ ...defaultForm() }); setVisible(true); @@ -91,7 +104,7 @@ // 打开修改 const openUpdate = (record: any) => { - title.value = '修改字典配置项'; + title.value = '修改字典配置值'; isAddHandle.value = false; renderForm({ ...defaultForm(), ...record }); setVisible(true); @@ -115,12 +128,12 @@ } if (isAddHandle.value) { // 新增 - await createDictKey(formModel.value); + await createDictValue(formModel.value); Message.success('创建成功'); emits('added'); } else { // 修改 - await updateDictKey(formModel.value); + await updateDictValue(formModel.value); Message.success('修改成功'); emits('updated'); } diff --git a/orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue similarity index 97% rename from orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue rename to orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue index 917534fe..979f4fe8 100644 --- a/orion-ops-ui/src/views/system/dict/components/dict-value-form-modal.vue +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-form-modal.vue @@ -67,7 +67,7 @@ import { ref } from 'vue'; import useLoading from '@/hooks/loading'; import useVisible from '@/hooks/visible'; - import formRules from '../types/dict-value.form.rules'; + import formRules from '../types/form.rules'; import { createDictValue, updateDictValue, DictValueUpdateRequest } from '@/api/system/dict-value'; import { Message } from '@arco-design/web-vue'; import {} from '../types/const'; @@ -100,7 +100,7 @@ // 打开新增 const openAdd = () => { - title.value = '添加字典值'; + title.value = '添加字典配置值'; isAddHandle.value = true; renderForm({ ...defaultForm() }); setVisible(true); @@ -108,7 +108,7 @@ // 打开修改 const openUpdate = (record: any) => { - title.value = '修改字典值'; + title.value = '修改字典配置值'; isAddHandle.value = false; renderForm({ ...defaultForm(), ...record }); setVisible(true); diff --git a/orion-ops-ui/src/views/system/dict/components/dict-value-table.vue b/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue similarity index 82% rename from orion-ops-ui/src/views/system/dict/components/dict-value-table.vue rename to orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue index 0914a08e..eafbf5be 100644 --- a/orion-ops-ui/src/views/system/dict/components/dict-value-table.vue +++ b/orion-ops-ui/src/views/system/dict-value/components/dict-value-table.vue @@ -5,7 +5,21 @@ label-align="left" @submit="fetchTableData" @reset="fetchTableData"> - + + + + + + + + + @@ -21,6 +35,17 @@ + + + + + + + + @@ -30,19 +55,8 @@
- 数据字典 + 字典配置值列表
- - - - 新增配置项 - - -
@@ -50,8 +64,8 @@ - 新增字典值 + @click="emits('openAdd')"> + 新增 @@ -95,16 +109,9 @@ + @click="emits('openUpdate', record)"> 修改 - - - 历史 - ([]); const { loading, setLoading } = useLoading(); - const emits = defineEmits(['openAddKey', 'openAddValue', 'openUpdateValue', 'openValueHistory']); + const emits = defineEmits(['openAdd', 'openUpdate']); const pagination = usePagination(); const selectedKeys = ref([]); diff --git a/orion-ops-ui/src/views/system/dict-value/index.vue b/orion-ops-ui/src/views/system/dict-value/index.vue new file mode 100644 index 00000000..aaf2ded3 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-value/index.vue @@ -0,0 +1,43 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/system/dict-value/types/card.fields.ts b/orion-ops-ui/src/views/system/dict-value/types/card.fields.ts new file mode 100644 index 00000000..14792006 --- /dev/null +++ b/orion-ops-ui/src/views/system/dict-value/types/card.fields.ts @@ -0,0 +1,71 @@ +import { CardField, CardFieldConfig } from '@/types/card'; +import { dateFormat } from '@/utils'; + +const fieldConfig = { + rowGap: '12px', + labelSpan: 8, + fields: [ + { + label: 'id', + dataIndex: 'id', + slotName: 'id', + }, { + label: '配置项id', + dataIndex: 'keyId', + slotName: 'keyId', + }, { + label: '配置项', + dataIndex: 'keyName', + slotName: 'keyName', + ellipsis: true, + }, { + label: '配置名称', + dataIndex: 'name', + slotName: 'name', + ellipsis: true, + }, { + label: '配置值', + dataIndex: 'value', + slotName: 'value', + ellipsis: true, + }, { + label: '配置描述', + dataIndex: 'label', + slotName: 'label', + ellipsis: true, + }, { + label: '额外参数', + dataIndex: 'extra', + slotName: 'extra', + ellipsis: true, + }, { + label: '排序', + dataIndex: 'sort', + slotName: 'sort', + }, { + label: '创建时间', + dataIndex: 'createTime', + slotName: 'createTime', + render: ({ record }) => { + return dateFormat(new Date(record.createTime)); + }, + }, { + label: '修改时间', + dataIndex: 'updateTime', + slotName: 'updateTime', + render: ({ record }) => { + return dateFormat(new Date(record.updateTime)); + }, + }, { + label: '创建人', + dataIndex: 'creator', + slotName: 'creator', + }, { + label: '修改人', + dataIndex: 'updater', + slotName: 'updater', + } + ] as CardField[] +} as CardFieldConfig; + +export default fieldConfig; diff --git a/orion-ops-ui/src/views/system/dict/types/const.ts b/orion-ops-ui/src/views/system/dict-value/types/const.ts similarity index 100% rename from orion-ops-ui/src/views/system/dict/types/const.ts rename to orion-ops-ui/src/views/system/dict-value/types/const.ts diff --git a/orion-ops-ui/src/views/system/dict-value/types/enum.types.ts b/orion-ops-ui/src/views/system/dict-value/types/enum.types.ts new file mode 100644 index 00000000..e69de29b diff --git a/orion-ops-ui/src/views/system/dict/types/dict-value.form.rules.ts b/orion-ops-ui/src/views/system/dict-value/types/form.rules.ts similarity index 84% rename from orion-ops-ui/src/views/system/dict/types/dict-value.form.rules.ts rename to orion-ops-ui/src/views/system/dict-value/types/form.rules.ts index 10202173..99757a10 100644 --- a/orion-ops-ui/src/views/system/dict/types/dict-value.form.rules.ts +++ b/orion-ops-ui/src/views/system/dict-value/types/form.rules.ts @@ -11,9 +11,6 @@ export const keyName = [{ }, { maxLength: 32, message: '配置项长度不能大于32位' -}, { - match: /^[a-zA-Z0-9]{4,32}$/, - message: '配置项需要为 4-32 位的数字以及字母' }] as FieldRule[]; export const name = [{ @@ -22,9 +19,6 @@ export const name = [{ }, { maxLength: 32, message: '配置名称长度不能大于32位' -}, { - match: /^[a-zA-Z0-9]{4,32}$/, - message: '配置名称需要为 4-32 位的数字以及字母' }] as FieldRule[]; export const value = [{ diff --git a/orion-ops-ui/src/views/system/dict/types/dict-key.table.columns.ts b/orion-ops-ui/src/views/system/dict-value/types/table.columns.ts similarity index 68% rename from orion-ops-ui/src/views/system/dict/types/dict-key.table.columns.ts rename to orion-ops-ui/src/views/system/dict-value/types/table.columns.ts index 7604bfc9..dfd0b742 100644 --- a/orion-ops-ui/src/views/system/dict/types/dict-key.table.columns.ts +++ b/orion-ops-ui/src/views/system/dict-value/types/table.columns.ts @@ -9,34 +9,51 @@ const columns = [ width: 70, align: 'left', fixed: 'left', + }, { + title: '配置项id', + dataIndex: 'keyId', + slotName: 'keyId', + align: 'left', }, { title: '配置项', dataIndex: 'keyName', slotName: 'keyName', - align: 'center', + align: 'left', ellipsis: true, tooltip: true, }, { - title: '配置值定义', - dataIndex: 'valueType', - slotName: 'valueType', - align: 'center', + title: '配置名称', + dataIndex: 'name', + slotName: 'name', + align: 'left', ellipsis: true, tooltip: true, }, { - title: '额外配置定义', - dataIndex: 'extraSchema', - slotName: 'extraSchema', - align: 'center', + title: '配置值', + dataIndex: 'value', + slotName: 'value', + align: 'left', ellipsis: true, tooltip: true, }, { title: '配置描述', - dataIndex: 'description', - slotName: 'description', - align: 'center', + dataIndex: 'label', + slotName: 'label', + align: 'left', ellipsis: true, tooltip: true, + }, { + title: '额外参数', + dataIndex: 'extra', + slotName: 'extra', + align: 'left', + ellipsis: true, + tooltip: true, + }, { + title: '排序', + dataIndex: 'sort', + slotName: 'sort', + align: 'left', }, { title: '创建时间', dataIndex: 'createTime', diff --git a/orion-ops-ui/src/views/system/dict/index.vue b/orion-ops-ui/src/views/system/dict/index.vue deleted file mode 100644 index d3113f3e..00000000 --- a/orion-ops-ui/src/views/system/dict/index.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - diff --git a/orion-ops-ui/src/views/system/dict/types/dict-value.table.columns.ts b/orion-ops-ui/src/views/system/dict/types/dict-value.table.columns.ts deleted file mode 100644 index f8f0c8b0..00000000 --- a/orion-ops-ui/src/views/system/dict/types/dict-value.table.columns.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; -import { dateFormat } from '@/utils'; - -const columns = [ - { - title: 'id', - dataIndex: 'id', - slotName: 'id', - width: 70, - align: 'left', - fixed: 'left', - }, { - title: '配置项', - dataIndex: 'keyName', - slotName: 'keyName', - ellipsis: true, - tooltip: true, - }, { - title: '配置名称', - dataIndex: 'name', - slotName: 'name', - ellipsis: true, - tooltip: true, - }, { - title: '配置描述', - dataIndex: 'label', - slotName: 'label', - ellipsis: true, - tooltip: true, - }, { - title: '配置值', - dataIndex: 'value', - slotName: 'value', - ellipsis: true, - tooltip: true, - }, { - title: '额外参数', - dataIndex: 'extra', - slotName: 'extra', - ellipsis: true, - tooltip: true, - }, { - title: '排序', - dataIndex: 'sort', - slotName: 'sort', - width: 70, - }, { - title: '修改时间', - dataIndex: 'updateTime', - slotName: 'updateTime', - width: 180, - render: ({ record }) => { - return dateFormat(new Date(record.updateTime)); - }, - }, { - title: '操作', - slotName: 'handle', - width: 160, - align: 'center', - fixed: 'right', - }, -] as TableColumnData[]; - -export default columns;