仪器管理-说明书优化

master
382696293@qq.com 2 years ago
parent 3ca80f079a
commit c6475f2a11

@ -42,6 +42,8 @@ public class WxInstrumentInstructions extends BaseEntity {
*/ */
private String nameUrl; private String nameUrl;
private boolean isSave = true;
/** /**
* 0 1 * 0 1
*/ */
@ -96,6 +98,14 @@ public class WxInstrumentInstructions extends BaseEntity {
this.nameUrl = nameUrl; this.nameUrl = nameUrl;
} }
public boolean isSave() {
return isSave;
}
public void setSave(boolean save) {
isSave = save;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="link != null and link != ''"> and link = #{link}</if> <if test="link != null and link != ''"> and link = #{link}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
<if test="id != null "> and id != #{id}</if>
</where> </where>
</select> </select>

@ -3,6 +3,8 @@ package com.flossom.system.service.impl;
import java.util.List; import java.util.List;
import com.flossom.common.core.domain.entity.WxInstrumentInstructions; 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.mapper.WxInstrumentInstructionsMapper;
import com.flossom.common.core.utils.DateUtils; import com.flossom.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -66,6 +68,13 @@ public class WxInstrumentInstructionsServiceImpl implements IWxInstrumentInstruc
@Override @Override
public int insertWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) { public int insertWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) {
wxInstrumentInstructions.setCreateTime(DateUtils.getNowDate()); wxInstrumentInstructions.setCreateTime(DateUtils.getNowDate());
WxInstrumentInstructions query = new WxInstrumentInstructions();
query.setName(wxInstrumentInstructions.getName());
query.setStatus(Status.OK.getCode().longValue());
List<WxInstrumentInstructions> instructions = wxInstrumentInstructionsMapper.selectWxInstrumentInstructionsList(query);
if(instructions != null && instructions.size() > 0) {
throw new ServiceException("不允许填写相同的说明书类型");
}
return wxInstrumentInstructionsMapper.insertWxInstrumentInstructions(wxInstrumentInstructions); return wxInstrumentInstructionsMapper.insertWxInstrumentInstructions(wxInstrumentInstructions);
} }
@ -77,6 +86,14 @@ public class WxInstrumentInstructionsServiceImpl implements IWxInstrumentInstruc
*/ */
@Override @Override
public int updateWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) { public int updateWxInstrumentInstructions(WxInstrumentInstructions wxInstrumentInstructions) {
WxInstrumentInstructions query = new WxInstrumentInstructions();
query.setId(wxInstrumentInstructions.getId());
query.setName(wxInstrumentInstructions.getName());
query.setStatus(Status.OK.getCode().longValue());
List<WxInstrumentInstructions> instructions = wxInstrumentInstructionsMapper.selectWxInstrumentInstructionsList(query);
if(instructions != null && instructions.size() > 0) {
throw new ServiceException("不允许填写相同的说明书类型");
}
return wxInstrumentInstructionsMapper.updateWxInstrumentInstructions(wxInstrumentInstructions); return wxInstrumentInstructionsMapper.updateWxInstrumentInstructions(wxInstrumentInstructions);
} }

@ -1191,6 +1191,7 @@
:on-error="uploadError" :on-error="uploadError"
:file-list="scope.row.fileList" :file-list="scope.row.fileList"
accept=".pdf,.PDF" accept=".pdf,.PDF"
:before-upload="pdfHandleBeforeUpload"
> >
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
</el-upload> </el-upload>
@ -1199,14 +1200,14 @@
<el-table-column label="操作"> <el-table-column label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.link != null" v-show="scope.row.save"
size="mini" size="mini"
type="text" type="text"
@click="copyInstructionNameUrl(scope.row)" @click="copyInstructionNameUrl(scope.row)"
>复制说明书 >复制说明书
</el-button> </el-button>
<el-button <el-button
v-if="scope.row.link != null" v-show="scope.row.save"
size="mini" size="mini"
type="text" type="text"
@click="viewInstrumentInstruction(scope.row)" @click="viewInstrumentInstruction(scope.row)"
@ -1216,7 +1217,7 @@
v-if="scope.row.link != null" v-if="scope.row.link != null"
size="mini" size="mini"
type="text" type="text"
@click="saveInstrumentInstruction(scope.row)" @click="saveInstrumentInstruction(scope.row, scope.$index)"
>保存说明书 >保存说明书
</el-button> </el-button>
<el-button <el-button
@ -1297,6 +1298,14 @@ export default {
type: Array, type: Array,
default: () => ["bmp", "gif", "jpg", "jpeg", "png", "mp4", "avi", "rmvb"], default: () => ["bmp", "gif", "jpg", "jpeg", "png", "mp4", "avi", "rmvb"],
}, },
pdfFileSize: {
type: Number,
default: 10,
},
pdfFileType: {
type: Array,
default: () => ["pdf", "PDF"],
},
}, },
data() { data() {
return { return {
@ -1512,6 +1521,7 @@ export default {
instrumentId: null, instrumentId: null,
name: null, name: null,
link: null, link: null,
save: false,
}, },
], ],
}, },
@ -2325,6 +2335,7 @@ export default {
instrumentId: this.instrumentInstructions.instrumentId, instrumentId: this.instrumentInstructions.instrumentId,
name: null, name: null,
link: null, link: null,
save: false,
}) })
}, },
editInstrumentInstructionVisible(row) { editInstrumentInstructionVisible(row) {
@ -2370,19 +2381,24 @@ export default {
this.addInstrumentInstructionLine() this.addInstrumentInstructionLine()
} }
}, },
saveInstrumentInstruction(item) { saveInstrumentInstruction(item, index) {
if (item.instrumentId == null) { if (item.instrumentId == null) {
this.$modal.msgError('参数异常') this.$modal.msgError('参数异常')
return return
} }
if (item.name == null) { if (item.name == null || item.name.trim().length === 0) {
this.$modal.msgError('请输入说明书名称') this.$modal.msgError('请输入说明书类型')
return return
} }
if (item.link == null) { if (item.link == null) {
this.$modal.msgError('请上传说明书') this.$modal.msgError('请上传说明书')
return return
} }
let pattern = /^[a-zA-Z0-9]+$/;
if (!pattern.test(item.name)) {
this.$modal.msgError("说明书类型只能为数字和英文的组合");
return;
}
if (item.id != null) { if (item.id != null) {
updateInstructions(item).then((response) => { updateInstructions(item).then((response) => {
this.$modal.msgSuccess('修改成功') this.$modal.msgSuccess('修改成功')
@ -2390,6 +2406,7 @@ export default {
} else { } else {
addInstructions(item).then((response) => { addInstructions(item).then((response) => {
this.$modal.msgSuccess('新增成功') this.$modal.msgSuccess('新增成功')
item.save = true;
}) })
} }
}, },
@ -2473,6 +2490,28 @@ export default {
} }
} }
return true; 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;
}, },
}, },
} }

Loading…
Cancel
Save