Commit 659023bb358512bc7c75178d6af7f8edb65ec1e1
1 parent
18a5c462
完成 FileConfig 的前端模块
Showing
10 changed files
with
411 additions
and
17 deletions
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
| @@ -80,4 +80,7 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | @@ -80,4 +80,7 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | ||
| 80 | entities.forEach(this::insert); | 80 | entities.forEach(this::insert); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | + default void updateBatch(T update) { | ||
| 84 | + update(update, new QueryWrapper<>()); | ||
| 85 | + } | ||
| 83 | } | 86 | } |
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
| @@ -47,5 +47,6 @@ public interface ErrorCodeConstants { | @@ -47,5 +47,6 @@ public interface ErrorCodeConstants { | ||
| 47 | 47 | ||
| 48 | // ========== 文件配置 1001006000 ========== | 48 | // ========== 文件配置 1001006000 ========== |
| 49 | ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1001006000, "文件配置不存在"); | 49 | ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1001006000, "文件配置不存在"); |
| 50 | + ErrorCode FILE_CONFIG_DELETE_FAIL_MASTER = new ErrorCode(1001006001, "该文件配置不允许删除,原因:它是主配置,删除会导致无法上传文件"); | ||
| 50 | 51 | ||
| 51 | } | 52 | } |
yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigRespVO.java
| @@ -19,13 +19,17 @@ public class FileConfigRespVO extends FileConfigBaseVO { | @@ -19,13 +19,17 @@ public class FileConfigRespVO extends FileConfigBaseVO { | ||
| 19 | @ApiModelProperty(value = "编号", required = true, example = "1") | 19 | @ApiModelProperty(value = "编号", required = true, example = "1") |
| 20 | private Long id; | 20 | private Long id; |
| 21 | 21 | ||
| 22 | - @ApiModelProperty(value = "存储配置", required = true) | ||
| 23 | - private FileClientConfig config; | 22 | + @ApiModelProperty(value = "存储器", required = true, example = "1", notes = "参见 FileStorageEnum 枚举类") |
| 23 | + @NotNull(message = "存储器不能为空") | ||
| 24 | + private Integer storage; | ||
| 24 | 25 | ||
| 25 | @ApiModelProperty(value = "是否为主配置", required = true, example = "true") | 26 | @ApiModelProperty(value = "是否为主配置", required = true, example = "true") |
| 26 | @NotNull(message = "是否为主配置不能为空") | 27 | @NotNull(message = "是否为主配置不能为空") |
| 27 | private Boolean master; | 28 | private Boolean master; |
| 28 | 29 | ||
| 30 | + @ApiModelProperty(value = "存储配置", required = true) | ||
| 31 | + private FileClientConfig config; | ||
| 32 | + | ||
| 29 | @ApiModelProperty(value = "创建时间", required = true) | 33 | @ApiModelProperty(value = "创建时间", required = true) |
| 30 | private Date createTime; | 34 | private Date createTime; |
| 31 | 35 |
yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java
| @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper; | @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper; | ||
| 15 | import cn.iocoder.yudao.module.infra.dal.mysql.codegen.SchemaColumnMapper; | 15 | import cn.iocoder.yudao.module.infra.dal.mysql.codegen.SchemaColumnMapper; |
| 16 | import cn.iocoder.yudao.module.infra.dal.mysql.codegen.SchemaTableMapper; | 16 | import cn.iocoder.yudao.module.infra.dal.mysql.codegen.SchemaTableMapper; |
| 17 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenImportTypeEnum; | 17 | import cn.iocoder.yudao.module.infra.enums.codegen.CodegenImportTypeEnum; |
| 18 | -import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; | ||
| 19 | import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; | 18 | import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; |
| 20 | import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder; | 19 | import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder; |
| 21 | import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine; | 20 | import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine; |
| @@ -26,7 +25,10 @@ import org.springframework.stereotype.Service; | @@ -26,7 +25,10 @@ import org.springframework.stereotype.Service; | ||
| 26 | import org.springframework.transaction.annotation.Transactional; | 25 | import org.springframework.transaction.annotation.Transactional; |
| 27 | 26 | ||
| 28 | import javax.annotation.Resource; | 27 | import javax.annotation.Resource; |
| 29 | -import java.util.*; | 28 | +import java.util.ArrayList; |
| 29 | +import java.util.List; | ||
| 30 | +import java.util.Map; | ||
| 31 | +import java.util.Set; | ||
| 30 | import java.util.stream.Collectors; | 32 | import java.util.stream.Collectors; |
| 31 | 33 | ||
| 32 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 34 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -81,10 +83,7 @@ public class CodegenServiceImpl implements CodegenService { | @@ -81,10 +83,7 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 81 | codegenTableMapper.insert(table); | 83 | codegenTableMapper.insert(table); |
| 82 | // 构建 CodegenColumnDO 数组,插入到 DB 中 | 84 | // 构建 CodegenColumnDO 数组,插入到 DB 中 |
| 83 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); | 85 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); |
| 84 | - columns.forEach(column -> { | ||
| 85 | - column.setTableId(table.getId()); | ||
| 86 | - codegenColumnMapper.insert(column); // TODO 批量插入 | ||
| 87 | - }); | 86 | + codegenColumnMapper.insertBatch(columns); |
| 88 | return table.getId(); | 87 | return table.getId(); |
| 89 | } | 88 | } |
| 90 | 89 | ||
| @@ -198,10 +197,7 @@ public class CodegenServiceImpl implements CodegenService { | @@ -198,10 +197,7 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 198 | 197 | ||
| 199 | // 插入新增的字段 | 198 | // 插入新增的字段 |
| 200 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); | 199 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); |
| 201 | - columns.forEach(column -> { | ||
| 202 | - column.setTableId(tableId); | ||
| 203 | - codegenColumnMapper.insert(column); // TODO 批量插入 | ||
| 204 | - }); | 200 | + codegenColumnMapper.insertBatch(columns); |
| 205 | // 删除不存在的字段 | 201 | // 删除不存在的字段 |
| 206 | if (CollUtil.isNotEmpty(deleteColumnIds)) { | 202 | if (CollUtil.isNotEmpty(deleteColumnIds)) { |
| 207 | codegenColumnMapper.deleteBatchIds(deleteColumnIds); | 203 | codegenColumnMapper.deleteBatchIds(deleteColumnIds); |
yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
| @@ -22,6 +22,9 @@ import lombok.extern.slf4j.Slf4j; | @@ -22,6 +22,9 @@ import lombok.extern.slf4j.Slf4j; | ||
| 22 | import org.springframework.context.annotation.Lazy; | 22 | import org.springframework.context.annotation.Lazy; |
| 23 | import org.springframework.scheduling.annotation.Scheduled; | 23 | import org.springframework.scheduling.annotation.Scheduled; |
| 24 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
| 25 | +import org.springframework.transaction.annotation.Transactional; | ||
| 26 | +import org.springframework.transaction.support.TransactionSynchronization; | ||
| 27 | +import org.springframework.transaction.support.TransactionSynchronizationManager; | ||
| 25 | import org.springframework.validation.annotation.Validated; | 28 | import org.springframework.validation.annotation.Validated; |
| 26 | 29 | ||
| 27 | import javax.annotation.PostConstruct; | 30 | import javax.annotation.PostConstruct; |
| @@ -33,6 +36,7 @@ import java.util.List; | @@ -33,6 +36,7 @@ import java.util.List; | ||
| 33 | import java.util.Map; | 36 | import java.util.Map; |
| 34 | 37 | ||
| 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 38 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 39 | +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_DELETE_FAIL_MASTER; | ||
| 36 | import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS; | 40 | import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_CONFIG_NOT_EXISTS; |
| 37 | 41 | ||
| 38 | /** | 42 | /** |
| @@ -151,13 +155,23 @@ public class FileConfigServiceImpl implements FileConfigService { | @@ -151,13 +155,23 @@ public class FileConfigServiceImpl implements FileConfigService { | ||
| 151 | } | 155 | } |
| 152 | 156 | ||
| 153 | @Override | 157 | @Override |
| 158 | + @Transactional(rollbackFor = Exception.class) | ||
| 154 | public void updateFileConfigMaster(Long id) { | 159 | public void updateFileConfigMaster(Long id) { |
| 155 | // 校验存在 | 160 | // 校验存在 |
| 156 | this.validateFileConfigExists(id); | 161 | this.validateFileConfigExists(id); |
| 162 | + // 更新其它为非 master | ||
| 163 | + fileConfigMapper.updateBatch(new FileConfigDO().setMaster(false)); | ||
| 157 | // 更新 | 164 | // 更新 |
| 158 | fileConfigMapper.updateById(new FileConfigDO().setId(id).setMaster(true)); | 165 | fileConfigMapper.updateById(new FileConfigDO().setId(id).setMaster(true)); |
| 159 | // 发送刷新配置的消息 | 166 | // 发送刷新配置的消息 |
| 160 | - fileConfigProducer.sendFileConfigRefreshMessage(); | 167 | + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { |
| 168 | + | ||
| 169 | + @Override | ||
| 170 | + public void afterCommit() { | ||
| 171 | + fileConfigProducer.sendFileConfigRefreshMessage(); | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + }); | ||
| 161 | } | 175 | } |
| 162 | 176 | ||
| 163 | private FileClientConfig parseClientConfig(Integer storage, Map<String, Object> config) { | 177 | private FileClientConfig parseClientConfig(Integer storage, Map<String, Object> config) { |
| @@ -174,7 +188,10 @@ public class FileConfigServiceImpl implements FileConfigService { | @@ -174,7 +188,10 @@ public class FileConfigServiceImpl implements FileConfigService { | ||
| 174 | @Override | 188 | @Override |
| 175 | public void deleteFileConfig(Long id) { | 189 | public void deleteFileConfig(Long id) { |
| 176 | // 校验存在 | 190 | // 校验存在 |
| 177 | - this.validateFileConfigExists(id); | 191 | + FileConfigDO config = this.validateFileConfigExists(id); |
| 192 | + if (Boolean.TRUE.equals(config.getMaster())) { | ||
| 193 | + throw exception(FILE_CONFIG_DELETE_FAIL_MASTER); | ||
| 194 | + } | ||
| 178 | // 删除 | 195 | // 删除 |
| 179 | fileConfigMapper.deleteById(id); | 196 | fileConfigMapper.deleteById(id); |
| 180 | // 发送刷新配置的消息 | 197 | // 发送刷新配置的消息 |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/RoleMenuMapper.java
| @@ -25,8 +25,7 @@ public interface RoleMenuMapper extends BaseMapperX<RoleMenuDO> { | @@ -25,8 +25,7 @@ public interface RoleMenuMapper extends BaseMapperX<RoleMenuDO> { | ||
| 25 | entity.setMenuId(menuId); | 25 | entity.setMenuId(menuId); |
| 26 | return entity; | 26 | return entity; |
| 27 | }).collect(Collectors.toList()); | 27 | }).collect(Collectors.toList()); |
| 28 | - // TODO 芋艿,mybatis plus 增加批量插入的功能 | ||
| 29 | - list.forEach(this::insert); | 28 | + insertBatch(list); |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | default void deleteListByRoleIdAndMenuIds(Long roleId, Collection<Long> menuIds) { | 31 | default void deleteListByRoleIdAndMenuIds(Long roleId, Collection<Long> menuIds) { |
yudao-ui-admin/src/api/infra/fileConfig.js
0 → 100755
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 创建文件配置 | ||
| 4 | +export function createFileConfig(data) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/infra/file-config/create', | ||
| 7 | + method: 'post', | ||
| 8 | + data: data | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 更新文件配置 | ||
| 13 | +export function updateFileConfig(data) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/infra/file-config/update', | ||
| 16 | + method: 'put', | ||
| 17 | + data: data | ||
| 18 | + }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// 更新文件配置为主配置 | ||
| 22 | +export function updateFileConfigMaster(id) { | ||
| 23 | + return request({ | ||
| 24 | + url: '/infra/file-config/update-master?id=' + id, | ||
| 25 | + method: 'put' | ||
| 26 | + }) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// 删除文件配置 | ||
| 30 | +export function deleteFileConfig(id) { | ||
| 31 | + return request({ | ||
| 32 | + url: '/infra/file-config/delete?id=' + id, | ||
| 33 | + method: 'delete' | ||
| 34 | + }) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// 获得文件配置 | ||
| 38 | +export function getFileConfig(id) { | ||
| 39 | + return request({ | ||
| 40 | + url: '/infra/file-config/get?id=' + id, | ||
| 41 | + method: 'get' | ||
| 42 | + }) | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +// 获得文件配置分页 | ||
| 46 | +export function getFileConfigPage(query) { | ||
| 47 | + return request({ | ||
| 48 | + url: '/infra/file-config/page', | ||
| 49 | + method: 'get', | ||
| 50 | + params: query | ||
| 51 | + }) | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +export function testFileConfig(id) { | ||
| 55 | + return request({ | ||
| 56 | + url: '/infra/file-config/test?id=' + id, | ||
| 57 | + method: 'get' | ||
| 58 | + }) | ||
| 59 | +} |
yudao-ui-admin/src/components/DictTag/index.vue
| @@ -17,7 +17,7 @@ export default { | @@ -17,7 +17,7 @@ export default { | ||
| 17 | name: "DictTag", | 17 | name: "DictTag", |
| 18 | props: { | 18 | props: { |
| 19 | type: String, | 19 | type: String, |
| 20 | - value: [Number, String, Array], | 20 | + value: [Number, String, Boolean, Array], |
| 21 | }, | 21 | }, |
| 22 | }; | 22 | }; |
| 23 | </script> | 23 | </script> |
yudao-ui-admin/src/utils/dict.js
| @@ -25,6 +25,7 @@ export const DICT_TYPE = { | @@ -25,6 +25,7 @@ export const DICT_TYPE = { | ||
| 25 | SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type', | 25 | SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type', |
| 26 | 26 | ||
| 27 | // ========== INFRA 模块 ========== | 27 | // ========== INFRA 模块 ========== |
| 28 | + INFRA_BOOLEAN_STRING: 'infra_boolean_string', | ||
| 28 | INFRA_REDIS_TIMEOUT_TYPE: 'infra_redis_timeout_type', | 29 | INFRA_REDIS_TIMEOUT_TYPE: 'infra_redis_timeout_type', |
| 29 | INFRA_JOB_STATUS: 'infra_job_status', | 30 | INFRA_JOB_STATUS: 'infra_job_status', |
| 30 | INFRA_JOB_LOG_STATUS: 'infra_job_log_status', | 31 | INFRA_JOB_LOG_STATUS: 'infra_job_log_status', |
| @@ -32,6 +33,7 @@ export const DICT_TYPE = { | @@ -32,6 +33,7 @@ export const DICT_TYPE = { | ||
| 32 | INFRA_CONFIG_TYPE: 'infra_config_type', | 33 | INFRA_CONFIG_TYPE: 'infra_config_type', |
| 33 | INFRA_CODEGEN_TEMPLATE_TYPE: 'infra_codegen_template_type', | 34 | INFRA_CODEGEN_TEMPLATE_TYPE: 'infra_codegen_template_type', |
| 34 | INFRA_CODEGEN_SCENE: 'infra_codegen_scene', | 35 | INFRA_CODEGEN_SCENE: 'infra_codegen_scene', |
| 36 | + INFRA_FILE_STORAGE: 'infra_file_storage', | ||
| 35 | 37 | ||
| 36 | // ========== BPM 模块 ========== | 38 | // ========== BPM 模块 ========== |
| 37 | BPM_MODEL_CATEGORY: 'bpm_model_category', | 39 | BPM_MODEL_CATEGORY: 'bpm_model_category', |
yudao-ui-admin/src/views/infra/fileConfig/index.vue
0 → 100755
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + | ||
| 4 | + <!-- 搜索工作栏 --> | ||
| 5 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 6 | + <el-form-item label="配置名" prop="name"> | ||
| 7 | + <el-input v-model="queryParams.name" placeholder="请输入配置名" clearable size="small" @keyup.enter.native="handleQuery"/> | ||
| 8 | + </el-form-item> | ||
| 9 | + <el-form-item label="存储器" prop="storage"> | ||
| 10 | + <el-select v-model="queryParams.storage" placeholder="请选择存储器" clearable size="small"> | ||
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_FILE_STORAGE)" | ||
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | ||
| 13 | + </el-select> | ||
| 14 | + </el-form-item> | ||
| 15 | + <el-form-item label="创建时间"> | ||
| 16 | + <el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" | ||
| 17 | + type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" /> | ||
| 18 | + </el-form-item> | ||
| 19 | + <el-form-item> | ||
| 20 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||
| 21 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||
| 22 | + </el-form-item> | ||
| 23 | + </el-form> | ||
| 24 | + | ||
| 25 | + <!-- 操作工具栏 --> | ||
| 26 | + <el-row :gutter="10" class="mb8"> | ||
| 27 | + <el-col :span="1.5"> | ||
| 28 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" | ||
| 29 | + v-hasPermi="['infra:file-config:create']">新增</el-button> | ||
| 30 | + </el-col> | ||
| 31 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 32 | + </el-row> | ||
| 33 | + | ||
| 34 | + <!-- 列表 --> | ||
| 35 | + <el-table v-loading="loading" :data="list"> | ||
| 36 | + <el-table-column label="编号" align="center" prop="id" /> | ||
| 37 | + <el-table-column label="配置名" align="center" prop="name" /> | ||
| 38 | + <el-table-column label="存储器" align="center" prop="storage"> | ||
| 39 | + <template slot-scope="scope"> | ||
| 40 | + <dict-tag :type="DICT_TYPE.INFRA_FILE_STORAGE" :value="scope.row.storage" /> | ||
| 41 | + </template> | ||
| 42 | + </el-table-column> | ||
| 43 | + <el-table-column label="备注" align="center" prop="remark" /> | ||
| 44 | + <el-table-column label="主配置" align="center" prop="primary"> | ||
| 45 | + <template slot-scope="scope"> | ||
| 46 | + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" /> | ||
| 47 | + </template> | ||
| 48 | + </el-table-column> | ||
| 49 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 50 | + <template slot-scope="scope"> | ||
| 51 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 52 | + </template> | ||
| 53 | + </el-table-column> | ||
| 54 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 55 | + <template slot-scope="scope"> | ||
| 56 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | ||
| 57 | + v-hasPermi="['infra:file-config:update']">修改</el-button> | ||
| 58 | + <el-button size="mini" type="text" icon="el-icon-attract" @click="handleMaster(scope.row)" | ||
| 59 | + :disabled="scope.row.master" v-hasPermi="['infra:file-config:update']">主配置</el-button> | ||
| 60 | + <el-button size="mini" type="text" icon="el-icon-share" @click="handleTest(scope.row)">测试</el-button> | ||
| 61 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | ||
| 62 | + v-hasPermi="['infra:file-config:delete']">删除</el-button> | ||
| 63 | + </template> | ||
| 64 | + </el-table-column> | ||
| 65 | + </el-table> | ||
| 66 | + <!-- 分页组件 --> | ||
| 67 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | ||
| 68 | + @pagination="getList"/> | ||
| 69 | + | ||
| 70 | + <!-- 对话框(添加 / 修改) --> | ||
| 71 | + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | ||
| 72 | + <el-form ref="form" :model="form" :rules="rules" label-width="120px"> | ||
| 73 | + <el-form-item label="配置名" prop="name"> | ||
| 74 | + <el-input v-model="form.name" placeholder="请输入配置名" /> | ||
| 75 | + </el-form-item> | ||
| 76 | + <el-form-item label="备注" prop="remark"> | ||
| 77 | + <el-input v-model="form.remark" placeholder="请输入备注" /> | ||
| 78 | + </el-form-item> | ||
| 79 | + <el-form-item label="存储器" prop="storage"> | ||
| 80 | + <el-select v-model="form.storage" placeholder="请选择存储器" :disabled="form.id"> | ||
| 81 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_FILE_STORAGE)" | ||
| 82 | + :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" /> | ||
| 83 | + </el-select> | ||
| 84 | + </el-form-item> | ||
| 85 | + <!-- DB --> | ||
| 86 | + <!-- Local / FTP / SFTP --> | ||
| 87 | + <el-form-item v-if="form.storage >= 10 && form.storage <= 12" label="基础路径" prop="config.basePath"> | ||
| 88 | + <el-input v-model="form.config.basePath" placeholder="请输入基础路径" /> | ||
| 89 | + </el-form-item> | ||
| 90 | + <el-form-item v-if="form.storage >= 11 && form.storage <= 12" label="主机地址" prop="config.host"> | ||
| 91 | + <el-input v-model="form.config.host" placeholder="请输入主机地址" /> | ||
| 92 | + </el-form-item> | ||
| 93 | + <el-form-item v-if="form.storage >= 11 && form.storage <= 12" label="主机端口" prop="config.port"> | ||
| 94 | + <el-input-number min="0" v-model="form.config.port" placeholder="请输入主机端口" /> | ||
| 95 | + </el-form-item> | ||
| 96 | + <el-form-item v-if="form.storage >= 11 && form.storage <= 12" label="用户名" prop="config.username"> | ||
| 97 | + <el-input v-model="form.config.username" placeholder="请输入密码" /> | ||
| 98 | + </el-form-item> | ||
| 99 | + <el-form-item v-if="form.storage >= 11 && form.storage <= 12" label="密码" prop="config.password"> | ||
| 100 | + <el-input v-model="form.config.password" placeholder="请输入密码" /> | ||
| 101 | + </el-form-item> | ||
| 102 | + <el-form-item v-if="form.storage === 11" label="连接模式" prop="config.mode"> | ||
| 103 | + <el-radio-group v-model="form.config.mode"> | ||
| 104 | + <el-radio key="Active" label="Active">主动模式</el-radio> | ||
| 105 | + <el-radio key="Passive" label="Passive">主动模式</el-radio> | ||
| 106 | + </el-radio-group> | ||
| 107 | + </el-form-item> | ||
| 108 | + <!-- S3 --> | ||
| 109 | + <el-form-item v-if="form.storage === 20" label="节点地址" prop="config.endpoint"> | ||
| 110 | + <el-input v-model="form.config.endpoint" placeholder="请输入节点地址" /> | ||
| 111 | + </el-form-item> | ||
| 112 | + <el-form-item v-if="form.storage === 20" label="区域" prop="config.region"> | ||
| 113 | + <el-input v-model="form.config.region" placeholder="请输入区域" /> | ||
| 114 | + </el-form-item> | ||
| 115 | + <el-form-item v-if="form.storage === 20" label="存储 bucket" prop="config.bucket"> | ||
| 116 | + <el-input v-model="form.config.bucket" placeholder="请输入 bucket" /> | ||
| 117 | + </el-form-item> | ||
| 118 | + <el-form-item v-if="form.storage === 20" label="accessKey" prop="config.accessKey"> | ||
| 119 | + <el-input v-model="form.config.accessKey" placeholder="请输入 accessKey" /> | ||
| 120 | + </el-form-item> | ||
| 121 | + <el-form-item v-if="form.storage === 20" label="accessSecret" prop="config.accessSecret"> | ||
| 122 | + <el-input v-model="form.config.accessSecret" placeholder="请输入 accessSecret" /> | ||
| 123 | + </el-form-item> | ||
| 124 | + <!-- 通用 --> | ||
| 125 | + <el-form-item v-if="form.storage === 20" label="自定义域名"> <!-- 无需参数校验,所以去掉 prop --> | ||
| 126 | + <el-input v-model="form.config.domain" placeholder="请输入自定义域名" /> | ||
| 127 | + </el-form-item> | ||
| 128 | + <el-form-item v-else-if="form.storage" label="自定义域名" prop="config.domain"> | ||
| 129 | + <el-input v-model="form.config.domain" placeholder="请输入自定义域名" /> | ||
| 130 | + </el-form-item> | ||
| 131 | + </el-form> | ||
| 132 | + <div slot="footer" class="dialog-footer"> | ||
| 133 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 134 | + <el-button @click="cancel">取 消</el-button> | ||
| 135 | + </div> | ||
| 136 | + </el-dialog> | ||
| 137 | + </div> | ||
| 138 | +</template> | ||
| 139 | + | ||
| 140 | +<script> | ||
| 141 | +import { | ||
| 142 | + createFileConfig, | ||
| 143 | + updateFileConfig, | ||
| 144 | + deleteFileConfig, | ||
| 145 | + getFileConfig, | ||
| 146 | + getFileConfigPage, | ||
| 147 | + testFileConfig, updateFileConfigMaster | ||
| 148 | +} from "@/api/infra/fileConfig"; | ||
| 149 | + | ||
| 150 | +export default { | ||
| 151 | + name: "FileConfig", | ||
| 152 | + components: { | ||
| 153 | + }, | ||
| 154 | + data() { | ||
| 155 | + return { | ||
| 156 | + // 遮罩层 | ||
| 157 | + loading: true, | ||
| 158 | + // 显示搜索条件 | ||
| 159 | + showSearch: true, | ||
| 160 | + // 总条数 | ||
| 161 | + total: 0, | ||
| 162 | + // 文件配置列表 | ||
| 163 | + list: [], | ||
| 164 | + // 弹出层标题 | ||
| 165 | + title: "", | ||
| 166 | + // 是否显示弹出层 | ||
| 167 | + open: false, | ||
| 168 | + dateRangeCreateTime: [], | ||
| 169 | + // 查询参数 | ||
| 170 | + queryParams: { | ||
| 171 | + pageNo: 1, | ||
| 172 | + pageSize: 10, | ||
| 173 | + name: null, | ||
| 174 | + storage: null, | ||
| 175 | + }, | ||
| 176 | + // 表单参数 | ||
| 177 | + form: { | ||
| 178 | + storage: undefined, | ||
| 179 | + config: {} | ||
| 180 | + }, | ||
| 181 | + // 表单校验 | ||
| 182 | + rules: { | ||
| 183 | + name: [{ required: true, message: "配置名不能为空", trigger: "blur" }], | ||
| 184 | + storage: [{ required: true, message: "存储器不能为空", trigger: "change" }], | ||
| 185 | + config: { | ||
| 186 | + basePath: [{ required: true, message: "基础路径不能为空", trigger: "blur" }], | ||
| 187 | + host: [{ required: true, message: "主机地址不能为空", trigger: "blur" }], | ||
| 188 | + port: [{ required: true, message: "主机端口不能为空", trigger: "blur" }], | ||
| 189 | + username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], | ||
| 190 | + password: [{ required: true, message: "密码不能为空", trigger: "blur" }], | ||
| 191 | + mode: [{ required: true, message: "连接模式不能为空", trigger: "change" }], | ||
| 192 | + endpoint: [{ required: true, message: "节点地址不能为空", trigger: "blur" }], | ||
| 193 | + region: [{ required: true, message: "区域名不能为空", trigger: "blur" }], | ||
| 194 | + bucket: [{ required: true, message: "存储 bucket 不能为空", trigger: "blur" }], | ||
| 195 | + accessKey: [{ required: true, message: "accessKey 不能为空", trigger: "blur" }], | ||
| 196 | + accessSecret: [{ required: true, message: "accessSecret 不能为空", trigger: "blur" }], | ||
| 197 | + domain: [{ required: true, message: "自定义域名不能为空", trigger: "blur" }], | ||
| 198 | + }, | ||
| 199 | + } | ||
| 200 | + }; | ||
| 201 | + }, | ||
| 202 | + created() { | ||
| 203 | + this.getList(); | ||
| 204 | + }, | ||
| 205 | + methods: { | ||
| 206 | + /** 查询列表 */ | ||
| 207 | + getList() { | ||
| 208 | + this.loading = true; | ||
| 209 | + // 处理查询参数 | ||
| 210 | + let params = {...this.queryParams}; | ||
| 211 | + this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); | ||
| 212 | + // 执行查询 | ||
| 213 | + getFileConfigPage(params).then(response => { | ||
| 214 | + this.list = response.data.list; | ||
| 215 | + this.total = response.data.total; | ||
| 216 | + this.loading = false; | ||
| 217 | + }); | ||
| 218 | + }, | ||
| 219 | + /** 取消按钮 */ | ||
| 220 | + cancel() { | ||
| 221 | + this.open = false; | ||
| 222 | + this.reset(); | ||
| 223 | + }, | ||
| 224 | + /** 表单重置 */ | ||
| 225 | + reset() { | ||
| 226 | + this.form = { | ||
| 227 | + id: undefined, | ||
| 228 | + name: undefined, | ||
| 229 | + storage: undefined, | ||
| 230 | + remark: undefined, | ||
| 231 | + config: {}, | ||
| 232 | + }; | ||
| 233 | + this.resetForm("form"); | ||
| 234 | + }, | ||
| 235 | + /** 搜索按钮操作 */ | ||
| 236 | + handleQuery() { | ||
| 237 | + this.queryParams.pageNo = 1; | ||
| 238 | + this.getList(); | ||
| 239 | + }, | ||
| 240 | + /** 重置按钮操作 */ | ||
| 241 | + resetQuery() { | ||
| 242 | + this.dateRangeCreateTime = []; | ||
| 243 | + this.resetForm("queryForm"); | ||
| 244 | + this.handleQuery(); | ||
| 245 | + }, | ||
| 246 | + /** 新增按钮操作 */ | ||
| 247 | + handleAdd() { | ||
| 248 | + this.reset(); | ||
| 249 | + this.open = true; | ||
| 250 | + this.title = "添加文件配置"; | ||
| 251 | + }, | ||
| 252 | + /** 修改按钮操作 */ | ||
| 253 | + handleUpdate(row) { | ||
| 254 | + this.reset(); | ||
| 255 | + const id = row.id; | ||
| 256 | + getFileConfig(id).then(response => { | ||
| 257 | + this.form = response.data; | ||
| 258 | + this.open = true; | ||
| 259 | + this.title = "修改文件配置"; | ||
| 260 | + }); | ||
| 261 | + }, | ||
| 262 | + /** 提交按钮 */ | ||
| 263 | + submitForm() { | ||
| 264 | + this.$refs["form"].validate(valid => { | ||
| 265 | + if (!valid) { | ||
| 266 | + return; | ||
| 267 | + } | ||
| 268 | + // 修改的提交 | ||
| 269 | + if (this.form.id != null) { | ||
| 270 | + updateFileConfig(this.form).then(response => { | ||
| 271 | + this.$modal.msgSuccess("修改成功"); | ||
| 272 | + this.open = false; | ||
| 273 | + this.getList(); | ||
| 274 | + }); | ||
| 275 | + return; | ||
| 276 | + } | ||
| 277 | + // 添加的提交 | ||
| 278 | + createFileConfig(this.form).then(response => { | ||
| 279 | + this.$modal.msgSuccess("新增成功"); | ||
| 280 | + this.open = false; | ||
| 281 | + this.getList(); | ||
| 282 | + }); | ||
| 283 | + }); | ||
| 284 | + }, | ||
| 285 | + /** 删除按钮操作 */ | ||
| 286 | + handleDelete(row) { | ||
| 287 | + const id = row.id; | ||
| 288 | + this.$modal.confirm('是否确认删除文件配置编号为"' + id + '"的数据项?').then(function() { | ||
| 289 | + return deleteFileConfig(id); | ||
| 290 | + }).then(() => { | ||
| 291 | + this.getList(); | ||
| 292 | + this.$modal.msgSuccess("删除成功"); | ||
| 293 | + }).catch(() => {}); | ||
| 294 | + }, | ||
| 295 | + /** 主配置按钮操作 */ | ||
| 296 | + handleMaster(row) { | ||
| 297 | + const id = row.id; | ||
| 298 | + this.$modal.confirm('是否确认修改配置编号为"' + id + '"的数据项为主配置?').then(function() { | ||
| 299 | + return updateFileConfigMaster(id); | ||
| 300 | + }).then(() => { | ||
| 301 | + this.getList(); | ||
| 302 | + this.$modal.msgSuccess("修改成功"); | ||
| 303 | + }).catch(() => {}); | ||
| 304 | + }, | ||
| 305 | + /** 测试按钮操作 */ | ||
| 306 | + handleTest(row) { | ||
| 307 | + testFileConfig(row.id).then((response) => { | ||
| 308 | + this.$modal.alert("测试通过,上传文件成功!访问地址:" + response.data); | ||
| 309 | + }).catch(() => {}); | ||
| 310 | + }, | ||
| 311 | + } | ||
| 312 | +}; | ||
| 313 | +</script> |