organization.vue 10.2 KB
<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: "",
					reportPlatform: "",
					incidentLocation: "",
					childName: "",
					sex: "",
					age: "",
					reportReason: "",
					reportRecord: "",
					reporterName: "",
					relationshipWithChild: "",
					phone: "",
					reporterType: "",
					reporterOrganizationName: "",
					reporterOccupation: "",
					userId: uni.getStorageSync('USERS_KEY').userId,
					reportPlatform: ''
				},
				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() {
				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>