organization.vue 12.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
<template>
	<!-- 机构 -->
	<view class="page">
		<view class="content">
			<view class="top-box" @click="gopath('/pages/receiptRegistration/receiptRegistrationList')">
				<view>上报历史</view>
				<view class="top-box-img">
					<image src="../../static/right2.png"></image>
				</view>
			</view>
			<view class="titleall-left">
				<view class="titleall-left-line"></view>我要上报
			</view>
			<view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">发生地点</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.incidentLocation" placeholder="请输入完整地址信息"
									style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">儿童姓名</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.childName" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">儿童性别</view>
							<view class="serve-right">
								<picker @change="bindPickerChangeSex" :value="index" :range="sexArray">
									<view class="uni-input">{{form.sex?sexArray[form.sex]:'请选择'}}</view>
								</picker>
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">儿童年龄</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.age" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">报告原因</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.reportReason" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view>
							<view class="serve-title" style="font-size: 25rpx;color: #909090;">其他信息</view>
							<textarea v-model="form.reportRecord" placeholder="请输入"
								placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
								style="margin-top: 20rpx;"></textarea>
							<view>

								<!-- <input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.reportRecord" placeholder="请输入" style="text-align: right;" /> -->
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="titleall-left">
				<view class="titleall-left-line"></view>报告人信息
			</view>
			<view class="message-list">
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">所属机构</view>
							<view class="serve-right">
								<picker @change="organization" :value="index2" :range="organizationArray">
									<view class="uni-input">{{form.filingAgencyName?organizationArray[index2]:'请选择'}}
									</view>
								</picker>
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">报告类型</view>
							<view class="serve-right">
								<picker @change="report" :value="index1" :range="reportArray">
									<view class="uni-input">{{form.reportType?reportArray[index1]:'请选择'}}</view>
								</picker>
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">姓名</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.reporterName" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">与儿童关系</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.relationshipWithChild" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">电话</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.phone" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">报告主体</view>
							<view class="serve-right">
								<picker @change="bindPickerChangeSubject" :value="index" :range="SubjectArray">
									<view class="uni-input">{{form.reporterType?SubjectArray[index]:'请选择'}}</view>
								</picker>
								<image src="../../static/down3.png"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="info-box" v-if="form.reporterType == '群众'">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">职业</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.reporterOccupation" placeholder="请输入" style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
				<view class="info-box" v-if="form.reporterType == '单位' || form.reporterType == '社会组织'">
					<view class="info-box-list">
						<view class="serve">
							<view class="serve-title">单位名称</view>
							<view>
								<input placeholder-style="color:#3d3d3d;font-weight: bold;font-size: 25rpx;"
									v-model="form.reporterOrganizationName" placeholder="请输入"
									style="text-align: right;" />
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="page-footer">
				<view class="footer-buy">
					<view class="cart-add" @click="register">
						<image src="../../static/btn5.png"></image>
						<text>立即上报</text>
					</view>
				</view>
			</view>

		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					reportTime: null,
					reportPlatform: null,
					incidentLocation: null,
					childName: null,
					sex: null,
					age: null,
					reportReason: null,
					reportRecord: null,
					reporterName: null,
					relationshipWithChild: null,
					phone: null,
					reporterType: null,
					reporterOrganizationName: null,
					reporterOccupation: null,
					userId: uni.getStorageSync('USERS_KEY').userId,
					reportPlatform: null,
					filingAgencyName: null,
					reportType: null,

				},
				pages: {
					roleName: '机构用户'
				},
				// 性别下拉框
				sexArray: ['男', '女'],
				// 报告主体
				SubjectArray: ['群众', '单位', '社会组织'],
				reportArray: ['强制报告', '机构项目'],
				organizationArray: [],
				organization1: [],
				index: 0,
				index1: 0,
				index2: 0,
			};
		},
		created() {
			this.getListRoles();
		},
		methods: {
			gopath(e) {
				uni.navigateTo({
					url: e
				})
			},
			// 选择性别
			bindPickerChangeSex: function(e) {
				console.log('picker发送选择改变,携带值为', e)
				this.form.sex = e.detail.value;
			},
			// 选择主体
			bindPickerChangeSubject: function(e) {
				console.log('picker发送选择改变,携带值为', e)
				this.index = e.detail.value;
				this.form.reporterType = this.SubjectArray[this.index];
			},
			// 选择报告类型
			report: function(e) {
				console.log('picker发送选择改变,携带值为', e)
				this.index1 = e.detail.value;
				this.form.reportType = this.reportArray[this.index1];
			},
			// 选择机构
			organization: function(e) {
				console.log('picker发送选择改变,携带值为', e)
				this.index2 = e.detail.value;
				this.form.filingAgencyName = this.organizationArray[this.index2];
			},
			// 获取当前时间
			getTime() {
				var now = new Date();
				var year = now.getFullYear(); //获取完整的年份(4位,1970-????)
				var month = now.getMonth() + 1; //获取当前月份(0-11,0代表1月)
				var day = now.getDate(); //获取当前日(1-31)
				var hour = now.getHours(); //获取当前小时数(0-23)
				var minute = now.getMinutes(); //获取当前分钟数(0-59)
				var second = now.getSeconds(); //获取当前秒数(0-59)
				this.form.reportTime = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day :
						day) + " " + (hour < 10 ? "0" + hour : hour) + ":" + (minute < 10 ? "0" + minute : minute) + ":" +
					(
						second < 10 ? "0" + second : second);
			},
			register() {
				if (this.form.incidentLocation == null || this.form.incidentLocation.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写发生地点'
					})
					return
				}
				if (this.form.childName == null || this.form.childName.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写儿童姓名'
					})
					return
				}
				if (this.form.sex == null || this.form.sex.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请选择儿童性别'
					})
					return
				}
				if (this.form.age == null || this.form.age.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写儿童年龄'
					})
					return
				}
				if (this.form.reportReason == null || this.form.reportReason.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写报告原因'
					})
					return
				}
				if (this.form.reportRecord == null || this.form.reportRecord.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写其他信息'
					})
					return
				}
				if (this.form.filingAgencyName == null || this.form.filingAgencyName.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请选择所属机构'
					})
					return
				}
				if (this.form.reportType == null || this.form.reportType.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请选择报告类型'
					})
					return
				}
				if (this.form.reporterName == null || this.form.reporterName.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写报告人姓名'
					})
					return
				}
				if (this.form.relationshipWithChild == null || this.form.relationshipWithChild.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写与儿童关系'
					})
					return
				}
				if (this.form.phone == null || this.form.phone.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请填写电话'
					})
					return
				}
				if (this.form.reporterType == null || this.form.reporterType.length == 0) {
					uni.showToast({
						icon: 'none',
						title: '请选择报告主体'
					})
					return
				}
				this.getTime();
				this.form.filingType = '机构';
				this.form.reportPlatform = this.form.filingAgencyName;
				this.organization1.forEach(item => {
					if (this.form.filingAgencyName == item.userName) {
						this.form.filingAgencyId = item.userId
					}
				})
				console.log(this.form)
				this.API.addRegistration(this.form).then(res => {
					console.log(res)
					if (res.code == 200) {
						uni.showToast({
							icon: 'success',
							title: '上报成功'
						})
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/receiptRegistrationSuccess/receiptRegistrationSuccess',
							})
						}, 800)
					}
				})
			},
			// 获得机构
			getListRoles() {
				this.API.getListRoles(this.pages).then(res => {
					console.log(res)
					if (res.code == 200) {
						this.organization1 = res.data;
						res.data.forEach(item => {
							this.organizationArray.push(item.userName)
						})
					}
				})

			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'receiptRegistration.scss';
</style>