From c6475f2a118231860aabcecdf4568db3f59c2374 Mon Sep 17 00:00:00 2001
From: "382696293@qq.com" <382696293@qq.com>
Date: Tue, 27 Feb 2024 10:11:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=AA=E5=99=A8=E7=AE=A1=E7=90=86-=E8=AF=B4?=
=?UTF-8?q?=E6=98=8E=E4=B9=A6=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../entity/WxInstrumentInstructions.java | 10 ++++
.../mapper/WxInstrumentInstructionsMapper.xml | 1 +
.../WxInstrumentInstructionsServiceImpl.java | 17 +++++++
.../src/views/system/instrument/index.vue | 51 ++++++++++++++++---
4 files changed, 73 insertions(+), 6 deletions(-)
diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentInstructions.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentInstructions.java
index f44b662..0c22650 100644
--- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentInstructions.java
+++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxInstrumentInstructions.java
@@ -42,6 +42,8 @@ public class WxInstrumentInstructions extends BaseEntity {
*/
private String nameUrl;
+ private boolean isSave = true;
+
/**
* 状态(0正常 1停用)
*/
@@ -96,6 +98,14 @@ public class WxInstrumentInstructions extends BaseEntity {
this.nameUrl = nameUrl;
}
+ public boolean isSave() {
+ return isSave;
+ }
+
+ public void setSave(boolean save) {
+ isSave = save;
+ }
+
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentInstructionsMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentInstructionsMapper.xml
index 7cf35ab..26418de 100644
--- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentInstructionsMapper.xml
+++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxInstrumentInstructionsMapper.xml
@@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and name like concat('%', #{name}, '%')
and link = #{link}
and status = #{status}
+ and id != #{id}
diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentInstructionsServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentInstructionsServiceImpl.java
index 349ec03..85daf0a 100644
--- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentInstructionsServiceImpl.java
+++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentInstructionsServiceImpl.java
@@ -3,6 +3,8 @@ package com.flossom.system.service.impl;
import java.util.List;
import com.flossom.common.core.domain.entity.WxInstrumentInstructions;
+import com.flossom.common.core.enums.Status;
+import com.flossom.common.core.exception.ServiceException;
import com.flossom.common.core.mapper.WxInstrumentInstructionsMapper;
import com.flossom.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -66,6 +68,13 @@ public class WxInstrumentInstructionsServiceImpl implements IWxInstrumentInstruc
@Override
public int insertWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) {
wxInstrumentInstructions.setCreateTime(DateUtils.getNowDate());
+ WxInstrumentInstructions query = new WxInstrumentInstructions();
+ query.setName(wxInstrumentInstructions.getName());
+ query.setStatus(Status.OK.getCode().longValue());
+ List instructions = wxInstrumentInstructionsMapper.selectWxInstrumentInstructionsList(query);
+ if(instructions != null && instructions.size() > 0) {
+ throw new ServiceException("不允许填写相同的说明书类型");
+ }
return wxInstrumentInstructionsMapper.insertWxInstrumentInstructions(wxInstrumentInstructions);
}
@@ -77,6 +86,14 @@ public class WxInstrumentInstructionsServiceImpl implements IWxInstrumentInstruc
*/
@Override
public int updateWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) {
+ WxInstrumentInstructions query = new WxInstrumentInstructions();
+ query.setId(wxInstrumentInstructions.getId());
+ query.setName(wxInstrumentInstructions.getName());
+ query.setStatus(Status.OK.getCode().longValue());
+ List instructions = wxInstrumentInstructionsMapper.selectWxInstrumentInstructionsList(query);
+ if(instructions != null && instructions.size() > 0) {
+ throw new ServiceException("不允许填写相同的说明书类型");
+ }
return wxInstrumentInstructionsMapper.updateWxInstrumentInstructions(wxInstrumentInstructions);
}
diff --git a/flossom-ui/src/views/system/instrument/index.vue b/flossom-ui/src/views/system/instrument/index.vue
index c034de4..084b0f2 100644
--- a/flossom-ui/src/views/system/instrument/index.vue
+++ b/flossom-ui/src/views/system/instrument/index.vue
@@ -1191,6 +1191,7 @@
:on-error="uploadError"
:file-list="scope.row.fileList"
accept=".pdf,.PDF"
+ :before-upload="pdfHandleBeforeUpload"
>
点击上传
@@ -1199,14 +1200,14 @@
复制说明书
保存说明书
["bmp", "gif", "jpg", "jpeg", "png", "mp4", "avi", "rmvb"],
},
+ pdfFileSize: {
+ type: Number,
+ default: 10,
+ },
+ pdfFileType: {
+ type: Array,
+ default: () => ["pdf", "PDF"],
+ },
},
data() {
return {
@@ -1512,6 +1521,7 @@ export default {
instrumentId: null,
name: null,
link: null,
+ save: false,
},
],
},
@@ -2325,6 +2335,7 @@ export default {
instrumentId: this.instrumentInstructions.instrumentId,
name: null,
link: null,
+ save: false,
})
},
editInstrumentInstructionVisible(row) {
@@ -2370,19 +2381,24 @@ export default {
this.addInstrumentInstructionLine()
}
},
- saveInstrumentInstruction(item) {
+ saveInstrumentInstruction(item, index) {
if (item.instrumentId == null) {
this.$modal.msgError('参数异常')
return
}
- if (item.name == null) {
- this.$modal.msgError('请输入说明书名称')
+ if (item.name == null || item.name.trim().length === 0) {
+ this.$modal.msgError('请输入说明书类型')
return
}
if (item.link == null) {
this.$modal.msgError('请上传说明书')
return
}
+ let pattern = /^[a-zA-Z0-9]+$/;
+ if (!pattern.test(item.name)) {
+ this.$modal.msgError("说明书类型只能为数字和英文的组合");
+ return;
+ }
if (item.id != null) {
updateInstructions(item).then((response) => {
this.$modal.msgSuccess('修改成功')
@@ -2390,6 +2406,7 @@ export default {
} else {
addInstructions(item).then((response) => {
this.$modal.msgSuccess('新增成功')
+ item.save = true;
})
}
},
@@ -2473,6 +2490,28 @@ export default {
}
}
return true;
+ },
+ pdfHandleBeforeUpload(file) {
+ // 校检文件类型
+ if (this.pdfFileType) {
+ const fileName = file.name.split('.');
+ const fileExt = fileName[fileName.length - 1];
+ const isTypeOk = this.pdfFileType.indexOf(fileExt) >= 0;
+ if (!isTypeOk) {
+ this.$modal.msgError(`说明书文件类型只能为PDF格式`);
+ return false;
+ }
+ }
+
+ // 校检文件大小
+ if (this.pdfFileSize) {
+ const isLt = file.size / 1024 / 1024 < this.pdfFileSize;
+ if (!isLt) {
+ this.$modal.msgError(`上传文件大小不能超过 ${this.pdfFileSize} MB!`);
+ return false;
+ }
+ }
+ return true;
},
},
}