Bladeren bron

修改微型消防站 事件

“yueshang” 1 jaar geleden
bovenliggende
commit
051cc9fb08

+ 17 - 0
main.js

@@ -60,6 +60,23 @@ function rs(){
 	// 	 rs()
 	//  },1*1000)
 }
+// 判断是否断网的函数
+function isOffline() {
+  return !navigator.onLine;
+}
+
+// 监听断网事件
+window.addEventListener('offline', function() {
+  if (isOffline()) {
+    showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then((res) => {
+      if (res.confirm) {
+        uni.navigateTo({
+          url: '/pages/login',
+        });
+      }
+    });
+  }
+});
 // #ifdef H5
 Vue.mixin({
     mounted() {

+ 18 - 14
pages/work/index.vue

@@ -34,7 +34,8 @@
 						</uni-grid-item>
 					</uni-grid>
 				</uni-section>
-				<uni-section title="乡镇消防工作档案" type="line" titleFontSize='18px' v-if="urlList2.length&&urlList2.length>0">
+				<uni-section title="乡镇消防工作档案" type="line" titleFontSize='18px'
+					v-if="urlList2.length&&urlList2.length>0">
 					<uni-grid :column="3" :showBorder="false" @change="changeGrid">
 						<uni-grid-item v-for="(item, index) in urlList2" :key="index">
 							<view class="example-body">
@@ -96,11 +97,14 @@
 			};
 		},
 		onLoad() {
-			this.getMenu();
+
 		},
 		onShow() {
-
+			this.urlList = []
+			this.urlList1 = []
+			this.urlList2 = []
 			this.getData()
+			this.getMenu();
 		},
 		methods: {
 			getData() {
@@ -118,19 +122,19 @@
 				}).then(response => {
 					console.log(response.data, 'dddd');
 					response.data.map(i => {
-					  if (i.menuSort.toString().startsWith("1")) {
-					    this.urlList1.push(i);
-					    this.urlList1 = this.urlList1.sort((a, b) => a.menuSort - b.menuSort);
-					  } else if (i.menuSort.toString().startsWith("2")) {
-					    this.urlList.push(i);
-					    this.urlList= this.urlList.sort((a, b) => a.menuSort - b.menuSort);
-					  } else if (i.menuSort.toString().startsWith("3")) {
-					    this.urlList2.push(i);
-					   this.urlList2 = this.urlList2.sort((a, b) => a.menuSort - b.menuSort);
-					  }
+						if (i.menuSort.toString().startsWith("1")) {
+							this.urlList1.push(i);
+							this.urlList1 = this.urlList1.sort((a, b) => a.menuSort - b.menuSort);
+						} else if (i.menuSort.toString().startsWith("2")) {
+							this.urlList.push(i);
+							this.urlList = this.urlList.sort((a, b) => a.menuSort - b.menuSort);
+						} else if (i.menuSort.toString().startsWith("3")) {
+							this.urlList2.push(i);
+							this.urlList2 = this.urlList2.sort((a, b) => a.menuSort - b.menuSort);
+						}
 					});
 
-					console.log(this.urlList2, 'asdbj',this.urlList);
+					console.log(this.urlList2, 'asdbj', this.urlList);
 				});
 			},
 			urlIconTran(val) {

+ 101 - 43
pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent.vue

@@ -1,18 +1,37 @@
 <template>
 	<view class="uni-container uni-container-bg">
+		<view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
 		<view class="event">
 			<view class="event-title">事件时间</view>
-			<uni-datetime-picker class="time-item-check" type="date" :clear-icon="false" v-model="eventTime"
+			<uni-datetime-picker class="time-item-check" type="date" :clear-icon="false":disabled="isview"  v-model="eventTime"
 				@maskClick="startMaskClick" placeholder="请选择事件时间" />
 			<view class="content">
+				<view class="event-title">出动人数</view>
+				<u-input v-model="eventPeples" placeholder="请输入出动人数" :maxlength="1000" :disabled="isview"  count height="150">
+				</u-input>
+			</view>
+			<view class="content">
+				<view class="event-title">燃烧面积</view>
+				<u-input v-model="burnArea" placeholder="请输入燃烧面积" :maxlength="1000" :disabled="isview" count height="150">
+				</u-input>
+			</view>
+			<view class="content">
+				<view class="event-title">过火面积</view>
+				<u-input v-model="fireArea" placeholder="请输入过火面积" :maxlength="1000" :disabled="isview"  count height="150">
+				</u-input>
+			</view>
+			<view class="content" style="margin-bottom: 60rpx;">
 				<view class="event-title">事件内容</view>
-				<u--textarea v-model="eventContent" placeholder="请输入内容" :maxlength="1000" count height="150">
-				</u--textarea>
+				<u--textarea v-model="eventContent" placeholder="请输入内容" :disabled="isview" :maxlength="1000" count height="150">
+				</u--textarea >
 			</view>
 		</view>
-		<view class="bottons">
+		</view>
+		<view class="bottons heigthButton" v-if="!isview">
 			<view class="buttons-item">
-				<u-button shape="circle" type="primary"  text="取消" :custom-style="{color:'#4CB2B6',backgroundColor: '#fff',border:'1px solid #fff',marginRight:'10px'}" @click="cancel">
+				<u-button shape="circle" type="primary" text="取消"
+					:custom-style="{color:'#4CB2B6',backgroundColor: '#fff',border:'1px solid #fff',marginRight:'10px'}"
+					@click="cancel">
 				</u-button>
 				<u-button shape="circle" type="primary" color="#4CB2B6" text="保存" @click="submit">
 				</u-button>
@@ -26,62 +45,92 @@
 	import riliicon from '@/static/images/riliicon.png'
 	import {
 		createStationEvent,
-		getOneMicrostation,//编辑获取
+		getOneMicrostation, //编辑获取
 		updateOrgReport
 	} from '@/api/fire_station/index';
 	export default {
 		data() {
 			return {
+				screenHeight: this.$screenHeight,
+				wheight: '',
 				eventContent: '',
 				eventTime: '',
 				riliicon: riliicon,
-				isEditId:false
+				isEditId: false,
+				eventPeples:'',//出动人数
+				burnArea:"",//燃烧面积
+				fireArea:'',//过火面积
+				runId:'',
+				isview:false
 			}
 		},
 		onLoad: function(option) {
-			if(option.id){
-				this.isEditId=option.id
+			if(option.isview=="isview"){
+				this.isview=true
+			}
+			this.runId=option.runId
+			if (option.id) {
+				this.isEditId = option.id
 				getOneMicrostation({
-					id:option.id
+					id: option.id
 				}).then(reponse => {
-					this.eventTime=reponse.data.eventTime
-					this.eventContent=reponse.data.eventContent
-					console.log(reponse,'opt');
+					this.eventTime = reponse.data.eventTime
+					this.eventContent = reponse.data.eventContent
+					this.eventPeples=reponse.data.eventPeples,//出动人数
+					this.burnArea=reponse.data.burnArea,//燃烧面积
+					this.fireArea=reponse.data.fireArea,//过火面积
+					console.log(reponse, 'opt');
 				})
 			}
 		},
+		mounted() {
+			uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
+				this.wheight = data.height
+			}).exec()
+		},
 		methods: {
 			submit() {
-				const that=this
-				if(!this.eventContent){return this.$modal.msgError('请填写事件内容')}
-				if(!this.eventTime){return this.$modal.msgError('请选择事件时间')}
-				if(!this.isEditId){
+				console.log(this.runId,'this.runIdthis.runId');
+				const that = this
+				if (!this.eventContent) {
+					return this.$modal.msgError('请填写事件内容')
+				}
+				if (!this.eventTime) {
+					return this.$modal.msgError('请选择事件时间')
+				}
+				if (!this.isEditId) {
 					createStationEvent({
 						eventContent: this.eventContent,
-						eventTime:this.eventTime+''
+						eventTime: this.eventTime + '',
+						eventPeples:this.eventPeples,//出动人数
+						burnArea:this.burnArea,//燃烧面积
+						fireArea:this.fireArea,//过火面积
+						microstationid:this.runId
 					}).then(reponse => {
-						   that.$modal.msg('保存成功')
-						   setTimeout(() => {
-						     uni.navigateBack()
-						   }, 400)
-						   
-					}).catch(err=>{
-					})
-				}else{
+						that.$modal.msg('保存成功')
+						setTimeout(() => {
+							uni.navigateBack()
+						}, 400)
+
+					}).catch(err => {})
+				} else {
 					updateOrgReport({
 						eventContent: this.eventContent,
-						eventTime:this.eventTime+'',
-						id:this.isEditId
+						eventTime: this.eventTime + '',
+						id: this.isEditId,
+						eventPeples:this.eventPeples,//出动人数
+						burnArea:this.burnArea,//燃烧面积
+						fireArea:this.fireArea,//过火面积
+						microstationid:this.runId
 					}).then(reponse => {
-						   that.$modal.msg('编辑成功')
-						   setTimeout(() => {
-						     uni.navigateBack()
-						   }, 400)
-						   
-					}).catch(err=>{
-					})
+						that.$modal.msg('编辑成功')
+						setTimeout(() => {
+							uni.navigateBack()
+						}, 400)
+
+					}).catch(err => {})
 				}
-				
+
 			},
 			cancel() {
 				uni.navigateBack()
@@ -106,8 +155,8 @@
 	.event {
 		margin-top: 40rpx;
 		background-color: #F5F7F9;
-	
-	.content {
+
+		.content {
 			margin-top: 40rpx
 		}
 
@@ -127,14 +176,17 @@
 		left: 14rpx;
 		top: 16rpx
 	}
-	/deep/ .uni-input-placeholder{
+
+	/deep/ .uni-input-placeholder {
 		left: 44rpx !important;
 	}
-	/deep/.uni-input-input{
+
+	/deep/.uni-input-input {
 		margin-left: 40rpx;
 	}
 
-	/deep/ .uni-date-x[data-v-6e13d7e2],/deep/ .uni-date-x {
+	/deep/ .uni-date-x[data-v-6e13d7e2],
+	/deep/ .uni-date-x {
 		height: 72rpx
 	}
 
@@ -152,7 +204,13 @@
 
 		position: fixed;
 		left: 0;
-		bottom: 100rpx;
+		bottom: 30rpx;
 		right: 0;
 	}
-</style>
+	/deep/ .u-input{
+		background: #fff;
+	}
+	.example {
+		overflow-y: auto;
+	}
+</style>

+ 20 - 3
pagesA/fire/add_fireRun/fireRun.vue

@@ -21,7 +21,7 @@
 			<view v-for="(item, index) in list" :key="index">
 				<uni-card  v-if="list.length>0">
 					<view class="main-item">
-						<rich-text :nodes="`事件内容: ${item.eventContent}`" class="font-16"></rich-text>
+						<rich-text :nodes="`事件内容: ${item.eventContent}`" class="font-16 uni-ellipsis-set"></rich-text>
 					</view>
 					<view class="main-item">
 						<text style="width: 140rpx;">事件日期:</text>
@@ -31,6 +31,9 @@
 						<view class="an-niu" @click.native="delClick(item.id)" link style="margin-left:3px">
 							<text class="deletes">删除事件</text>
 						</view>
+						<view class="an-niu" @click.native="detailClick(item.id)" link style="margin-left:3px;">
+							<text class="bianji details">查看详情</text>
+						</view>
 						<view class="an-niu" @click.native="editClick(item.id)" link style="margin-left:3px;">
 							<text class="bianji">编辑事件</text>
 						</view>
@@ -68,16 +71,22 @@
 					pageSize: 5,
 					eventTime: [],
 					eventContent: null,
+					microstationid:''
 				},
 				eventTimeString: '',
 				// 总条数
 				total: 0,
+				runId:""
 			}
 		},
 		onShow() {
 			this.list = []
 			this.getData()
 		},
+		onLoad: function(option) {
+			this.runId=option.runId
+			this.queryParams.microstationid=option.runId
+			},
 		methods: {
 			getData() {
 				if (this.queryParams.pageNo != 1) {
@@ -144,13 +153,18 @@
 			},
 			addClick() {
 				uni.navigateTo({
-					url: '/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent'
+					url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?runId=${this.runId}`
 				});
 
 			},
+			detailClick(val){
+				uni.navigateTo({
+					url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?id=${val}&runId=${this.runId}&isview=isview`
+				});
+			},
 			editClick(val) {
 				uni.navigateTo({
-					url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?id=${val}`
+					url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?id=${val}&runId=${this.runId}`
 				});
 			}
 		},
@@ -254,6 +268,9 @@
 		.bianji {
 			background-color: #4CB2B6
 		}
+		.details{
+			background-color: #F7C41E
+		}
 	}
 
 	/deep/.u-button--primary {

+ 12 - 6
pagesA/fire/fire_station/add_fireStation/add_fireStation.vue

@@ -11,7 +11,7 @@
 					<u-form-item prop="org_name" label="所属单位" @click="
 							showSex5 = true;
 							hideKeyboard();
-						" :required="true">
+						" :required="true"  v-if="!township">
 						<u-input v-model="formData.org_name" disabled disabledColor="#ffffff" placeholder="请选择所属单位">
 						</u-input>
 					</u-form-item>
@@ -98,7 +98,8 @@
 				// 自定义表单数据
 				formData: {
 					status: '0',
-					empList: []
+					empList: [],
+					mkind:''
 				},
 				// 自定义表单校验规则
 				customRules: {
@@ -150,6 +151,7 @@
 						trigger: ['blur', 'change']
 					},
 					newEmpList: [],
+					township:''
 				},
 
 			};
@@ -163,7 +165,9 @@
 		// 在 vue页面,向起始页通过事件传递数据
 		onLoad: function(option) {
 			this.formData.org_name = option.orgName ? option.orgName : ''
-			this.formData.orgId = option.orgId ? option.orgId : ''
+			if( option.orgId!="undefined"){
+				this.formData.orgId = option.orgId
+			}
 			// 获取单位id
 			getOrgId({
 				pageNo: this.pageNo,
@@ -184,6 +188,10 @@
 			this.$refs.customForm.setRules(this.customRules);
 		},
 		onShow() {
+			this.township=uni.getStorageSync('getUserInfo_key').streetInfo?uni.getStorageSync('getUserInfo_key').streetInfo:''
+			if(this.township){
+				this.formData.mkind=2
+			}
 			let empList = localStorage.getItem('empList')
 			empList = JSON.parse(empList)
 			console.log(empList,'emplddddddd');
@@ -230,9 +238,7 @@
 							setTimeout(() => {
 								// console.log('新增成功!');
 								uni.hideLoading();
-								uni.navigateBack({
-									delta: 2
-								})
+								uni.navigateBack()
 							}, 0);
 						});
 						localStorage.removeItem('empList')

+ 16 - 9
pagesA/fire/fire_station/index.vue

@@ -11,7 +11,7 @@
 				</uni-col>
 			</uni-row>
 			<!-- 下拉框 -->
-			<view class="u-page__tag-item"
+			<view  v-if="!township" class="u-page__tag-item"
 				style="margin-bottom: 26upx;width: 700upx;border-bottom: 2px solid #55cbbf;background-color: #f5f7fa;">
 				<u-form>
 					<u-form-item prop="orgName" @click="
@@ -27,7 +27,7 @@
 			<!-- 卡片栏 -->
 			<view v-if="tableData.length>0 && isLoaded" style="margin-bottom: 80rpx;">
 				<view v-for="(item, index) in tableData" :key="index"
-					v-if="formData.orgName === item.orgName || formData.orgId === item.orgId">
+					v-if="formData.orgName === item.orgName || formData.orgId === item.orgId||township">
 					<uni-card>
 						<!-- 标题 -->
 						<view class="titles">{{ item.microName }}</view>
@@ -111,16 +111,22 @@
 				keyword: '',
 				// 存放orgid,orgname
 				formData: {
-					orgName: ''
+					orgName: '',
+					mkind:1
 				},
 				show: false,
 				showtimeStart: false,
-				showtimeEnd: false
+				showtimeEnd: false,
+				township:''
 			};
 		},
 		// 在 vue页面,向起始页通过事件传递数据
 		onLoad: function(option) {},
 		onShow() {
+			this.township=uni.getStorageSync('getUserInfo_key').streetInfo?uni.getStorageSync('getUserInfo_key').streetInfo:''
+			if(this.township){
+				this.formData.mkind=2
+			}
 			this.actions = []
 			that = this;
 			getOrgId({
@@ -137,8 +143,8 @@
 					});
 				});
 				console.log(response.data, '21321312');
-				this.formData.orgName = response.data[0].orgName ? response.data[0].orgName : '';
-				this.formData.orgId = response.data[0].dwid;
+				this.formData.orgName = response.data[0]?.orgName ? response.data[0].orgName : '';
+				this.formData.orgId = response.data[0]?.dwid;
 				this.tableData = []
 				this.getData();
 			});
@@ -200,7 +206,8 @@
 					pageNo: this.pageNo,
 					pageSize: this.pageSize,
 					orgId: this.formData.orgId,
-					microName: this.keyword
+					microName: this.keyword,
+					mkind:this.formData.mkind
 					// userId: this.$store.state.user.id
 				}).then(response => {
 					this.isLoaded = true
@@ -255,10 +262,10 @@
 				});
 			},
 			//微型消防站运行
-			onClickFireRun() {
+			onClickFireRun(item) {
 				this.isLoaded = false
 				uni.navigateTo({
-					url: '/pagesA/fire/add_fireRun/fireRun'
+					url: `/pagesA/fire/add_fireRun/fireRun?runId=${item.id}`
 				});
 			},
 			sexSelect(e) {

+ 40 - 22
utils/request.js

@@ -15,14 +15,14 @@ import {
 	showConfirm,
 	tansParams
 } from '@/utils/common'
-var that=this
+var that = this
 let timeout = 10000
 const baseUrl = config.baseUrl + config.baseApi;
 // 请求队列
 let requests = []
 // 是否正在刷新中
 let isRefreshing = false
-const request = config=> {
+const request = config => {
 	// 是否需要设置 token
 	const isToken = (config.headers || {}).isToken === false
 	config.header = config.header || {}
@@ -65,31 +65,45 @@ const request = config=> {
 						try {
 							refreshToken({
 								refreshToken: getRefreshToken() // 刷新token的令牌存在token的对象里面,需要传给后端
-							}).then(reshRespore=>{
-								console.log(reshRespore, 'reshResporereshResporereshRespore');
+							}).then(reshRespore => {
+								console.log(reshRespore,
+									'reshResporereshResporereshRespore');
 								// 请求成功把新的token存到本地
 								setToken(reshRespore.data);
 								// 已经刷新了token,将所有队列中的请求进行重试
-								requests.forEach((item) => item(reshRespore.data.accessToken))
+								requests.forEach((item) => item(reshRespore.data
+									.accessToken))
+								// requests = []
+								// // 每个接口请求都要存入队列,等刷新完以后都需要执行
+								// return new Promise((resolve) => {
+								// 	// 将resolve放进队列,用一个函数形式来保存,等token刷新后直接执行
+								// 	requests.push((token) => {
+								// 		//这一步一定要有,刷新token,因为存入的信息是旧的token
+								// 		response.config.header[
+								// 				'Authorization'] =
+								// 			'Bearer ' + token;
+								// 		resolve(uni.$u.http.request(response
+								// 			.config)) //执行请求
+
+								// 	})
+								// that.$forceUpdate()
+								// })
 								requests = []
-								// 每个接口请求都要存入队列,等刷新完以后都需要执行
-								return new Promise((resolve) => {
-									// 将resolve放进队列,用一个函数形式来保存,等token刷新后直接执行
-									requests.push((token) => {
-										//这一步一定要有,刷新token,因为存入的信息是旧的token
-										response.config.header['Authorization'] =
-											'Bearer ' +
-											token;
-										resolve(uni.$u.http.request(response
-											.config)) //执行请求
-											
-									})
-									// that.$forceUpdate()
-								})
+								// 刷新完token后重新调用上一次的接口
+								resolve(uni.$u.http.request(config)) // 执行请求
+								if (reshRespore.code == 400) {
+									showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
+										if (res.confirm) {
+											uni.navigateTo({
+												url: '/pages/login'
+											})
+										}
+									});
+								}
 							})
-							
+
 						} catch {
-					// 		uni.$u.toast('未知错误')
+							// 		uni.$u.toast('未知错误')
 							showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
 								if (res.confirm) {
 									uni.navigateTo({
@@ -102,7 +116,11 @@ const request = config=> {
 							isRefreshing = false
 						}
 					} else {
-					
+						// 添加到请求队列中
+						requests.push(token => {
+							config.header['Authorization'] = 'Bearer ' + token;
+							resolve(uni.$u.http.request(config)) // 执行请求
+						})
 					}
 				} else if (code === 500) {
 					toast(msg)