瀏覽代碼

合并分支 并解决冲突

liuQiang 1 年之前
父節點
當前提交
4db65dfede

+ 14 - 18
pagesA/fire/fpd_detection/add_detection/add_detection.vue

@@ -20,7 +20,7 @@
 					<u-form-item label="检测维保结果" prop="detresult" @click="
 							showreOption = true;
 							hideKeyboard();" :required="true">
-						<u--input v-model="formData.detresult" disabled disabledColor="#ffffff"
+						<u--input v-model="formData.detresult.name" disabled disabledColor="#ffffff"
 							placeholder="请输入检测维保结果"></u--input>
 						<!-- <u-input v-model="formData.detresult" placeholder="请输入检测维保结果" /> -->
 					</u-form-item>
@@ -132,7 +132,7 @@
 				formData: {
 					status: '0',
 					File: [],
-					drillDate: ''
+					detresult:{id:null,name:null}
 				},
 				// 自定义表单校验规则
 				customRules: {
@@ -142,7 +142,7 @@
 						message: '	检测项目不能为空',
 						trigger: ['blur', 'change']
 					},
-					detdate: {
+					unitTime: {
 						type: 'string',
 						message: '预计检测时间不能为空',
 						trigger: ['blur', 'change']
@@ -196,7 +196,7 @@
 			const trueArr = []
 			this.resultOptions.forEach(item => {
 				trueArr.push({
-					id: item.label,
+					id: item.value,
 					name: item.label
 				})
 			})
@@ -222,9 +222,9 @@
 				// if (!this.formData.orgName) {
 				// 	return this.$modal.msgError('请选择所属单位')
 				// }
-				if (this.formData.unitTime && this.formData.unitTime.indexOf(":") === -1) {
-					this.formData.unitTime = this.formData.unitTime + ' 00:00:00'
-				}
+				// if (this.formData.unitTime && this.formData.unitTime.indexOf(":") === -1) {
+				// 	this.formData.unitTime = this.formData.unitTime + ' 00:00:00'
+				// }
 				this.$refs[ref]
 					.validate()
 					.then(res => {
@@ -235,6 +235,8 @@
 						} else {
 							this.formData.att = ''
 						}
+						//对要提交的数据进行处理 {id,name}只保存name
+						this.$set(this.formData,'detresult',this.formData.detresult.id)
 						var jsdata = JSON.stringify(this.formData);
 						console.log(jsdata, 'jsdatajsdatajsdata');
 						createFpdDetection(jsdata).then(response => {
@@ -330,25 +332,19 @@
 			},
 			checkboxCancel2() {
 				this.showInspOption = false
+				if(this.formData.detinspect){
+					
 				const nowArr = this.formData.detinspect.split(',')
-
 				this.checkArr = [...nowArr]
+				}
+				
 			},
 			// 隐藏键盘
 			hideKeyboard() {
 
-
 				uni.hideKeyboard();
 			},
 
-			// 单位成立时间
-			ActiveUnitTime(e) {
-				// this.unitTime = false;
-				// console.log(e.value, e.mode);
-				// let value = new Date(e.value);
-				// // this.formData.drillDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
-			},
-
 			changetime(e) {
 				console.log('change', e);
 			},
@@ -362,7 +358,7 @@
 			// 检测维保结果select事件
 			setResult(e) {
 				console.log('e', e);
-				this.formData.detresult = e.id;
+				this.formData.detresult = {id:e.id,name:e.name};
 				// this.formData.orgName = e.name;
 				// console.log(this.formData.orgId);
 			},

+ 109 - 13
pagesA/fire/fpd_detection/detection_details/detection_details.vue

@@ -7,14 +7,14 @@
 					<u-input v-model="formData.detinspect" disabled placeholder="请输入检测项目" />
 				</u-form-item>
 				<u-form-item label="预计检测时间" prop="detdate">
-					<uni-datetime-picker v-model="formData.detdate" type="datetime"
-						closeOnClickOverlay disabled></uni-datetime-picker>
+					<uni-datetime-picker v-model="formData.detdate" type="datetime" closeOnClickOverlay
+						disabled></uni-datetime-picker>
 				</u-form-item>
-				<u-form-item label="检测维保结果" prop="detresult" >
-					<u-input v-model="formData.detresult" disabled placeholder="请输入检测维保结果" />
+				<u-form-item label="检测维保结果" prop="detresult">
+					<u-input v-model="formData.detresult.name" disabled placeholder="请输入检测维保结果" />
 				</u-form-item>
-				<u-form-item label="所属单位"  prop="orgName" :required="true">
-						<u-input v-model="formData.orgName" disabled placeholder="" />
+				<u-form-item label="所属单位" prop="orgName" :required="true">
+					<u-input v-model="formData.orgName" disabled placeholder="" />
 				</u-form-item>
 				<u-form-item label="附件">
 					<view class="buju">
@@ -31,14 +31,27 @@
 			</u--form>
 		</view>
 		<uni-row class="heigthButton">
-			<u-button @click="gotoEditDetection(formData)" shape="circle" size="large" color="#4cb2b6" style="width: 60%;"
-				text="修改信息"></u-button>
+			<u-button @click="gotoEditDetection(formData)" shape="circle" size="large" color="#4cb2b6"
+				style="width: 60%;" text="修改信息"></u-button>
 		</uni-row>
 	</view>
 </template>
 <script>
 	var that = null;
 	import {
+		createFpdDetection, //创建消防设备维护和检测台账
+		updateFpdDetection, //更新消防设备维护和检测台账
+		deleteFpdDetection, //删除消防设备维护和检测台账
+		getFpdDetection, //获得消防设备维护和检测台账
+		getFpdDetectionPage, //获得消防设备维护和检测台账分页
+		exportFpdDetectionExcel, //导出消防设备维护和检测台账 Excel
+		getOrgId
+	} from '@/api/fpdDetection/index.js';
+	import {
+		DICT_TYPE,
+		getDictDatas
+	} from '@/utils/dict';
+	import {
 		downSee
 	} from '@/utils/common'
 	export default {
@@ -49,6 +62,8 @@
 				},
 				screenHeight: this.$screenHeight,
 				wheight: '',
+				//当前id
+				thisId: '',
 			};
 		},
 		mounted() {
@@ -56,14 +71,95 @@
 				this.wheight = data.height
 			}).exec()
 		},
+		onShow() {
+			if (this.thisId) {
+				getFpdDetection(this.thisId).then(res => {
+					console.log('thisform', res);
+					//对检测结果进行初始化
+					const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
+					// console.log('reArr',reArr);
+
+					const thisItem = reArr.find(par => par.value === res.data.detresult)
+					// console.log('thisItem',thisItem);
+					if (thisItem) {
+						res.data.detresult = {
+							id: thisItem.value,
+							name: thisItem.label
+						}
+					}
+
+
+					this.formData = res.data
+					// 获取单位id
+					getOrgId({
+						pageNo: this.pageNo,
+						pageSize: this.pageSize,
+						userId: this.$store.state.user.id
+					}).then(response => {
+						console.log(response, 'response');
+						// 取到用户对应的单位名称与id
+						response.data.forEach(v => {
+							if (this.formData.orgId === v.dwid) {
+								this.$set(this.formData, 'orgName', v.orgName)
+							}
+						});
+					});
+
+					console.log('edit页面的val的值', this.formData);
+				})
+			}
+		},
 		onLoad: function(option) {
+
 			that = this
-			var data = option.id;
+			this.thisId = option.id
+			//获取当前表单数据
+			getFpdDetection(option.id).then(res => {
+				console.log('thisform', res);
+				//对检测结果进行初始化
+				const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
+				// console.log('reArr',reArr);
 
+				const thisItem = reArr.find(par => par.value === res.data.detresult)
+				// console.log('thisItem',thisItem);
+				if (thisItem) {
+					res.data.detresult = {
+						id: thisItem.value,
+						name: thisItem.label
+					}
+				}
+
+
+				this.formData = res.data
+				// 获取单位id
+				getOrgId({
+					pageNo: this.pageNo,
+					pageSize: this.pageSize,
+					userId: this.$store.state.user.id
+				}).then(response => {
+					console.log(response, 'response');
+					// 取到用户对应的单位名称与id
+					response.data.forEach(v => {
+						if (this.formData.orgId === v.dwid) {
+							this.$set(this.formData, 'orgName', v.orgName)
+						}
+					});
+				});
+				// var File = this.formData.File = []
+				// if (this.formData.att != '') {
+				// 	File.push({
+				// 		url: this.formData.att,
+				// 		name: this.formData.att
+				// 	});
+				// } else {
+				// 	File = null
+				// }
+				console.log('edit页面的val的值', this.formData);
+			})
 
 			// 接收来自上个页面传递的参数
-			const navData = JSON.parse(option.navData)
-			that.formData = navData;
+			// const navData = JSON.parse(option.navData)
+			// that.formData = navData;
 			// const eventChannel = this.getOpenerEventChannel();
 			// eventChannel.on('acceptDataFromOpenerPage', function(val) {
 			// 	that.formData = val;
@@ -82,9 +178,9 @@
 			// 传递当前页面数据到 ‘修改信息’
 			gotoEditDetection(val) {
 				// console.log('val',val);
-				const navData = JSON.stringify(this.formData)
+				// const navData = JSON.stringify(this.formData)
 				uni.navigateTo({
-					url: '/pagesA/fire/fpd_detection/edit_detection/edit_detection?id=' + val.id+'&navData='+navData,
+					url: '/pagesA/fire/fpd_detection/edit_detection/edit_detection?id=' + val.id,
 				});
 			}
 		}

+ 77 - 51
pagesA/fire/fpd_detection/edit_detection/edit_detection.vue

@@ -2,7 +2,7 @@
 	<view class=" uni-container">
 		<view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
 			<!-- 自定义表单校验 1-->
-			<u-form ref="customForm" :rules='customRules' :model="formData" labelPosition="left" labelWidth="150"
+			<u-form ref="editDeteForm" :rules='customRules' :model="formData" labelPosition="left" labelWidth="150"
 				labelAlign="left">
 				<view class=" flex  flex-direction width100">
 					<u-form-item label="检测项目" prop="detinspect" :required="true"
@@ -20,7 +20,7 @@
 					<u-form-item label="检测维保结果" prop="detresult" @click="
 							showreOption = true;
 							hideKeyboard();" :required="true">
-						<u--input v-model="formData.detresult" disabled disabledColor="#ffffff"
+						<u--input v-model="formData.detresult.name" disabled disabledColor="#ffffff"
 							placeholder="请输入检测维保结果"></u--input>
 						<!-- <u-input v-model="formData.detresult" placeholder="请输入检测维保结果" /> -->
 					</u-form-item>
@@ -32,15 +32,8 @@
 					</u-form-item>
 					<u-form-item label="附件">
 						<!-- 选择文件上传 -->
-						<uni-file-picker
-							v-model="formData.File"
-							del-icon
-							limit="1"
-							auto-upload
-							file-mediatype="all"
-							@select="select"
-							@delete="deleteFile"
-						>
+						<uni-file-picker v-model="formData.File" del-icon limit="1" auto-upload file-mediatype="all"
+							@select="select" @delete="deleteFile">
 							<button type="primary" class="selectBtn">选择附件</button>
 							<!-- 加载中 -->
 							<isLodingModel v-if="loading"></isLodingModel>
@@ -84,7 +77,7 @@
 			<!-- ----隐患 -->
 		</view>
 		<uni-row class="heigthButton">
-			<u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
+			<u-button @click="submit('editDeteForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
 				text="确认修改"></u-button>
 		</uni-row>
 	</view>
@@ -143,7 +136,7 @@
 				formData: {
 					status: '0',
 					File: [],
-					drillDate: ''
+					detresult: {id:null,name:null}
 				},
 				// 自定义表单校验规则
 				customRules: {
@@ -189,24 +182,62 @@
 				i.id = i.value;
 			});
 			//获取当前表单数据
-			// getFpdDetection(option.id).then(res => {
-			// 	console.log('thisform', res);
-			// 	this.formData = res.data
-			// })
-			const navData = JSON.parse(option.navData)
-			console.log('navdata', navData);
-			this.formData = navData;
-			var File = this.formData.File = []
-			if (this.formData.att != '') {
-				File.push({
-					url: this.formData.att,
-					name: this.formData.att
+			getFpdDetection(option.id).then(res => {
+				console.log('thisform', res);
+				//对检测结果进行初始化
+				const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
+				// console.log('reArr',reArr);
+
+				const thisItem = reArr.find(par => par.value === res.data.detresult)
+				// console.log('thisItem',thisItem);
+				if (thisItem) {
+					res.data.detresult = {
+						id: thisItem.value,
+						name: thisItem.label
+					}
+				}
+
+
+				this.formData = res.data
+				var File = this.formData.File = []
+				if (this.formData.att != '') {
+					File.push({
+						url: this.formData.att,
+						name: this.formData.att
+					});
+				} else {
+					File = null
+				}
+				// 获取单位id
+				getOrgId({
+					pageNo: this.pageNo,
+					pageSize: this.pageSize,
+					userId: this.$store.state.user.id
+				}).then(response => {
+					console.log(response, 'response');
+					// 取到用户对应的单位名称与id
+					response.data.forEach(v => {
+						if (this.formData.orgId === v.dwid) {
+							this.$set(this.formData, 'orgName', v.orgName)
+						}
+					});
 				});
-			} else {
-				File = null
-			}
-			console.log('edit页面的val的值', this.formData);
-			
+				console.log('edit页面的val的值', this.formData);
+			})
+			// const navData = JSON.parse(option.navData)
+			// console.log('navdata', navData);
+			// this.formData = navData;
+			// var File = this.formData.File = []
+			// if (this.formData.att != '') {
+			// 	File.push({
+			// 		url: this.formData.att,
+			// 		name: this.formData.att
+			// 	});
+			// } else {
+			// 	File = null
+			// }
+			// console.log('edit页面的val的值', this.formData);
+
 			// 获取单位id
 			getOrgId({
 				pageNo: this.pageNo,
@@ -226,7 +257,7 @@
 			const trueArr = []
 			this.resultOptions.forEach(item => {
 				trueArr.push({
-					id: item.label,
+					id: item.value,
 					name: item.label
 				})
 			})
@@ -243,7 +274,7 @@
 			this.detinspectOptions = [...trueArr1]
 		},
 		onReady() {
-			this.$refs.customForm.setRules(this.customRules);
+			this.$refs.editDeteForm.setRules(this.customRules);
 		},
 
 		methods: {
@@ -252,9 +283,9 @@
 				// if (!this.formData.orgName) {
 				// 	return this.$modal.msgError('请选择所属单位')
 				// }
-				if (this.formData.drillDate && this.formData.drillDate.indexOf(":") === -1) {
-					this.formData.drillDate = this.formData.drillDate + ' 00:00:00'
-				}
+				// if (this.formData.drillDate && this.formData.drillDate.indexOf(":") === -1) {
+				// 	this.formData.drillDate = this.formData.drillDate + ' 00:00:00'
+				// }
 				this.$refs[ref]
 					.validate()
 					.then(res => {
@@ -265,6 +296,8 @@
 						// } else {
 						// 	this.formData.attId = ''
 						// }
+						//对提交的数据进行处理
+						this.$set(this.formData, 'detresult', this.formData.detresult.id)
 						var jsdata = JSON.stringify(this.formData);
 						console.log(jsdata, 'jsdatajsdatajsdata');
 						updateFpdDetection(jsdata).then(response => {
@@ -278,6 +311,9 @@
 								uni.navigateBack({
 									delta: 1
 								})
+								// uni.navigateTo({
+								// 	url: '/pagesA/fire/fpd_detection/detection_details/detection_details?id='+this.formData.id
+								// })
 							}, 0);
 						}).catch(err => {});
 					})
@@ -373,21 +409,6 @@
 
 				uni.hideKeyboard();
 			},
-			// 记录类型
-			sexSelect2(e) {
-				this.formData.drillType = e.value;
-				this.formData.drillTypeName = e.label;
-				console.log(this.formData.drillType);
-
-			},
-
-			// 单位成立时间
-			ActiveUnitTime(e) {
-				// this.unitTime = false;
-				// console.log(e.value, e.mode);
-				// let value = new Date(e.value);
-				// // this.formData.drillDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
-			},
 
 			changetime(e) {
 				console.log('change', e);
@@ -401,7 +422,12 @@
 			// 检测维保结果select事件
 			setResult(e) {
 				console.log('e', e);
-				this.formData.detresult = e.id;
+				// this.formData.detresult.id = e.id;
+				// this.formData.detresult.name = e.name;
+				this.$set(this.formData, 'detresult', {
+					id: e.id,
+					name: e.name
+				})
 				// this.formData.orgName = e.name;
 				// console.log(this.formData.orgId);
 			},

+ 38 - 9
pagesA/fire/fpd_detection/fpd_detection.vue

@@ -40,7 +40,7 @@
 					</view>
 					<view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
 						<text class="name-align-drill"> 检测维保结果:</text>
-						<text class="conts max-width">{{ item.detresult }}</text>
+						<text class="conts max-width">{{ item.detresult.name }}</text>
 					</view>
 					<!-- 删除按钮 -->
 					<view class="an-niu" @click.native="showModal(item)">
@@ -81,6 +81,10 @@
 		getOrgId
 	} from '@/api/fpdDetection/index.js';
 	import config from '@/config'
+	import {
+		DICT_TYPE,
+		getDictDatas
+	} from '@/utils/dict';
 	const baseUrlImg = config.baseUrlImg
 	export default {
 		data() {
@@ -131,7 +135,17 @@
 				}).then(res => {
 					console.log('res', res);
 					if (res.data) {
-						this.tableData = res.data.list
+						//对检测结果进行初始化
+						const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
+						// console.log('reArr',reArr);
+						this.tableData = res.data.list.map(item => {
+							const thisItem = reArr.find(par=>par.value === item.detresult)
+							// console.log('thisItem',thisItem);
+							if(thisItem){
+								item.detresult = {id:thisItem.value,name:thisItem.label}
+							}
+							return item
+						})
 					} else {
 						this.tableData = []
 					}
@@ -189,9 +203,22 @@
 			getData() {
 				this.loading = true;
 				getFpdDetectionPage(this.queryParams).then(response => {
+					// console.log('res',response	);
 					if (response.data) {
+						
+						//对检测结果进行初始化
+						const reArr = getDictDatas(DICT_TYPE.BACKEND_DET_RESULT)
+						// console.log('reArr',reArr);
+						this.tableData = response.data.list.map(item => {
+							const thisItem = reArr.find(par=>par.value === item.detresult)
+							// console.log('thisItem',thisItem);
+							if(thisItem){
+								item.detresult = {id:thisItem.value,name:thisItem.label}
+							}
+							return item
+						})
+						// this.tableData = response.data.list;
 
-						this.tableData = response.data.list;
 					}
 					this.isLoaded = true
 					this.loading = false;
@@ -207,11 +234,13 @@
 			// 传递数据
 			onClick(val, orgName) {
 				console.log(val.orgName, val, 'val');
-				const navData = JSON.stringify({...val})
-				console.log('navData',navData);
+				const navData = JSON.stringify({
+					...val
+				})
+				console.log('navData', navData);
 				this.isLoaded = false
 				uni.navigateTo({
-					url: '/pagesA/fire/fpd_detection/detection_details/detection_details?id=' + val.id+'&navData='+navData,
+					url: '/pagesA/fire/fpd_detection/detection_details/detection_details?id=' + val.id
 				});
 			},
 		},
@@ -231,7 +260,7 @@
 				pageSize: this.pageSize,
 				userId: this.$store.state.user.id
 			}).then(response => {
-				console.log(response, 'response');
+				// console.log(response, 'response');
 				// 取到用户对应的单位名称与id
 				response.data.map(v => {
 					this.actions.push({
@@ -239,7 +268,7 @@
 						name: v.orgName
 					});
 				});
-				console.log(response.data, '21321312');
+				// console.log(response.data, '21321312');
 				this.formData.orgName = response.data[0].orgName;
 				this.formData.orgId = response.data[0].dwid;
 				this.tableData = []
@@ -251,7 +280,7 @@
 			})
 			// this.tableData={}
 			// this.getData();
-			this.getData()
+			// this.getData()
 		}
 
 	}