Commit 4c70d55c authored by 陈明豪's avatar 陈明豪

Merge remote-tracking branch 'origin/master'

parents 72d15941 e09806ce
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.DictUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -20,6 +29,7 @@ import com.ruoyi.system.domain.Yxry; ...@@ -20,6 +29,7 @@ import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.service.IYxryService; import com.ruoyi.system.service.IYxryService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/** /**
* 阳性人员Controller * 阳性人员Controller
...@@ -101,4 +111,47 @@ public class YxryController extends BaseController ...@@ -101,4 +111,47 @@ public class YxryController extends BaseController
{ {
return toAjax(yxryService.deleteYxryByIds(ids)); return toAjax(yxryService.deleteYxryByIds(ids));
} }
@PostMapping("/importTemplate")
@PreAuthorize("@ss.hasPermi('system:yxry:add')")
@Log(title = "下载阳性人员模板", businessType = BusinessType.IMPORT)
public void importTemplate(HttpServletResponse response) throws Exception {
ExcelUtil<Yxry> util = new ExcelUtil<Yxry>(Yxry.class);
Class<? extends Yxry> clazz = new Yxry().getClass();
List<SysDictData> isYzs = DictUtils.getDictCache("yz_status");
List<SysDictData> isYins = DictUtils.getDictCache("yin_status");
List<SysDictData> areas = DictUtils.getDictCache("residential_area");
List<SysDictData> streets = DictUtils.getDictCache("street_town");
List<SysDictData> isControls = DictUtils.getDictCache("control_status");
List<SysDictData> isHomes = DictUtils.getDictCache("home_status");
List<SysDictData> glPlaces = DictUtils.getDictCache("isolation_status");
String[] isYz=isYzs.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] isYin=isYins.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] area=areas.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] street=streets.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] isControl=isControls.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] isHome=isHomes.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
String[] glPlace=glPlaces.stream().map(SysDictData::getDictLabel).toArray(String[]::new);
ExcelUtil.setClassExcelAttribute( clazz,"isYz","combo",isYz);
ExcelUtil.setClassExcelAttribute( clazz,"isYin","combo",isYin);
ExcelUtil.setClassExcelAttribute( clazz,"area","combo",area);
ExcelUtil.setClassExcelAttribute( clazz,"street","combo",street);
ExcelUtil.setClassExcelAttribute( clazz,"isControl","combo",isControl);
ExcelUtil.setClassExcelAttribute( clazz,"isHome","combo",isHome);
ExcelUtil.setClassExcelAttribute( clazz,"glPlace","combo",glPlace);
util.importTemplateExcel(response, "阳性人员");
}
@Log(title = "导入阳性人员", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:yxry:add')")
@PostMapping("/importData")
public void importData(MultipartFile file, HttpServletResponse response) throws Exception
{
ExcelUtil<Yxry> util = new ExcelUtil<Yxry>(Yxry.class);
List<Yxry> list = util.importExcel(file.getInputStream());
yxryService.importList(list, response);
}
} }
...@@ -107,7 +107,7 @@ public class ZlqkController extends BaseController ...@@ -107,7 +107,7 @@ public class ZlqkController extends BaseController
@PostMapping("/importTemplate") @PostMapping("/importTemplate")
@PreAuthorize("@ss.hasPermi('system:zlqk:add')") @PreAuthorize("@ss.hasPermi('system:zlqk:import')")
@Log(title = "下载治疗情况模板", businessType = BusinessType.IMPORT) @Log(title = "下载治疗情况模板", businessType = BusinessType.IMPORT)
public void importTemplate(HttpServletResponse response) public void importTemplate(HttpServletResponse response)
{ {
...@@ -116,7 +116,7 @@ public class ZlqkController extends BaseController ...@@ -116,7 +116,7 @@ public class ZlqkController extends BaseController
} }
@Log(title = "导入治疗情况", businessType = BusinessType.IMPORT) @Log(title = "导入治疗情况", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:zlqk:add')") @PreAuthorize("@ss.hasPermi('system:zlqk:import')")
@PostMapping("/importData") @PostMapping("/importData")
public void importData(MultipartFile file,HttpServletResponse response) throws Exception public void importData(MultipartFile file,HttpServletResponse response) throws Exception
{ {
......
...@@ -23,5 +23,15 @@ public class CheckUtils ...@@ -23,5 +23,15 @@ public class CheckUtils
return Pattern.matches(regex, card); return Pattern.matches(regex, card);
} }
/**
* 校验手机号
* 校验通过返回true,否则返回false
*/
public static boolean checkPhone(String phone)
{
if (StringUtils.isEmpty(phone))
return false;
String regex="/^1\\d{10}$|^(0\\d{2,3}-?|\\(0\\d{2,3}\\))?[1-9]\\d{4,7}(-\\d{1,8})?$/";
return Pattern.matches(regex, phone);
}
} }
...@@ -5,9 +5,7 @@ import java.io.FileOutputStream; ...@@ -5,9 +5,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.Field; import java.lang.reflect.*;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -1731,4 +1729,19 @@ public class ExcelUtil<T> ...@@ -1731,4 +1729,19 @@ public class ExcelUtil<T>
} }
return method; return method;
} }
//利用反射机制设置combo
public static void setClassExcelAttribute(Class clazz,String declareField,String
memberKey,Object memberValue) throws Exception{
Field declaredField = clazz.getDeclaredField(declareField);
declaredField.setAccessible(true);
Excel annotation = declaredField.getAnnotation(Excel.class);
if (annotation != null) {
InvocationHandler ih = Proxy.getInvocationHandler(annotation);
Field memberValuesField = ih.getClass().getDeclaredField("memberValues");
memberValuesField.setAccessible(true);
Map memberValues = (Map) memberValuesField.get(ih);
memberValues.put(memberKey, memberValue);
}
}
} }
...@@ -22,45 +22,57 @@ public class Yxry extends BaseEntity ...@@ -22,45 +22,57 @@ public class Yxry extends BaseEntity
/** 日期 */ /** 日期 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "阳性时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date sbDate; private Date sbDate;
/** 流调人员 */ /** 流调人员 */
@Excel(name = "流调人员") @Excel(name = "流调人员姓名")
private String ldry; private String ldry;
/** 姓名 */ /** 姓名 */
@Excel(name = "姓名") @Excel(name = "患者姓名")
private String userName; private String userName;
/** 身份证号码 */ /** 身份证号码 */
@Excel(name = "身份证号码") @Excel(name = "患者身份证号码",cellType= Excel.ColumnType.STRING)
private String cardNo; private String cardNo;
/** 联系方式 */ /** 联系方式 */
@Excel(name = "联系方式") @Excel(name = "患者联系方式")
private String phone; private String phone;
/** 联系方式 */
@Excel(name = "人员类别")
private String userType;
/** 联系方式 */
@Excel(name = "风险来源")
private String riskSource;
/** 是否重症 */
@Excel(name = "是否重症", dictType = "yz_status",combo = "")
private String isYz;
/** 是否转阴 */
@Excel(name = "是否转阴", dictType = "yin_status",combo = "")
private String isYin;
/** 居住地所在区 */ /** 居住地所在区 */
@Excel(name = "居住地所在区") @Excel(name = "患者居住地所在区", dictType = "residential_area",combo = "")
private String area; private String area;
/** 街道/镇 */ /** 街道/镇 */
@Excel(name = "街道/镇") @Excel(name = "街道/镇", dictType = "street_town",combo = "")
private String street; private String street;
/** 隔离状态 */
@Excel(name = "隔离状态")
private String isolationStatus;
/** 是否已管控 */
@Excel(name = "是否已管控")
private String isControl;
/** 小区/村名称 */ /** 小区/村名称 */
@Excel(name = "小区/村名称") @Excel(name = "小区/村名称")
private String community; private String community;
/** 住址 */
@Excel(name = "住址")
private String address;
/** 楼号单元号门牌号 */ /** 楼号单元号门牌号 */
@Excel(name = "楼号") @Excel(name = "楼号")
private String building; private String building;
...@@ -73,27 +85,50 @@ public class Yxry extends BaseEntity ...@@ -73,27 +85,50 @@ public class Yxry extends BaseEntity
@Excel(name = "门牌号") @Excel(name = "门牌号")
private String house; private String house;
/** 转运状态 */ /** 是否已管控 */
@Excel(name = "转运状态") @Excel(name = "是否已管控", dictType = "control_status",combo = "")
private String hasAcid; private String isControl;
/** 是否符合居家隔离 */
@Excel(name = "是否符合居家隔离", dictType = "home_status",combo = "")
private String isHome;
/** 转运时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "转运时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date zyTime;
/** 隔离位置 */ /** 隔离位置 */
@Excel(name = "隔离位置") @Excel(name = "隔离位置", dictType = "isolation_status",combo = "")
private String glPlace; private String glPlace;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 隔离状态 */
// @Excel(name = "隔离状态")
private String isolationStatus;
/** 转运状态 */
// @Excel(name = "转运状态")
private String hasAcid;
/** 状态(0正常 1停用) */ /** 状态(0正常 1停用) */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用") // @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
/** 删除标志(0代表存在 2代表删除) */ /** 删除标志(0代表存在 2代表删除) */
private String delFlag; private String delFlag;
/** 住址 */
private String address;
/** 是否重症 */
@Excel(name = "是否重症",readConverterExp = "0=是,1=否")
private String isYz;
/** 身份证校验 */
private String checkCard;
public void setId(Long id) public void setId(Long id)
{ {
...@@ -298,4 +333,62 @@ public class Yxry extends BaseEntity ...@@ -298,4 +333,62 @@ public class Yxry extends BaseEntity
public void setIsYz(String isYz) { public void setIsYz(String isYz) {
this.isYz = isYz; this.isYz = isYz;
} }
public String getCheckCard() {
return checkCard;
}
public void setCheckCard(String checkCard) {
this.checkCard = checkCard;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getRiskSource() {
return riskSource;
}
public void setRiskSource(String riskSource) {
this.riskSource = riskSource;
}
public String getIsYin() {
return isYin;
}
public void setIsYin(String isYin) {
this.isYin = isYin;
}
public String getIsHome() {
return isHome;
}
public void setIsHome(String isHome) {
this.isHome = isHome;
}
public Date getZyTime() {
return zyTime;
}
public void setZyTime(Date zyTime) {
this.zyTime = zyTime;
}
@Override
public String getRemark() {
return remark;
}
@Override
public void setRemark(String remark) {
this.remark = remark;
}
} }
...@@ -2,6 +2,9 @@ package com.ruoyi.system.service; ...@@ -2,6 +2,9 @@ package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.Yxry; import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.Zlqk;
import javax.servlet.http.HttpServletResponse;
/** /**
* 阳性人员Service接口 * 阳性人员Service接口
...@@ -58,4 +61,6 @@ public interface IYxryService ...@@ -58,4 +61,6 @@ public interface IYxryService
* @return 结果 * @return 结果
*/ */
public int deleteYxryById(Long id); public int deleteYxryById(Long id);
void importList(List<Yxry> list, HttpServletResponse response);
} }
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.CheckUtils;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Zlqk;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
...@@ -10,6 +18,8 @@ import com.ruoyi.system.mapper.YxryMapper; ...@@ -10,6 +18,8 @@ import com.ruoyi.system.mapper.YxryMapper;
import com.ruoyi.system.domain.Yxry; import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.service.IYxryService; import com.ruoyi.system.service.IYxryService;
import javax.servlet.http.HttpServletResponse;
/** /**
* 阳性人员Service业务层处理 * 阳性人员Service业务层处理
* *
...@@ -97,4 +107,61 @@ public class YxryServiceImpl implements IYxryService ...@@ -97,4 +107,61 @@ public class YxryServiceImpl implements IYxryService
{ {
return yxryMapper.deleteYxryById(id); return yxryMapper.deleteYxryById(id);
} }
/**
* 导入数据
*
* @return 结果
*/
@Override
public void importList(List<Yxry> list, HttpServletResponse response)
{
if (StringUtils.isNull(list) || list.size() == 0)
{
throw new ServiceException("导入数据不能为空!");
}
List<Yxry> trueList = new ArrayList<>();
List<Yxry> failureList = new ArrayList<>();
for (Yxry zlqk : list) {
// if (StringUtils.isNotEmpty(zlqk.getCardNo()) && StringUtils.isNotEmpty(zlqk.getUserName())
// &&StringUtils.isNotEmpty(zlqk.getPhone()) && zlqk.getSbDate() != null
// &&StringUtils.isNotEmpty(zlqk.getRemark()) && StringUtils.isNotEmpty(zlqk.getMedication())){
// //校验身份证是否重复
// List<Zlqk> zlqks = zlqkMapper.selectZlqkByCard(zlqk.getCardNo());
// if (!zlqks.isEmpty())
// failureList.add(zlqk);
// else {
// zlqks = list.stream().filter(l -> zlqk.getCardNo().equals(l.getCardNo())).collect(Collectors.toList());
// if (zlqks.size()>1)
// failureList.add(zlqk);
// else {
// if (CheckUtils.checkCard(zlqk.getCardNo()))
// zlqk.setCheckCard("正确");
// else
// zlqk.setCheckCard("不正确");
// trueList.add(zlqk);
// }
// }
// } else if (StringUtils.isEmpty(zlqk.getCardNo()) || StringUtils.isEmpty(zlqk.getUserName())
// &&StringUtils.isEmpty(zlqk.getPhone()) || zlqk.getSbDate() == null
// &&StringUtils.isEmpty(zlqk.getRemark()) || StringUtils.isEmpty(zlqk.getMedication())) {
// continue;
// } else {
// failureList.add(zlqk);
// }
}
if (!trueList.isEmpty()){
for (Yxry zlqk : trueList) {
zlqk.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
zlqk.setCreateTime(DateUtils.getNowDate());
}
// zlqkMapper.insertBatchZlqk(trueList);
}
if (!failureList.isEmpty()) {
ExcelUtil<Yxry> util = new ExcelUtil<Yxry>(Yxry.class);
util.exportExcel(response, failureList, "阳性人员数据");
// return AjaxResult.error(111,"导出失败数据"+failureList.size()+"条");
}
// return AjaxResult.success("数据导入成功");
}
} }
...@@ -111,11 +111,8 @@ public class ZlqkServiceImpl implements IZlqkService ...@@ -111,11 +111,8 @@ public class ZlqkServiceImpl implements IZlqkService
} }
/** /**
* 导入用户数据 * 导入数据
* *
* @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @return 结果 * @return 结果
*/ */
@Override @Override
...@@ -147,9 +144,9 @@ public class ZlqkServiceImpl implements IZlqkService ...@@ -147,9 +144,9 @@ public class ZlqkServiceImpl implements IZlqkService
trueList.add(zlqk); trueList.add(zlqk);
} }
} }
} else if (StringUtils.isEmpty(zlqk.getCardNo()) || StringUtils.isEmpty(zlqk.getUserName()) } else if (StringUtils.isEmpty(zlqk.getCardNo()) && StringUtils.isEmpty(zlqk.getUserName())
&&StringUtils.isEmpty(zlqk.getPhone()) || zlqk.getSbDate() == null &&StringUtils.isEmpty(zlqk.getPhone()) && zlqk.getSbDate() == null
&&StringUtils.isEmpty(zlqk.getRemark()) || StringUtils.isEmpty(zlqk.getMedication())) { &&StringUtils.isEmpty(zlqk.getRemark()) && StringUtils.isEmpty(zlqk.getMedication())) {
continue; continue;
} else { } else {
failureList.add(zlqk); failureList.add(zlqk);
......
...@@ -18,14 +18,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,14 +18,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="checkCard" column="check_card" />
</resultMap> </resultMap>
<sql id="selectZlqkVo"> <sql id="selectZlqkVo">
select id, sb_date, user_name, card_no, phone, medication, status, del_flag, create_by, create_time, update_by, update_time, remark from zlqk select id, sb_date, user_name, card_no, phone, medication, status, del_flag, create_by, create_time, update_by, update_time, remark,check_card from zlqk
</sql> </sql>
<select id="selectZlqkList" parameterType="Zlqk" resultMap="ZlqkResult"> <select id="selectZlqkList" parameterType="Zlqk" resultMap="ZlqkResult">
select a.id, a.sb_date, a.user_name, a.card_no, a.phone, a.medication, a.status, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark from zlqk a select a.id, a.sb_date, a.user_name, a.card_no, a.phone, a.medication, a.status, a.del_flag, a.create_by,
a.create_time, a.update_by, a.update_time, a.remark,a.check_card from zlqk a
left join sys_user u on u.user_id = a.create_by left join sys_user u on u.user_id = a.create_by
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
where a.del_flag = 0 where a.del_flag = 0
...@@ -64,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -64,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="checkCard != null">check_card,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sbDate != null">#{sbDate},</if> <if test="sbDate != null">#{sbDate},</if>
...@@ -78,14 +81,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -78,14 +81,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="checkCard != null">#{checkCard},</if>
</trim> </trim>
</insert> </insert>
<insert id="insertBatchZlqk" parameterType="Zlqk"> <insert id="insertBatchZlqk" parameterType="Zlqk">
insert into zlqk (sb_date,user_name,card_no,phone,medication,create_by,create_time,remark) values insert into zlqk (sb_date,user_name,card_no,phone,medication,create_by,create_time,remark,check_card) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
(#{item.sbDate},#{item.userName},#{item.cardNo},#{item.phone},#{item.medication},#{item.createBy}, (#{item.sbDate},#{item.userName},#{item.cardNo},#{item.phone},#{item.medication},#{item.createBy},
#{item.createTime},#{item.remark}) #{item.createTime},#{item.remark},#{item.checkCard})
</foreach> </foreach>
</insert> </insert>
...@@ -104,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -104,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="checkCard != null">check_card = #{checkCard},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
</el-table> </el-table>
</div> </div>
<div class="tableList"> <div class="tableList">
<div class="title">累计数据</div>0- <div class="title">累计数据</div>
<el-table <el-table
border border
v-loading="loading" v-loading="loading"
......
...@@ -150,6 +150,15 @@ ...@@ -150,6 +150,15 @@
v-hasPermi="['system:fcry:remove']" v-hasPermi="['system:fcry:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -312,17 +321,69 @@ ...@@ -312,17 +321,69 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog">取 消</el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listFcry, getFcry, delFcry, addFcry, updateFcry } from "@/api/system/fcry"; import { listFcry, getFcry, delFcry, addFcry, updateFcry } from "@/api/system/fcry";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Fcry", name: "Fcry",
dicts: ['street_town', 'residential_area', 'sys_normal_disable'], dicts: ['street_town', 'residential_area', 'sys_normal_disable'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -370,6 +431,105 @@ export default { ...@@ -370,6 +431,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询方舱人员列表 */ /** 查询方舱人员列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -92,6 +92,15 @@ ...@@ -92,6 +92,15 @@
v-hasPermi="['system:fkqk:remove']" v-hasPermi="['system:fkqk:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -215,17 +224,69 @@ ...@@ -215,17 +224,69 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog">取 消</el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listFkqk, getFkqk, delFkqk, addFkqk, updateFkqk } from "@/api/system/fkqk"; import { listFkqk, getFkqk, delFkqk, addFkqk, updateFkqk } from "@/api/system/fkqk";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Fkqk", name: "Fkqk",
dicts: ['street_town', 'sys_normal_disable'], dicts: ['street_town', 'sys_normal_disable'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -266,6 +327,105 @@ export default { ...@@ -266,6 +327,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询小区封控情况列表 */ /** 查询小区封控情况列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -142,6 +142,15 @@ ...@@ -142,6 +142,15 @@
v-hasPermi="['system:gldry:remove']" v-hasPermi="['system:gldry:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -300,17 +309,69 @@ ...@@ -300,17 +309,69 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog">取 消</el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listGldry, getGldry, delGldry, addGldry, updateGldry } from "@/api/system/gldry"; import { listGldry, getGldry, delGldry, addGldry, updateGldry } from "@/api/system/gldry";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Gldry", name: "Gldry",
dicts: ['street_town', 'residential_area', 'sys_normal_disable'], dicts: ['street_town', 'residential_area', 'sys_normal_disable'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -357,6 +418,105 @@ export default { ...@@ -357,6 +418,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询隔离点人员列表 */ /** 查询隔离点人员列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -232,6 +232,15 @@ ...@@ -232,6 +232,15 @@
v-hasPermi="['system:hscj:remove']" v-hasPermi="['system:hscj:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -445,17 +454,70 @@ ...@@ -445,17 +454,70 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog">取 消</el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listHscj, getHscj, delHscj, addHscj, updateHscj } from "@/api/system/hscj"; import { listHscj, getHscj, delHscj, addHscj, updateHscj } from "@/api/system/hscj";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Hscj", name: "Hscj",
dicts: ['street_town', 'residential_area', 'sys_user_sex', 'sys_normal_disable'], dicts: ['street_town', 'residential_area', 'sys_user_sex', 'sys_normal_disable'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -513,6 +575,105 @@ export default { ...@@ -513,6 +575,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询核酸采集列表 */ /** 查询核酸采集列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -126,6 +126,15 @@ ...@@ -126,6 +126,15 @@
v-hasPermi="['system:ycsb:remove']" v-hasPermi="['system:ycsb:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -267,17 +276,69 @@ ...@@ -267,17 +276,69 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog"> </el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listYcsb, getYcsb, delYcsb, addYcsb, updateYcsb } from "@/api/system/ycsb"; import { listYcsb, getYcsb, delYcsb, addYcsb, updateYcsb } from "@/api/system/ycsb";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Ycsb", name: "Ycsb",
dicts: ['street_town', 'residential_area', 'sys_normal_disable'], dicts: ['street_town', 'residential_area', 'sys_normal_disable'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -322,6 +383,105 @@ export default { ...@@ -322,6 +383,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询抗原异常上报列表 */ /** 查询抗原异常上报列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -188,6 +188,15 @@ ...@@ -188,6 +188,15 @@
v-hasPermi="['system:yxry:remove']" v-hasPermi="['system:yxry:remove']"
>删除</el-button> >删除</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -389,17 +398,69 @@ ...@@ -389,17 +398,69 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 治疗情况导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog"> </el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listYxry, getYxry, delYxry, addYxry, updateYxry } from "@/api/system/yxry"; import { listYxry, getYxry, delYxry, addYxry, updateYxry } from "@/api/system/yxry";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
export default { export default {
name: "Yxry", name: "Yxry",
dicts: ['isolation_status', 'street_town', 'residential_area', 'sys_normal_disable', 'control_status','yz_status'], dicts: ['isolation_status', 'street_town', 'residential_area', 'sys_normal_disable', 'control_status','yz_status'],
data() { data() {
return { return {
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
},
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
...@@ -451,6 +512,105 @@ export default { ...@@ -451,6 +512,105 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '治疗情况导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 查询阳性人员列表 */ /** 查询阳性人员列表 */
getList() { getList() {
this.loading = true; this.loading = true;
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
icon="el-icon-upload2" icon="el-icon-upload2"
size="mini" size="mini"
@click="handleImport" @click="handleImport"
v-hasPermi="['system:zlqk:import']"
>导入</el-button> >导入</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment