Commit b0437b7e by yuwei

项目初始化

parent 68449eaa
...@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
...@@ -41,6 +40,8 @@ public class ModelColumnDto implements Serializable { ...@@ -41,6 +40,8 @@ public class ModelColumnDto implements Serializable {
private String columnScale; private String columnScale;
@ApiModelProperty(value = "列默认值") @ApiModelProperty(value = "列默认值")
private String defaultValue; private String defaultValue;
@ApiModelProperty(value = "是否系统默认(0否,1是)")
private String isSystem;
@ApiModelProperty(value = "是否主键(0否,1是)") @ApiModelProperty(value = "是否主键(0否,1是)")
private String isPk; private String isPk;
@ApiModelProperty(value = "是否必填(0否,1是)") @ApiModelProperty(value = "是否必填(0否,1是)")
......
package cn.datax.service.data.masterdata.api.entity; package cn.datax.service.data.masterdata.api.entity;
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum; import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
import cn.datax.service.data.masterdata.api.parser.ColumnParser; import cn.datax.service.data.masterdata.api.parser.ColumnParser;
import cn.datax.service.data.masterdata.api.parser.DataType; import cn.datax.service.data.masterdata.api.parser.DataType;
import cn.datax.service.data.masterdata.api.parser.oracle.OracleColumnParser; import cn.datax.service.data.masterdata.api.parser.mysql.MysqlColumnParser;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import cn.datax.common.base.BaseEntity; import cn.datax.common.base.BaseEntity;
...@@ -63,6 +63,11 @@ public class ModelColumnEntity extends BaseEntity { ...@@ -63,6 +63,11 @@ public class ModelColumnEntity extends BaseEntity {
private String defaultValue; private String defaultValue;
/** /**
* 是否系统默认(0否,1是)
*/
private String isSystem;
/**
* 是否主键(0否,1是) * 是否主键(0否,1是)
*/ */
private String isPk; private String isPk;
...@@ -128,9 +133,9 @@ public class ModelColumnEntity extends BaseEntity { ...@@ -128,9 +133,9 @@ public class ModelColumnEntity extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String columnDefinition; private String columnDefinition;
public String getColumnDefinition() throws Exception { public String getColumnDefinition() {
ColumnParser columnParser = new OracleColumnParser(); ColumnParser columnParser = new MysqlColumnParser();
DataType parse = columnParser.parse(OracleDataTypeEnum.match(this.columnType, OracleDataTypeEnum.CHAR)); DataType parse = columnParser.mysqlParse(MysqlDataTypeEnum.match(this.columnType, MysqlDataTypeEnum.VARCHAR));
return parse.fillTypeString(this.columnLength, this.columnScale); return parse.fillTypeString(this.columnLength, this.columnScale);
} }
} }
...@@ -40,6 +40,11 @@ public class ModelEntity extends DataScopeBaseEntity { ...@@ -40,6 +40,11 @@ public class ModelEntity extends DataScopeBaseEntity {
*/ */
private String modelPhysicalTable; private String modelPhysicalTable;
/**
* 是否建模(0否,1是)
*/
private String isSync;
@TableField(exist = false) @TableField(exist = false)
private List<ModelColumnEntity> modelColumns; private List<ModelColumnEntity> modelColumns;
} }
package cn.datax.service.data.masterdata.api.enums;
public enum MysqlDataTypeEnum {
TINYINT("tinyint", "tinyint整型"), INT("int", "int整型"), BIGINT("bigint", "bigint整型"),
FLOAT("float", "单精度"), DOUBLE("double", "双精度"), DECIMAL("decimal", "定点数"),
CHAR("char", "定长字符串"), VARCHAR("varchar", "变长字符串"), TEXT("text", "长文本"),
DATE("date", "date日期"), TIME("time", "time日期"), YEAR("year", "year日期"), DATETIME("datetime", "datetime日期"),
BLOB("blob", "二进制");
private String value;
private String title;
MysqlDataTypeEnum(String value, String title) {
this.value = value;
this.title = title;
}
public String getValue() {
return value;
}
public String getTitle() {
return title;
}
public static MysqlDataTypeEnum match(String value, MysqlDataTypeEnum defaultItem) {
if (value != null) {
for (MysqlDataTypeEnum item: MysqlDataTypeEnum.values()) {
if (item.getValue().equals(value)) {
return item;
}
}
}
return defaultItem;
}
}
...@@ -2,7 +2,7 @@ package cn.datax.service.data.masterdata.api.enums; ...@@ -2,7 +2,7 @@ package cn.datax.service.data.masterdata.api.enums;
public enum OracleDataTypeEnum { public enum OracleDataTypeEnum {
CHAR("char", "字符串"), NUMBER("number", "数值"), DATE("date", "日期"), CLOB("clob", "文本"), BLOB("blob", "二进制"); CHAR("char", "字符串"), NUMBER("number", "数值"), DATE("date", "日期"), CLOB("clob", "文本"), BLOB("blob", "二进制");
private String value; private String value;
private String title; private String title;
......
package cn.datax.service.data.masterdata.api.parser; package cn.datax.service.data.masterdata.api.parser;
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum; import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
public interface ColumnParser { public abstract class ColumnParser {
DataType parse(OracleDataTypeEnum dataTypeEnum) throws Exception; public abstract DataType oracleParse(OracleDataTypeEnum dataTypeEnum);
public abstract DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum);
} }
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlBigintDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "bigint";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlBlobDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "blob";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
import java.util.Optional;
public class MysqlCharDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "char(" + Optional.ofNullable(columnLength).orElse("1") + ")";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.common.exception.DataException;
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
import cn.datax.service.data.masterdata.api.parser.ColumnParser;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlColumnParser extends ColumnParser {
@Override
public DataType oracleParse(OracleDataTypeEnum dataTypeEnum) {
return null;
}
@Override
public DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum) {
switch(dataTypeEnum) {
case TINYINT:
return new MysqlTinyintDataType();
case INT:
return new MysqlIntDataType();
case BIGINT:
return new MysqlBigintDataType();
case FLOAT:
return new MysqlFloatDataType();
case DOUBLE:
return new MysqlDoubleDataType();
case DECIMAL:
return new MysqlDecimalDataType();
case CHAR:
return new MysqlCharDataType();
case VARCHAR:
return new MysqlVarcharDataType();
case TEXT:
return new MysqlTextDataType();
case DATE:
return new MysqlDateDataType();
case TIME:
return new MysqlTimeDataType();
case YEAR:
return new MysqlYearDataType();
case DATETIME:
return new MysqlDatetimeDataType();
case BLOB:
return new MysqlBlobDataType();
default:
throw new DataException("字段数据类型错误");
}
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlDateDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "date";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlDatetimeDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "datetime";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
import java.util.Optional;
public class MysqlDecimalDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "decimal(" + Optional.ofNullable(columnLength).orElse("10") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
import java.util.Optional;
public class MysqlDoubleDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "double(" + Optional.ofNullable(columnLength).orElse("5") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
import java.util.Optional;
public class MysqlFloatDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "float(" + Optional.ofNullable(columnLength).orElse("5") + ", " + Optional.ofNullable(columnScale).orElse("2") + ")";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlIntDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "int";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlTextDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "text";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlTimeDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "time";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlTinyintDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "tinyint";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
import java.util.Optional;
public class MysqlVarcharDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "varchar(" + Optional.ofNullable(columnLength).orElse("255") + ")";
}
}
package cn.datax.service.data.masterdata.api.parser.mysql;
import cn.datax.service.data.masterdata.api.parser.DataType;
public class MysqlYearDataType implements DataType {
@Override
public String fillTypeString(String columnLength, String columnScale) {
return "year";
}
}
package cn.datax.service.data.masterdata.api.parser.oracle; package cn.datax.service.data.masterdata.api.parser.oracle;
import cn.datax.common.exception.DataException; import cn.datax.common.exception.DataException;
import cn.datax.service.data.masterdata.api.enums.MysqlDataTypeEnum;
import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum; import cn.datax.service.data.masterdata.api.enums.OracleDataTypeEnum;
import cn.datax.service.data.masterdata.api.parser.ColumnParser; import cn.datax.service.data.masterdata.api.parser.ColumnParser;
import cn.datax.service.data.masterdata.api.parser.DataType; import cn.datax.service.data.masterdata.api.parser.DataType;
public class OracleColumnParser implements ColumnParser { public class OracleColumnParser extends ColumnParser {
@Override @Override
public DataType parse(OracleDataTypeEnum dataTypeEnum) throws Exception { public DataType oracleParse(OracleDataTypeEnum dataTypeEnum) {
switch(dataTypeEnum) { switch(dataTypeEnum) {
case CHAR: case CHAR:
return new OracleCharDataType(); return new OracleCharDataType();
...@@ -20,7 +21,13 @@ public class OracleColumnParser implements ColumnParser { ...@@ -20,7 +21,13 @@ public class OracleColumnParser implements ColumnParser {
return new OracleClobDataType(); return new OracleClobDataType();
case BLOB: case BLOB:
return new OracleBlobDataType(); return new OracleBlobDataType();
default:
throw new DataException("字段数据类型错误");
} }
throw new DataException("字段数据类型错误"); }
@Override
public DataType mysqlParse(MysqlDataTypeEnum dataTypeEnum) {
return null;
} }
} }
...@@ -30,6 +30,7 @@ public class ModelColumnVo implements Serializable { ...@@ -30,6 +30,7 @@ public class ModelColumnVo implements Serializable {
private String columnLength; private String columnLength;
private String columnScale; private String columnScale;
private String defaultValue; private String defaultValue;
private String isSystem;
private String isPk; private String isPk;
private String isRequired; private String isRequired;
private String isInsert; private String isInsert;
......
...@@ -27,5 +27,6 @@ public class ModelVo implements Serializable { ...@@ -27,5 +27,6 @@ public class ModelVo implements Serializable {
private String modelName; private String modelName;
private String modelLogicTable; private String modelLogicTable;
private String modelPhysicalTable; private String modelPhysicalTable;
private String isSync;
private List<ModelColumnVo> modelColumns; private List<ModelColumnVo> modelColumns;
} }
...@@ -7,7 +7,7 @@ import cn.datax.service.data.masterdata.api.dto.ModelColumnDto; ...@@ -7,7 +7,7 @@ import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity; import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
import cn.datax.service.data.masterdata.api.vo.ModelColumnVo; import cn.datax.service.data.masterdata.api.vo.ModelColumnVo;
import cn.datax.service.data.masterdata.api.query.ModelColumnQuery; import cn.datax.service.data.masterdata.api.query.ModelColumnQuery;
import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapper; import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapstruct;
import cn.datax.service.data.masterdata.service.ModelColumnService; import cn.datax.service.data.masterdata.service.ModelColumnService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -43,7 +43,7 @@ public class ModelColumnController extends BaseController { ...@@ -43,7 +43,7 @@ public class ModelColumnController extends BaseController {
private ModelColumnService modelColumnService; private ModelColumnService modelColumnService;
@Autowired @Autowired
private ModelColumnMapper modelColumnMapper; private ModelColumnMapstruct modelColumnMapstruct;
/** /**
* 通过ID查询信息 * 通过ID查询信息
...@@ -56,7 +56,7 @@ public class ModelColumnController extends BaseController { ...@@ -56,7 +56,7 @@ public class ModelColumnController extends BaseController {
@GetMapping("/{id}") @GetMapping("/{id}")
public R getModelColumnById(@PathVariable String id) { public R getModelColumnById(@PathVariable String id) {
ModelColumnEntity modelColumnEntity = modelColumnService.getModelColumnById(id); ModelColumnEntity modelColumnEntity = modelColumnService.getModelColumnById(id);
return R.ok().setData(modelColumnMapper.toVO(modelColumnEntity)); return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
} }
/** /**
...@@ -75,7 +75,7 @@ public class ModelColumnController extends BaseController { ...@@ -75,7 +75,7 @@ public class ModelColumnController extends BaseController {
queryWrapper.eq(StrUtil.isNotBlank(modelColumnQuery.getModelId()), "model_id", modelColumnQuery.getModelId()); queryWrapper.eq(StrUtil.isNotBlank(modelColumnQuery.getModelId()), "model_id", modelColumnQuery.getModelId());
queryWrapper.like(StrUtil.isNotBlank(modelColumnQuery.getColumnName()), "column_name", modelColumnQuery.getColumnName()); queryWrapper.like(StrUtil.isNotBlank(modelColumnQuery.getColumnName()), "column_name", modelColumnQuery.getColumnName());
IPage<ModelColumnEntity> page = modelColumnService.page(new Page<>(modelColumnQuery.getPageNum(), modelColumnQuery.getPageSize()), queryWrapper); IPage<ModelColumnEntity> page = modelColumnService.page(new Page<>(modelColumnQuery.getPageNum(), modelColumnQuery.getPageSize()), queryWrapper);
List<ModelColumnVo> collect = page.getRecords().stream().map(modelColumnMapper::toVO).collect(Collectors.toList()); List<ModelColumnVo> collect = page.getRecords().stream().map(modelColumnMapstruct::toVO).collect(Collectors.toList());
JsonPage<ModelColumnVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect); JsonPage<ModelColumnVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
return R.ok().setData(jsonPage); return R.ok().setData(jsonPage);
} }
...@@ -90,7 +90,7 @@ public class ModelColumnController extends BaseController { ...@@ -90,7 +90,7 @@ public class ModelColumnController extends BaseController {
@PostMapping() @PostMapping()
public R saveModelColumn(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelColumnDto modelColumn) { public R saveModelColumn(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelColumnDto modelColumn) {
ModelColumnEntity modelColumnEntity = modelColumnService.saveModelColumn(modelColumn); ModelColumnEntity modelColumnEntity = modelColumnService.saveModelColumn(modelColumn);
return R.ok().setData(modelColumnMapper.toVO(modelColumnEntity)); return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
} }
/** /**
...@@ -106,7 +106,7 @@ public class ModelColumnController extends BaseController { ...@@ -106,7 +106,7 @@ public class ModelColumnController extends BaseController {
@PutMapping("/{id}") @PutMapping("/{id}")
public R updateModelColumn(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelColumnDto modelColumn) { public R updateModelColumn(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelColumnDto modelColumn) {
ModelColumnEntity modelColumnEntity = modelColumnService.updateModelColumn(modelColumn); ModelColumnEntity modelColumnEntity = modelColumnService.updateModelColumn(modelColumn);
return R.ok().setData(modelColumnMapper.toVO(modelColumnEntity)); return R.ok().setData(modelColumnMapstruct.toVO(modelColumnEntity));
} }
/** /**
......
...@@ -7,7 +7,7 @@ import cn.datax.service.data.masterdata.api.dto.ModelDto; ...@@ -7,7 +7,7 @@ import cn.datax.service.data.masterdata.api.dto.ModelDto;
import cn.datax.service.data.masterdata.api.entity.ModelEntity; import cn.datax.service.data.masterdata.api.entity.ModelEntity;
import cn.datax.service.data.masterdata.api.vo.ModelVo; import cn.datax.service.data.masterdata.api.vo.ModelVo;
import cn.datax.service.data.masterdata.api.query.ModelQuery; import cn.datax.service.data.masterdata.api.query.ModelQuery;
import cn.datax.service.data.masterdata.mapstruct.ModelMapper; import cn.datax.service.data.masterdata.mapstruct.ModelMapstruct;
import cn.datax.service.data.masterdata.service.ModelService; import cn.datax.service.data.masterdata.service.ModelService;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -43,7 +43,7 @@ public class ModelController extends BaseController { ...@@ -43,7 +43,7 @@ public class ModelController extends BaseController {
private ModelService modelService; private ModelService modelService;
@Autowired @Autowired
private ModelMapper modelMapper; private ModelMapstruct modelMapstruct;
/** /**
* 通过ID查询信息 * 通过ID查询信息
...@@ -56,7 +56,7 @@ public class ModelController extends BaseController { ...@@ -56,7 +56,7 @@ public class ModelController extends BaseController {
@GetMapping("/{id}") @GetMapping("/{id}")
public R getModelById(@PathVariable String id) { public R getModelById(@PathVariable String id) {
ModelEntity modelEntity = modelService.getModelById(id); ModelEntity modelEntity = modelService.getModelById(id);
return R.ok().setData(modelMapper.toVO(modelEntity)); return R.ok().setData(modelMapstruct.toVO(modelEntity));
} }
/** /**
...@@ -74,7 +74,7 @@ public class ModelController extends BaseController { ...@@ -74,7 +74,7 @@ public class ModelController extends BaseController {
QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StrUtil.isNotBlank(modelQuery.getModelName()), "model_name", modelQuery.getModelName()); queryWrapper.like(StrUtil.isNotBlank(modelQuery.getModelName()), "model_name", modelQuery.getModelName());
IPage<ModelEntity> page = modelService.page(new Page<>(modelQuery.getPageNum(), modelQuery.getPageSize()), queryWrapper); IPage<ModelEntity> page = modelService.page(new Page<>(modelQuery.getPageNum(), modelQuery.getPageSize()), queryWrapper);
List<ModelVo> collect = page.getRecords().stream().map(modelMapper::toVO).collect(Collectors.toList()); List<ModelVo> collect = page.getRecords().stream().map(modelMapstruct::toVO).collect(Collectors.toList());
JsonPage<ModelVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect); JsonPage<ModelVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
return R.ok().setData(jsonPage); return R.ok().setData(jsonPage);
} }
...@@ -89,7 +89,7 @@ public class ModelController extends BaseController { ...@@ -89,7 +89,7 @@ public class ModelController extends BaseController {
@PostMapping() @PostMapping()
public R saveModel(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelDto model) { public R saveModel(@RequestBody @Validated({ValidationGroups.Insert.class}) ModelDto model) {
ModelEntity modelEntity = modelService.saveModel(model); ModelEntity modelEntity = modelService.saveModel(model);
return R.ok().setData(modelMapper.toVO(modelEntity)); return R.ok().setData(modelMapstruct.toVO(modelEntity));
} }
/** /**
...@@ -105,7 +105,7 @@ public class ModelController extends BaseController { ...@@ -105,7 +105,7 @@ public class ModelController extends BaseController {
@PutMapping("/{id}") @PutMapping("/{id}")
public R updateModel(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelDto model) { public R updateModel(@PathVariable String id, @RequestBody @Validated({ValidationGroups.Update.class}) ModelDto model) {
ModelEntity modelEntity = modelService.updateModel(model); ModelEntity modelEntity = modelService.updateModel(model);
return R.ok().setData(modelMapper.toVO(modelEntity)); return R.ok().setData(modelMapstruct.toVO(modelEntity));
} }
/** /**
...@@ -133,4 +133,10 @@ public class ModelController extends BaseController { ...@@ -133,4 +133,10 @@ public class ModelController extends BaseController {
modelService.deleteModelBatch(ids); modelService.deleteModelBatch(ids);
return R.ok(); return R.ok();
} }
@PostMapping("/table/{id}")
public R createTable(@PathVariable String id) {
modelService.createTable(id);
return R.ok();
}
} }
package cn.datax.service.data.masterdata.dao;
import cn.datax.service.data.masterdata.api.entity.ModelDataEntity;
import cn.datax.service.data.masterdata.api.entity.ModelEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface MysqlDynamicDao {
void createTable(ModelEntity modelEntity);
void dropTable(@Param("tableName") String tableName);
void insertData(ModelDataEntity modelDataEntity);
void updateData(ModelDataEntity modelDataEntity);
void deleteData(ModelDataEntity modelDataEntity);
}
...@@ -15,6 +15,6 @@ import org.mapstruct.Mapper; ...@@ -15,6 +15,6 @@ import org.mapstruct.Mapper;
* @since 2020-08-26 * @since 2020-08-26
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface ModelColumnMapper extends EntityMapper<ModelColumnDto, ModelColumnEntity, ModelColumnVo> { public interface ModelColumnMapstruct extends EntityMapper<ModelColumnDto, ModelColumnEntity, ModelColumnVo> {
} }
...@@ -15,6 +15,6 @@ import org.mapstruct.Mapper; ...@@ -15,6 +15,6 @@ import org.mapstruct.Mapper;
* @since 2020-08-26 * @since 2020-08-26
*/ */
@Mapper(componentModel = "spring") @Mapper(componentModel = "spring")
public interface ModelMapper extends EntityMapper<ModelDto, ModelEntity, ModelVo> { public interface ModelMapstruct extends EntityMapper<ModelDto, ModelEntity, ModelVo> {
} }
...@@ -25,4 +25,6 @@ public interface ModelService extends BaseService<ModelEntity> { ...@@ -25,4 +25,6 @@ public interface ModelService extends BaseService<ModelEntity> {
void deleteModelById(String id); void deleteModelById(String id);
void deleteModelBatch(List<String> ids); void deleteModelBatch(List<String> ids);
void createTable(String id);
} }
...@@ -3,7 +3,7 @@ package cn.datax.service.data.masterdata.service.impl; ...@@ -3,7 +3,7 @@ package cn.datax.service.data.masterdata.service.impl;
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity; import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
import cn.datax.service.data.masterdata.api.dto.ModelColumnDto; import cn.datax.service.data.masterdata.api.dto.ModelColumnDto;
import cn.datax.service.data.masterdata.service.ModelColumnService; import cn.datax.service.data.masterdata.service.ModelColumnService;
import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapper; import cn.datax.service.data.masterdata.mapstruct.ModelColumnMapstruct;
import cn.datax.service.data.masterdata.dao.ModelColumnDao; import cn.datax.service.data.masterdata.dao.ModelColumnDao;
import cn.datax.common.base.BaseServiceImpl; import cn.datax.common.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -29,12 +29,12 @@ public class ModelColumnServiceImpl extends BaseServiceImpl<ModelColumnDao, Mode ...@@ -29,12 +29,12 @@ public class ModelColumnServiceImpl extends BaseServiceImpl<ModelColumnDao, Mode
private ModelColumnDao modelColumnDao; private ModelColumnDao modelColumnDao;
@Autowired @Autowired
private ModelColumnMapper modelColumnMapper; private ModelColumnMapstruct modelColumnMapstruct;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ModelColumnEntity saveModelColumn(ModelColumnDto modelColumnDto) { public ModelColumnEntity saveModelColumn(ModelColumnDto modelColumnDto) {
ModelColumnEntity modelColumn = modelColumnMapper.toEntity(modelColumnDto); ModelColumnEntity modelColumn = modelColumnMapstruct.toEntity(modelColumnDto);
modelColumnDao.insert(modelColumn); modelColumnDao.insert(modelColumn);
return modelColumn; return modelColumn;
} }
...@@ -42,7 +42,7 @@ public class ModelColumnServiceImpl extends BaseServiceImpl<ModelColumnDao, Mode ...@@ -42,7 +42,7 @@ public class ModelColumnServiceImpl extends BaseServiceImpl<ModelColumnDao, Mode
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ModelColumnEntity updateModelColumn(ModelColumnDto modelColumnDto) { public ModelColumnEntity updateModelColumn(ModelColumnDto modelColumnDto) {
ModelColumnEntity modelColumn = modelColumnMapper.toEntity(modelColumnDto); ModelColumnEntity modelColumn = modelColumnMapstruct.toEntity(modelColumnDto);
modelColumnDao.updateById(modelColumn); modelColumnDao.updateById(modelColumn);
return modelColumn; return modelColumn;
} }
......
package cn.datax.service.data.masterdata.service.impl; package cn.datax.service.data.masterdata.service.impl;
import cn.datax.common.core.DataConstant;
import cn.datax.common.exception.DataException;
import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity; import cn.datax.service.data.masterdata.api.entity.ModelColumnEntity;
import cn.datax.service.data.masterdata.api.entity.ModelEntity; import cn.datax.service.data.masterdata.api.entity.ModelEntity;
import cn.datax.service.data.masterdata.api.dto.ModelDto; import cn.datax.service.data.masterdata.api.dto.ModelDto;
import cn.datax.service.data.masterdata.dao.ModelColumnDao; import cn.datax.service.data.masterdata.dao.ModelColumnDao;
import cn.datax.service.data.masterdata.dao.MysqlDynamicDao;
import cn.datax.service.data.masterdata.mapstruct.ModelMapstruct;
import cn.datax.service.data.masterdata.service.ModelService; import cn.datax.service.data.masterdata.service.ModelService;
import cn.datax.service.data.masterdata.mapstruct.ModelMapper;
import cn.datax.service.data.masterdata.dao.ModelDao; import cn.datax.service.data.masterdata.dao.ModelDao;
import cn.datax.common.base.BaseServiceImpl; import cn.datax.common.base.BaseServiceImpl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
...@@ -36,15 +39,19 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp ...@@ -36,15 +39,19 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
private ModelDao modelDao; private ModelDao modelDao;
@Autowired @Autowired
private ModelMapper modelMapper; private ModelMapstruct modelMapstruct;
@Autowired @Autowired
private ModelColumnDao modelColumnDao; private ModelColumnDao modelColumnDao;
@Autowired
private MysqlDynamicDao dynamicDao;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ModelEntity saveModel(ModelDto modelDto) { public ModelEntity saveModel(ModelDto modelDto) {
ModelEntity model = modelMapper.toEntity(modelDto); ModelEntity model = modelMapstruct.toEntity(modelDto);
model.setIsSync(DataConstant.TrueOrFalse.FALSE.getKey());
model.setModelPhysicalTable("dynamic_" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN)); model.setModelPhysicalTable("dynamic_" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN));
modelDao.insert(model); modelDao.insert(model);
String modelId = model.getId(); String modelId = model.getId();
...@@ -61,7 +68,7 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp ...@@ -61,7 +68,7 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ModelEntity updateModel(ModelDto modelDto) { public ModelEntity updateModel(ModelDto modelDto) {
ModelEntity model = modelMapper.toEntity(modelDto); ModelEntity model = modelMapstruct.toEntity(modelDto);
modelDao.updateById(model); modelDao.updateById(model);
String modelId = model.getId(); String modelId = model.getId();
modelColumnDao.delete(Wrappers.<ModelColumnEntity>lambdaQuery() modelColumnDao.delete(Wrappers.<ModelColumnEntity>lambdaQuery()
...@@ -97,4 +104,15 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp ...@@ -97,4 +104,15 @@ public class ModelServiceImpl extends BaseServiceImpl<ModelDao, ModelEntity> imp
.in(ModelColumnEntity::getModelId, ids)); .in(ModelColumnEntity::getModelId, ids));
modelDao.deleteBatchIds(ids); modelDao.deleteBatchIds(ids);
} }
@Override
public void createTable(String id) {
ModelEntity modelEntity = super.getById(id);
if (DataConstant.TrueOrFalse.TRUE.getKey().equals(modelEntity.getIsSync())) {
throw new DataException("重复建模");
}
dynamicDao.createTable(modelEntity);
modelEntity.setIsSync(DataConstant.TrueOrFalse.TRUE.getKey());
modelDao.updateById(modelEntity);
}
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<result column="column_length" property="columnLength" /> <result column="column_length" property="columnLength" />
<result column="column_scale" property="columnScale" /> <result column="column_scale" property="columnScale" />
<result column="default_value" property="defaultValue" /> <result column="default_value" property="defaultValue" />
<result column="is_system" property="isSystem" />
<result column="is_pk" property="isPk" /> <result column="is_pk" property="isPk" />
<result column="is_required" property="isRequired" /> <result column="is_required" property="isRequired" />
<result column="is_insert" property="isInsert" /> <result column="is_insert" property="isInsert" />
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
update_by, update_by,
update_time, update_time,
remark, remark,
model_id, column_name, column_comment, column_type, column_length, column_scale, default_value, is_pk, is_required, is_insert, is_edit, is_list, is_query, query_type, is_bind_dict, bind_dict_type_id, bind_dict_column, html_type, sort model_id, column_name, column_comment, column_type, column_length, column_scale, default_value, is_system, is_pk, is_required, is_insert, is_edit, is_list, is_query, query_type, is_bind_dict, bind_dict_type_id, bind_dict_column, html_type, sort
</sql> </sql>
</mapper> </mapper>
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result column="model_name" property="modelName" /> <result column="model_name" property="modelName" />
<result column="model_logic_table" property="modelLogicTable" /> <result column="model_logic_table" property="modelLogicTable" />
<result column="model_physical_table" property="modelPhysicalTable" /> <result column="model_physical_table" property="modelPhysicalTable" />
<result column="is_sync" property="isSync" />
</resultMap> </resultMap>
<resultMap id="ExtendResultMap" type="cn.datax.service.data.masterdata.api.entity.ModelEntity" extends="BaseResultMap"> <resultMap id="ExtendResultMap" type="cn.datax.service.data.masterdata.api.entity.ModelEntity" extends="BaseResultMap">
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
update_by, update_by,
update_time, update_time,
remark, remark,
model_name, model_logic_table, model_physical_table model_name, model_logic_table, model_physical_table, is_sync
</sql> </sql>
<select id="getModelColumnList" resultType="cn.datax.service.data.masterdata.api.entity.ModelColumnEntity"> <select id="getModelColumnList" resultType="cn.datax.service.data.masterdata.api.entity.ModelColumnEntity">
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.datax.service.data.masterdata.dao.MysqlDynamicDao">
<insert id="createTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelEntity">
CREATE TABLE `${modelPhysicalTable}` (
<foreach collection="modelColumns" item="column" separator=",">
`${column.columnName}` ${column.columnDefinition}
<if test="column.defaultValue != null and column.defaultValue != ''">
DEFAULT #{column.defaultValue}
</if>
<if test="column.isRequired != null and column.isRequired == '1'.toString()">
NOT NULL
</if>
<if test="column.columnComment != null and column.columnComment != ''">
comment #{column.columnComment}
</if>
</foreach>
, PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC
<if test="modelName != null and modelName != ''">
comment=#{modelName}
</if>
</insert>
<!-- 验证表是否存在 -->
<update id="dropTable" parameterType="java.lang.String">
DROP TABLE IF EXISTS ${tableName}
</update>
<!-- 插入数据 -->
<insert id="insertData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
INSERT INTO ${tableName}
<foreach collection="datas.keys" item="key" open="(" close=")" separator=",">
${key}
</foreach>
VALUES
<foreach collection="datas.values" item="value" open="(" close=")" separator=",">
#{value}
</foreach>
</insert>
<!-- 更新数据 -->
<update id="updateData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
UPDATE ${tableName} SET
<foreach collection="datas.keys" index="key" item="value" separator=",">
${key} = #{value}
</foreach>
WHERE ID = #{datas[id]}
</update>
<!-- 删除数据 -->
<delete id="deleteData" parameterType="cn.datax.service.data.masterdata.api.entity.ModelDataEntity">
DELETE FROM ${tableName} WHERE id = #{datas[id]}
</delete>
</mapper>
...@@ -3,15 +3,7 @@ ...@@ -3,15 +3,7 @@
<mapper namespace="cn.datax.service.data.masterdata.dao.OracleDynamicDao"> <mapper namespace="cn.datax.service.data.masterdata.dao.OracleDynamicDao">
<insert id="createTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelEntity"> <insert id="createTable" parameterType="cn.datax.service.data.masterdata.api.entity.ModelEntity">
CREATE TABLE ${modelLogicTable} ( CREATE TABLE ${modelPhysicalTable} (
ID VARCHAR2(20) NOT NULL PRIMARY KEY,
STATUS NUMBER(1, 0) DEFAULT '1' NOT NULL,
CREATE_BY VARCHAR2(20),
CREATE_TIME DATE,
CREATE_DEPT VARCHAR2(20),
UPDATE_BY VARCHAR2(20),
UPDATE_TIME DATE,
REMARK VARCHAR2(2000),
<foreach collection="modelColumns" item="column" separator=","> <foreach collection="modelColumns" item="column" separator=",">
${column.columnName} ${column.columnDefinition} ${column.columnName} ${column.columnDefinition}
<if test="column.defaultValue != null and column.defaultValue != ''"> <if test="column.defaultValue != null and column.defaultValue != ''">
...@@ -20,9 +12,6 @@ ...@@ -20,9 +12,6 @@
<if test="column.isRequired != null and column.isRequired == '1'.toString()"> <if test="column.isRequired != null and column.isRequired == '1'.toString()">
NOT NULL NOT NULL
</if> </if>
<if test="column.isPk != null and column.isPk == '1'.toString()">
PRIMARY KEY
</if>
</foreach> </foreach>
) )
</insert> </insert>
......
...@@ -44,3 +44,10 @@ export function updateDataModel(data) { ...@@ -44,3 +44,10 @@ export function updateDataModel(data) {
data: data data: data
}) })
} }
export function createTable(id) {
return request({
url: '/data/masterdata/models/table/' + id,
method: 'post'
})
}
...@@ -283,8 +283,7 @@ export default { ...@@ -283,8 +283,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error.data.msg || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
...@@ -322,8 +322,7 @@ export default { ...@@ -322,8 +322,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error.data.msg || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
...@@ -556,8 +556,7 @@ export default { ...@@ -556,8 +556,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
...@@ -587,8 +587,7 @@ export default { ...@@ -587,8 +587,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
...@@ -185,6 +185,10 @@ export default { ...@@ -185,6 +185,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -195,6 +195,10 @@ export default { ...@@ -195,6 +195,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -39,21 +39,21 @@ ...@@ -39,21 +39,21 @@
<el-table-column label="列名称"> <el-table-column label="列名称">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnName'" :rules="rules.columnName"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnName'" :rules="rules.columnName">
<el-input v-model="scope.row.columnName" clearable placeholder="请输入列名称" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnName" clearable placeholder="请输入列名称" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列描述"> <el-table-column label="列描述">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnComment'" :rules="rules.columnComment"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnComment'" :rules="rules.columnComment">
<el-input v-model="scope.row.columnComment" clearable placeholder="请输入列描述" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnComment" clearable placeholder="请输入列描述" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列类型"> <el-table-column label="列类型">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnType'" :rules="rules.columnType"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnType'" :rules="rules.columnType">
<el-select v-model="scope.row.columnType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in columnTypeOptions" v-for="item in columnTypeOptions"
:key="item.value" :key="item.value"
...@@ -67,70 +67,70 @@ ...@@ -67,70 +67,70 @@
<el-table-column label="长度" width="70"> <el-table-column label="长度" width="70">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnLength'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnLength'">
<el-input-number v-model="scope.row.columnLength" style="width: 50px;" :controls="false" /> <el-input-number :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnLength" style="width: 50px;" :controls="false" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="小数位" width="70"> <el-table-column label="小数位" width="70">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnScale'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnScale'">
<el-input-number v-model="scope.row.columnScale" style="width: 50px;" :controls="false" /> <el-input-number :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnScale" style="width: 50px;" :controls="false" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="默认值"> <el-table-column label="默认值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.defaultValue'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.defaultValue'">
<el-input v-model="scope.row.defaultValue" clearable placeholder="请输入默认值" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.defaultValue" clearable placeholder="请输入默认值" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="主键" align="center" width="55"> <el-table-column label="主键" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isPk'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isPk'">
<el-checkbox v-model="scope.row.isPk" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isPk" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="必填" align="center" width="55"> <el-table-column label="必填" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isRequired'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isRequired'">
<el-checkbox v-model="scope.row.isRequired" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isRequired" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="插入" align="center" width="55"> <el-table-column label="插入" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isInsert'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isInsert'">
<el-checkbox v-model="scope.row.isInsert" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isInsert" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="编辑" align="center" width="55"> <el-table-column label="编辑" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isEdit'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isEdit'">
<el-checkbox v-model="scope.row.isEdit" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isEdit" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列表" align="center" width="55"> <el-table-column label="列表" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isList'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isList'">
<el-checkbox v-model="scope.row.isList" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isList" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="查询" align="center" width="55"> <el-table-column label="查询" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isQuery'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isQuery'">
<el-checkbox v-model="scope.row.isQuery" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isQuery" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="查询方式" width="120"> <el-table-column label="查询方式" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.queryType'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.queryType'">
<el-select v-model="scope.row.queryType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.queryType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in queryTypeOptions" v-for="item in queryTypeOptions"
:key="item.value" :key="item.value"
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<el-table-column label="显示类型" width="120"> <el-table-column label="显示类型" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType"> <el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select v-model="scope.row.htmlType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in htmlTypeOptions" v-for="item in htmlTypeOptions"
:key="item.value" :key="item.value"
...@@ -158,9 +158,9 @@ ...@@ -158,9 +158,9 @@
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item> <el-form-item>
<el-button :disabled="scope.$index === 0" @click="upRow(scope.$index)" icon="el-icon-arrow-up" circle></el-button> <el-button :disabled="scope.row.isSystem === '1' || scope.$index <= 8" icon="el-icon-arrow-up" circle @click="upRow(scope.$index)" />
<el-button :disabled="scope.$index === (form.modelColumns.length - 1)" @click="downRow(scope.$index)" icon="el-icon-arrow-down" circle></el-button> <el-button :disabled="scope.row.isSystem === '1' || scope.$index === (form.modelColumns.length - 1)" icon="el-icon-arrow-down" circle @click="downRow(scope.$index)" />
<el-button @click="delRow(scope.$index)" icon="el-icon-delete" circle></el-button> <el-button :disabled="scope.row.isSystem === '1'" icon="el-icon-delete" circle @click="delRow(scope.$index)" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
...@@ -240,7 +240,18 @@ export default { ...@@ -240,7 +240,18 @@ export default {
// 查询方式数据字典 // 查询方式数据字典
queryTypeOptions: [], queryTypeOptions: [],
// 显示类型数据字典 // 显示类型数据字典
htmlTypeOptions: [] htmlTypeOptions: [],
// 系统默认列
systemColumns: [
{ columnName: 'id', columnComment: '主键ID', columnType: 'varchar', columnLength: '20', columnScale: '0', defaultValue: '', isPk: '1', isRequired: '1', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'status', columnComment: '状态(0禁用,1启用)', columnType: 'tinyint', columnLength: '0', columnScale: '0', defaultValue: '1', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'create_by', columnComment: '创建人', columnType: 'varchar', columnLength: '20', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'create_time', columnComment: '创建日期', columnType: 'datetime', columnLength: '0', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'create_dept', columnComment: '创建人所属部门', columnType: 'varchar', columnLength: '20', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'update_by', columnComment: '更新人', columnType: 'varchar', columnLength: '20', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'update_time', columnComment: '更新日期', columnType: 'datetime', columnLength: '0', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' },
{ columnName: 'remark', columnComment: '备注', columnType: 'varchar', columnLength: '2000', columnScale: '0', defaultValue: '', isPk: '0', isRequired: '0', isInsert: '0', isEdit: '0', isList: '0', isQuery: '0', queryType: '', htmlType: 'input', isSystem: '1' }
]
} }
}, },
created() { created() {
...@@ -249,7 +260,7 @@ export default { ...@@ -249,7 +260,7 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_type_oracle').then(response => { this.getDicts('data_type_mysql').then(response => {
if (response.success) { if (response.success) {
this.columnTypeOptions = response.data this.columnTypeOptions = response.data
} }
...@@ -265,6 +276,9 @@ export default { ...@@ -265,6 +276,9 @@ export default {
} }
}) })
}, },
mounted() {
this.form.modelColumns = this.form.modelColumns.concat(this.systemColumns)
},
methods: { methods: {
showCard() { showCard() {
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
...@@ -273,10 +287,11 @@ export default { ...@@ -273,10 +287,11 @@ export default {
const item = { const item = {
columnName: '', columnName: '',
columnComment: '', columnComment: '',
columnType: 'char', columnType: 'varchar',
columnLength: '255', columnLength: '255',
columnScale: '0', columnScale: '0',
defaultValue: '', defaultValue: '',
isSystem: '0',
isPk: '0', isPk: '0',
isRequired: '0', isRequired: '0',
isInsert: '0', isInsert: '0',
...@@ -331,6 +346,10 @@ export default { ...@@ -331,6 +346,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{ title }}</span> <span>{{ title }}</span>
<el-button-group style="float: right;"> <el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-s-data" round @click="createTable">建模</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button> <el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group> </el-button-group>
</div> </div>
...@@ -162,7 +163,7 @@ ...@@ -162,7 +163,7 @@
</template> </template>
<script> <script>
import { getDataModel } from '@/api/masterdata/datamodel' import { getDataModel, createTable } from '@/api/masterdata/datamodel'
export default { export default {
name: 'DataModelDetail', name: 'DataModelDetail',
...@@ -202,7 +203,7 @@ export default { ...@@ -202,7 +203,7 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_type_oracle').then(response => { this.getDicts('data_type_mysql').then(response => {
if (response.success) { if (response.success) {
this.columnTypeOptions = response.data this.columnTypeOptions = response.data
} }
...@@ -232,6 +233,15 @@ export default { ...@@ -232,6 +233,15 @@ export default {
this.form = response.data this.form = response.data
} }
}) })
},
createTable() {
createTable(this.data.id).then(response => {
if (response.success) {
this.$message.error('建模成功')
} else {
this.$message.error('建模失败')
}
})
} }
} }
} }
......
...@@ -39,21 +39,21 @@ ...@@ -39,21 +39,21 @@
<el-table-column label="列名称"> <el-table-column label="列名称">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnName'" :rules="rules.columnName"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnName'" :rules="rules.columnName">
<el-input v-model="scope.row.columnName" clearable placeholder="请输入列名称" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnName" clearable placeholder="请输入列名称" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列描述"> <el-table-column label="列描述">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnComment'" :rules="rules.columnComment"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnComment'" :rules="rules.columnComment">
<el-input v-model="scope.row.columnComment" clearable placeholder="请输入列描述" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnComment" clearable placeholder="请输入列描述" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列类型"> <el-table-column label="列类型">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnType'" :rules="rules.columnType"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnType'" :rules="rules.columnType">
<el-select v-model="scope.row.columnType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in columnTypeOptions" v-for="item in columnTypeOptions"
:key="item.value" :key="item.value"
...@@ -64,73 +64,73 @@ ...@@ -64,73 +64,73 @@
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="长度" width="90"> <el-table-column label="长度" width="70">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnLength'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnLength'">
<el-input-number v-model="scope.row.columnLength" style="width: 70px;" :controls="false" /> <el-input-number :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnLength" style="width: 50px;" :controls="false" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="小数位" width="70"> <el-table-column label="小数位" width="70">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.columnScale'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.columnScale'">
<el-input-number v-model="scope.row.columnScale" style="width: 50px;" :controls="false" /> <el-input-number :disabled="scope.row.isSystem === '1'" v-model="scope.row.columnScale" style="width: 50px;" :controls="false" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="默认值"> <el-table-column label="默认值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.defaultValue'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.defaultValue'">
<el-input v-model="scope.row.defaultValue" clearable placeholder="请输入默认值" /> <el-input :disabled="scope.row.isSystem === '1'" v-model="scope.row.defaultValue" clearable placeholder="请输入默认值" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="主键" align="center" width="55"> <el-table-column label="主键" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isPk'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isPk'">
<el-checkbox v-model="scope.row.isPk" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isPk" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="必填" align="center" width="55"> <el-table-column label="必填" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isRequired'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isRequired'">
<el-checkbox v-model="scope.row.isRequired" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isRequired" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="插入" align="center" width="55"> <el-table-column label="插入" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isInsert'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isInsert'">
<el-checkbox v-model="scope.row.isInsert" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isInsert" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="编辑" align="center" width="55"> <el-table-column label="编辑" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isEdit'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isEdit'">
<el-checkbox v-model="scope.row.isEdit" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isEdit" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列表" align="center" width="55"> <el-table-column label="列表" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isList'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isList'">
<el-checkbox v-model="scope.row.isList" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isList" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="查询" align="center" width="55"> <el-table-column label="查询" align="center" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.isQuery'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.isQuery'">
<el-checkbox v-model="scope.row.isQuery" true-label="1" false-label="0" /> <el-checkbox :disabled="scope.row.isSystem === '1'" v-model="scope.row.isQuery" true-label="1" false-label="0" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="查询方式" width="120"> <el-table-column label="查询方式" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.queryType'"> <el-form-item :prop="'modelColumns.' + scope.$index + '.queryType'">
<el-select v-model="scope.row.queryType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.queryType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in queryTypeOptions" v-for="item in queryTypeOptions"
:key="item.value" :key="item.value"
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<el-table-column label="显示类型" width="120"> <el-table-column label="显示类型" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType"> <el-form-item :prop="'modelColumns.' + scope.$index + '.htmlType'" :rules="rules.htmlType">
<el-select v-model="scope.row.htmlType" clearable placeholder="请选择"> <el-select :disabled="scope.row.isSystem === '1'" v-model="scope.row.htmlType" clearable placeholder="请选择">
<el-option <el-option
v-for="item in htmlTypeOptions" v-for="item in htmlTypeOptions"
:key="item.value" :key="item.value"
...@@ -158,9 +158,9 @@ ...@@ -158,9 +158,9 @@
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-form-item> <el-form-item>
<el-button :disabled="scope.$index === 0" @click="upRow(scope.$index)" icon="el-icon-arrow-up" circle></el-button> <el-button :disabled="scope.row.isSystem === '1' || scope.$index <= 8" icon="el-icon-arrow-up" circle @click="upRow(scope.$index)" />
<el-button :disabled="scope.$index === (form.modelColumns.length - 1)" @click="downRow(scope.$index)" icon="el-icon-arrow-down" circle></el-button> <el-button :disabled="scope.row.isSystem === '1' || scope.$index === (form.modelColumns.length - 1)" icon="el-icon-arrow-down" circle @click="downRow(scope.$index)" />
<el-button @click="delRow(scope.$index)" icon="el-icon-delete" circle></el-button> <el-button :disabled="scope.row.isSystem === '1'" icon="el-icon-delete" circle @click="delRow(scope.$index)" />
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
...@@ -240,7 +240,7 @@ export default { ...@@ -240,7 +240,7 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_type_oracle').then(response => { this.getDicts('data_type_mysql').then(response => {
if (response.success) { if (response.success) {
this.columnTypeOptions = response.data this.columnTypeOptions = response.data
} }
...@@ -275,10 +275,11 @@ export default { ...@@ -275,10 +275,11 @@ export default {
const item = { const item = {
columnName: '', columnName: '',
columnComment: '', columnComment: '',
columnType: 'char', columnType: 'varchar',
columnLength: '255', columnLength: '255',
columnScale: '0', columnScale: '0',
defaultValue: '', defaultValue: '',
isSystem: '0',
isPk: '0', isPk: '0',
isRequired: '0', isRequired: '0',
isInsert: '0', isInsert: '0',
...@@ -333,6 +334,10 @@ export default { ...@@ -333,6 +334,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -128,6 +128,10 @@ export default { ...@@ -128,6 +128,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -151,6 +151,10 @@ export default { ...@@ -151,6 +151,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -214,6 +214,10 @@ export default { ...@@ -214,6 +214,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -212,6 +212,10 @@ export default { ...@@ -212,6 +212,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -125,6 +125,10 @@ export default { ...@@ -125,6 +125,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -135,6 +135,10 @@ export default { ...@@ -135,6 +135,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -115,6 +115,10 @@ export default { ...@@ -115,6 +115,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -126,6 +126,10 @@ export default { ...@@ -126,6 +126,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -116,6 +116,10 @@ export default { ...@@ -116,6 +116,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -126,6 +126,10 @@ export default { ...@@ -126,6 +126,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -151,6 +151,10 @@ export default { ...@@ -151,6 +151,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -159,6 +159,10 @@ export default { ...@@ -159,6 +159,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -114,6 +114,10 @@ export default { ...@@ -114,6 +114,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -124,6 +124,10 @@ export default { ...@@ -124,6 +124,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -120,6 +120,10 @@ export default { ...@@ -120,6 +120,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -127,6 +127,10 @@ export default { ...@@ -127,6 +127,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -203,6 +203,10 @@ export default { ...@@ -203,6 +203,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -208,6 +208,10 @@ export default { ...@@ -208,6 +208,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -104,6 +104,10 @@ export default { ...@@ -104,6 +104,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -114,6 +114,10 @@ export default { ...@@ -114,6 +114,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -222,6 +222,10 @@ export default { ...@@ -222,6 +222,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -247,6 +247,10 @@ export default { ...@@ -247,6 +247,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -231,6 +231,10 @@ export default { ...@@ -231,6 +231,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -232,6 +232,10 @@ export default { ...@@ -232,6 +232,10 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(() => {
this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false
}) })
} }
}) })
......
...@@ -341,8 +341,7 @@ export default { ...@@ -341,8 +341,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error.data.msg || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
...@@ -360,8 +360,7 @@ export default { ...@@ -360,8 +360,7 @@ export default {
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
} }
}).catch(error => { }).catch(() => {
this.$message.error(error.data.msg || '保存失败')
this.loadingOptions.loading = false this.loadingOptions.loading = false
this.loadingOptions.loadingText = '保存' this.loadingOptions.loadingText = '保存'
this.loadingOptions.isDisabled = false this.loadingOptions.isDisabled = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment