|
@@ -45,7 +45,7 @@
|
|
<view class="processList deviceRegistList" style="height: calc(100vh - 470rpx);">
|
|
<view class="processList deviceRegistList" style="height: calc(100vh - 470rpx);">
|
|
<checkbox-group @change="changeCheckbox">
|
|
<checkbox-group @change="changeCheckbox">
|
|
<view class="cu-list menu-avatar ">
|
|
<view class="cu-list menu-avatar ">
|
|
- <view class=" site-item text-center margin-top" v-if="!newDeviceManage.length" >暂无结果</view>
|
|
|
|
|
|
+ <view class=" site-item text-center margin-top" v-if="!newDeviceManage.length">暂无结果</view>
|
|
<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
|
|
<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
|
|
v-for="(item,index) in deviceManage" :key="index" :data-target="'move-box-' + index">
|
|
v-for="(item,index) in deviceManage" :key="index" :data-target="'move-box-' + index">
|
|
<view class="cu-form-group margin-top">
|
|
<view class="cu-form-group margin-top">
|
|
@@ -54,7 +54,7 @@
|
|
</view>
|
|
</view>
|
|
<view class="cu-avatar round lg" style="background-image:url(../../static/device-icon.png)">
|
|
<view class="cu-avatar round lg" style="background-image:url(../../static/device-icon.png)">
|
|
</view>
|
|
</view>
|
|
- <view class="content" @longpress="showDetail(item)" >
|
|
|
|
|
|
+ <view class="content" @longpress="showDetail(item)">
|
|
<view class="pro-title">
|
|
<view class="pro-title">
|
|
<view class="cut">{{item.owner_name}}</view>
|
|
<view class="cut">{{item.owner_name}}</view>
|
|
</view>
|
|
</view>
|
|
@@ -67,12 +67,12 @@
|
|
|
|
|
|
<view class="showDetailEdit" v-if="item.isShow">
|
|
<view class="showDetailEdit" v-if="item.isShow">
|
|
<view @tap="goDeviceEdit(item)">修改设备</view>
|
|
<view @tap="goDeviceEdit(item)">修改设备</view>
|
|
- <!-- <view @tap="deleteItem2" data-target="DialogModal2" :data-id='item.id'
|
|
|
|
|
|
+ <!-- <view @tap="deleteItem2" data-target="DialogModal2" :data-id='item.id'
|
|
:data-index='index'>删除设备</view> -->
|
|
:data-index='index'>删除设备</view> -->
|
|
</view>
|
|
</view>
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
</view>
|
|
</view>
|
|
<view class="nav-right num">
|
|
<view class="nav-right num">
|
|
<view class="text-grey">
|
|
<view class="text-grey">
|
|
@@ -101,7 +101,16 @@
|
|
</view>
|
|
</view>
|
|
<view class="share-item text-center">
|
|
<view class="share-item text-center">
|
|
<view><text class="icon iconfont margin-xs" style="color:#FF642E"></text></view>
|
|
<view><text class="icon iconfont margin-xs" style="color:#FF642E"></text></view>
|
|
- <view @tap="showModal" data-target="DialogModal">导出</view>
|
|
|
|
|
|
+ <view @tap="showModal" data-target="DialogModal" v-if="this.exportData.length">
|
|
|
|
+ 导出
|
|
|
|
+ </view>
|
|
|
|
+ <view @tap="showModal" data-target="DialogModal" v-else>
|
|
|
|
+ <download-excel class="export-excel-wrapper" :data="exportData" :fields="json_fields" header='导出数据'
|
|
|
|
+ name="设备管理数据表.xls">
|
|
|
|
+ 导出
|
|
|
|
+ </download-excel>
|
|
|
|
+
|
|
|
|
+ </view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
<view class="checkAll" style="display:inline-block">
|
|
<view class="checkAll" style="display:inline-block">
|
|
@@ -117,7 +126,7 @@
|
|
<!-- 分享区域 end-->
|
|
<!-- 分享区域 end-->
|
|
|
|
|
|
<!-- 导出弹框 -->
|
|
<!-- 导出弹框 -->
|
|
- <export-modal :modalName='modalName' @fatherHideModal="hideModal()"></export-modal>
|
|
|
|
|
|
+ <!-- <export-modal :modalName='modalName' @fatherHideModal="hideModal()"></export-modal> -->
|
|
<!-- 导出弹框 end -->
|
|
<!-- 导出弹框 end -->
|
|
|
|
|
|
<!-- 删除弹框 -->
|
|
<!-- 删除弹框 -->
|
|
@@ -181,6 +190,15 @@
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+
|
|
|
|
+ json_fields: {
|
|
|
|
+ "单位编号": "company", //常规字段
|
|
|
|
+ "状态": "device_state",
|
|
|
|
+ "设备编号": "owner_code",
|
|
|
|
+ "设备名称": "owner_name",
|
|
|
|
+ "单元地址": "unitinfo",
|
|
|
|
+ "创建时间": "install_time",
|
|
|
|
+ },
|
|
|
|
|
|
deviceManage: [],
|
|
deviceManage: [],
|
|
validCode: '',
|
|
validCode: '',
|
|
@@ -207,7 +225,7 @@
|
|
|
|
|
|
// checkAllFlag:false,
|
|
// checkAllFlag:false,
|
|
|
|
|
|
-
|
|
|
|
|
|
+ exportData:[],
|
|
isChecked: false,
|
|
isChecked: false,
|
|
checkedArr: [], //复选框选中的值
|
|
checkedArr: [], //复选框选中的值
|
|
allChecked: false //是否全选
|
|
allChecked: false //是否全选
|
|
@@ -233,13 +251,13 @@
|
|
|
|
|
|
mounted() {
|
|
mounted() {
|
|
document.addEventListener('click', (event) => {
|
|
document.addEventListener('click', (event) => {
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
if (event.target.className != 'showDetailEdit') {
|
|
if (event.target.className != 'showDetailEdit') {
|
|
this.deviceManage.forEach(item => {
|
|
this.deviceManage.forEach(item => {
|
|
item.isShow = false;
|
|
item.isShow = false;
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -268,7 +286,6 @@
|
|
showLoading: true
|
|
showLoading: true
|
|
})
|
|
})
|
|
this.deviceManage = res.data.data;
|
|
this.deviceManage = res.data.data;
|
|
-
|
|
|
|
},
|
|
},
|
|
|
|
|
|
// 页面跳转
|
|
// 页面跳转
|
|
@@ -288,9 +305,61 @@
|
|
if (this.checkedArr.length == 0) {
|
|
if (this.checkedArr.length == 0) {
|
|
alert('请选择至少一条需要导出的数据')
|
|
alert('请选择至少一条需要导出的数据')
|
|
} else {
|
|
} else {
|
|
- this.modalName = e.currentTarget.dataset.target
|
|
|
|
|
|
+ this.modalName = e.currentTarget.dataset.target;
|
|
|
|
+
|
|
|
|
+ // this.getDataExport()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ getDataExport() {
|
|
|
|
+ const base64 = s => window.btoa(unescape(encodeURIComponent(s)));
|
|
|
|
+ // let exportData = [];
|
|
|
|
+ let newData = [];
|
|
|
|
+ this.exportData = this.deviceManage.filter((item) => this.checkedArr.includes(item.id));
|
|
|
|
+ this.exportData.forEach(function(item, index) {
|
|
|
|
+ newData.push({
|
|
|
|
+ company: item.company,
|
|
|
|
+ device_state: item.device_state,
|
|
|
|
+ owner_code: item.owner_code,
|
|
|
|
+ unitinfo: item.unitinfo,
|
|
|
|
+ owner_name: item.owner_name,
|
|
|
|
+ install_time: item.install_time,
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ console.log('newData')
|
|
|
|
+ console.log(newData);
|
|
|
|
+ let str =
|
|
|
|
+ '<tr style="text-align:center"><th>单位编号</th><th>状态</th><th>设备编号</th><th>设备名称</th><th>单位地址</th><th>创建时间</th></tr>';
|
|
|
|
+ // 循环遍历,每行加入tr标签,每个单元格加td标签
|
|
|
|
+ for (let i = 0; i < newData.length; i++) {
|
|
|
|
+ str += '<tr style="text-align:center">';
|
|
|
|
+ for (const key in newData[i]) {
|
|
|
|
+ // 增加\t为了不让表格显示科学计数法或者其他格式
|
|
|
|
+ str += `<td x:str>${ newData[i][key] + '\t'}</td>`;
|
|
|
|
+ }
|
|
|
|
+ str += '</tr>';
|
|
|
|
+ }
|
|
|
|
+ // Worksheet名
|
|
|
|
+ const worksheet = 'Sheet1'
|
|
|
|
+ const uri = 'data:application/vnd.ms-excel;base64,';
|
|
|
|
+
|
|
|
|
+ // 下载的表格模板数据
|
|
|
|
+ let template = `<html xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
|
|
+ xmlns:x="urn:schemas-microsoft-com:office:excel"
|
|
|
|
+ xmlns="http://www.w3.org/TR/REC-html40">
|
|
|
|
+ <head><meta charset='UTF-8'><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
|
|
|
|
+ <x:Name>${worksheet}</x:Name>
|
|
|
|
+ <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
|
|
|
|
+ </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
|
|
|
|
+ </head><body><table>${str}</table></body></html>`;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 通过创建a标签实现
|
|
|
|
+ const link = document.createElement("a");
|
|
|
|
+ link.href = uri + base64(template);
|
|
|
|
+ // 对下载的文件命名
|
|
|
|
+ link.download = "设备注册管理数据表.xls";
|
|
|
|
+ link.click();
|
|
|
|
+ },
|
|
|
|
|
|
//关闭弹框
|
|
//关闭弹框
|
|
hideModal(e) {
|
|
hideModal(e) {
|
|
@@ -299,16 +368,16 @@
|
|
|
|
|
|
//删除弹出框操作
|
|
//删除弹出框操作
|
|
deleteItem(e) {
|
|
deleteItem(e) {
|
|
-
|
|
|
|
- uni.showModal({
|
|
|
|
- showCancel: false,
|
|
|
|
- content: '暂不支持删除功能'
|
|
|
|
- });
|
|
|
|
- // if (this.checkedArr.length == 0) {
|
|
|
|
- // alert('请选择至少一条需要删除的数据')
|
|
|
|
- // } else {
|
|
|
|
- // this.modalName = e.currentTarget.dataset.target;
|
|
|
|
- // }
|
|
|
|
|
|
+
|
|
|
|
+ // uni.showModal({
|
|
|
|
+ // showCancel: false,
|
|
|
|
+ // content: '暂不支持删除功能'
|
|
|
|
+ // });
|
|
|
|
+ if (this.checkedArr.length == 0) {
|
|
|
|
+ alert('请选择至少一条需要删除的数据')
|
|
|
|
+ } else {
|
|
|
|
+ this.modalName = e.currentTarget.dataset.target;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
deleteItem2(e) {
|
|
deleteItem2(e) {
|
|
this.checkedArr.push(e.target.dataset.id);
|
|
this.checkedArr.push(e.target.dataset.id);
|
|
@@ -318,9 +387,6 @@
|
|
this.modalName = e.currentTarget.dataset.target;
|
|
this.modalName = e.currentTarget.dataset.target;
|
|
},
|
|
},
|
|
confirmDelete() {
|
|
confirmDelete() {
|
|
- // alert(this.deleteIndex)
|
|
|
|
- // this.deviceManage.splice(this.deleteIndex,1);
|
|
|
|
-
|
|
|
|
this.deviceManage = this.deviceManage.filter((item) => !this.checkedArr.includes(item.id));
|
|
this.deviceManage = this.deviceManage.filter((item) => !this.checkedArr.includes(item.id));
|
|
console.log('this.deviceManage')
|
|
console.log('this.deviceManage')
|
|
console.log(this.deviceManage)
|
|
console.log(this.deviceManage)
|
|
@@ -334,7 +400,7 @@
|
|
|
|
|
|
// 隐藏显示
|
|
// 隐藏显示
|
|
showDetail(e) {
|
|
showDetail(e) {
|
|
-
|
|
|
|
|
|
+
|
|
console.log(this.deviceManage)
|
|
console.log(this.deviceManage)
|
|
// console.log('e')
|
|
// console.log('e')
|
|
// console.log(e)
|
|
// console.log(e)
|