<template>
	<view>
		<view class="perfect-title">完善企业信息</view>
			<!-- Ⅰ类知识产权数 -->
			<view class="cu-form">
				<view class="title">{{list[0]}}：</view>
				<input name="input" type="digit" v-model="intellectualPropertyRightI"></input>
			</view>
			<!-- Ⅱ类知识产权数 -->
			<view class="cu-form">
				<view class="title">{{list[1]}}：</view>
				<input name="input" type="digit" v-model="intellectualPropertyRightIi"></input>
			</view>
			<!-- 对企业主要产品（服务）发挥核心支持作用的技术 -->
			<view class="cu-form">
				<view class="title">{{list[2]}}：</view>
				<input name="input" type="digit" v-model="mainProductTechnologyText" disabled @click="changeIncubatorShow"></input>
				<view class="incubator-box" :class="incubatorShow ? 'show' : ''" >
					<view class="incubator-content" v-for="(item,index) in incubatorList" :key="index" @click="changeIncubator(item,index)">
						{{item}}
					</view>
				</view>
			</view>

			<!-- 职工总数 -->
			<view class="cu-form">
				<view class="title">{{list[3]}}：</view>
				<input name="input" type="digit" v-model="workforce"></input>
			</view>
			<!-- 科技人员总数 -->
			<view class="cu-form">
				<view class="title">{{list[4]}}：</view>
				<input name="input" type="digit" v-model="technicians"></input>
			</view>
			<!-- 资产总额 -->
			<view class="cu-form">
				<view class="title">{{list[5]}}：</view>
				<input name="input" type="digit" v-model="totalAssets"></input>
			</view>
			<!-- 今年销售收入总额 -->
			<view class="cu-form">
				<view class="title">{{list[6]}}：</view>
				<input name="input" type="digit" v-model="grossSalesOne"></input>
			</view>
			<!-- 去年销售收入总额 -->
			<view class="cu-form">
				<view class="title">{{list[7]}}：</view>
				<input name="input" type="digit" v-model="grossSalesTwo"></input>
			</view>
			<!-- 前年销售收入总额 -->
			<view class="cu-form">
				<view class="title">{{list[8]}}：</view>
				<input name="input" type="digit" v-model="grossSalesThree"></input>
			</view>
			<!-- 今年研发费用总额 -->
			<view class="cu-form">
				<view class="title">{{list[9]}}：</view>
				<input name="input" type="digit" v-model="rdexpensesOne"></input>
			</view>
			<!-- 去年研发费用总额 -->
			<view class="cu-form">
				<view class="title">{{list[10]}}：</view>
				<input name="input" type="digit" v-model="rdexpensesTwo"></input>
			</view>
			<!-- 前年研发费用总额 -->
			<view class="cu-form">
				<view class="title">{{list[11]}}：</view>
				<input name="input" type="digit" v-model="rdexpensesThree"></input>
			</view>
			<!-- 今年成本费用支出总额 -->
			<view class="cu-form">
				<view class="title">{{list[12]}}：</view>
				<input name="input" type="digit" v-model="totalCostExpensesOne"></input>
			</view>
			<!-- 去年成本费用支出总额 -->
			<view class="cu-form">
				<view class="title">{{list[13]}}：</view>
				<input name="input" type="digit" v-model="totalCostExpensesTwo"></input>
			</view>
			<!-- 前年成本费用支出总额 -->
			<view class="cu-form">
				<view class="title">{{list[14]}}：</view>
				<input name="input" type="digit" v-model="totalCostExpensesThree"></input>
			</view>
			<!-- 高新技术产品（服务）费用 -->
			<view class="cu-form">
				<view class="title">{{list[15]}}：</view>
				<input name="input" type="digit" v-model="highNewTechnologyFee"></input>
			</view>
			<!-- 前一年及当年内有无发生重大安全、重大质量事故和严重环境违法、科研严重失信行为 -->
			<view class="cu-form">
				<view class="title">{{list[16]}}：</view>
				<radio-group class="radio-box" name="one" @change="changeOne">
					<label>
						<view>
							<radio value="0" :checked="illegalAct-0 === 0" /><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="illegalAct-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 企业是否被列入经营异常名录和严重违法失信企业名单 -->
			<view class="cu-form">
				<view class="title">{{list[17]}}：</view>
				<radio-group class="radio-box" name="two" @change="changeTwo">
					<label>
						<view>
							<radio value="0" :checked="dishonestEnterprise-0 === 0" /><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="dishonestEnterprise-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 产品和服务是否属于国家规定的禁止、限制和淘汰类 -->
			<view class="cu-form">
				<view class="title">{{list[18]}}：</view>
				<radio-group class="radio-box" name="three" @change="changeThree">
					<label>
						<view>
							<radio value="0" :checked="forbidProduct-0 === 0" /><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="forbidProduct-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 是否拥有有效期内高新技术企业资格证书 -->
			<view class="cu-form">
				<view class="title">{{list[19]}}：</view>
				<radio-group class="radio-box" name="four" @change="changeFour">
					<label>
						<view>
							<radio value="0" :checked="highNewTechnologyEnterprise-0 === 0" /><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="highNewTechnologyEnterprise-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 企业近五年内是否获得过国家级科技奖励，并在获奖单位中排在前三名 -->
			<view class="cu-form">
				<view class="title">{{list[20]}}：</view>
				<radio-group class="radio-box" name="five" @change="changeFive">
					<label>
						<view>
							<radio value="0" :checked="technologyAwards-0 === 0" /><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="technologyAwards-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 企业是否拥有经认定的省部级以上研发机构 -->
			<view class="cu-form">
				<view class="title">{{list[21]}}：</view>
				<radio-group class="radio-box" name="six" @change="changeSix">
					<label>
						<view>
							<radio value="0" :checked="organization-0 === 0"/><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="organization-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
			<!-- 企业近五年内是否主导制定过国际标准、国家标准或行业标准 -->
			<view class="cu-form">
				<view class="title">{{list[22]}}：</view>
				<radio-group class="radio-box" name="seven" @change="changeSeven">
					<label>
						<view>
							<radio value="0" :checked="standard-0 === 0"/><text> 否</text>
						</view>
						<view>
							<radio value="1" :checked="standard-0 === 1" /><text> 是</text>
						</view>
					</label>
				</radio-group>
			</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-red margin-tb-sm lg" @click="commit">提交</button>
		</view>
	</view>
</template>

<script>
	import { additional } from 'api/additional'
	import { additionalDetail } from 'api/additionalDetail'
	
	export default {
		onShareAppMessage(res) {
			if (res.from === 'button') {// 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: '',
				path: '/pages/Binding/Binding'
			}
		},
		data() {
			return {
				list:['Ⅰ类知识产权数','Ⅱ类知识产权','对企业主要产品（服务）发挥核心支持作用的技术','职工总数','科技人员总数','资产总额，单位：万（例如：100）','今年销售收入总额，单位：万',
				'去年销售收入总额，单位：万','前年销售收入总额，单位：万','今年研发费用总额，单位：万','去年研发费用总额，单位：万','前年研发费用总额，单位：万','今年成本费用支出总额，单位：万',
				'去年成本费用支出总额，单位：万','前年成本费用支出总额，单位：万','高新技术产品（服务）费用，单位：万','前一年及当年内有无发生重大安全、重大质量事故和严重环境违法、科研严重失信行为',
				'企业是否被列入经营异常名录和严重违法失信企业名单','产品和服务是否属于国家规定的禁止、限制和淘汰类','是否拥有有效期内高新技术企业资格证书',
				'企业近五年内是否获得过国家级科技奖励，并在获奖单位中排在前三名 ','企业是否拥有经认定的省部级以上研发机构','企业近五年内是否主导制定过国际标准、国家标准或行业标准',],
				incubatorList:['其他','电子信息技术','生物与医药技术','航空航天技术','新材料技术','高新技术服务技术','新能源及节能技术','资源与环境技术','高新技术改造传统产业'],
				incubatorShow:false,
				intellectualPropertyRightI:'', // I类知识产权数
				intellectualPropertyRightIi	:'', // Ⅱ类知识产权
				mainProductTechnology:'', // 核心支持作用的技术
				mainProductTechnologyText:'',
				workforce:'', // 职工总数
				technicians:'', // 科技人员总数
				totalAssets:'', // 资产总额
				grossSalesOne:'', // 今年销售收入总额
				grossSalesThree:'', // 前年销售收入总额
				grossSalesTwo:'', // 去年销售收入总额
				rdexpensesOne:'', // 今年研发费用总额
				rdexpensesThree	:'', // 前年研发费用总额
				rdexpensesTwo:'', // 去年研发费用总额
				totalCostExpensesOne:'', // 今年成本费用支出总额
				totalCostExpensesThree:'', // 前年成本费用支出总额
				totalCostExpensesTwo:'', // 去年成本费用支出总额
				highNewTechnologyFee:'', // 高新技术产品（服务）费用
				
				illegalAct:0, // 前一年及当年内有无发生重大安全、重大质量事故和严重环境违法、科研严重失信行为
				checkedOne:'',
				dishonestEnterprise:0, // 企业是否被列入经营异常名录和严重违法失信企业名单
				checkedTwo:'',
				forbidProduct:0, // 产品和服务是否属于国家规定的禁止、限制和淘汰类
				checkedThree:'',
				highNewTechnologyEnterprise:2, // 是否拥有有效期内高新技术企业资格证书
				checkedFour:'',
				technologyAwards:2, // 企业近五年内是否获得过国家级科技奖励
				checkedFive:'',
				organization:2, // 企业是否拥有经认定的省部级以上研发机构
				checkedSix:'',
				standard:2, //企业近五年内是否主导制定过国际标准、国家标准或行业标准
				checkedSeven:'',
			}
		},
		async onLoad(){
			const that = this
			if(this.$store.state.user.bindMsg.perfectStatus === 1){
				const params = {
					param:{
						
					}
				}
				const data = await additionalDetail(params)
				if(data !== null){
					that.intellectualPropertyRightI = data.intellectualPropertyRightI
					that.intellectualPropertyRightIi = data.intellectualPropertyRightIi
					that.mainProductTechnology = data.mainProductTechnology
					that.mainProductTechnologyText = that.incubatorList[data.mainProductTechnology]
					that.workforce = data.workforce
					that.technicians = data.technicians
					that.totalAssets = data.totalAssets
					that.grossSalesOne = data.grossSalesOne
					that.grossSalesThree = data.grossSalesThree
					that.grossSalesTwo = data.grossSalesTwo
					that.rdexpensesOne = data.rdexpensesOne
					that.rdexpensesThree = data.rdexpensesThree
					that.rdexpensesTwo = data.rdexpensesTwo
					that.totalCostExpensesOne = data.totalCostExpensesOne
					that.totalCostExpensesThree = data.totalCostExpensesThree
					that.totalCostExpensesTwo = data.totalCostExpensesTwo
					that.highNewTechnologyFee = data.highNewTechnologyFee
					
					that.illegalAct = data.illegalAct
					that.dishonestEnterprise = data.dishonestEnterprise
					that.forbidProduct = data.forbidProduct
					that.highNewTechnologyEnterprise = data.highNewTechnologyEnterprise
					that.technologyAwards = data.technologyAwards
					that.organization = data.organization
					that.standard = data.standard
					console.log(that.illegalAct,that.dishonestEnterprise,that.forbidProduct)
				}else{
					console.log('没有数据')
				}
			}
		},
		methods:{
			changeOne(e){
				console.log(e.detail.value)
				this.illegalAct = e.detail.value
			},
			changeTwo(e){
				console.log(e.detail.value)
				this.dishonestEnterprise = e.detail.value
			},
			changeThree(e){
				console.log(e.detail.value)
				this.forbidProduct = e.detail.value
			},
			changeFour(e){
				console.log(e.detail.value)
				this.highNewTechnologyEnterprise = e.detail.value
			},
			changeFive(e){
				console.log(e.detail.value)
				this.technologyAwards = e.detail.value
			},
			changeSix(e){
				console.log(e.detail.value)
				this.organization = e.detail.value
			},
			changeSeven(e){
				console.log(e.detail.value)
				this.standard = e.detail.value
			},
			async commit(){
				const that = this
				try{
					const params = {
						param:{
							dishonestEnterprise:that.dishonestEnterprise,
							forbidProduct:that.forbidProduct,
							grossSalesOne:that.grossSalesOne,
							grossSalesThree:that.grossSalesThree,
							grossSalesTwo:that.grossSalesTwo,
							highNewTechnologyEnterprise:that.highNewTechnologyEnterprise,
							highNewTechnologyFee:that.highNewTechnologyFee,
							illegalAct:that.illegalAct,
							intellectualPropertyRightI:that.intellectualPropertyRightI,
							intellectualPropertyRightIi:that.intellectualPropertyRightIi,
							mainProductTechnology:that.mainProductTechnology,
							organization:that.organization,
							rdexpensesOne:that.rdexpensesOne,
							rdexpensesThree:that.rdexpensesThree,
							rdexpensesTwo:that.rdexpensesTwo,
							standard:that.standard,
							technicians:that.technicians,
							technologyAwards:that.technologyAwards,
							totalAssets:that.totalAssets,
							totalCostExpensesOne:that.totalCostExpensesOne,
							totalCostExpensesThree:that.totalCostExpensesThree,
							totalCostExpensesTwo:that.totalCostExpensesTwo,
							workforce:that.workforce
						}
					}
					const data = await additional(params)
					if(that.$store.state.user.bindMsg.perfectStatus === 0){
						that.$store.state.user.bindMsg.perfectStatus = 1
					}
					uni.showToast({
						title:'即将跳转...',
						duration:2000,
						icon:'success'
					})
					setTimeout(function(){
						uni.switchTab({
							url:'/pages/tabBar/Enterprise'
						})
					},2000)
				}catch(e){
					uni.showToast({
						title:'提交失败,非法字符',
						icon:'none'
					})
					console.log(e)
				}
			},
			changeIncubatorShow(){
				const that = this
				if(that.incubatorShow === true){
					that.incubatorShow = false
				}else{
					that.incubatorShow = true
				}
				console.log(that.incubatorShow)
			},
			changeIncubator(item,index){
				const that = this
				console.log(item,index)
				that.mainProductTechnologyText = item
				that.mainProductTechnology = index
				that.incubatorShow = false
			}
		},
		watch:{
			async '$store.state.user.bindMsg.perfectStatus'(val){
				const that = this
				const params = {
					param:{
					}
				}
				const data = await additionalDetail(params)
				if(data !== null){
					that.intellectualPropertyRightI = data.intellectualPropertyRightI
					that.intellectualPropertyRightIi = data.intellectualPropertyRightIi
					that.mainProductTechnology = data.mainProductTechnology
					that.mainProductTechnologyText = that.incubatorList[data.mainProductTechnology]
					that.workforce = data.workforce
					that.technicians = data.technicians
					that.totalAssets = data.totalAssets
					that.grossSalesOne = data.grossSalesOne
					that.grossSalesThree = data.grossSalesThree
					that.grossSalesTwo = data.grossSalesTwo
					that.rdexpensesOne = data.rdexpensesOne
					that.rdexpensesThree = data.rdexpensesThree
					that.rdexpensesTwo = data.rdexpensesTwo
					that.totalCostExpensesOne = data.totalCostExpensesOne
					that.totalCostExpensesThree = data.totalCostExpensesThree
					that.totalCostExpensesTwo = data.totalCostExpensesTwo
					that.highNewTechnologyFee = data.highNewTechnologyFee
					
					that.illegalAct = data.illegalAct
					that.dishonestEnterprise = data.dishonestEnterprise
					that.forbidProduct = data.forbidProduct
					that.highNewTechnologyEnterprise = data.highNewTechnologyEnterprise
					that.technologyAwards = data.technologyAwards
					that.organization = data.organization
					that.standard = data.standard
				}
			}
		}
	}
</script>

<style lang="scss">
.perfect-title{
	display: flex;
	background-color: $white;
	padding: 1upx 30upx;
	font-size: 20px;
	font-weight: 600;
	align-items: center;
	min-height: 100upx;
}
.cu-form{
	background-color: $white;
	padding: 10upx 30upx;
	align-items: center;
	min-height: 100upx;
	justify-content: space-between;
}

.title {
	text-align: justify;
	padding-right: 30upx;
	font-size: 14px;
	position: relative;
	// height: 60upx;
	line-height: 50upx;
	// padding-bottom: 20upx;
}

.cu-form input {
	flex: 1;
	font-size: 14px;
	color: #555;
	padding-right: 20upx;
	border: 1px solid #eee;
	border-radius: 5px;
	margin-bottom: 20upx;
	height: 30px;
	padding-left: 10px;
}
.radio-box>label{
	width: 600upx;
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.show{
	display: block !important;
}
.incubator-box{
	display: none;
	background-color: $white;
	padding-left: 20upx;
	padding-right: 20upx;
	border-radius: 0 0 5px 5px;
	position: absolute;
	z-index: 10;
	width: 690upx;
	border: 1px solid $grey;
	border-top: none !important;
}
.incubator-content{
	line-height: 30px;
	margin-bottom: 4px;
	height: 30px;
	border-bottom: 1px solid #eee;
}
</style>
