Commit df6ecdfc authored by wanghao's avatar wanghao

1 用户管理-燃气用户界面 导出,使用 模版填充格式实现。

2 用户管理-燃气用户界面 导出 时增加全局遮罩。
parent 2abf4f95
......@@ -2,6 +2,7 @@ package com.zehong.web.controller.supervise;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
......@@ -303,6 +304,77 @@ public class TDetectorUserController extends BaseController
return AjaxResult.success(message);
}
/**
* 自定义-模版下载-正确数据导出
* @param response r
* @param tDetectorUser t
*/
@GetMapping("/exportSuccessData")
public void exportSuccessData(HttpServletResponse response,TDetectorUser tDetectorUser) {
//获取用户信息
SysUser user = SecurityUtils.getLoginUser().getUser();
tDetectorUser.setBeyondEnterpriseId(user.getDeptId());
List<TDetectorUser> tDetectorUsers = tDetectorUserService.selectForExportTDetectorUserList(tDetectorUser);
//判断是否是 windows环境,
String osName = System.getProperty("os.name").toLowerCase();
try {
File file;
//如果是本地或测试环境
if (osName.contains("windows")) {
String filePath = "importTemplate/燃气用户导出模版.xlsx";
//用来读取resources下的文件
Resource resource = new ClassPathResource(filePath);
file = resource.getFile();
} else {
file = ResourceUtils.getFile("/data/java/baseversion/importTemplate/燃气用户导出模版.xlsx");
}
List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVoList = new ArrayList<>();
for (TDetectorUser tDetectorUserDb : tDetectorUsers) {
List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos = tDetectorUserDb.getUserManageSafetyDeviceExportVos();
if (userManageSafetyDeviceExportVos != null && userManageSafetyDeviceExportVos.size() > 0) {
userManageSafetyDeviceExportVoList.addAll(userManageSafetyDeviceExportVos);
}
}
TemplateExportParams params = new TemplateExportParams(file.getAbsolutePath(), true);
Map<String, Object> total = new HashMap<>();
total.put("gasUserMaplist",tDetectorUsers);
if(userManageSafetyDeviceExportVoList.size() > 0) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (UserManageSafetyDeviceExportVo userManageSafetyDeviceExportVo : userManageSafetyDeviceExportVoList) {
if (userManageSafetyDeviceExportVo.getDeviceInstallTime() != null) {
String format = sdf.format(userManageSafetyDeviceExportVo.getDeviceInstallTime());
userManageSafetyDeviceExportVo.setDeviceInstallTimeStr(format);
}
}
}
total.put("safetyDeviceMaplist",userManageSafetyDeviceExportVoList);
Workbook workbook = ExcelExportUtil.exportExcel(params, total);
String fileName = "燃气用户数据.xlsx";
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
workbook.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* 自定义-模版下载-带有错误数据
* @param response r
......@@ -388,8 +460,6 @@ public class TDetectorUserController extends BaseController
// 获取文件名
String filename = file.getName();
// 获取文件后缀名
String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
// 将文件写入输入流
FileInputStream fileInputStream = new FileInputStream(file);
......
......@@ -5,6 +5,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
......@@ -121,6 +122,10 @@ public class TDetectorUser extends BaseEntity
private List<Long> hasInspectUser;
/**
* 安全装置集合 导出时使用
*/
private List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos;
public String getBeyondEnterpriseName() {
return beyondEnterpriseName;
......@@ -339,6 +344,14 @@ public class TDetectorUser extends BaseEntity
this.errorMsg = errorMsg;
}
public List<UserManageSafetyDeviceExportVo> getUserManageSafetyDeviceExportVos() {
return userManageSafetyDeviceExportVos;
}
public void setUserManageSafetyDeviceExportVos(List<UserManageSafetyDeviceExportVo> userManageSafetyDeviceExportVos) {
this.userManageSafetyDeviceExportVos = userManageSafetyDeviceExportVos;
}
@Override
public String toString() {
return "TDetectorUser{" +
......
......@@ -33,9 +33,11 @@ public class UserManageSafetyDeviceExportVo {
/** 设备安装时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "设备安装时间(yyyy-mm-dd)", width = 30,format="yyyy-MM-dd")
@Excel(name = "设备安装时间(yyyy-mm-dd)",width = 30,format ="yyyy-MM-dd")
private Date deviceInstallTime;
private String deviceInstallTimeStr;
/** 安装位置 */
@Excel(name = "安装位置")
private String deviceInstallPosition;
......@@ -127,4 +129,12 @@ public class UserManageSafetyDeviceExportVo {
public void setPhone(String phone) {
this.phone = phone;
}
public String getDeviceInstallTimeStr() {
return deviceInstallTimeStr;
}
public void setDeviceInstallTimeStr(String deviceInstallTimeStr) {
this.deviceInstallTimeStr = deviceInstallTimeStr;
}
}
......@@ -61,6 +61,13 @@ public interface TDetectorUserMapper
* @return 燃气用户集合
*/
public List<TDetectorUser> selectTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表 - 导出使用
*
* @param tDetectorUser 燃气用户
* @return 燃气用户集合
*/
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表-new 有 居住区了
......
......@@ -68,6 +68,13 @@ public interface TGasuserSafetyDeviceInfoMapper
*/
public int deleteTGasuserSafetyDeviceInfoById(Long gasUserSafetyDeviceId);
/**
* 根据 userid删除 数据
* @param userId user
* @return r
*/
public void deleteTGasuserSafetyDeviceInfoByUserId(Long userId);
/**
* 批量删除用户管理-燃气用户-安全装置加装维护
*
......
......@@ -99,6 +99,15 @@ public interface ITDetectorUserService
* @return 燃气用户集合
*/
public List<TDetectorUser> newSelectTDetectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户列表 - 导出使用
* @param tDetectorUser t
* @return r
*/
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser);
public List<TDetectorUser> selectTDetectorListstatus(TDetectorUser tDetectorUser);
/**
......
......@@ -304,6 +304,16 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
return tDetectorUserMapper.newSelectTDetectorUserList(tDetectorUser);
}
/**
* 查询燃气用户列表 - 导出使用
* @param tDetectorUser t
* @return r
*/
@Override
public List<TDetectorUser> selectForExportTDetectorUserList(TDetectorUser tDetectorUser) {
return tDetectorUserMapper.selectForExportTDetectorUserList(tDetectorUser);
}
@Override
public List<TDetectorUser> selectTDetectorListstatus(TDetectorUser tDetectorUser){
return tDetectorUserMapper.selectTDetectorListstatus(tDetectorUser);
......@@ -335,8 +345,8 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
for (TGasuserSafetyDeviceInfo tGasuserSafetyDeviceInfo : gasuserSafetyDeviceInfoList) {
tGasuserSafetyDeviceInfo.setRelationGasuserId(detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.updatetRelationSafetyDeviceInfo(gasuserSafetyDeviceInfoList, detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.insertBatch(gasuserSafetyDeviceInfoList);
return 1;
}
......@@ -346,15 +356,21 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
* @return r
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateUserAndSafetyDevice(GasUserAndSafetyDeviceVo gasUserAndSafetyDeviceVo) {
TDetectorUser detectorUser = gasUserAndSafetyDeviceVo.getDetectorUser();
tDetectorUserMapper.updateTDetectorUser(detectorUser);
List<TGasuserSafetyDeviceInfo> gasuserSafetyDeviceInfoList = gasUserAndSafetyDeviceVo.getGasuserSafetyDeviceInfoList();
if (gasuserSafetyDeviceInfoList != null && gasuserSafetyDeviceInfoList.size() > 0) {
for (TGasuserSafetyDeviceInfo tGasuserSafetyDeviceInfo : gasuserSafetyDeviceInfoList) {
tGasuserSafetyDeviceInfo.setRelationGasuserId(detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.updatetRelationSafetyDeviceInfo(gasuserSafetyDeviceInfoList, detectorUser.getUserId());
}
gasuserSafetyDeviceInfoMapper.deleteTGasuserSafetyDeviceInfoByUserId(detectorUser.getUserId());
if (gasuserSafetyDeviceInfoList != null && gasuserSafetyDeviceInfoList.size() > 0) {
gasuserSafetyDeviceInfoMapper.insertBatch(gasuserSafetyDeviceInfoList);
}
return 1;
}
......
......@@ -21,12 +21,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
<result property="beyondEnterpriseName" column="beyond_enterprise_name" />
<result property="beyondEnterpriseName" column="enterprise_name" />
<result property="villageId" column="f_village_id" />
<result property="villageName" column="village_name" />
<result property="villageName" column="f_village_name" />
<result property="errorMsg" column="error_msg" />
</resultMap>
<resultMap type="TDetectorUser" id="TDetectorUserExportResult">
<result property="userId" column="user_id" />
<result property="username" column="username" />
<result property="nickName" column="nick_name" />
<result property="beyondEnterpriseId" column="beyond_enterprise_id" />
<result property="userType" column="user_type" />
<result property="gasType" column="gas_type" />
<result property="address" column="address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="linkman" column="linkman" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remarks" column="remarks" />
<result property="beyondEnterpriseName" column="enterprise_name" />
<result property="villageId" column="f_village_id" />
<result property="villageName" column="f_village_name" />
<result property="errorMsg" column="error_msg" />
<!-- collection 是用于建立一对多中集合属性的对应关系
ofType 用于指定集合元素的数据类型
-->
<collection property="userManageSafetyDeviceExportVos" ofType="UserManageSafetyDeviceExportVo">
<id property="userOwnId" column="user_id"/>
<result property="relationDeviceType" column="f_relation_device_type"/>
<result property="deviceName" column="f_device_name"/>
<result property="deviceModel" column="f_device_model"/>
<result property="fIotNo" column="f_iot_no"/>
<result property="detectionMedium" column="f_detection_medium"/>
<result property="deviceInstallTime" column="f_device_install_time"/>
<result property="deviceInstallPosition" column="f_device_install_position"/>
<result property="head" column="f_head"/>
<result property="phone" column="f_phone"/>
</collection>
</resultMap>
<resultMap type="TDetectorUserInspectVo" id="TDetectorUserInspectResult">
<result property="userId" column="user_id" />
<result property="nickName" column="nick_name" />
......@@ -54,6 +92,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="selectForExportTDetectorUserList" parameterType="TDetectorUser" resultMap="TDetectorUserExportResult">
select a.user_id,
a.username,
a.nick_name,
(CASE a.user_type WHEN '1' THEN '居民用户' WHEN '2' THEN '商业用户'WHEN '3' THEN '工业用户'WHEN '4' THEN '餐饮单位用户'end) as user_type ,
(CASE a.gas_type WHEN '0' THEN '天然气' WHEN '1' THEN '液化气' end) as gas_type ,
a.address, a.longitude, a.latitude, a.linkman, a.phone, a.email, a.create_time, a.update_time, a.is_del, a.remarks,
b.enterprise_name,a.f_village_id,v.f_village_name,
deviceInfo.f_relation_device_type,
deviceInfo.f_device_name,
deviceInfo.f_device_model,
deviceInfo.f_iot_no,
deviceInfo.f_detection_medium,
deviceInfo.f_device_install_time,
deviceInfo.f_device_install_position,
deviceInfo.f_head,
deviceInfo.f_phone
from t_detector_user a left join t_enterprise_info b on a.beyond_enterprise_id=b.enterprise_id
left join t_user_manage_village v on a.f_village_id=v.f_village_id
left join t_gasuser_safety_device_info deviceInfo on a.user_id = deviceInfo.f_relation_gasUser_id
<where> a.is_del = '0' and a.error_msg is null
<if test="beyondEnterpriseId != null and beyondEnterpriseId != -2"> and a.beyond_enterprise_id =#{beyondEnterpriseId}</if>
<if test="username != null and username != ''"> and a.username like concat('%', #{username}, '%')</if>
<if test="nickName != null and nickName != ''"> and (a.nick_name like concat('%', #{nickName}, '%') or a.username like concat('%', #{nickName}, '%'))</if>
<if test="isInspect != null and isInspect == 0">
and a.user_id not in
<foreach item="hasInspectUser" collection="hasInspectUser" open="(" separator="," close=")">
#{hasInspectUser}
</foreach>
</if>
<if test="isInspect != null and isInspect == 1">
and a.user_id in
<foreach item="hasInspectUser" collection="hasInspectUser" open="(" separator="," close=")">
#{hasInspectUser}
</foreach>
</if>
</where>
order by a.user_id desc
</select>
<select id="selectTDetectorUserList" parameterType="TDetectorUser" resultMap="TDetectorUserResult">
select a.user_id,
a.username,
......
......@@ -130,6 +130,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteTGasuserSafetyDeviceInfoById" parameterType="Long">
delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id = #{gasUserSafetyDeviceId}
</delete>
<select id="deleteTGasuserSafetyDeviceInfoByUserId" parameterType="Long">
delete from t_gasuser_safety_device_info where f_relation_gasUser_id = #{userId}
</select>
<delete id="deleteTGasuserSafetyDeviceInfoByIds" parameterType="String">
delete from t_gasuser_safety_device_info where f_gasUser_safety_device_id in
......
......@@ -175,4 +175,14 @@ export function exportErrorData() {
method: 'get',
responseType: 'blob'
})
}
//自定义-模版下载-正确数据导出-燃气用户
export function exportSuccessData(query) {
return request({
url: '/supervise/user/exportSuccessData',
method: 'get',
responseType: 'blob',
params: query
})
}
\ No newline at end of file
import Vue from 'vue'
import loading001 from './index.vue'
const LoadingConstructor = Vue.extend(loading001)
let loadingNum=0;
const instance = new LoadingConstructor({
el: document.createElement('div')
})
instance.show = false
const loading = {
show() {
instance.show = true
document.body.appendChild(instance.$el)
loadingNum++
},
hide() {
loadingNum--
if(loadingNum===0){
instance.show = false
}
}
}
export default {
install() {
if (!Vue.$showLoading) {
Vue.$showLoading = loading
}
Vue.mixin({
created() {
this.$showLoading = Vue.$showLoading
}
})
}
}
\ No newline at end of file
<template>
<div v-if="show">
<div class="loader-rainbow">
<div class="loader-inner">
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="loader-line-wrap">
<div class="loader-line"></div>
</div>
<div class="box10" style="margin-top: 120px">拼命加载中....</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "loading",
props: {
show: Boolean,
},
data() {
return {};
},
};
</script>
<style scoped>
.loader-rainbow {
position: fixed;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
transform: translate(-50%, -50%);
z-index: 9999;
background-color: rgba(0,0,0,.5);
}
.loader-inner {
bottom: 0;
height: 100px;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
width: 150px;
}
.loader-line-wrap {
animation: spin 2000ms cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
box-sizing: border-box;
height: 50px;
left: 0;
overflow: hidden;
position: absolute;
top: 0;
transform-origin: 50% 100%;
width: 100px;
}
.loader-line {
border: 4px solid transparent;
border-radius: 100%;
box-sizing: border-box;
height: 100px;
left: 0;
margin: 0 auto;
position: absolute;
right: 0;
top: 0;
width: 100px;
}
.loader-line-wrap:nth-child(1) {
animation-delay: -50ms;
}
.loader-line-wrap:nth-child(2) {
animation-delay: -100ms;
}
.loader-line-wrap:nth-child(3) {
animation-delay: -150ms;
}
.loader-line-wrap:nth-child(4) {
animation-delay: -200ms;
}
.loader-line-wrap:nth-child(5) {
animation-delay: -250ms;
}
.loader-line-wrap:nth-child(1) .loader-line {
border-color: hsl(0, 80%, 60%);
height: 90px;
width: 90px;
top: 7px;
}
.loader-line-wrap:nth-child(2) .loader-line {
border-color: hsl(60, 80%, 60%);
height: 76px;
width: 76px;
top: 14px;
}
.loader-line-wrap:nth-child(3) .loader-line {
border-color: hsl(120, 80%, 60%);
height: 62px;
width: 62px;
top: 21px;
}
.loader-line-wrap:nth-child(4) .loader-line {
border-color: hsl(180, 80%, 60%);
height: 48px;
width: 48px;
top: 28px;
}
.loader-line-wrap:nth-child(5) .loader-line {
border-color: hsl(240, 80%, 60%);
height: 34px;
width: 34px;
top: 35px;
}
@keyframes spin {
0%,
15% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.box10 {
background: linear-gradient(to bottom, rgb(107, 175, 240), rgb(245, 137, 227));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: bold;
font-size: 20px;
}
</style>
\ No newline at end of file
......@@ -47,6 +47,9 @@ import 'video.js/dist/video-js.css'
//require('video.js/dist/video-js.css')
//require('vue-video-player/src/custom-theme.css')
import exportLoadong from "./components/loading/index";
Vue.use(exportLoadong)
Vue.use(VideoPlayer)
// 全局方法挂载
Vue.prototype.$echarts = echarts;
......
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<!--<el-form-item label="用户账号" prop="username">
<el-input
v-model="queryParams.username"
placeholder="请输入用户账号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>-->
<el-form-item label="用户名称" prop="nickName">
<el-input
v-model="queryParams.nickName"
......@@ -62,7 +53,7 @@
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
@click="downloadSuccessDataMethod"
>导出</el-button>
</el-col>
......@@ -73,14 +64,12 @@
size="mini"
@click="handleImport">导入</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!--<el-table-column label="用户账号" align="center" prop="username" />-->
<el-table-column label="用户名称" align="center" prop="nickName" >
<span slot-scope="scope" v-if="scope.row.nickName">{{scope.row.nickName}}</span>
<span v-else>-</span>
......@@ -125,7 +114,6 @@
<span slot-scope="scope" v-if="scope.row.email">{{scope.row.email}}</span>
<span v-else>-</span>
</el-table-column>
<!--<el-table-column label="备注" align="center" prop="remarks" />-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
......@@ -265,11 +253,24 @@
</el-form>
<div class="tableTitle">
<img :src="relationImg" style="width: 24px; height: 25px;position: relative; left: -355px; top: -12px;"/>
<img :src="relationImg" style="width: 24px; height: 25px;position: relative; left: -355px; top: -12px; bottom: 8px;"/>
<span class="midText">安全装置</span>
<el-row :gutter="10" class="mb9">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="dialogFormVisible = true"
>新增</el-button>
</el-col>
</el-row>
</div>
<el-table v-loading="loadings" ref="multipleTable" :data="DetailInfoList" tooltip-effect="dark" style="width: 100%" max-height="250" @selection-change="tableDataSelectionChange">
<el-table v-loading="loadings" ref="multipleTable" :data="DetailInfoList" tooltip-effect="dark" style="width: 100%" max-height="250">
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="设备型号" align="center" prop="deviceModel" />
<el-table-column label="设备类型" align="center" prop="relationDeviceType" />
......@@ -293,15 +294,14 @@
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="selectDataListInfo">选择安全装置</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!--添加关联设备弹出框-->
<el-dialog title="添加安装置" :visible.sync="dialogFormVisible">
<el-form ref="formDetailInfo" :model="formDetailInfo" :rules="formDetailInfoRules" label-width="100px" style="height: 230px">
<el-dialog title="添加安装置" :visible.sync="dialogFormVisible">
<el-form ref="formDetailInfo" :model="formDetailInfo" :rules="formDetailInfoRules" label-width="100px">
<el-row>
<el-col :span="11">
......@@ -374,99 +374,11 @@
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="addSafetyDeviceInfo">提 交</el-button>
<el-button @click="dialogFormVisible=false">取 消</el-button>
</div>
</el-dialog>
<!--选择安全装置弹出框-->
<el-dialog title="选择安全装置" width="1100px" :visible.sync="dialogTableVisible" formLabelWidth="160px">
<template>
<el-form :model="dateQueryParams" ref="queryForm" :inline="true" v-show="showSearch" >
<el-form-item label="设备名称" prop="deviceName">
<el-input
v-model="dateQueryParams.deviceName"
placeholder="请输入设备名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备型号" prop="deviceCode">
<el-input
v-model="dateQueryParams.deviceModel"
placeholder="请输入设备型号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物联网编号" prop="deviceAddr">
<el-input
v-model="dateQueryParams.fIotNo"
placeholder="请输入物联网编号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryData">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQueryDate">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="dialogFormVisible = true"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="deleteListDetailInfo"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getDataList"></right-toolbar>
</el-row>
<el-table v-loading="safetyDeviceManageLoadings" ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" max-height="250" @selection-change="tableDataSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="设备型号" align="center" prop="deviceModel" />
<el-table-column label="设备类型" align="center" prop="relationDeviceType" />
<el-table-column label="物联网编号" width="85" align="center" prop="fIotNo" />
<el-table-column label="探测介质" align="center" prop="detectionMedium" />
<el-table-column label="设备安装时间" width="100" align="center" prop="deviceInstallTime" />
<el-table-column label="安装位置" align="center" prop="deviceInstallPosition" />
<el-table-column label="负责人" align="center" prop="head" />
<el-table-column label="联系电话" align="center" prop="phone" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="deleteDetailInfo(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="insertListDetailInfo">提 交</el-button>
<el-button @click="dialogTableVisible=false">取 消</el-button>
<el-button @click="dialogFormVisible=false">取 消</el-button>
</div>
</template>
</el-dialog>
<GetPos
......@@ -538,11 +450,11 @@
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser,newExportUser,
import { listUser, getUser, delUser,newExportUser,
getNoSelectSafetyDetailInfo,addSafetyDetailInfo,deleteSafetyDeviceInfo,
deleteSafetyDeviceListInfo,selectSafetyDeviceDetailInfo,
addUserAndSafetyDevice,updateUserAndSafetyDevice,importTemplate,downloadTemplate,
countImportError,clearImportError,exportErrorData} from "@/api/regulation/user";
countImportError,clearImportError,exportErrorData,exportSuccessData} from "@/api/regulation/user";
import { selectTEnterprise} from "@/api/regulation/supervise";
import { noPageListVillage} from "@/api/regulation/userManagement/village";
import GetPos from '@/components/GetPos';
......@@ -729,9 +641,39 @@ export default {
}
},
//自定义-模版下载-正确数据导出-燃气用户
downloadSuccessDataMethod() {
this.$showLoading.show()
exportSuccessData(this.queryParams).then((res) =>{
let blob = new Blob([res], {type: 'data:application/vnd.ms-excel;base64;charset=utf-8'});
let downloadElement = document.createElement('a');
let href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = '燃气用户数据'+'.xlsx'; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
this.$showLoading.hide()
return true
})
},
// 下载燃气用户错误 按钮
downloadImportError() {
// exportErrorData();
downloadImportError() {
exportErrorData().then((res) =>{
let blob = new Blob([res], {type: 'data:application/vnd.ms-excel;base64;charset=utf-8'});
......@@ -876,15 +818,6 @@ export default {
this.msgSuccess("删除成功");
}).catch(() => {});
},
//关联数据多选框选中数据
tableDataSelectionChange(selection){
this.ids = selection.map(item => item.gasUserSafetyDeviceId)
this.datalist=selection.map(item => item)
//按钮 非选中禁用
this.single = selection.length!==1
this.multiple = !selection.length
},
/**关联设备单条删除方法*/
deleteSafetyDeviceInfo(row){
const deviceIds = row.gasUserSafetyDeviceId;
......@@ -919,36 +852,24 @@ export default {
}).catch(() => {});
},
/**添加关联设备与设备绑定的数据 (存储到数组中)*/
insertListDetailInfo(row){
//获取已经选中的下级设备id
const deviceIds = this.ids;
const li=this.datalist;
if (this.form.userId != null) {
if (this.DetailInfoList) {
//修改
this.DetailInfoList=this.DetailInfoList.concat(this.datalist)
} else {
this.DetailInfoList=this.datalist;
}
//添加到数组中 以便下次使用
this.DetailInfoListId.push(deviceIds);
// alert(this.DetailInfoListId)
this.dialogTableVisible=false
this.msgSuccess("添加成功");
}else {
//添加
// this.DetailInfoList.push(this.datalist)
//清空数组数据 将之前的数据清空
this.DetailInfoListId.splice(row);
this.DetailInfoList=this.datalist;
//添加到数组中 以便下次使用
this.DetailInfoListId.push(deviceIds);
// alert(this.DetailInfoListId)
this.dialogTableVisible=false
this.msgSuccess("添加成功");
}
},
insertListDetailInfo(){
this.DetailInfoList.push(this.formDetailInfo);
//数据表单重置
this.formDetailInfo={
relationDeviceType: null,
deviceName:null,
deviceModel:null,
fIotNo:null,
detectionMedium:null,
deviceInstallTime:null,
deviceInstallPosition:null,
head:null,
phone:null
};
this.dialogFormVisible = false;
},
/**关联设备添加方法*/
addSafetyDeviceInfo(){
......@@ -1114,29 +1035,21 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.userId != null) {
updateUser(this.form).then(response => {
var tDeviceInfon={
detectorUser:this.form,
gasuserSafetyDeviceInfoList:this.DetailInfoList
}
updateUserAndSafetyDevice(JSON.stringify(tDeviceInfon)).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
if ( this.datalist !=null){
var tDeviceInfon={
detectorUser:this.form,
gasuserSafetyDeviceInfoList:this.datalist
}
//重新绑定修改后的关联设备
updateUserAndSafetyDevice(JSON.stringify(tDeviceInfon)).then(response => {
this.open = false;
this.getList();
});
}
});
} else {
var tDeviceInfon={
detectorUser:this.form,
gasuserSafetyDeviceInfoList:this.datalist
gasuserSafetyDeviceInfoList:this.DetailInfoList
}
addUserAndSafetyDevice(JSON.stringify(tDeviceInfon)).then(response => {
......@@ -1201,7 +1114,7 @@ export default {
}
};
</script>
<style>
<style scoped>
.tableTitle {
position: relative;
......@@ -1226,5 +1139,9 @@ export default {
.el-badge__content.is-fixed {
top: 0 !important;
right: 5px !important;
}
.mb9 {
left: -60px;
bottom: 8px;
}
</style>
\ No newline at end of file
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