消息通知功能和指定租户编号不进行租户过滤功能通知
This commit is contained in:
parent
c8052ffa72
commit
e3ca77c89b
@ -4,6 +4,7 @@ import com.inspur.framework.common.enums.WebFilterOrderEnum;
|
||||
import com.inspur.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.inspur.framework.redis.config.ImtCacheProperties;
|
||||
import com.inspur.framework.tenant.core.aop.TenantIgnoreAspect;
|
||||
import com.inspur.framework.tenant.core.db.ImtTenantLineInnerInterceptor;
|
||||
import com.inspur.framework.tenant.core.db.TenantDatabaseInterceptor;
|
||||
import com.inspur.framework.tenant.core.job.TenantJobAspect;
|
||||
import com.inspur.framework.tenant.core.mq.rabbitmq.TenantRabbitMQInitializer;
|
||||
@ -57,7 +58,7 @@ public class ImtTenantAutoConfiguration {
|
||||
@Bean
|
||||
public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantProperties properties,
|
||||
MybatisPlusInterceptor interceptor) {
|
||||
TenantLineInnerInterceptor inner = new TenantLineInnerInterceptor(new TenantDatabaseInterceptor(properties));
|
||||
TenantLineInnerInterceptor inner = new ImtTenantLineInnerInterceptor(new TenantDatabaseInterceptor(properties));
|
||||
// 添加到 interceptor 中
|
||||
// 需要加在首个,主要是为了在分页插件前面。这个是 MyBatis Plus 的规定
|
||||
MyBatisUtils.addInterceptor(interceptor, inner, 0);
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.inspur.framework.tenant.core.db;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.Parenthesis;
|
||||
import net.sf.jsqlparser.expression.RowConstructor;
|
||||
import net.sf.jsqlparser.expression.StringValue;
|
||||
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
|
||||
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
|
||||
import net.sf.jsqlparser.expression.operators.relational.LikeExpression;
|
||||
import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList;
|
||||
import net.sf.jsqlparser.schema.Column;
|
||||
import net.sf.jsqlparser.schema.Table;
|
||||
import net.sf.jsqlparser.statement.insert.Insert;
|
||||
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||
import net.sf.jsqlparser.statement.select.Select;
|
||||
import net.sf.jsqlparser.statement.select.Values;
|
||||
import net.sf.jsqlparser.statement.update.UpdateSet;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author zhangjunwen
|
||||
* @create 2024/10/8
|
||||
*/
|
||||
public class ImtTenantLineInnerInterceptor extends TenantLineInnerInterceptor {
|
||||
private TenantLineHandler tenantLineHandler;
|
||||
|
||||
@Value("${imt.ignoreTenantId}")
|
||||
private String ignoreTenantId;
|
||||
|
||||
public ImtTenantLineInnerInterceptor() {}
|
||||
|
||||
@Override
|
||||
public TenantLineHandler getTenantLineHandler() {
|
||||
return tenantLineHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTenantLineHandler(TenantLineHandler tenantLineHandler) {
|
||||
this.tenantLineHandler = tenantLineHandler;
|
||||
}
|
||||
|
||||
public ImtTenantLineInnerInterceptor(final TenantLineHandler tenantLineHandler) {
|
||||
super.setTenantLineHandler(tenantLineHandler);
|
||||
this.tenantLineHandler = tenantLineHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression buildTableExpression(final Table table, final Expression where, final String whereSegment) {
|
||||
if (this.tenantLineHandler.ignoreTable(table.getName())) {
|
||||
return null;
|
||||
}
|
||||
Expression expression = this.tenantLineHandler.getTenantId();
|
||||
String tenantId = expression.toString();
|
||||
if(tenantId.equals(ignoreTenantId)){
|
||||
return null;
|
||||
}
|
||||
return new EqualsTo(this.getAliasColumn(table), this.tenantLineHandler.getTenantId());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -227,10 +227,29 @@ public class MyMqttCallback implements MqttCallback {
|
||||
AlarmRulesApi alarmRulesApi = SpringUtils.getBean(AlarmRulesApi.class);
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
String dataType;
|
||||
if(measurement.split("_").length >= 2) {
|
||||
dataType = measurement.split("_")[1];
|
||||
} else {
|
||||
dataType = "";
|
||||
}
|
||||
tags.put("equip_id",equipId);
|
||||
mapping.forEach((k,v)->{
|
||||
if(msg.containsKey(k)){
|
||||
fields.put(v,msg.get(k));
|
||||
switch(dataType){
|
||||
case "current":
|
||||
fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 0.00125);
|
||||
break;
|
||||
case "hy":
|
||||
fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 1.25);
|
||||
break;
|
||||
case "temp":
|
||||
fields.put(v,Double.parseDouble(msg.get(k).toString()) * 0.1);
|
||||
break;
|
||||
default:
|
||||
fields.put(v,msg.get(k));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
//报警过滤
|
||||
|
@ -3,6 +3,7 @@ package com.inspur.module.system.controller.admin.gatewayinfo.vo;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
|
||||
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
|
||||
import com.inspur.module.system.dal.dataobject.tenant.TenantDO;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ -47,4 +48,10 @@ public class TreeSelect {
|
||||
this.label = gatewayCardParamsDO.getChannelAlias();
|
||||
this.value = gatewayCardParamsDO.getParamMappingName();
|
||||
}
|
||||
|
||||
public TreeSelect(TenantDO tenantDO){
|
||||
this.id = tenantDO.getId().toString();
|
||||
this.label = tenantDO.getName();
|
||||
this.value = tenantDO.getId().toString();
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,15 @@ import com.inspur.framework.common.enums.UserTypeEnum;
|
||||
import com.inspur.framework.common.pojo.CommonResult;
|
||||
import com.inspur.framework.common.pojo.PageResult;
|
||||
import com.inspur.framework.common.util.object.BeanUtils;
|
||||
import com.inspur.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.inspur.module.infra.api.websocket.WebSocketSenderApi;
|
||||
import com.inspur.module.system.controller.admin.notice.vo.NoticePageReqVO;
|
||||
import com.inspur.module.system.controller.admin.notice.vo.NoticeRespVO;
|
||||
import com.inspur.module.system.controller.admin.notice.vo.NoticeSaveReqVO;
|
||||
import com.inspur.module.system.dal.dataobject.notice.NoticeDO;
|
||||
import com.inspur.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import com.inspur.module.system.service.notice.NoticeService;
|
||||
import com.inspur.module.system.service.notify.NotifyMessageService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -35,6 +38,9 @@ public class NoticeController {
|
||||
@Resource
|
||||
private WebSocketSenderApi webSocketSenderApi;
|
||||
|
||||
@Resource
|
||||
private NotifyMessageService notifyMessageService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建通知公告")
|
||||
@PreAuthorize("@ss.hasPermission('system:notice:create')")
|
||||
@ -89,4 +95,20 @@ public class NoticeController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/pushMessage")
|
||||
@Operation(summary = "推送通知公告", description = "直接插入到相关租户的通知")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:notice:update')")
|
||||
public CommonResult<Boolean> pushMessage(@RequestParam("id") Long id) {
|
||||
NoticeDO notice = noticeService.getNotice(id);
|
||||
Assert.notNull(notice, "公告不能为空");
|
||||
// 直接插入站内信表
|
||||
notice.setId(null);
|
||||
NotifyMessageDO notifyMessage = BeanUtils.toBean(notice, NotifyMessageDO.class);
|
||||
notifyMessage.setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname());
|
||||
notifyMessage.setTemplateType(notice.getType());
|
||||
notifyMessage.setUserId(SecurityFrameworkUtils.getLoginUserId());
|
||||
Long nums = notifyMessageService.createNotifyMessage(notifyMessage);
|
||||
return success(nums > 0);
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,6 @@ public class NoticeRespVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
private Integer tenantId;
|
||||
}
|
||||
|
@ -29,4 +29,6 @@ public class NoticeSaveReqVO {
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
private Integer tenantId;
|
||||
}
|
||||
|
@ -33,4 +33,6 @@ public class NotifyMessagePageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "是否已读", example = "true")
|
||||
private Boolean readStatus;
|
||||
}
|
||||
|
@ -46,4 +46,15 @@ public class NotifyMessageRespVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "通知标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "通知类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "通知内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
private Integer tenantId;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.inspur.framework.common.pojo.PageParam;
|
||||
import com.inspur.framework.common.pojo.PageResult;
|
||||
import com.inspur.framework.common.util.object.BeanUtils;
|
||||
import com.inspur.framework.excel.core.util.ExcelUtils;
|
||||
import com.inspur.module.system.controller.admin.gatewayinfo.vo.TreeSelect;
|
||||
import com.inspur.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
||||
import com.inspur.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
|
||||
import com.inspur.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||
@ -24,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.inspur.framework.common.pojo.CommonResult.success;
|
||||
@ -95,6 +97,15 @@ public class TenantController {
|
||||
return success(BeanUtils.toBean(pageResult, TenantRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getList")
|
||||
@Operation(summary = "获得租户列表")
|
||||
// @PreAuthorize("@ss.hasPermission('system:tenant:query')")
|
||||
public CommonResult<List<TreeSelect>> getTenantList(@Valid TenantPageReqVO pageVO) {
|
||||
List<TenantDO> tenantDOList = tenantService.getTenantList();
|
||||
List<TreeSelect> treeSelectList = tenantDOList.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
return success(treeSelectList);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出租户 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:tenant:export')")
|
||||
|
@ -43,6 +43,9 @@ public class UserProfileRespVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 所属角色
|
||||
*/
|
||||
|
@ -48,4 +48,5 @@ public class CustomerInfoSaveReqVO {
|
||||
@Size(message = "备注最大不允许超过500个字符", max = 500)
|
||||
private String remark;
|
||||
|
||||
private String tenantId;
|
||||
}
|
@ -71,4 +71,8 @@ public class CustomerInfoDO extends BaseDO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
@ -43,5 +43,8 @@ public class NoticeDO extends BaseDO {
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Integer tenantId;
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.inspur.module.system.dal.dataobject.notify;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.inspur.framework.common.enums.UserTypeEnum;
|
||||
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
@ -30,7 +31,7 @@ public class NotifyMessageDO extends BaseDO {
|
||||
/**
|
||||
* 站内信编号,自增
|
||||
*/
|
||||
@TableId
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 用户编号
|
||||
@ -96,4 +97,23 @@ public class NotifyMessageDO extends BaseDO {
|
||||
*/
|
||||
private LocalDateTime readTime;
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Integer tenantId;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
|
||||
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
|
||||
.likeIfPresent(NotifyMessageDO::getTemplateCode, reqVO.getTemplateCode())
|
||||
.eqIfPresent(NotifyMessageDO::getTemplateType, reqVO.getTemplateType())
|
||||
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
|
||||
@ -39,16 +40,16 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
|
||||
return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()),
|
||||
new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.in(NotifyMessageDO::getId, ids)
|
||||
.eq(NotifyMessageDO::getUserId, userId)
|
||||
.eq(NotifyMessageDO::getUserType, userType)
|
||||
// .eq(NotifyMessageDO::getUserId, userId)
|
||||
// .eq(NotifyMessageDO::getUserType, userType)
|
||||
.eq(NotifyMessageDO::getReadStatus, false));
|
||||
}
|
||||
|
||||
default int updateListRead(Long userId, Integer userType) {
|
||||
return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()),
|
||||
new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||
.eq(NotifyMessageDO::getUserId, userId)
|
||||
.eq(NotifyMessageDO::getUserType, userType)
|
||||
// .eq(NotifyMessageDO::getUserId, userId)
|
||||
// .eq(NotifyMessageDO::getUserType, userType)
|
||||
.eq(NotifyMessageDO::getReadStatus, false));
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,11 @@ public interface NotifyMessageService {
|
||||
Long createNotifyMessage(Long userId, Integer userType,
|
||||
NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams);
|
||||
|
||||
/**
|
||||
* 新增站内信
|
||||
*/
|
||||
Long createNotifyMessage(NotifyMessageDO notifyMessageDO);
|
||||
|
||||
/**
|
||||
* 获得站内信分页
|
||||
*
|
||||
|
@ -37,6 +37,16 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
|
||||
return message.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增站内信
|
||||
*/
|
||||
@Override
|
||||
public Long createNotifyMessage(NotifyMessageDO notifyMessageDO){
|
||||
notifyMessageDO.setReadStatus(false);
|
||||
notifyMessageMapper.insert(notifyMessageDO);
|
||||
return notifyMessageDO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NotifyMessageDO> getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
|
||||
return notifyMessageMapper.selectPage(pageReqVO);
|
||||
|
@ -120,6 +120,11 @@ public interface TenantService {
|
||||
*/
|
||||
List<Long> getTenantIdList();
|
||||
|
||||
/**
|
||||
* 获得所有租户信息列表
|
||||
*/
|
||||
List<TenantDO> getTenantList();
|
||||
|
||||
/**
|
||||
* 校验租户是否合法
|
||||
*
|
||||
|
@ -81,6 +81,10 @@ public class TenantServiceImpl implements TenantService {
|
||||
return CollectionUtils.convertList(tenants, TenantDO::getId);
|
||||
}
|
||||
|
||||
public List<TenantDO> getTenantList(){
|
||||
return tenantMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validTenant(Long id) {
|
||||
TenantDO tenant = getTenant(id);
|
||||
|
@ -232,6 +232,7 @@ imt:
|
||||
base-package: ${imt.info.base-package}
|
||||
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
||||
front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
||||
ignoreTenantId: 1
|
||||
tenant: # 多租户相关配置项
|
||||
enable: true
|
||||
ignore-urls:
|
||||
@ -316,7 +317,7 @@ imt:
|
||||
data:
|
||||
mqtt:
|
||||
host: tcp://117.73.2.117:1883
|
||||
clientId: imt
|
||||
clientId: imt_2
|
||||
topics: printer/top/# #符号“#”是代表以 printer/top 开头的所有子主题
|
||||
topic1: iipwg/jc #单个topic
|
||||
userName: jc
|
||||
|
@ -51,3 +51,14 @@ export function exportGatewayCardInfoExcel(params) {
|
||||
responseType: "blob",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取采集卡参数树
|
||||
*/
|
||||
// 获得机床网关采集卡
|
||||
export function getGatewayCardTree(equipId) {
|
||||
return request({
|
||||
url: "/imt/gateway-card-info/getCardTree?equipId=" + equipId,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
@ -473,31 +473,39 @@
|
||||
:before-close="beforeAlarmDataClose"
|
||||
center
|
||||
>
|
||||
<div
|
||||
class="block"
|
||||
style="text-align:center;"
|
||||
>
|
||||
<el-date-picker
|
||||
v-model="datetimeRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
align="right"
|
||||
style="margin-right:10px"
|
||||
>
|
||||
</el-date-picker>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleAlarmDataQuery(null)"
|
||||
>查 询</el-button>
|
||||
<el-button
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
@click="resetAlarmDataQuery"
|
||||
>重 置</el-button>
|
||||
<div style="display:flex;justify-content: space-between;">
|
||||
<div class="block">
|
||||
<el-cascader
|
||||
v-model="dataQueryParams.nameKey"
|
||||
:options="cardOptions"
|
||||
filterable
|
||||
@change="cardChange"
|
||||
></el-cascader>
|
||||
</div>
|
||||
<div class="block">
|
||||
<el-date-picker
|
||||
v-model="datetimeRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
align="right"
|
||||
style="margin-right:10px"
|
||||
@change="datetimeChange"
|
||||
>
|
||||
</el-date-picker>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleAlarmDataQuery(null)"
|
||||
>查 询</el-button>
|
||||
<el-button
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
@click="resetAlarmDataQuery"
|
||||
>重 置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-loading="loading"
|
||||
@ -505,7 +513,7 @@
|
||||
style="height:500px"
|
||||
></div>
|
||||
</el-dialog>
|
||||
<alarm-submit-maintenance-order-form ref="submitOrderForm"/>
|
||||
<alarm-submit-maintenance-order-form ref="submitOrderForm" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -516,8 +524,8 @@ import * as EquipAlarmDataApi from "@/api/system/alarm/equipalarmdata";
|
||||
import AlarmDataForm from "./AlarmDataForm.vue";
|
||||
import { getFieldList } from "@/api/data/query.js";
|
||||
import { getAlarmRules } from "@/api/system/alarm/alarmrules";
|
||||
import AlarmSubmitMaintenanceOrderForm
|
||||
from "@/views/system/maintenance/maintenanceInfo/alarmSubmitMaintenanceOrderForm.vue";
|
||||
import AlarmSubmitMaintenanceOrderForm from "@/views/system/maintenance/maintenanceInfo/alarmSubmitMaintenanceOrderForm.vue";
|
||||
import { getGatewayCardTree } from "@/api/system/gatewayinfo/card";
|
||||
var _ = require("lodash");
|
||||
export default {
|
||||
name: "AlarmData",
|
||||
@ -585,6 +593,7 @@ export default {
|
||||
dataQueryParams: {
|
||||
equipId: null,
|
||||
nameKey: null,
|
||||
tableName: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
},
|
||||
@ -599,6 +608,7 @@ export default {
|
||||
selectedRow: {},
|
||||
datetimeRange: [],
|
||||
showOrderSubmit: false,
|
||||
cardOptions: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -611,26 +621,35 @@ export default {
|
||||
this.alarmLevel = this.$route.query.alarmLevel;
|
||||
},
|
||||
methods: {
|
||||
getIsSubmitOrder(){
|
||||
EquipAlarmDataApi.isSubmitOrder(this.$route.query.equipAlarmId).then(res=>{
|
||||
this.showOrderSubmit = res.data
|
||||
})
|
||||
cardChange(e) {
|
||||
// console.log("选择:", e);
|
||||
// console.log("绑定:", this.dataQueryParams.nameKey);
|
||||
this.dataQueryParams.nameKey = e[1];
|
||||
this.dataQueryParams.tableName = e[0];
|
||||
this.handleAlarmDataQuery(null);
|
||||
},
|
||||
datetimeChange() {
|
||||
this.datetimeRange = this.formatTimeRange(this.datetimeRange);
|
||||
},
|
||||
getIsSubmitOrder() {
|
||||
EquipAlarmDataApi.isSubmitOrder(this.$route.query.equipAlarmId).then(
|
||||
(res) => {
|
||||
this.showOrderSubmit = res.data;
|
||||
}
|
||||
);
|
||||
},
|
||||
async handleAlarmDataQuery(row) {
|
||||
//需要row提供匹配数据名称和单位等信息
|
||||
this.loading = true;
|
||||
//根据时间查询参数数据
|
||||
this.dataQueryParams.nameKey = row
|
||||
? row.nameKey
|
||||
: this.selectedRow.nameKey;
|
||||
// this.dataQueryParams.nameKey = row
|
||||
// ? row.nameKey
|
||||
// : this.selectedRow.nameKey;
|
||||
if (this.datetimeRange == null || this.datetimeRange.length == 0) {
|
||||
this.datetimeRange = this.getDefaultTimeRange(row.lastAlarmTime);
|
||||
} else if (row == null) {
|
||||
this.datetimeRange = this.formatTimeRange(this.datetimeRange);
|
||||
}
|
||||
this.dataQueryParams.startTime = this.datetimeRange[0];
|
||||
this.dataQueryParams.endTime = this.datetimeRange[1];
|
||||
|
||||
const data = await getFieldList(this.dataQueryParams);
|
||||
const info = await getAlarmRules(this.selectedRow.alarmRulesId);
|
||||
this.getEchartData(data.data, info.data);
|
||||
@ -660,15 +679,29 @@ export default {
|
||||
this.detailLoading = false;
|
||||
},
|
||||
/**报警趋势 */
|
||||
handleAlarmTrend(row) {
|
||||
async handleAlarmTrend(row) {
|
||||
// console.log("row:", row);
|
||||
if (_.endsWith(row.nameKey, "_diff")) {
|
||||
row.nameKey = row.nameKey.substr(0, row.nameKey.length - 5);
|
||||
}
|
||||
this.dataQueryParams.equipId = row.equipId;
|
||||
this.selectedRow = row;
|
||||
this.alarmDataOpen = true;
|
||||
this.alarmDataTitle = row.nameKey + "参数报警趋势";
|
||||
this.datetimeRange = this.getDefaultTimeRange(row.lastAlarmTime); //最新报警时间前一小时数据
|
||||
this.handleAlarmDataQuery(row);
|
||||
const cardTree = await getGatewayCardTree(row.equipId);
|
||||
this.cardOptions = cardTree.data;
|
||||
this.cardOptions.forEach((e) => {
|
||||
const list = e.children;
|
||||
const matchKey = list.filter((c) => c.value === row.nameKey);
|
||||
if (matchKey && matchKey.length > 0) {
|
||||
this.dataQueryParams.tableName = e.value;
|
||||
this.dataQueryParams.nameKey = row.nameKey;
|
||||
// console.log("匹配的数据1:", matchKey);
|
||||
// console.log("匹配的数据2:", e);
|
||||
this.handleAlarmDataQuery(row);
|
||||
}
|
||||
});
|
||||
},
|
||||
getDefaultTimeRange(time) {
|
||||
const alarmTime = new Date(time);
|
||||
@ -711,7 +744,7 @@ export default {
|
||||
* 维修工单
|
||||
*/
|
||||
handelMaintanence() {
|
||||
this.$refs.submitOrderForm.open(this.$route.query.equipAlarmId)
|
||||
this.$refs.submitOrderForm.open(this.$route.query.equipAlarmId);
|
||||
},
|
||||
/**echart表初始化 */
|
||||
initchart(xData, yData, name, unit) {
|
||||
@ -754,8 +787,9 @@ export default {
|
||||
color: "#4E5969", //设置文字颜色
|
||||
},
|
||||
formatter: (prams) => {
|
||||
let name = parseFloat(_.get(prams, [0, "name"])).toFixed(2);
|
||||
let value = parseFloat(_.get(prams, [0, "value"])).toFixed(4);
|
||||
console.log("prams:", prams);
|
||||
let name = _.get(prams, [0, "name"]);
|
||||
let value = parseFloat(_.get(prams, [0, "value"])).toFixed(2);
|
||||
return (
|
||||
"<span style='color:#6D85CE'>" +
|
||||
`(${name}` +
|
||||
|
@ -1,56 +1,125 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
width="45%"
|
||||
v-dialogDrag
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="客户名称" prop="customerName">
|
||||
<el-input v-model="formData.customerName" placeholder="请输入客户名称"/>
|
||||
<el-form-item
|
||||
label="客户名称"
|
||||
prop="customerName"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.customerName"
|
||||
placeholder="请输入客户名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="所属行业" prop="industryType">
|
||||
<el-select v-model="formData.industryType" placeholder="请选择所属行业" style="width:100%">
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||
<el-form-item
|
||||
label="所属行业"
|
||||
prop="industryType"
|
||||
>
|
||||
<el-select
|
||||
v-model="formData.industryType"
|
||||
placeholder="请选择所属行业"
|
||||
style="width:100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="地区" prop="districtName">
|
||||
<el-cascader v-model="areaTreeData" :options="areaTree" clearable
|
||||
:props="{ value: 'id',label: 'name',children: 'children'}"
|
||||
@change="areaTreeChange" style="width:100%"></el-cascader>
|
||||
<el-form-item
|
||||
label="地区"
|
||||
prop="districtName"
|
||||
>
|
||||
<el-cascader
|
||||
v-model="areaTreeData"
|
||||
:options="areaTree"
|
||||
clearable
|
||||
:props="{ value: 'id',label: 'name',children: 'children'}"
|
||||
@change="areaTreeChange"
|
||||
style="width:100%"
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="详细地址" prop="address">
|
||||
<el-input v-model="formData.address" placeholder="请输入详细地址"/>
|
||||
<el-form-item
|
||||
label="详细地址"
|
||||
prop="address"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.address"
|
||||
placeholder="请输入详细地址"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系人姓名" prop="contactPerson">
|
||||
<el-input v-model="formData.contactPerson" placeholder="请输入联系人姓名"/>
|
||||
<el-form-item
|
||||
label="联系人姓名"
|
||||
prop="contactPerson"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.contactPerson"
|
||||
placeholder="请输入联系人姓名"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系人电话" prop="contactPhone">
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入联系人电话"/>
|
||||
<el-form-item
|
||||
label="联系人电话"
|
||||
prop="contactPhone"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.contactPhone"
|
||||
placeholder="请输入联系人电话"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea"
|
||||
:rows="4" placeholder="请输入内容"/>
|
||||
<el-form-item
|
||||
label="备注"
|
||||
prop="remark"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="请输入内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
|
||||
<div
|
||||
slot="footer"
|
||||
class="dialog-footer"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitForm"
|
||||
:disabled="formLoading"
|
||||
>确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -58,8 +127,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as CustomerInfoApi from '@/api/system/baseData/customerInfo';
|
||||
import {getAreaTree} from "@/api/system/area";
|
||||
import * as CustomerInfoApi from "@/api/system/baseData/customerInfo";
|
||||
import { getAreaTree } from "@/api/system/area";
|
||||
|
||||
export default {
|
||||
name: "CustomerInfoForm",
|
||||
@ -91,30 +160,36 @@ export default {
|
||||
},
|
||||
// 表单校验
|
||||
formRules: {
|
||||
customerName: [{required: true, message: '客户名称不能为空', trigger: 'blur'}],
|
||||
industryType: [{ required: true, message: '请选择所属行业', trigger: 'change' }],
|
||||
customerName: [
|
||||
{ required: true, message: "客户名称不能为空", trigger: "blur" },
|
||||
],
|
||||
industryType: [
|
||||
{ required: true, message: "请选择所属行业", trigger: "change" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
getAreaTree().then(res => {
|
||||
getAreaTree().then((res) => {
|
||||
const list = res.data;
|
||||
this.areaTree = this.handleTreeList(list);
|
||||
})
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
areaTreeChange(value) {
|
||||
console.log(value)
|
||||
console.log(value);
|
||||
},
|
||||
handleTreeList(list) { // 删除第三级children
|
||||
handleTreeList(list) {
|
||||
// 删除第三级children
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].children.length < 1) { // 判断children的数组长度
|
||||
list[i].children = undefined
|
||||
if (list[i].children.length < 1) {
|
||||
// 判断children的数组长度
|
||||
list[i].children = undefined;
|
||||
} else {
|
||||
this.handleTreeList(list[i].children)
|
||||
this.handleTreeList(list[i].children);
|
||||
}
|
||||
}
|
||||
return list
|
||||
return list;
|
||||
},
|
||||
/** 打开弹窗 */
|
||||
async open(id) {
|
||||
@ -144,7 +219,10 @@ export default {
|
||||
const data = this.formData;
|
||||
// 修改的提交
|
||||
if (data.customerId) {
|
||||
if (this.areaTreeData[2] != null && this.areaTreeData[2] !== undefined){
|
||||
if (
|
||||
this.areaTreeData[2] != null &&
|
||||
this.areaTreeData[2] !== undefined
|
||||
) {
|
||||
data.provinceCode = this.areaTreeData[0];
|
||||
data.cityCode = this.areaTreeData[1];
|
||||
data.district = this.areaTreeData[2];
|
||||
@ -152,11 +230,14 @@ export default {
|
||||
await CustomerInfoApi.updateCustomerInfo(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
this.$emit("success");
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
if (this.areaTreeData[2] != null && this.areaTreeData[2] !== undefined){
|
||||
if (
|
||||
this.areaTreeData[2] != null &&
|
||||
this.areaTreeData[2] !== undefined
|
||||
) {
|
||||
data.provinceCode = this.areaTreeData[0];
|
||||
data.cityCode = this.areaTreeData[1];
|
||||
data.district = this.areaTreeData[2];
|
||||
@ -165,7 +246,7 @@ export default {
|
||||
await CustomerInfoApi.createCustomerInfo(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
this.$emit("success");
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -188,7 +269,7 @@ export default {
|
||||
};
|
||||
this.areaTreeData = [];
|
||||
this.resetForm("formRef");
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -1,52 +1,107 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="120px">
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
width="45%"
|
||||
v-dialogDrag
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="120px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="机床组件名称" prop="componentName">
|
||||
<el-input v-model="formData.componentName" placeholder="请输入机床组件名称"/>
|
||||
<el-form-item
|
||||
label="机床组件名称"
|
||||
prop="componentName"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.componentName"
|
||||
placeholder="请输入机床组件名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="组件编号" prop="componentNo">
|
||||
<el-input v-model="formData.componentNo" placeholder="请输入组件编号"/>
|
||||
<el-form-item
|
||||
label="组件编号"
|
||||
prop="componentNo"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.componentNo"
|
||||
placeholder="请输入组件编号"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="机床设备" prop="equipId">
|
||||
<el-form-item
|
||||
label="机床设备"
|
||||
prop="equipId"
|
||||
>
|
||||
<el-cascader
|
||||
v-model="cascaderValue"
|
||||
:options="equipCascader"
|
||||
:props="{ value: 'id',label: 'name',children: 'children'}"
|
||||
clearable
|
||||
@change="cascaderChange" style="width:100%"></el-cascader>
|
||||
@change="cascaderChange"
|
||||
style="width:100%"
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="组件类型" prop="componentType">
|
||||
<el-select v-model="formData.componentType" placeholder="请选择组件类型" style="width:100%">
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMPONENT_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||
<el-form-item
|
||||
label="组件类型"
|
||||
prop="componentType"
|
||||
>
|
||||
<el-select
|
||||
v-model="formData.componentType"
|
||||
placeholder="请选择组件类型"
|
||||
style="width:100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in this.getDictDatas(DICT_TYPE.COMPONENT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- <el-form-item label="组件状态" prop="status">-->
|
||||
<!-- <el-select v-model="formData.status" placeholder="请选择组件状态" style="width:100%">-->
|
||||
<!-- <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMPONENT_STATUS)"-->
|
||||
<!-- :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" :rows="4" type="textarea" placeholder="请输入备注"/>
|
||||
<!-- <el-form-item label="组件状态" prop="status">-->
|
||||
<!-- <el-select v-model="formData.status" placeholder="请选择组件状态" style="width:100%">-->
|
||||
<!-- <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMPONENT_STATUS)"-->
|
||||
<!-- :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item
|
||||
label="备注"
|
||||
prop="remark"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
:rows="4"
|
||||
type="textarea"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
|
||||
<div
|
||||
slot="footer"
|
||||
class="dialog-footer"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitForm"
|
||||
:disabled="formLoading"
|
||||
>确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -54,15 +109,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as ComponentInfoApi from '@/api/system/equip/componentInfo';
|
||||
import {getEquipCascader} from '@/api/system/equip/equipInfo';
|
||||
import * as ComponentInfoApi from "@/api/system/equip/componentInfo";
|
||||
import { getEquipCascader } from "@/api/system/equip/equipInfo";
|
||||
|
||||
export default {
|
||||
name: "ComponentInfoForm",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
cascaderValue:[],
|
||||
cascaderValue: [],
|
||||
equipCascader: [],
|
||||
equipSelection: [],
|
||||
// 弹出层标题
|
||||
@ -83,23 +138,33 @@ export default {
|
||||
},
|
||||
// 表单校验
|
||||
formRules: {
|
||||
equipId: [{ required: true, message: '机床设备不能为空', trigger: 'change' }],
|
||||
componentName: [{ required: true, message: '机床组件名称不能为空', trigger: 'blur' }],
|
||||
componentType: [{ required: true, message: '组件类型不能为空', trigger: 'change' }],
|
||||
componentNo: [{ required: true, message: '组件编号不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '组件状态不能为空', trigger: 'change' }],
|
||||
equipId: [
|
||||
{ required: true, message: "机床设备不能为空", trigger: "change" },
|
||||
],
|
||||
componentName: [
|
||||
{ required: true, message: "机床组件名称不能为空", trigger: "blur" },
|
||||
],
|
||||
componentType: [
|
||||
{ required: true, message: "组件类型不能为空", trigger: "change" },
|
||||
],
|
||||
componentNo: [
|
||||
{ required: true, message: "组件编号不能为空", trigger: "blur" },
|
||||
],
|
||||
status: [
|
||||
{ required: true, message: "组件状态不能为空", trigger: "change" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
getEquipCascader().then(res=>{
|
||||
res.forEach(item=>{
|
||||
if (item.children == null){
|
||||
getEquipCascader().then((res) => {
|
||||
res.forEach((item) => {
|
||||
if (item.children == null) {
|
||||
item.disabled = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
this.equipCascader = res;
|
||||
})
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
//回显(多级)
|
||||
@ -126,10 +191,10 @@ export default {
|
||||
}
|
||||
return childrenEach(treeData, depth);
|
||||
},
|
||||
cascaderChange(value){
|
||||
if (value.length > 0){
|
||||
cascaderChange(value) {
|
||||
if (value.length > 0) {
|
||||
this.formData.equipId = value[1];
|
||||
}else {
|
||||
} else {
|
||||
this.formData.equipId = null;
|
||||
}
|
||||
},
|
||||
@ -143,7 +208,10 @@ export default {
|
||||
try {
|
||||
const res = await ComponentInfoApi.getComponentInfo(id);
|
||||
this.formData = res.data;
|
||||
this.cascaderValue = this.changeDetSelect(this.formData.equipId,this.equipCascader);
|
||||
this.cascaderValue = this.changeDetSelect(
|
||||
this.formData.equipId,
|
||||
this.equipCascader
|
||||
);
|
||||
this.title = "修改机床组件信息";
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
@ -163,14 +231,14 @@ export default {
|
||||
await ComponentInfoApi.updateComponentInfo(data);
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
this.$emit("success");
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
await ComponentInfoApi.createComponentInfo(data);
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.$emit('success');
|
||||
this.$emit("success");
|
||||
} finally {
|
||||
this.formLoading = false;
|
||||
}
|
||||
@ -188,7 +256,7 @@ export default {
|
||||
};
|
||||
this.cascaderValue = [];
|
||||
this.resetForm("formRef");
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -1,84 +1,215 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="公告标题" prop="title">
|
||||
<el-input v-model="queryParams.title" placeholder="请输入公告标题" clearable @keyup.enter.native="handleQuery"/>
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryForm"
|
||||
size="small"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item
|
||||
label="公告标题"
|
||||
prop="title"
|
||||
>
|
||||
<el-input
|
||||
v-model="queryParams.title"
|
||||
placeholder="请输入公告标题"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="公告状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="公告状态" clearable>
|
||||
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label"
|
||||
:value="parseInt(dict.value)"/>
|
||||
<el-form-item
|
||||
label="公告状态"
|
||||
prop="status"
|
||||
>
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="公告状态"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in statusDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button>
|
||||
<el-button
|
||||
icon="el-icon-refresh"
|
||||
@click="resetQuery"
|
||||
>重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-row
|
||||
:gutter="10"
|
||||
class="mb8"
|
||||
>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['system:notice:create']" s>新增
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:notice:create']"
|
||||
s
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar
|
||||
:showSearch.sync="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="noticeList">
|
||||
<el-table-column label="序号" align="center" prop="id" width="100"/>
|
||||
<el-table-column label="公告标题" align="center" prop="title" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="公告类型" align="center" prop="type" width="100">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="noticeList"
|
||||
>
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
prop="id"
|
||||
width="100"
|
||||
/>
|
||||
<el-table-column
|
||||
label="公告标题"
|
||||
align="center"
|
||||
prop="title"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="公告类型"
|
||||
align="center"
|
||||
prop="type"
|
||||
width="100"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTICE_TYPE" :value="scope.row.type"/>
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.SYSTEM_NOTICE_TYPE"
|
||||
:value="scope.row.type"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status" width="100">
|
||||
<el-table-column
|
||||
label="状态"
|
||||
align="center"
|
||||
prop="status"
|
||||
width="100"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.COMMON_STATUS"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建者" align="center" prop="createBy" width="100"/>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
|
||||
<el-table-column
|
||||
label="创建者"
|
||||
align="center"
|
||||
prop="createBy"
|
||||
width="100"
|
||||
/>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="100"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:notice:update']">修改
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:notice:update']"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:notice:delete']">删除
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:notice:delete']"
|
||||
>删除
|
||||
</el-button>
|
||||
<el-button size="mini" type="text" @click="handlePush(scope.row.id)"
|
||||
v-hasPermi="['system:notice:update']">推送
|
||||
<el-button
|
||||
v-if="userData.tenantId === '1'"
|
||||
size="mini"
|
||||
type="text"
|
||||
@click="handlePush(scope.row.id)"
|
||||
v-hasPermi="['system:notice:update']"
|
||||
>推送
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改公告对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="open"
|
||||
width="780px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="公告标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入公告标题"/>
|
||||
<el-form-item
|
||||
label="公告标题"
|
||||
prop="title"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.title"
|
||||
placeholder="请输入公告标题"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="公告类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择">
|
||||
<el-form-item
|
||||
label="公告类型"
|
||||
prop="type"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.type"
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in noticeTypeDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
v-for="dict in noticeTypeDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@ -87,9 +218,9 @@
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in statusDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="parseInt(dict.value)"
|
||||
v-for="dict in statusDictDatas"
|
||||
:key="parseInt(dict.value)"
|
||||
:label="parseInt(dict.value)"
|
||||
>{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
@ -97,13 +228,40 @@
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="内容">
|
||||
<editor v-model="form.content" :min-height="192"/>
|
||||
<editor
|
||||
v-model="form.content"
|
||||
:min-height="192"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item
|
||||
label="推送客户"
|
||||
prop="tenantId"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.tenantId"
|
||||
placeholder="请选择客户名"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in tenantLists"
|
||||
:key="parseInt(item.id)"
|
||||
:label="item.label"
|
||||
:value="parseInt(item.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<div
|
||||
slot="footer"
|
||||
class="dialog-footer"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitForm"
|
||||
>确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -111,16 +269,26 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {addNotice, delNotice, getNotice, listNotice, pushNotice, updateNotice} from "@/api/system/notice";
|
||||
import Editor from '@/components/Editor';
|
||||
import {
|
||||
addNotice,
|
||||
delNotice,
|
||||
getNotice,
|
||||
listNotice,
|
||||
pushNotice,
|
||||
updateNotice,
|
||||
pushMessage,
|
||||
} from "@/api/system/notice";
|
||||
import Editor from "@/components/Editor";
|
||||
|
||||
import {CommonStatusEnum} from '@/utils/constants'
|
||||
import {DICT_TYPE, getDictDatas} from '@/utils/dict'
|
||||
import { CommonStatusEnum } from "@/utils/constants";
|
||||
import { DICT_TYPE, getDictDatas } from "@/utils/dict";
|
||||
import { getUserProfile } from "@/api/system/user";
|
||||
import { getTenantList } from "@/api/system/tenant";
|
||||
|
||||
export default {
|
||||
name: "SystemNotice",
|
||||
components: {
|
||||
Editor
|
||||
Editor,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -141,27 +309,36 @@ export default {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
title: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
title: [
|
||||
{required: true, message: "公告标题不能为空", trigger: "blur"}
|
||||
{ required: true, message: "公告标题不能为空", trigger: "blur" },
|
||||
],
|
||||
type: [
|
||||
{required: true, message: "公告类型不能为空", trigger: "change"}
|
||||
]
|
||||
{ required: true, message: "公告类型不能为空", trigger: "change" },
|
||||
],
|
||||
tenantId: [
|
||||
{ required: true, message: "推送客户不能为空", trigger: "change" },
|
||||
],
|
||||
},
|
||||
|
||||
// 枚举
|
||||
CommonStatusEnum: CommonStatusEnum,
|
||||
// 数据字典
|
||||
noticeTypeDictDatas: getDictDatas(DICT_TYPE.SYSTEM_NOTICE_TYPE),
|
||||
statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS)
|
||||
statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS),
|
||||
|
||||
userData: {},
|
||||
tenantLists: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getUserInfo();
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
@ -169,12 +346,22 @@ export default {
|
||||
/** 查询公告列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listNotice(this.queryParams).then(response => {
|
||||
listNotice(this.queryParams).then((response) => {
|
||||
this.noticeList = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
getUserInfo() {
|
||||
getUserProfile().then((res) => {
|
||||
this.userData = res.data;
|
||||
});
|
||||
},
|
||||
getTenantLists() {
|
||||
getTenantList().then((res) => {
|
||||
this.tenantLists = res.data;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
@ -187,7 +374,7 @@ export default {
|
||||
title: undefined,
|
||||
type: undefined,
|
||||
content: undefined,
|
||||
status: CommonStatusEnum.ENABLE
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
@ -204,14 +391,15 @@ export default {
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.getTenantLists();
|
||||
this.open = true;
|
||||
this.title = "添加公告";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getNotice(id).then(response => {
|
||||
const id = row.id || this.ids;
|
||||
getNotice(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改公告";
|
||||
@ -219,16 +407,16 @@ export default {
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate(valid => {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id !== undefined) {
|
||||
updateNotice(this.form).then(response => {
|
||||
updateNotice(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addNotice(this.form).then(response => {
|
||||
addNotice(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
@ -239,29 +427,34 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除公告编号为"' + ids + '"的数据项?').then(function () {
|
||||
return delNotice(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal
|
||||
.confirm('是否确认删除公告编号为"' + ids + '"的数据项?')
|
||||
.then(function () {
|
||||
return delNotice(ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
/** 推送按钮操作 */
|
||||
handlePush(id) {
|
||||
try {
|
||||
const self = this;
|
||||
// 推送的二次确认
|
||||
this.$modal.confirm('是否推送所选中通知?').then(() => {
|
||||
this.$modal.confirm("是否推送所选中通知?").then(() => {
|
||||
// 发起推送
|
||||
pushNotice(id).then(() => {
|
||||
self.$modal.success('推送成功');
|
||||
})
|
||||
})
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
// pushNotice(id).then(() => {
|
||||
// self.$modal.success("推送成功");
|
||||
// });
|
||||
pushMessage(id).then(() => {
|
||||
self.$modal.msgSuccess("推送成功");
|
||||
});
|
||||
});
|
||||
} catch {}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user