12 changed files with 837 additions and 0 deletions
@ -0,0 +1,38 @@ |
|||||
|
package org.nl.common.domain.handler; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.parser.Feature; |
||||
|
import com.alibaba.fastjson.serializer.SerializerFeature; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Assert; |
||||
|
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.ibatis.type.JdbcType; |
||||
|
import org.apache.ibatis.type.MappedJdbcTypes; |
||||
|
import org.apache.ibatis.type.MappedTypes; |
||||
|
|
||||
|
@Slf4j |
||||
|
@MappedTypes({Object.class}) |
||||
|
@MappedJdbcTypes(JdbcType.VARCHAR) |
||||
|
public class FastjsonSortTypeHandler extends AbstractJsonTypeHandler<Object> { |
||||
|
private Class<?> type; |
||||
|
|
||||
|
public FastjsonSortTypeHandler(Class<?> type) { |
||||
|
if (log.isTraceEnabled()) { |
||||
|
log.trace("FastjsonSortTypeHandler(" + type + ")"); |
||||
|
} |
||||
|
Assert.notNull(type, "Type argument cannot be null"); |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected Object parse(String json) { |
||||
|
return JSON.parseObject(json, type, Feature.OrderedField); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected String toJson(Object obj) { |
||||
|
return JSON.toJSONString(obj,SerializerFeature.WriteMapNullValue, |
||||
|
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty,SerializerFeature.SortField); |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,47 @@ |
|||||
|
package org.nl.common.domain.handler; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import org.apache.ibatis.type.BaseTypeHandler; |
||||
|
import org.apache.ibatis.type.JdbcType; |
||||
|
|
||||
|
import java.sql.CallableStatement; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
import java.util.ArrayList; |
||||
|
|
||||
|
/** |
||||
|
* Description: |
||||
|
* |
||||
|
* @author <a href="mailto:qinghehe@qq.com">gongmanman</a> |
||||
|
* @Date Create on 2020/3/19/0019 18:30 |
||||
|
* @since version1.0 Copyright 2020 CLKJ All Rights Reserved. |
||||
|
*/ |
||||
|
public class ListTypeHandler extends BaseTypeHandler<Object> { |
||||
|
@Override |
||||
|
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException { |
||||
|
return jsonTrans(rs.getString(columnName)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException { |
||||
|
return jsonTrans(rs.getString(columnIndex)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { |
||||
|
return jsonTrans(cs.getString(columnIndex)); |
||||
|
} |
||||
|
|
||||
|
private Object jsonTrans(String s) { |
||||
|
if(s == null){ |
||||
|
return new ArrayList<String>(); |
||||
|
} |
||||
|
return JSONArray.parseArray(s,String.class); |
||||
|
} |
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
package org.nl.wms.decision_manage.controller; |
||||
|
import org.nl.common.base.TableDataInfo; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.common.logging.annotation.Log; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import org.nl.common.utils.MapOf; |
||||
|
import org.nl.wms.decision_manage.service.IStStrategyConfigService; |
||||
|
import org.nl.wms.decision_manage.service.dao.StStrategyConfig; |
||||
|
import org.nl.wms.decision_manage.service.dto.StrategyQuery; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 仓储策略配置表 前端控制器 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author generator |
||||
|
* @since 2024-04-07 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/api/strategy") |
||||
|
public class StStrategyConfigController { |
||||
|
|
||||
|
@Autowired |
||||
|
private IStStrategyConfigService iStStrategyConfigService; |
||||
|
|
||||
|
@GetMapping |
||||
|
@Log("查询规则") |
||||
|
public ResponseEntity<Object> query(StrategyQuery query, PageQuery page) { |
||||
|
return new ResponseEntity<>(TableDataInfo.build(iStStrategyConfigService.page(page.build(),query.build())), HttpStatus.OK); |
||||
|
} |
||||
|
@GetMapping("/decisionColumns") |
||||
|
@SaIgnore |
||||
|
public ResponseEntity<Object> decisionColumns() { |
||||
|
List<StStrategyConfig> list = iStStrategyConfigService.list(new QueryWrapper<StStrategyConfig>().select("strategy_code", "strategy_name")); |
||||
|
List<Map> result = new ArrayList<>(); |
||||
|
for (StStrategyConfig config : list) { |
||||
|
result.add(MapOf.of("label",config.getStrategy_name(),"value",config.getStrategy_code())); |
||||
|
} |
||||
|
return new ResponseEntity<>(result, HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
@Log("新增规格") |
||||
|
public ResponseEntity<Object> create(@Validated @RequestBody StStrategyConfig dao) { |
||||
|
iStStrategyConfigService.create(dao); |
||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
@Log("修改规格") |
||||
|
public ResponseEntity<Object> update(@Validated @RequestBody StStrategyConfig dao) { |
||||
|
iStStrategyConfigService.update(dao); |
||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
@Log("删除规格") |
||||
|
public ResponseEntity<Object> delete(@RequestBody Long[] ids) { |
||||
|
iStStrategyConfigService.deleteAll(ids); |
||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PutMapping("/changeActive") |
||||
|
@Log("修改启用状态规格") |
||||
|
public ResponseEntity<Object> changeActive(@Validated @RequestBody StStrategyConfig dao) { |
||||
|
iStStrategyConfigService.changeActive(dao); |
||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,48 @@ |
|||||
|
package org.nl.wms.decision_manage.service; |
||||
|
|
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.wms.decision_manage.service.dao.StStrategyConfig; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import org.nl.wms.decision_manage.service.dto.StrategyQuery; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 仓储策略配置表 服务类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author generator |
||||
|
* @since 2024-04-07 |
||||
|
*/ |
||||
|
public interface IStStrategyConfigService extends IService<StStrategyConfig> { |
||||
|
|
||||
|
/** |
||||
|
* 分页查询 |
||||
|
* @param query,page / |
||||
|
* @return JSONObject |
||||
|
*/ |
||||
|
Object pageQuery(StrategyQuery query, PageQuery page); |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param dao:实体类 |
||||
|
*/ |
||||
|
void create(StStrategyConfig dao); |
||||
|
|
||||
|
/** |
||||
|
* 修改 |
||||
|
* @param dao: 实体类 |
||||
|
*/ |
||||
|
void update(StStrategyConfig dao); |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids : 标识 |
||||
|
*/ |
||||
|
void deleteAll(Long[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 修改启用状态 |
||||
|
* @param dao:实体类 |
||||
|
*/ |
||||
|
void changeActive(StStrategyConfig dao); |
||||
|
} |
@ -0,0 +1,89 @@ |
|||||
|
package org.nl.wms.decision_manage.service.dao; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import org.nl.common.domain.handler.FastjsonSortTypeHandler; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 仓储策略配置表 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author generator |
||||
|
* @since 2024-04-07 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
@TableName(value = "st_strategy_config",autoResultMap = true) |
||||
|
public class StStrategyConfig implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 策略标识 |
||||
|
*/ |
||||
|
@TableId |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 策略编码 |
||||
|
*/ |
||||
|
private String strategy_code; |
||||
|
|
||||
|
/** |
||||
|
* 策略名称 |
||||
|
*/ |
||||
|
private String strategy_name; |
||||
|
|
||||
|
/** |
||||
|
* 策略类型 |
||||
|
*/ |
||||
|
private String strategy_type; |
||||
|
|
||||
|
/** |
||||
|
* 类处理类型 |
||||
|
*/ |
||||
|
private String class_type; |
||||
|
|
||||
|
/** |
||||
|
* 处理类 |
||||
|
*/ |
||||
|
private String param; |
||||
|
/** |
||||
|
*限定参数 |
||||
|
*/ |
||||
|
@TableField(typeHandler = FastjsonSortTypeHandler.class) |
||||
|
private JSONObject form_data = new JSONObject();; |
||||
|
/** |
||||
|
* 描述 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 是否启用 |
||||
|
*/ |
||||
|
private Boolean is_used; |
||||
|
|
||||
|
private Boolean ban; |
||||
|
/** |
||||
|
* 修改人名称 |
||||
|
*/ |
||||
|
private String update_name; |
||||
|
|
||||
|
/** |
||||
|
* 修改时间 |
||||
|
*/ |
||||
|
private String update_time; |
||||
|
|
||||
|
/** |
||||
|
* 是否删除 |
||||
|
*/ |
||||
|
private Boolean is_delete; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package org.nl.wms.decision_manage.service.dao.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.wms.decision_manage.service.dao.StStrategyConfig; |
||||
|
import org.nl.wms.decision_manage.service.dto.StrategyQuery; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 仓储策略配置表 Mapper 接口 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author generator |
||||
|
* @since 2024-04-07 |
||||
|
*/ |
||||
|
public interface StStrategyConfigMapper extends BaseMapper<StStrategyConfig> { |
||||
|
|
||||
|
/** |
||||
|
* 分页查询 |
||||
|
* @param query:查询条件 |
||||
|
* @param pageQuery 分页 |
||||
|
* @return List<Map> |
||||
|
*/ |
||||
|
List<Map> getPageQuery(@Param("query") StrategyQuery query, @Param("pageQuery") PageQuery pageQuery); |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
<?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="org.nl.wms.decision_manage.service.dao.mapper.StStrategyConfigMapper"> |
||||
|
<select id="getPageQuery" resultType="java.util.Map"> |
||||
|
SELECT |
||||
|
* |
||||
|
FROM |
||||
|
st_strategy_config |
||||
|
<where> |
||||
|
is_delete = "0" |
||||
|
|
||||
|
<if test="query.strategy_name != null and query.strategy_name != ''"> |
||||
|
and (strategy_name LIKE '%${query.strategy_name}%' |
||||
|
or strategy_code LIKE '%${query.strategy_name}%') |
||||
|
</if> |
||||
|
|
||||
|
</where> |
||||
|
|
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,25 @@ |
|||||
|
package org.nl.wms.decision_manage.service.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.common.domain.query.BaseQuery; |
||||
|
import org.nl.common.domain.query.QParam; |
||||
|
import org.nl.common.enums.QueryTEnum; |
||||
|
import org.nl.wms.decision_manage.service.dao.StStrategyConfig; |
||||
|
|
||||
|
/* |
||||
|
* @author ZZQ |
||||
|
* @Date 2023/5/4 19:49 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class StrategyQuery extends BaseQuery<StStrategyConfig> { |
||||
|
|
||||
|
private String strategy_name; |
||||
|
private Boolean is_delete =Boolean.FALSE; |
||||
|
|
||||
|
@Override |
||||
|
public void paramMapping() { |
||||
|
super.doP.put("strategy_name", QParam.builder().k(new String[]{"strategy_name"}).type(QueryTEnum.LK).build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,101 @@ |
|||||
|
package org.nl.wms.decision_manage.service.impl; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.github.pagehelper.Page; |
||||
|
import org.nl.common.utils.IdUtil; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import org.nl.common.base.TableDataInfo; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.common.exception.BadRequestException; |
||||
|
import org.nl.common.utils.SecurityUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.nl.wms.decision_manage.service.IStStrategyConfigService; |
||||
|
import org.nl.wms.decision_manage.service.dao.StStrategyConfig; |
||||
|
import org.nl.wms.decision_manage.service.dao.mapper.StStrategyConfigMapper; |
||||
|
import org.nl.wms.decision_manage.service.dto.StrategyQuery; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 仓储策略配置表 服务实现类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author generator |
||||
|
* @since 2024-04-07 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class StStrategyConfigServiceImpl extends ServiceImpl<StStrategyConfigMapper, StStrategyConfig> implements IStStrategyConfigService { |
||||
|
|
||||
|
@Override |
||||
|
public Object pageQuery(StrategyQuery query, PageQuery pageQuery) { |
||||
|
Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize()); |
||||
|
page.setOrderBy("create_time DESC"); |
||||
|
List<Map> mstDetail = this.baseMapper.getPageQuery(query, pageQuery); |
||||
|
|
||||
|
TableDataInfo<Map> build = TableDataInfo.build(mstDetail); |
||||
|
build.setTotalElements(page.getTotal()); |
||||
|
return build; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void create(StStrategyConfig dao) { |
||||
|
|
||||
|
StStrategyConfig oldDao = this.getOne( |
||||
|
new QueryWrapper<StStrategyConfig>().lambda() |
||||
|
.eq(StStrategyConfig::getStrategy_name, dao.getStrategy_name()) |
||||
|
); |
||||
|
|
||||
|
if (ObjectUtil.isNotEmpty(oldDao)) { |
||||
|
throw new BadRequestException("已存在相同名称的策略【"+dao.getStrategy_name()+"】"); |
||||
|
} |
||||
|
|
||||
|
dao.setId(IdUtil.getStringId()); |
||||
|
dao.setStrategy_code("000"); |
||||
|
this.save(dao); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(StStrategyConfig dao) { |
||||
|
dao.setUpdate_name(SecurityUtils.getCurrentNickName()); |
||||
|
dao.setUpdate_time(DateUtil.now()); |
||||
|
this.updateById(dao); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void deleteAll(Long[] ids) { |
||||
|
this.update( |
||||
|
new UpdateWrapper<StStrategyConfig>().lambda() |
||||
|
.set(StStrategyConfig::getUpdate_name, SecurityUtils.getCurrentNickName()) |
||||
|
.set(StStrategyConfig::getUpdate_time, DateUtil.now()) |
||||
|
.set(StStrategyConfig::getIs_delete, "1") |
||||
|
.in(StStrategyConfig::getId, ids) |
||||
|
); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void changeActive(StStrategyConfig dao) { |
||||
|
|
||||
|
Boolean isUsed = true; |
||||
|
if (dao.getIs_used()) { |
||||
|
isUsed = false; |
||||
|
} |
||||
|
dao.setIs_used(isUsed); |
||||
|
dao.setUpdate_time(DateUtil.now()); |
||||
|
dao.setUpdate_name(SecurityUtils.getCurrentNickName()); |
||||
|
this.updateById(dao); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,166 @@ |
|||||
|
<template> |
||||
|
<el-dialog |
||||
|
:title="crud.status.title" |
||||
|
append-to-body |
||||
|
:before-close="crud.cancelCU" |
||||
|
:visible.sync="crud.status.cu > 0 || crud.status.view > 0" |
||||
|
> |
||||
|
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="110px"> |
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="策略名称:" prop="strategy_name"> |
||||
|
<el-input v-model="form.strategy_name" style="width: 200px;" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="策略类型:" prop="strategy_type"> |
||||
|
<el-select |
||||
|
v-model="form.strategy_type" |
||||
|
placeholder="" |
||||
|
style="width: 200px" |
||||
|
> |
||||
|
<el-option |
||||
|
v-for="item in strategyTypeList" |
||||
|
:key="item.id" |
||||
|
:label="item.label" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="类处理类型:" prop="class_type"> |
||||
|
<el-select |
||||
|
v-model="form.class_type" |
||||
|
placeholder="" |
||||
|
style="width: 200px" |
||||
|
> |
||||
|
<el-option |
||||
|
v-for="item in classTypeList" |
||||
|
:key="item.id" |
||||
|
:label="item.label" |
||||
|
:value="item.value" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="参数:" prop="param"> |
||||
|
<el-input v-model="form.param" style="width: 200px;" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="策略编码:" prop="param"> |
||||
|
<el-input v-model="form.strategy_code" style="width: 200px;" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
|
||||
|
<el-row :gutter="20"> |
||||
|
<el-col :span="24"> |
||||
|
<el-form-item label="描述:" prop="remark"> |
||||
|
<el-input v-model="form.remark" :rows="3" type="textarea" style="width: 560px;" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</el-form> |
||||
|
<div v-show="crud.status.cu > 0" slot="footer" class="dialog-footer"> |
||||
|
<el-button type="text" @click="crud.cancelCU">取消</el-button> |
||||
|
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
const defaultForm = { |
||||
|
id: null, |
||||
|
strategy_code: null, |
||||
|
strategy_name: null, |
||||
|
strategy_type: null, |
||||
|
class_type: null, |
||||
|
param: null, |
||||
|
remark: null, |
||||
|
is_used: null, |
||||
|
ban: null, |
||||
|
update_name: null, |
||||
|
update_time: null, |
||||
|
is_delete: null |
||||
|
} |
||||
|
import CRUD, { form, crud } from '@crud/crud' |
||||
|
|
||||
|
export default { |
||||
|
name: 'AddDialog', |
||||
|
mixins: [form(defaultForm), crud()], |
||||
|
props: { |
||||
|
dialogShow: { |
||||
|
type: Boolean, |
||||
|
default: false |
||||
|
}, |
||||
|
openParam: { |
||||
|
type: Object |
||||
|
} |
||||
|
}, |
||||
|
watch: { |
||||
|
dialogShow: { |
||||
|
handler(newValue, oldValue) { |
||||
|
this.dialogVisible = newValue |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
dialogVisible: false, |
||||
|
strategyTypeList: [ |
||||
|
{ 'label': '入库', 'value': '1' }, |
||||
|
{ 'label': '出库', 'value': '2' }, |
||||
|
{ 'label': '通用', 'value': '3' } |
||||
|
], |
||||
|
classTypeList: [ |
||||
|
{ 'label': '实现类', 'value': '1' }, |
||||
|
{ 'label': '表达式', 'value': '2' }, |
||||
|
{ 'label': '脚本', 'value': '3' } |
||||
|
], |
||||
|
rules: { |
||||
|
strategy_name: [ |
||||
|
{ required: true, message: '策略名称不能为空', trigger: 'blur' } |
||||
|
], |
||||
|
strategy_type: [ |
||||
|
{ required: true, message: '策略类型不能为空', trigger: 'blur' } |
||||
|
], |
||||
|
strategy_code: [ |
||||
|
{ required: true, message: '策略编码不能为空', trigger: 'blur' } |
||||
|
], |
||||
|
param: [ |
||||
|
{ required: true, message: '参数不能为空', trigger: 'blur' } |
||||
|
], |
||||
|
class_type: [ |
||||
|
{ required: true, message: '类处理类型不能为空', trigger: 'blur' } |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
handleClose(done) { |
||||
|
this.$confirm('确认关闭?') |
||||
|
.then(_ => { |
||||
|
done() |
||||
|
}) |
||||
|
.catch(_ => { |
||||
|
}) |
||||
|
}, |
||||
|
close() { |
||||
|
this.form = [] |
||||
|
this.$emit('update:dialogShow', false) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
|
||||
|
</style> |
@ -0,0 +1,160 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<!--工具栏--> |
||||
|
<div class="head-container"> |
||||
|
<div v-if="crud.props.searchToggle"> |
||||
|
<!-- 搜索 --> |
||||
|
<el-form |
||||
|
:inline="true" |
||||
|
class="demo-form-inline" |
||||
|
label-position="right" |
||||
|
label-width="80px" |
||||
|
label-suffix=":" |
||||
|
> |
||||
|
<el-form-item label="策略名称"> |
||||
|
<el-input |
||||
|
v-model="query.strategy_name" |
||||
|
clearable |
||||
|
size="mini" |
||||
|
placeholder="策略名称" |
||||
|
style="width: 200px;" |
||||
|
class="filter-item" |
||||
|
@keyup.enter.native="crud.toQuery" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<rrOperation /> |
||||
|
</el-form> |
||||
|
|
||||
|
</div> |
||||
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
||||
|
<crudOperation :permission="permission"/> |
||||
|
<!--表单组件--> |
||||
|
<el-table |
||||
|
ref="table" |
||||
|
v-loading="crud.loading" |
||||
|
:data="crud.data" |
||||
|
size="mini" |
||||
|
style="width: 100%;" |
||||
|
@selection-change="crud.selectionChangeHandler" |
||||
|
> |
||||
|
<el-table-column type="selection" width="55" /> |
||||
|
<el-table-column label="策略类型" > |
||||
|
<template slot-scope="scope"> |
||||
|
{{scope.row.ban?"系统策略":"自定义策略"}} |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column prop="strategy_name" label="策略名称" /> |
||||
|
<el-table-column prop="strategy_code" label="策略编码" /> |
||||
|
<el-table-column prop="strategy_type" label="决策类型" /> |
||||
|
<el-table-column prop="class_type" label="策略执行器" /> |
||||
|
<el-table-column prop="param" show-overflow-tooltip label="参数" /> |
||||
|
<el-table-column prop="remark" show-overflow-tooltip label="描述" /> |
||||
|
<el-table-column label="是否启用" align="center" prop="is_used"> |
||||
|
<template slot-scope="scope"> |
||||
|
<el-switch |
||||
|
:value="scope.row.is_used" |
||||
|
active-color="#409EFF" |
||||
|
inactive-color="#F56C6C" |
||||
|
@change="changeEnabled(scope.row, scope.row.is_used)" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column prop="update_name" label="操作人" /> |
||||
|
<el-table-column min-width="160" prop="update_time" label="操作时间" /> |
||||
|
<el-table-column |
||||
|
v-permission="[]" |
||||
|
label="操作" |
||||
|
width="120" |
||||
|
align="center" |
||||
|
fixed="right" |
||||
|
> |
||||
|
<template slot-scope="scope"> |
||||
|
<udOperation |
||||
|
:disabledDle="scope.row.ban" |
||||
|
:disabledEdit="scope.row.ban" |
||||
|
:data="scope.row" |
||||
|
:permission="permission" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
<pagination /> |
||||
|
</div> |
||||
|
<AddDialog /> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import crudStrategy from './strategy' |
||||
|
import AddDialog from './AddDialog' |
||||
|
import CRUD, { crud, form, header, presenter } from '@crud/crud' |
||||
|
import rrOperation from '@crud/RR.operation' |
||||
|
import crudOperation from '@crud/CRUD.operation' |
||||
|
import udOperation from '@crud/UD.operation' |
||||
|
import pagination from '@crud/Pagination' |
||||
|
|
||||
|
export default { |
||||
|
name: 'Strategy', |
||||
|
dicts: [], |
||||
|
components: { pagination, crudOperation, rrOperation, udOperation, AddDialog }, |
||||
|
mixins: [presenter(), header(), crud()], |
||||
|
cruds() { |
||||
|
return CRUD({ |
||||
|
title: '策略管理', |
||||
|
url: 'api/strategy', |
||||
|
idField: 'id', |
||||
|
sort: 'id,desc', |
||||
|
crudMethod: { ...crudStrategy }, |
||||
|
optShow: { |
||||
|
add: true, |
||||
|
edit: false, |
||||
|
del: false, |
||||
|
download: false, |
||||
|
reset: true |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
dialogVisible: false, |
||||
|
permission: {}, |
||||
|
rules: { |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
||||
|
[CRUD.HOOK.beforeRefresh]() { |
||||
|
return true |
||||
|
}, |
||||
|
format_is_used(is_used) { |
||||
|
return is_used==true |
||||
|
}, |
||||
|
changeEnabled(data, val) { |
||||
|
let msg = '此操作将停用,是否继续!' |
||||
|
if (val !== '1') { |
||||
|
msg = '此操作将启用,是否继续!' |
||||
|
} |
||||
|
this.$confirm(msg, '提示', { |
||||
|
confirmButtonText: '确定', |
||||
|
cancelButtonText: '取消', |
||||
|
type: 'warning' |
||||
|
}).then(() => { |
||||
|
crudStrategy.changeActive(data).then(res => { |
||||
|
this.crud.toQuery() |
||||
|
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
||||
|
}).catch(() => { |
||||
|
data.is_used = !data.is_used |
||||
|
}) |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.is-scrolling-none + .el-table__fixed-right { |
||||
|
height: 100% !important; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,35 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
export function add(data) { |
||||
|
return request({ |
||||
|
url: 'api/strategy', |
||||
|
method: 'post', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function del(ids) { |
||||
|
return request({ |
||||
|
url: 'api/strategy/', |
||||
|
method: 'delete', |
||||
|
data: ids |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function edit(data) { |
||||
|
return request({ |
||||
|
url: 'api/strategy', |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function changeActive(data) { |
||||
|
return request({ |
||||
|
url: 'api/strategy/changeActive', |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export default { add, edit, del, changeActive } |
Loading…
Reference in new issue