<template>
	<view>
		<view class="form">
			<view class="flex">
				<image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/icon/tag1.png" mode=""></image>
				<text class="text-lg text-bold" v-if="opera==1">请填写基本信息</text>
				<text class="text-lg text-bold" v-if="opera==2">请编辑基本信息</text>
				<text class="text-lg text-bold" v-if="opera==3">企业项目详情</text>
			</view>
			<view class="card">
				<u-form label-width="240" :model="model"  ref="uForm">
					<u-form-item :required="true" prop="name"    label="项目名称" >
						<u-input :disabled="opera==3"  type="text"  v-model="model.name"  placeholder="请填写项目名称" ></u-input>
					</u-form-item>
					<u-form-item :required="true" prop="investmentScale"  label="投资规模" >
						<u-input :disabled="opera==3" type="number"  v-model="model.investmentScale"  placeholder="请填写投资规模" ></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="employmentNumber"  label="项目就业人数" >
						<u-input :disabled="opera==3" type="number"  v-model="model.employmentNumber"  placeholder="请填写项目就业人数"></u-input>
						<text style="color: #828282;" slot="right">人</text>
					</u-form-item>
					<u-form-item :required="true" prop="investmentAmount"  label="项目投资总额" >
						<u-input :disabled="opera==3" type="number"  v-model="model.investmentAmount"  placeholder="请填写项目投资总额"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="investmentReturn"  label="项目投资收益" >
						<u-input :disabled="opera==3" type="number"  v-model="model.investmentReturn"  placeholder="请填写项目投资收益"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="investmentCompleted"  label="已完成投资总额" >
						<u-input :disabled="opera==3" type="number"  v-model="model.investmentCompleted"  placeholder="请填写已完成投资总额"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="researchCost"  label="项目研发费用" >
						<u-input :disabled="opera==3" type="number"  v-model="model.researchCost"  placeholder="请填写项目研发费用"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="taxes"  label="项目上缴税金" >
						<u-input :disabled="opera==3" type="number"  v-model="model.taxes"  placeholder="请填写项目上缴税金"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="taward"  label="已申请奖补金额" >
						<u-input :disabled="opera==3" type="number"  v-model="model.taward"  placeholder="请填写已申请奖补金额"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
					<u-form-item :required="true" prop="tawardCompleted" label="已发放奖补金额" >
						<u-input :disabled="opera==3" type="number"  v-model="model.tawardCompleted"  placeholder="请填写已发放奖补金额"></u-input>
						<text style="color: #828282;" slot="right">万</text>
					</u-form-item>
				</u-form>
			</view>
			<view v-if="opera!=3">
				<view class="bg-white" style="height: 80rpx;"></view>
				<view class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
					<view  class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;" >
						<text class="cuIcon-edit margin-right-10" v-if="opera==2"></text>
						<text class="cuIcon-add margin-right-10" v-else></text>
						<text v-text="opera==1?'确认添加':'确认编辑'"></text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model:{},
				disabled:false,
				//1新增，2编辑，3详情
				opera:1
			}
		},
		onLoad(options) {
			if (!this.$isEmpty(options)) {
				this.opera=options.opera
				this.model=options
			}
			
			if (this.opera==2) {
				uni.setNavigationBarTitle({
					title:"编辑"
				})
			}
			if (this.opera==3) {
				uni.setNavigationBarTitle({
					title:"项目详情"
				})
			}
			
			
			 this.model.enterpriseId=this.$cache.get('enterpriseId')
			 if (!this.model.enterpriseId) {
			 	this.$dialog.showModal('系统错误',false).then(res=>{
					this.$navigateBack()
				})
			 }
		},
		methods: {
			submit() {
				if (this.$isEmpty(this.model.name)) {
					this.$u.toast('请填写项目名称')
					return
				}
				if (this.$isEmpty(this.model.investmentScale)) {
					this.$u.toast('请填写投资规模')
					return
				}
				if (this.$isEmpty(this.model.employmentNumber)) {
					this.$u.toast('请填写项目就业人数')
					return
				}
				if (this.$isEmpty(this.model.investmentAmount)) {
					this.$u.toast('请填写项目投资总额')
					return
				}
				if (this.$isEmpty(this.model.investmentReturn)) {
					this.$u.toast('请填写项目投资收益')
					return
				}
				if (this.$isEmpty(this.model.investmentCompleted)) {
					this.$u.toast('请填写已完成投资总额')
					return
				}
				if (this.$isEmpty(this.model.researchCost)) {
					this.$u.toast('请填写项目研发费用')
					return
				}
				if (this.$isEmpty(this.model.taxes)) {
					this.$u.toast('请填写项目上缴税金')
					return
				}
				if (this.$isEmpty(this.model.taward)) {
					this.$u.toast('请填写已申请奖补金额')
					return
				}
				if (this.$isEmpty(this.model.tawardCompleted)) {
					this.$u.toast('请填写已发放奖补金额')
					return
				}
				this.$api.enterpriseproject.submit(this.model).then(res=>{
					if (res.success==true) {
						this.$dialog.showModal('操作成功',false).then(res=>{
							this.$util.isReloadAndBack()
						})
					}else{
						this.$u.toast(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #FFFFFF;
}
	
.form{
	padding: 40rpx 30rpx;
	.card{
		margin-top: 20rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		border-radius: 12rpx;
		box-shadow: 0 -10rpx rgba(248, 248, 248,.9) ,0 10rpx rgba(248, 248, 248,.9) , -10rpx 0rpx rgba(248, 248, 248,.9) ,10rpx 0rpx rgba(248, 248, 248,.9);
		.item{
			padding:30rpx 0;
			display: flex;
			justify-content: space-between;
		}
	}
}
</style>
