Browse Source

数据对接bug修复

Ming 4 năm trước cách đây
mục cha
commit
1859bb2142
2 tập tin đã thay đổi với 224 bổ sung108 xóa
  1. 72 44
      pages/deviceManage/deviceManage.vue
  2. 152 64
      pages/setting/messagePush/messagePush.vue

+ 72 - 44
pages/deviceManage/deviceManage.vue

@@ -3,12 +3,12 @@
 
 		<!-- 筛选框start -->
 		<view>
-			
+
 			<view style="height:206rpx"></view>
 			<view class="ding">
 				<view class="cu-bar search bg-gray filter-section" style="with:50%;">
 					<view class="search-form round bg-white">
-						<select name="" id="" placeholder="">
+						<select name="" id="" placeholder="" v-model="dwtype">
 							<option value="0">请选择设备类型</option>
 							<option value="1">用传</option>
 							<option value="2">水表</option>
@@ -21,10 +21,10 @@
 						</select>
 					</view>
 				</view>
-			
+
 				<view class="cu-bar search bg-gray filter-section">
 					<view class="search-form round bg-white" style="margin-bottom:26rpx">
-						<select name="" id="" placeholder="">
+						<select name="" id="" placeholder="" v-model="transmission_mode">
 							<option value="0">请选择传输方式</option>
 							<option value="NB">NB</option>
 							<option value="4G">4G</option>
@@ -32,11 +32,11 @@
 						</select>
 					</view>
 					<view class="action">
-						<button class="cu-btn bg-blue round">查询</button>
+						<button class="cu-btn bg-blue round" @click="searchList">查询</button>
 					</view>
 				</view>
 			</view>
-			
+
 		</view>
 		<!-- 筛选框end -->
 
@@ -45,6 +45,7 @@
 			<view class="processList deviceRegistList" style="height: calc(100vh - 470rpx);">
 				<checkbox-group @change="changeCheckbox">
 					<view class="cu-list menu-avatar ">
+						<view class=" site-item text-center margin-top" v-if="!deviceManage.length" >暂无结果</view>
 						<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
 							v-for="(item,index) in deviceManage" :key="index" :data-target="'move-box-' + index">
 							<view class="cu-form-group margin-top">
@@ -53,7 +54,7 @@
 							</view>
 							<view class="cu-avatar round lg" style="background-image:url(../../static/device-icon.png)">
 							</view>
-							<view class="content" @longpress="showDetail(item)">
+							<view class="content" @longpress="showDetail(item)" >
 								<view class="pro-title">
 									<view class="cut">{{item.owner_name}}</view>
 								</view>
@@ -64,10 +65,14 @@
 								</view>
 								<view class="pro-date ">{{item.install_time}}</view>
 
-								<view class="showDetail" v-if="item.isShow">
+								<view class="showDetailEdit" v-if="item.isShow==true">
 									<view @tap="goDeviceEdit(item)">修改设备</view>
-									<view @tap="deleteItem2" data-target="DialogModal2" :data-id='item.id'  :data-index='index'>删除设备</view>
+								<!-- 	<view @tap="deleteItem2" data-target="DialogModal2" :data-id='item.id'
+										:data-index='index'>删除设备</view> -->
 								</view>
+								
+								
+								
 							</view>
 							<view class="nav-right num">
 								<view class="text-grey">
@@ -101,7 +106,7 @@
 			</view>
 			<view class="checkAll" style="display:inline-block">
 
-				<checkbox-group @change="allChoose">
+				<checkbox-group @change="allChoose" v-if="deviceManage.length">
 					<label>
 						<checkbox value="all" :class="{'checked':allChecked}" :checked="allChecked?true:false">
 						</checkbox> <text class="margin-left-xs">全选</text>
@@ -151,7 +156,7 @@
 					<valid-code :value.sync="validCode"></valid-code>
 				</view>
 				<view class="cu-bar operate bg-white" style="min-height: 100rpx;">
-					<view class="action margin-0   " @tap="hideModal">
+					<view class="action margin-0" @tap="hideModal">
 						取消</view>
 					<view class="action margin-0  solid-left text-blue" @tap="confirmDelete">确定</view>
 				</view>
@@ -176,8 +181,8 @@
 		},
 		data() {
 			return {
-				
-				deviceManage:[],
+
+				deviceManage: [],
 				validCode: '',
 
 				checkbox: [{
@@ -195,9 +200,10 @@
 				listTouchDirection: null,
 				CustomBar: this.CustomBar,
 
-				deleteIndex:'',
-				deleteId:'',
-
+				deleteIndex: '',
+				deleteId: '',
+				dwtype: 0,
+				transmission_mode: 0,
 
 				// checkAllFlag:false,
 
@@ -226,34 +232,49 @@
 		},
 
 		mounted() {
-			document.addEventListener('click', (e) => {
-				if (e.target.className != 'showDetail') {
+			document.addEventListener('click', (event) => {
+				console.log(this.deviceManage)
+				
+				if (event.target.className != 'showDetailEdit') {
 					this.deviceManage.forEach(item => {
-						item.isShow = false
+						item.isShow = false;
+						// console.log(item)
 					})
-					
+					// console.log(this.deviceManage)
+
 				}
 			})
 		},
-		onLoad:function(option){
-			this.getDataList({'company_code':uni.getStorageSync('selectedCode')})
+		onLoad: function(option) {
+			this.getDataList({
+				'company_code': uni.getStorageSync('selectedCode')
+			})
 		},
 		methods: {
-			
+
+			//筛选
+			searchList() {
+				this.getDataList({
+					"transmission_mode": this.transmission_mode,
+					"dwtype": this.dwtype,
+					'company_code': uni.getStorageSync('selectedCode')
+				})
+			},
+
 			// 列表数据请求
 			async getDataList(params = {}) {
 				const res = await this.$myRequest({
 					url: 'DeviceConfig/getDeviceList',
-					data:params,
+					data: params,
 					showLoading: true
 				})
-				this.deviceManage=res.data.data;
-			
+				this.deviceManage = res.data.data;
+
 				// console.log(res.data.data.length)
 				console.log(this.deviceManage);
-				
+
 			},
-			
+
 			// 页面跳转
 			goDeviceAdd() {
 				uni.navigateTo({
@@ -279,18 +300,23 @@
 			hideModal(e) {
 				this.modalName = null
 			},
-			
+
 			//删除弹出框操作
 			deleteItem(e) {
-				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) {
 				this.checkedArr.push(e.target.dataset.id);
-				this.deleteIndex=e.target.dataset.index;
+				this.deleteIndex = e.target.dataset.index;
 				console.log('this.checkedArr  单个点击删除按钮 存入要删除的索引')
 				console.log(this.checkedArr)
 				this.modalName = e.currentTarget.dataset.target;
@@ -298,7 +324,7 @@
 			confirmDelete() {
 				// alert(this.deleteIndex)
 				// this.deviceManage.splice(this.deleteIndex,1);
-				
+
 				this.deviceManage = this.deviceManage.filter((item) => !this.checkedArr.includes(item.id));
 				console.log('this.deviceManage')
 				console.log(this.deviceManage)
@@ -312,14 +338,16 @@
 
 			// 隐藏显示
 			showDetail(e) {
+				
+				console.log(this.deviceManage)
 				// console.log('e')
 				// console.log(e)
 				// 存储点击那一项的状态
 				const nowStatu = e.isShow;
-				
-			   //判断如果长摁弹框出来时,情况选中状态 ???
-				if(!nowStatu){
-					this.checkedArr=[];
+
+				//判断如果长摁弹框出来时,情况选中状态 ???
+				if (!nowStatu) {
+					this.checkedArr = [];
 					this.allChecked = false;
 				}
 				// 将每一项列表的isShow设置为false,让所有的列表都隐藏
@@ -331,7 +359,7 @@
 			},
 
 
-InputFocus(e) {
+			InputFocus(e) {
 				this.InputBottom = e.detail.height
 			},
 			InputBlur(e) {
@@ -372,7 +400,7 @@ InputFocus(e) {
 </script>
 
 <style>
-	.showDetail {
+	.showDetailEdit {
 		position: absolute;
 		background: #fff;
 		box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
@@ -383,11 +411,11 @@ InputFocus(e) {
 		font-size: 28rpx;
 	}
 
-	.showDetail view {
+	.showDetailEdit view {
 		padding: 0rpx 20rpx;
 	}
 
-	.showDetail view:first-child {
+	.showDetailEdit view:first-child {
 		border-bottom: 1px solid #EDEDED;
 	}
 </style>

+ 152 - 64
pages/setting/messagePush/messagePush.vue

@@ -2,56 +2,21 @@
 	<view class="padding-sm messagePush">
 
 		<form action="">
+
 			<checkbox-group class="block" @change="CheckboxChange">
 				<view class="margin-top  ">
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[0].checked?'checked':''" :checked="checkbox[0].checked?true:false" value="A"></checkbox>
-						<view class="title">火警报警</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[1].checked?'checked':''" :checked="checkbox[1].checked?true:false" value="B"></checkbox>
-						<view class="title">火警故障</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[2].checked?'checked':''" :checked="checkbox[2].checked?true:false" value="C"></checkbox>
-						<view class="title">水压越限</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[3].checked?'checked':''" :checked="checkbox[3].checked?true:false" value="D"></checkbox>
-						<view class="title">开关变化</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[4].checked?'checked':''" :checked="checkbox[4].checked?true:false" value="E"></checkbox>
-						<view class="title">设备离线</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[5].checked?'checked':''" :checked="checkbox[5].checked?true:false" value="F"></checkbox>
-						<view class="title">烟感报警</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[6].checked?'checked':''" :checked="checkbox[6].checked?true:false" value="G"></checkbox>
-						<view class="title">电气火灾</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[7].checked?'checked':''" :checked="checkbox[7].checked?true:false" value="H"></checkbox>
-						<view class="title">视频报警</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[8].checked?'checked':''" :checked="checkbox[8].checked?true:false" value="I"></checkbox>
-						<view class="title">电梯监测</view>
-					</view>
-					<view class="flex align-center checkItems">
-						<checkbox class="blue" :class="checkbox[9].checked?'checked':''" :checked="checkbox[9].checked?true:false" value="J"></checkbox>
-						<view class="title">井盖监测</view>
+					<view class="flex align-center checkItems" v-for="(item,index) in checkbox">
+						<checkbox class="blue" :class="item.checked==1?'checked':''"
+							:checked="item.checked==1?true:false" :value="item.value"></checkbox>
+						<view class="title">{{item.title}}</view>
+
+
 					</view>
 				</view>
-
 			</checkbox-group>
 
-
-
 			<view class="btn-area submitBottomBtn padding-lr-sm">
-				<button class="bg-blue round  margin-top">提 交 </button>
+				<button class="bg-blue round  margin-top" @click="$noMultipleClicks(btnSubmit())">提 交 </button>
 			</view>
 
 		</form>
@@ -63,54 +28,77 @@
 	export default {
 		data() {
 			return {
+				noClick: true,
+				flag: false,
+				getData: {},
+				checkedValue: [],
 				checkbox: [{
-						value: 'A',
-						checked: true
+						value: 'm1',
+						checked: false,
+						title: '火警报警'
 					},
 					{
-						value: 'B',
-						checked: false
+						value: 'm2',
+						checked: false,
+						title: '火警故障'
 					},
 					{
-						value: 'C',
-						checked: false
+						value: 'm3',
+						checked: false,
+						title: '水压越线'
 					},
 					{
-						value: 'D',
-						checked: false
+						value: 'm4',
+						checked: false,
+						title: '开关变化'
 					},
 					{
-						value: 'E',
-						checked: false
+						value: 'm5',
+						checked: false,
+						title: '设备离线'
 					},
 					{
-						value: 'F',
-						checked: false
+						value: 'm6',
+						checked: false,
+						title: '烟感报警'
 					},
 					{
-						value: 'G',
-						checked: false
+						value: 'm7',
+						checked: false,
+						title: '电气火灾'
 					},
 					{
-						value: 'H',
-						checked: false
+						value: 'm8',
+						checked: false,
+						title: '视频报警'
 					},
 					{
-						value: 'I',
-						checked: false
+						value: 'm9',
+						checked: false,
+						title: '电梯监测'
 					},
 					{
-						value: 'J',
-						checked: false
+						value: 'm10',
+						checked: false,
+						title: '井盖监测'
 					}
 				],
 
 			}
 		},
+		onLoad: function(option) {
+			this.getCheckList();
+		},
 		methods: {
 			CheckboxChange(e) {
+				this.flag = true;
 				var items = this.checkbox,
 					values = e.detail.value;
+				this.checkedValue = values;
+				// console.log(values)
+
+				// console.log('点击复选框时this.checkedValue')
+				// console.log(this.checkedValue)
 				for (var i = 0, lenI = items.length; i < lenI; ++i) {
 					items[i].checked = false;
 					for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
@@ -121,6 +109,107 @@
 					}
 				}
 			},
+
+
+			// 回显数据请求
+			async getCheckList(params = {}) {
+				const res = await this.$myRequest({
+					url: 'PushSettings/setperm',
+					data: params,
+					showLoading: true
+				})
+				this.getData = res.data.data[0];
+
+
+
+				// 遍历checkbox数组对象
+				for (let i = 0; i < this.checkbox.length; i++) {
+					//判断value是否存在于返回对象中.存在的话checked重新赋值
+					if (this.getData.hasOwnProperty(this.checkbox[i].value)) {
+						// console.log(this.checkbox[i].value)
+						this.checkbox[i].checked = true
+					}
+				}
+			},
+
+
+			//提交
+			async btnSubmit() {
+
+				// 提交验证
+				// alert(this.aa);
+				// alert(this.checkedValue)
+				// if (!this.aa.length) {
+				// 	uni.showToast({
+				// 		title: "请选择推送选项",
+				// 		icon: "none"
+				// 	});
+				// 	return
+				// }
+
+
+				let mingParams = {};
+				if (!this.flag) {
+					//不点击默认传参
+					var obgj = this.getData;
+					console.log('不点击默认传参obgj')
+					console.log(obgj);
+					var arr = [];
+					for (var key in obgj) {
+						console.log(key)
+						console.log(obgj[key])
+						arr.push([key][0])
+					}
+					arr.map((e) => {
+						mingParams[e] = true;
+					});
+				} else {
+					//点击复选框后传参
+					var arr = this.checkedValue;
+					console.log('自由选中复选框后传参arr')
+					console.log(arr)
+
+
+					arr.map((e) => {
+						mingParams[e] = true;
+					});
+					console.log('mingParams')
+					console.log(mingParams)
+
+
+				}
+
+
+
+				let res = await this.PushSettings(mingParams);
+				// let res = await this.PushSettings({'m1':true,"m2":true,"m6":true});
+
+				if (!res.data.flag) {
+					uni.showToast({
+						title: "添加失败",
+						icon: "none"
+					});
+				} else {
+					uni.showToast({
+						title: "添加成功",
+					});
+					setTimeout(() => {
+						uni.switchTab({
+							url: '/pages/setting/setting',
+						});
+					}, 1000);
+				}
+				
+
+			},
+			PushSettings(params = {}) {
+				return this.$myRequest({
+					url: 'PushSettings/setperm',
+					data: params
+				})
+			},
+
+
 		}
 	}
 </script>
@@ -137,5 +226,4 @@
 			margin-left: 10rpx;
 		}
 	}
-	
 </style>