ming vor 3 Jahren
Ursprung
Commit
6a3a17c833
3 geänderte Dateien mit 242 neuen und 109 gelöschten Zeilen
  1. 2 1
      pages.json
  2. 117 35
      pages/setting/funReport/funReport.vue
  3. 123 73
      pages/setting/funReport/funcAdd/funcAdd.vue

+ 2 - 1
pages.json

@@ -710,7 +710,8 @@
             "style" :                                                                                    
             {
                 "navigationBarTitleText": "功能报备",
-                "enablePullDownRefresh": false
+                "enablePullDownRefresh": false,
+				"onReachBottomDistance":100 //距离底部多远时触发 单位px
             }
             
         }

+ 117 - 35
pages/setting/funReport/funReport.vue

@@ -24,14 +24,14 @@
 					</view>
 					<view class="content">
 						<view class="pro-title">
-							<view class="cut">{{item.title}}</view>
+							<view class="cut">{{item.report_name}}</view>
 						</view>
 						<view class="pro-des  ">
 							<view class="text-cut">
-								{{item.des}}
+								{{item.remarks  }}
 							</view>
 						</view>
-						<view class="pro-date ">{{item.time}}</view>
+						<view class="pro-date ">{{item.add_time}}</view>
 					</view>
 					<view class="nav-right num">
 						<view class="text-grey">
@@ -44,13 +44,14 @@
 					</view>
 				</view>
 			</view>
+			<view v-if="!funcReport.length&&authListRes==1" class="text-center margin-top"> 暂无数据</view>
+			<view v-show="isLoadMore&&this.pages>1" style="padding-bottom:60px">
+				<uni-load-more :status="loadStatus"></uni-load-more>
+			</view>
 			
 			<view  style="padding-bottom:60px"></view>
 			
-			<!-- <view v-if="!authList.length&&authListRes==1" class="text-center margin-top"> 暂无数据</view>
-			<view v-show="isLoadMore&&this.currentPage>1" style="padding-bottom:60px">
-				<uni-load-more :status="loadStatus"></uni-load-more>
-			</view> -->
+			
 		</view>
 		
 		
@@ -76,20 +77,40 @@
 	export default {
 		data() {
 			return {
-				funcReport: json.funcReport,
+				funcReport: [],
 				modalName: null,
 				getData:[],
 				dwtype:0,
 				datetimerange: ['', ''],
 				
 				listTouchStart: 0,
-				listTouchDirection: null,
+				listTouchDirection: null,
+				
+				
+				flag:false,
+				
+				authListRes:0,
+				
+				
+				pages: 1,
+				size: 12,
+				loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
+				isLoadMore: false, //是否加载中
+				deleteStatus:false,
 			};
+		},
+		
+		onReachBottom() { //上拉触底函数
+			if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
+				this.isLoadMore = true
+				this.pages += 1;
+				this.loadData()
+			}
 		},
 
 		onLoad: function(option) {
 			this.dwtype=option.dwtype
-			// this.getDeviceList({'company_code':uni.getStorageSync('selectedCode'),"dwtype":option.dwtype})
+			this.loadData()
 
 		},
 		onNavigationBarButtonTap(e) {
@@ -98,21 +119,66 @@
 				url: './export/export?dwtype='+this.dwtype,
 
 			});
+		},
+		watch: {
+			
+			
+			datetimerange:function(){
+				this.funcReport=[];
+				this.pages = 1;
+				this.authListRes=[]
+				this.loadData()
+			},
+			
+			
 		},
-		methods: {
+		methods: {
+			
+			loadData(){
+			
+				this.getDeviceList({
+					'company_code':uni.getStorageSync('selectedCode'),
+					// 'start_time':this.datetimerange[0],
+					// 'end_time':this.datetimerange[1],
+					'pages': this.pages,
+					'size': this.size
+				})
+				
+			},
 
 		
 			
 			// 设备类型数据请求
-			// async getDeviceList(params = {}) {
-			// 	const res = await this.$myRequest({
-			// 		url: 'DeviceManagement/getDeviceList',
-			// 		data:params,
-			// 		showLoading: true
-			// 	})
-			// 	this.getData=res.data.data;
-			// 	console.log(this.getData);
-			// },
+			async getDeviceList(params = {}) {
+				const res = await this.$myRequest({
+					url: 'AlarmReport/index',
+					data:params,
+					showLoading: true
+				})
+				
+				if(this.deleteStatus){
+					this.funcReport=[];
+					this.deleteStatus=false;
+				}
+				this.authListRes = 1;
+				
+			
+				if (res.data.totalcount) {
+					this.funcReport = this.funcReport.concat(res.data.data)
+					if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
+					alert(1)
+						this.isLoadMore = true
+						this.loadStatus = 'nomore'
+					} else {
+						this.isLoadMore = false
+					}
+				} else {
+					this.isLoadMore = true
+					this.loadStatus = 'nomore'
+				}
+				
+	
+			},
 			
 			//编辑
 			editItem(item) {
@@ -123,21 +189,37 @@
 			
 			//删除
 			deleteItem(item) {
-				alert('删除')
-				// this.deleteStatus=true
-				// uni.showModal({
-				// 	title: '确认删除吗?',
-				// 	content: '',
-				// 	success: function(result) {
-				// 		if (result.confirm) {
-				// 			this.setDelSite({
-				// 				"id": item.id
-				// 			})
-				// 		} else if (result.cancel) {
-				// 			// console.log('用户点击取消');
-				// 		}
-				// 	}.bind(this)
-				// });
+				 let deleteT=0;
+				 this.deleteStatus=true
+				 uni.showModal({	
+				     title: '确认删除吗?',
+				     content: '',
+				     success: function (result) {
+				         if (result.confirm) {
+							  this.deleteAlarm({
+							 	"id": item.id
+							 });
+				         } else if (result.cancel) {
+				             console.log('用户点击取消');
+				         }
+				     }.bind(this)
+				 }); 
+			},
+			
+			
+			// 删除请求接口
+			async deleteAlarm(ming = {}) {
+				let res = await  this.$myRequest({
+					url: 'AlarmReport/del ',
+					data: ming
+				})
+				if (!res.data.flag) {
+					alert('删除失败');
+					return;
+				}
+				this.getDeviceList({'company_code':uni.getStorageSync('selectedCode')})
+				
+				return res;
 			},
 			
 			// 新增

+ 123 - 73
pages/setting/funReport/funcAdd/funcAdd.vue

@@ -4,7 +4,7 @@
 		<form action="" class="funcAdd">
 			<view class="form-item selectBox">
 				<view class="title"><text class="necessary">*</text>报备类型:</view>
-				<select name="" id="" placeholder=""clearable  v-model="repType">
+				<select name="" id="" placeholder=""clearable  v-model="report_type">
 					<option value="">请选择</option>
 					<option value="1">单位</option>
 					<option value="2">类型</option>
@@ -12,9 +12,9 @@
 				</select>
 				<text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
 			</view>
-			<view class="form-item selectBox" v-if="repType==2||repType==3">
+			<view class="form-item selectBox" v-if="report_type==2||report_type==3">
 				<view class="title"><text class="necessary">*</text>设备类型:</view>
-				<select name="" id="" placeholder=""clearable  v-model="deviceType">
+				<select name="" id="" placeholder=""clearable  v-model="device_type">
 					<option value="">请选择</option>
 					<option value="1">火系统</option>
 					<option value="2">水系统</option>
@@ -33,36 +33,36 @@
 				<text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
 			</view>
 			
-			<view class="form-item" v-if="repType">
+			<view class="form-item" v-if="report_type">
 				<view class="title">
 					<text class="necessary">*</text>
 					开始时间:
 				</view>
 				<view class="example-body">
-					<uni-datetime-picker v-model="startTime" :start="now"/>
+					<uni-datetime-picker v-model="start_time" :start="this.id?'':now"/>
 				</view>
 			</view>
-			<view class="form-item" v-if="repType">
+			<view class="form-item" v-if="report_type">
 				<view class="title">
 					<text class="necessary">*</text>
 					结束时间:
 				</view>
 				<view class="example-body">
-					<uni-datetime-picker v-model="endTime" :start="startTime" />
+					<uni-datetime-picker v-model="end_time" :start="start_time" />
 				</view>
 			</view>
 			
 			
 
 			
-			<view class="form-item " v-if="repType==3&&deviceType==6">
+			<view class="form-item " v-if="report_type==3&&device_type==6">
 				<view class="title"><text class="necessary">*</text>端口号:</view>
-				<input name="input" v-model="portId"></input>
+				<input name="input" v-model="device_port"></input>
 			</view>
 			
-			<view class="form-item selectBox" v-if="repType==3&&deviceType==6">
+			<view class="form-item selectBox" v-if="report_type==3&&device_type==6">
 				<view class="title"><text class="necessary">*</text>端口类型:</view>
-				<select name="" id="" placeholder=""clearable  v-model="portType">
+				<select name="" id="" placeholder=""clearable  v-model="port_type">
 					<option value="">请选择</option>
 					<option value="1">数字量</option>
 					<option value="2">模拟量</option>
@@ -70,19 +70,20 @@
 				<text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
 			</view>
 			
-			<view class="form-item selectBox" v-if="repType==3&&deviceType">
+			<view class="form-item selectBox" v-if="report_type==3&&device_type">
 				<view class="title"><text class="necessary">*</text>报备设备:</view>
-				<select name="" id="" placeholder=""clearable  v-model="deviceNo">
+				<select name="" id="" placeholder=""clearable  v-model="device_code">
 					<option value="">请选择</option>
-					<option value="1">编号1</option>
-					<option value="2">编号2</option>
+					<option :value="item.owner_code" v-for="(item,index) in deviceListData" :key="index">{{item.owner_name}}
+					</option>
+				
 				</select>
 				<text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
 			</view>
 			
-			<view class="form-item " v-if="repType">
+			<view class="form-item " v-if="report_type">
 				<view class="title"><text class="necessary"></text>备注:</view>
-				<input name="input" v-model="remark"></input>
+				<input name="input" v-model="remarks"></input>
 			</view>
 			
 			<view class="btn-area submitBottomBtn padding-lr-sm">
@@ -111,61 +112,100 @@
 			return {
 				id:'',
 
-				repType:'',
-				deviceType:'',
-				startTime:'',
-				endTime:'',
-				remark:'',
-				portId:'',
-				portType:'',
-				deviceNo:'',
-				now:''
+				report_type:'',
+				device_type:'',
+				start_time:'',
+				end_time:'',
+				remarks:'',
+				device_port:'',
+				port_type:'',
+				device_code:'',
+				now:'',
+				
+				deviceListData:[],
+				detailsData:''
 			
 			}
 		},
 		onLoad: function(option) {
 			
 			this.id=option.id;
-			this.getSiteList();
-			
 			uni.setNavigationBarTitle({
 				title: option.id?"编辑":"新增",
 			});
 			
+			
+			
 			var nowTemp = new Date();
 			this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
-
-
+			
+			if(option.id){
+				this.getDetailsData({'id':option.id})
+				
+			}
+			
+			
 
 		},
 		watch: {
-			startTime:function(){
-				alert(this.startTime)
+			start_time:function(){
+				// alert(this.start_time)
+			},
+			device_type:function(newVal){
+			
+				if(newVal){
+
+					this.deviceList({'company_code':uni.getStorageSync('selectedCode'),'device_type' :this.device_type });
+					
+					
+				}
+				
 			}
 			
 		},
 		methods: {
+			
+			// 回显信息请求
+			async getDetailsData(params = {}) {
+				const res = await this.$myRequest({
+					url: 'AlarmReport/editData',
+					data:params,
+					showLoading: true
+				})
+				
+				this.detailsData=res.data.data[0];
+				console.log(this.detailsData)
+				this.report_type=this.detailsData.report_type;
+				this.device_type=this.detailsData.device_type;
+				this.start_time=this.detailsData.start_time;
+				this.end_time=this.detailsData.end_time;
+				this.remarks=this.detailsData.remarks;
+				this.port_type=this.detailsData.port_type;
+				this.device_port=this.detailsData.device_port;
+				this.device_code=this.detailsData.device_code;
+
+			},
 
 			async submit() {
 				
 				//提交验证
 				
-				if (!this.repType) {
+				if (!this.report_type) {
 					uni.showToast({
 						title: "请输入报备类型",
 						icon: "none"
 					});
 					return
 				}
-				if(this.repType==1){
-					if (!this.startTime.replace(/^\s*/g,'')) {
+				if(this.report_type==1){
+					if (!this.start_time.replace(/^\s*/g,'')) {
 						uni.showToast({
 							title: "请选择开始时间",
 							icon: "none"
 						});
 						return
 					}
-					if (!this.endTime.replace(/^\s*/g,'')) {
+					if (!this.end_time.replace(/^\s*/g,'')) {
 						uni.showToast({
 							title: "请选择结束时间",
 							icon: "none"
@@ -173,22 +213,22 @@
 						return
 					}
 				}
-				if(this.repType==2||this.repType==3){
-					if (!this.deviceType) {
+				if(this.report_type==2||this.report_type==3){
+					if (!this.device_type) {
 						uni.showToast({
 							title: "请选择设备类型",
 							icon: "none"
 						});
 						return
 					}
-					if (!this.startTime.replace(/^\s*/g,'')) {
+					if (!this.start_time.replace(/^\s*/g,'')) {
 						uni.showToast({
 							title: "请输入开始时间",
 							icon: "none"
 						});
 						return
 					}
-					if (!this.endTime.replace(/^\s*/g,'')) {
+					if (!this.end_time.replace(/^\s*/g,'')) {
 						uni.showToast({
 							title: "请输入结束时间",
 							icon: "none"
@@ -197,24 +237,24 @@
 					}
 				}
 				
-				if(this.repType==3&&this.deviceType){
+				if(this.report_type==3&&this.device_type){
 					
-					if (this.deviceType==6) {
-						if (!this.portId.replace(/^\s*/g,'')) {
+					if (this.device_type==6) {
+						if (!this.device_port.replace(/^\s*/g,'')) {
 							uni.showToast({
 								title: "请输入端口号",
 								icon: "none"
 							});
 							return
 						}
-						if (!this.portType) {
+						if (!this.port_type) {
 							uni.showToast({
 								title: "请选择端口类型",
 								icon: "none"
 							});
 							return
 						}
-						if (!this.deviceNo) {
+						if (!this.device_code) {
 							uni.showToast({
 								title: "请选择报备设备",
 								icon: "none"
@@ -222,7 +262,7 @@
 							return
 						}
 					}
-					if (!this.deviceNo) {
+					if (!this.device_code) {
 						uni.showToast({
 							title: "请选择报备设备",
 							icon: "none"
@@ -236,28 +276,32 @@
 				if(this.id){
 					queryParam.id=this.id
 				}
-				queryParam.repType = this.repType;
-				queryParam.companyCode='10012';
-				queryParam.remark = this.remark;
-				queryParam.startTime = this.startTime;
-				queryParam.endTime = this.endTime;
+				queryParam.report_type = this.report_type;
+				queryParam.company_code=uni.getStorageSync('selectedCode');
+				queryParam.remarks = this.remarks;
+				queryParam.start_time = this.start_time;
+				queryParam.end_time = this.end_time;
 				
-				if (this.repType==1) {
+				if(this.id){
+					queryParam.id = this.id;
+				}
+				
+				if (this.report_type==1) {
 					this.addDevice(queryParam)
 					return;
 				}
-				if (this.repType==2) {
-					queryParam.deviceType = this.deviceType;
+				if (this.report_type==2) {
+					queryParam.device_type = this.device_type;
 					this.addDevice(queryParam)
 					return;
 				}
-				if (this.repType==3) {
-					queryParam.deviceType = this.deviceType;
-					if(this.deviceType==6){
-						queryParam.portType = this.portType;
-						queryParam.portId = this.portId;
+				if (this.report_type==3) {
+					queryParam.device_type = this.device_type;
+					if(this.device_type==6){
+						queryParam.port_type = this.port_type;
+						queryParam.device_port = this.device_port;
 					}
-					queryParam.deviceNo = this.deviceNo;
+					queryParam.device_code = this.device_code;
 					this.addDevice(queryParam)
 					return;
 				}
@@ -268,18 +312,13 @@
 			
 			async addDevice(params = {}) {
 				const res = await this.$myRequest({
-					url: 'DeviceConfig/setDevice',
+					url: this.id?'AlarmReport/edit':'AlarmReport/add',
 					data: params
 				})
 				if (res.data.flag) {
-					// uni.showToast({
-					// 	title: "提交成功",
-					// });
-					// setTimeout(() => {
-					// 	uni.navigateTo({
-					// 		url: '/pages/deviceManage/deviceManage',
-					// 	});
-					// }, 1000);
+					uni.showToast({
+						title: "提交成功",
+					});
 					setTimeout(() => {
 						uni.navigateTo({
 							url: '/pages/accountManage/success/success',
@@ -295,12 +334,23 @@
 				this.radioOne = e.detail.value;
 			},
 
-			//单位下拉请求数据
-			async getSiteList() {
+			//报备设备下拉请求数据
+			async deviceList(params = {}) {
+			
 				const res = await this.$myRequest({
-					url: 'Index/getCompanyList',
+					url: 'AlarmReport/deviceList',
+					data:params,
 				})
-				this.companyListData = res.data.data;
+				this.deviceListData = res.data.data;
+				
+				var arr=[]
+				this.deviceListData.forEach(function(item){
+					arr.push(item.owner_code)
+				})
+				if(arr.indexOf(this.device_code)==-1){
+					this.device_code=''
+				}
+				
 			},