<template>
	<Layout :index="-1" :banner="0"  :img="'/static/img/about.jpg'" :titles="'个人中心'" :title_content="'个人中心'">
		<view class="bg ptm-80">
			<view class="content">
				<view class="content_left">
					<memberleft :index="'3'"></memberleft>
				</view>
				<view class="content_right">
					<view class="mtitle">
						<span>新增游戏产品评估确权</span>
						<view class="goback" @tap="goBack()">
							返回
						<i class="el-icon-back"></i>
						</view>
					</view>
					<view class="lines"></view>
					<view class="content_r">
						<view class="step d-b-c">
							<view class="step_one d-b-c" @tap="gosteps(0)">
								<view class="step_num" :class="{'step_num_active':steps==0,'step_num_actives':steps>0}">1</view>
								<view class="step_title">填写基本信息</view>	
							</view>
							<i class="el-icon-d-arrow-right" :class="{'active-step':steps>=0}"></i>
							<view class="step_one d-b-c" @tap="gosteps(1)">
								<view class="step_num" :class="{'step_num_active':steps==1,'step_num_actives':steps>1}">2</view>
								<view class="step_title">填写研发信息</view>	
							</view>
							<i class="el-icon-d-arrow-right" :class="{'active-step':steps>1}"></i>
							<view class="step_one d-b-c" @tap="gosteps(2)">
								<view class="step_num" :class="{'step_num_active':steps==2,'step_num_actives':steps>2}">3</view>
								<view class="step_title">填写产权信息</view>	
							</view>
							<i class="el-icon-d-arrow-right" :class="{'active-step':steps>=3}"></i>
							<view class="step_one d-b-c" @tap="gosteps(3)">
								<view class="step_num" :class="{'step_num_active':steps==3}">4</view>
								<view class="step_title">填写运营信息</view>	
							</view>
								
						</view>
				<el-form label-position="right" :model="form" :rules="rules" ref="ruleForm" class="ruleForm" label-width="100px" >
					<!-- 基本信息 -->
					<view class="asset_content" v-show="steps==0">
						<view class="asset_title">资产基本信息</view>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="资产名称：" :label-width="formLabelWidth" prop="base_info.name" :rules="[{required: true,message: '请输入资产名称', trigger: 'blur'}]">
								   <el-input v-model="form.base_info.name" placeholder="请输入资产名称"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="来源渠道：" :label-width="formLabelWidth" prop="base_info.source_id" >
									<el-input  v-model="form.base_info.source_id" placeholder="(选填)请输入编号"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="资产类型：" :label-width="formLabelWidth" prop="base_info.asset_type" :rules="[{required: true,message: '请输入资产类型', trigger: 'blur'}]">
								   <el-input v-model="form.base_info.asset_type" placeholder="游戏数字资产包" ></el-input>
								 </el-form-item> 
							   
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="资产权属人：" :label-width="formLabelWidth" prop="base_info.owner" :rules="[{required: true,message: '请输入资产权属人', trigger: 'blur'}]">
									<el-input  v-model="form.base_info.owner" placeholder="请输入资产权属人"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-form-item label="权属人规模：" prop="base_info.owner_scale" :label-width="formLabelWidth" :rules="[{required: true,message: '请输入权属人规模', trigger: 'blur'}]">
						<el-input  v-model="form.base_info.owner_scale" placeholder="请输入权属人规模"></el-input>
						</el-form-item>
						
						<el-form-item label="权属人股权及融资情况：" :label-width="formLabelWidth" prop="base_info.owner_finance" :rules="[{required: true,message: '请输入权属人股权及融资情况', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.base_info.owner_finance" placeholder="请输入"></el-input>
						  </el-form-item>
						
						<view class="asset_title">团队基本信息</view>
						<el-form-item label="企业征信报告：" :label-width="formLabelWidth" >
							<el-upload
							  class="uploads"
							    action=""
								:before-upload="beforeUploadFile"
								:http-request="customUpload"
								multiple
								:limit="1"
								:on-exceed="handleExceed1"
							  :file-list="fileList1"
							  :on-remove="handleRemove1"
							  >
							  <el-button size="small" type="primary" class="xzfile" @tap="select(1)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
							  <div slot="tip" class="el-upload__tip">请至<text class="lans" @tap="goUrl('https://www.tianfucredit.cn/cui/credit-report/cog')">天府信用通平台</text>登录查看并下载回传</div>
							</el-upload>
							
						 </el-form-item>
						 <el-form-item label="报告编号：" :label-width="formLabelWidth" >
						     <el-input type="text" v-model="form.base_info.credit_report_no" placeholder="请输入报告编号"></el-input>
						   </el-form-item>
						 
						 
						
						<el-form-item label="团队基本情况：" :label-width="formLabelWidth" prop="base_info.team_info" :rules="[{required: true,message: '请输入团队基本情况', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.base_info.team_info" placeholder="请输入"></el-input>
						  </el-form-item>
						<el-form-item label="核心成员履历：" :label-width="formLabelWidth" prop="base_info.core_members" :rules="[{required: true,message: '请输入核心成员履历', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.base_info.core_members" placeholder="请输入"></el-input>
						  </el-form-item>
					</view>
					<!-- 项目研发信息 -->
					<view class="asset_content" v-show="steps==1" >
						<view class="asset_title">项目研发信息</view>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="游戏名称：" :label-width="formLabelWidth" prop="develop_info.game_name" :rules="[{required: true,message: '请输入游戏名称', trigger: 'blur'}]">
								   <el-input v-model="form.develop_info.game_name" placeholder="请输入游戏名称"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="游戏类型：" :label-width="formLabelWidth" prop="develop_info.game_type" :rules="[{required: true,message: '请输入游戏类型', trigger: 'blur'}]">
									<el-input  v-model="form.develop_info.game_type" placeholder="请输入游戏类型"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="产品形态：" :label-width="formLabelWidth" prop="ptype" :rules="[{required: true,message: '请选择产品形态', trigger: 'blur'}]">
								   <el-checkbox-group v-model="form.ptype">
								         <el-checkbox label="电脑" name="type"></el-checkbox>
								         <el-checkbox label="移动" name="type"></el-checkbox>
								         <el-checkbox label="游戏机" name="type"></el-checkbox>
								       </el-checkbox-group>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="付费方式：" :label-width="formLabelWidth" prop="develop_info.payment_method" :rules="[{required: true,message: '请输入付费方式', trigger: 'blur'}]">
									<el-input  v-model="form.develop_info.payment_method" placeholder="请输入付费方式"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="研发进度：" :label-width="formLabelWidth" prop="develop_info.dev_progress" :rules="[{required: true,message: '请输入研发进度', trigger: 'blur'}]">
								   <el-input v-model="form.develop_info.dev_progress" placeholder="请输入研发进度"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="发行地区：" :label-width="formLabelWidth" prop="develop_info.release_region" :rules="[{required: true,message: '请输入发行地区', trigger: 'blur'}]">
									<el-input  v-model="form.develop_info.release_region" placeholder="请输入发行地区"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						<el-form-item label="发行渠道：" prop="develop_info.release_channel" :label-width="formLabelWidth" :rules="[{required: true,message: '请输入发行渠道', trigger: 'blur'}]">
						<el-input  v-model="form.develop_info.release_channel" placeholder="请输入发行渠道"></el-input>
						</el-form-item>
						
						<el-form-item label="游戏简介：" :label-width="formLabelWidth" prop="develop_info.game_intro" :rules="[{required: true,message: '请输入游戏简介', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.develop_info.game_intro"  placeholder="请输入"></el-input>
							<el-upload
							  class="uploadss"
							    action=""
								:before-upload="beforeUploadFile"
								:http-request="customUpload"
								multiple
								:limit="1"
								:on-exceed="handleExceed8"
								:on-remove="handleRemove8"
							  :file-list="fileList8">
							  <el-button size="small" type="primary" class="xzfile" @tap="select(8)" v-loading.fullscreen.lock="save_loading">选择附件</el-button>
							</el-upload>
						</el-form-item>
						
						
						<el-form-item label="已投入成本：" :label-width="formLabelWidth" prop="develop_info.investment_cost" :rules="[{required: true,message: '请输入已投入成本', trigger: 'blur'}]">
						    <el-input type="textarea" v-model="form.develop_info.investment_cost" placeholder="请输入"></el-input>
						  </el-form-item>
					</view>
					
					<!-- 产权信息 -->
					<view class="asset_content" v-show="steps==2" >
						<view class="asset_title">软著信息</view>
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="著作权人：" :label-width="formLabelWidth" >
								   <el-input v-model="form.title_info.copyright_owner" placeholder="请输入著作权人"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="取得时间：" :label-width="formLabelWidth" >
									<el-input  v-model="form.title_info.acquire_time" placeholder="请输入取得时间"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							 <el-col :span="12">
								 <el-form-item label="登记号：" :label-width="formLabelWidth" >
									<el-input  v-model="form.title_info.registration_no" placeholder="请输入登记号"></el-input>
								  </el-form-item>
							 </el-col>
							  <el-col :span="12">
								  <el-form-item label="权力范围：" :label-width="formLabelWidth" >
									<el-input  v-model="form.title_info.power_scope" placeholder="请输入权力范围"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="证明文件：" :label-width="formLabelWidth" >
								  <el-upload
								    class="uploadss"
								      action=""
								  	:before-upload="beforeUpload"
								  	:http-request="customUpload"
								  	multiple
								  	:limit="1"
								  	:on-exceed="handleExceed2"
									:on-remove="handleRemove2"
								    :file-list="fileList2">
								    <el-button size="small" type="primary" class="xzfile" @tap="select(2)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
								  </el-upload>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="是否和申报包符合：" :label-width="formLabelWidth">
									<el-input  v-model="form.title_info.is_match_declaration" placeholder="请输入是或否"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<view class="asset_title push-t-40">版号信息</view>
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="出版单位：" :label-width="formLabelWidth" >
								   <el-input v-model="form.title_info.publisher" placeholder="请输入出版单位"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="运营单位：" :label-width="formLabelWidth" >
									<el-input  v-model="form.title_info.operator" placeholder="请输入运营单位"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
							  <el-form-item label="批准时间：" :label-width="formLabelWidth" >
								<el-input  v-model="form.title_info.approval_time" placeholder="请输入批准时间"></el-input>
							  	</el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="批准单位：" :label-width="formLabelWidth">
									<el-input  v-model="form.title_info.approval_unit" placeholder="请输入批准单位"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						
						<el-row>
							<view class="d-b-c">
							  <el-col :span="12">
								 <el-form-item label="ISBN号：" :label-width="formLabelWidth">
								   <el-input v-model="form.title_info.isbn" placeholder="请输入ISBN号"></el-input>
								 </el-form-item>
							  </el-col>
							  <el-col :span="12">
								  <el-form-item label="是否和申报包匹配：" :label-width="formLabelWidth">
									<el-input  v-model="form.title_info.is_match_package" placeholder="请输入是或否"></el-input>
								  </el-form-item>
							  </el-col>
						   </view>
						</el-row>
						<el-form-item label="证明文件：" :label-width="formLabelWidth" >
						 <el-upload
						   class="uploadss"
						     action=""
						 	:before-upload="beforeUpload"
						 	:http-request="customUpload"
						 	multiple
						 	:limit="1"
						 	:on-exceed="handleExceed3"
							:on-remove="handleRemove3"
						   :file-list="fileList3">
						   <el-button size="small" type="primary" class="xzfile" @tap="select(3)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						 </el-upload>
						</el-form-item>
						
						<view class="asset_title push-t-40">版权信息</view>
						<el-form-item label="作品版权情况说明：" :label-width="formLabelWidth" >
						    <el-input type="textarea" v-model="form.title_info.copyright_description"  placeholder="请输入"></el-input>
						  </el-form-item>
						
						<el-form-item label="证明文件：" :label-width="formLabelWidth">
						 <el-upload
						   class="uploadss"
						     action=""
						 	:before-upload="beforeUpload"
						 	:http-request="customUpload"
						 	multiple
						 	:limit="1"
						 	:on-exceed="handleExceed4"
							:on-remove="handleRemove4"
						   :file-list="fileList4">
						   <el-button size="small" type="primary" class="xzfile" @tap="select(4)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						 </el-upload>
						</el-form-item>
					</view>
					
					<!-- 运营信息 -->
					<view class="asset_content" v-show="steps==3" >
						<view class="asset_title">项目运营数据</view>
						<el-form-item label="上线时间：" :label-width="formLabelWidth" prop="operation_info.online_time" :rules="[{required: true,message: '请输入上线时间', trigger: 'blur'}]" class="aa">
							 <uni-datetime-picker class="online_times"
							 				type="date"
							 				:value="form.operation_info.online_time"
							 				@change="change"
							 			/>
							 <view class="tips">请选择上线时间或拟上线时间</view>			
						</el-form-item>
						<el-form-item label="收入预估：" :label-width="formLabelWidth">
						 <el-upload
						   class="uploads"
						     action=""
						 	:before-upload="beforeUpload"
						 	:http-request="customUpload"
						 	multiple
						 	:limit="1"
						 	:on-exceed="handleExceed5"
							:on-remove="handleRemove5"
						   :file-list="fileList5">
						   <el-button size="small" type="primary" class="xzfile" @tap="select(5)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						   <div slot="tip" class="el-upload__tip">查看 <text class="lans" @tap="goUrl('https://cogapi.scszsj.com/COG%E9%A2%84%E4%BC%B0%E6%95%B0%E6%8D%AE%E6%A8%A1%E6%9D%BF.xlsx')">收入预估模板</text></div>
						 </el-upload>
						</el-form-item>
						
						<el-form-item label="运营数据：" :label-width="formLabelWidth" >
						  <el-checkbox-group v-model="form.ptypes">
						        <el-checkbox label="已接入COG运营发行中枢，授权获取数据" name="type"></el-checkbox>
						  </el-checkbox-group>
							<el-upload
							  class="uploads"
							    action=""
								:before-upload="beforeUpload"
								:http-request="customUpload"
								multiple
								:limit="1"
								:on-exceed="handleExceed6"
								:on-remove="handleRemove6"
							  :file-list="fileList6">
							  <el-button size="small" type="primary" class="xzfile" @tap="select(6)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
							  <div slot="tip" class="el-upload__tip">查看 <text class="lans" @tap="goUrl('https://cogapi.scszsj.com/COG%E8%BF%90%E8%90%A5%E6%95%B0%E6%8D%AE%E6%A8%A1%E6%9D%BF.xlsx')">运营数据模板</text></div>
							</el-upload>  
						</el-form-item>
						
						<el-form-item label="第三方补充附件：" :label-width="formLabelWidth" >
						 <el-upload
						   class="uploads"
						     action=""
						 	:before-upload="beforeUploadimg"
						 	:http-request="customUpload"
						 	multiple
						 	:limit="1"
						 	:on-exceed="handleExceed7"
							:on-remove="handleRemove7"
						   :file-list="fileList7">
						   <el-button size="small" type="primary" class="xzfile" @tap="select(7)" v-loading.fullscreen.lock="save_loading">选择文件</el-button>
						 </el-upload>
						</el-form-item>
						
						<el-form-item label="第三方补充信息：" :label-width="formLabelWidth" >
						    <el-input type="textarea" v-model="form.operation_info.third_party_info"  placeholder="请输入"></el-input>
						  </el-form-item>
					</view>
					
					</el-form>
					<view class="dialog-footer">
					  <el-button @tap="gosteps(steps-1)" v-if="steps>0">上一步</el-button>
					  <el-button @tap="addAsset('bc')" v-if="id==0&&is_edit==1" v-loading.fullscreen.lock="save_loading">保存</el-button>
					  <el-button @tap="editAsset('bc')" v-if="id>0&&status!='pending'&&is_edit==1" v-loading.fullscreen.lock="save_loading">保存</el-button>
					  <el-button type="primary" @tap="gosteps(steps+1)" v-if="steps<3">下一步</el-button>
					  <el-button type="primary" @tap="addAsset()" v-if="steps==3&&id==0&&status==''" :loading="loading" >立即免费提交</el-button>
					  <el-button
					    type="primary"
					    @tap="editAsset()"
					    v-if="steps==3 && id>0 && status!='pending'&&is_edit==1"
					    :loading="loading"
					  >重新提交</el-button>
						
					</view>
					</view>	
				</view>
			</view>
			
		</view>
	</Layout>
</template>

<script>

import Layout from './part/layouts.vue';
	import memberleft from './part/member_left.vue';
	export default {
		components:{
			Layout,
			memberleft
		},
		data(){
			return {
				/*是否正在提交保存*/
				save_loading: false,
				page: 1,
				list_rows: 10,
				listData: [],
				total: 0,
				steps:0,
				loading:false,
				form:{
				  base_info: {
					  name:'',
					  source_id:'',
					  asset_type:'游戏数字资产包',
					  credit_report_img:'',
					  owner: '',
					  owner_scale: '',
					  owner_finance: '',
					  team_info: '',
					  core_members: '',
					  credit_report_no:''
				  },
				  develop_info: {
					  pc:false,
					  mobile:false,
					  console:false,
					  game_name: '',
					  game_type: '',
					  payment_method: '',
					  dev_progress: '',
					  release_region: '',
					  release_channel: '',
					  game_intro: '',
					  game_intro_file: '',
					  investment_cost: ''
				  },
				  title_info:  {
					  copyright_owner: '',
					  acquire_time: '',
					  registration_no: '',
					  power_scope: '',
					  is_match_declaration: '',
					  software_proof_img: '',
					  publisher: '',
					  operator: '',
					  approval_time: '',
					  approval_unit: '',
					  isbn: '',
					  is_match_package: '',
					  isbn_proof_img: '',
					  copyright_description: '',
					  copyright_proof_img: '',
				  },
				  operation_info: {
					  online_time: '',
					  income_forecast_img: '',
					  operation_data_img: '',
					  third_party_info: '',
					  third_party_attachment_img: '',
					  is_access:false
				  },
				  ptype:[],
				  ptypes:[],
				},
				formLabelWidth: '150px',
				rules: {
				          name: [
				            { required: true, message: '请输入资产名称', trigger: 'blur' },
				            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
				          ],
				          region: [
				            { required: true, message: '请选择活动区域', trigger: 'change' }
				          ],
				          date1: [
				            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
				          ],
				          date2: [
				            { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
				          ],
				          type: [
				            { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
				          ],
				          resource: [
				            { required: true, message: '请选择活动资源', trigger: 'change' }
				          ],
				          desc: [
				            { required: true, message: '请填写活动形式', trigger: 'blur' }
				          ]
				},
				  fileList1: [],
				  fileList2: [],
				  fileList3: [],
				  fileList4: [],
				  fileList5: [],
				  fileList6: [],
				  fileList7: [],
                  credit_report_img:'',
				  file_num:0,
				  id:0,
				  status:'',
				  contract_status:'',
				  report_url:'',
				  is_edit:1
			}
		},
		created(){
			const width = window.innerWidth;
			const height = window.innerHeight;
			const mobileWidth = 768; // 可以根据需要调整这个值
			const isMobile = width <= mobileWidth || height <= mobileWidth;
			if(isMobile){
				this.list_rows = 30;
			}
			
		},
		onShow() {
			this.steps = 0;
			let obj = this.$Route.query;
			if(obj.hasOwnProperty('id')){
				this.id = Number(obj.id);
				this.is_edit = Number(obj.is_edit||1);
			}
			if(this.id>0){
				this.getdetail()
			}
		},
		mounted() {
		   
		},
		methods:{
			getdetail(){
				this._get('asset.asset/detail',{
					id: this.id,
				},
				res=>{
						console.log(res.data,3333)
						this.status = res.data.status;
						this.contract_status = res.data.contract_status;
						this.report_url = res.data.report_url;
						console.log(this.status,this.contract_status,3333)
						this.form.base_info = res.data.base_info;
						this.form.develop_info = res.data.develop_info;
						this.form.title_info = res.data.title_info;
						this.form.operation_info = res.data.operation_info;
						if(this.form.operation_info.is_access==true){
							const backfillData = ['已接入COG运营发行中枢，授权获取数据'];
							this.form.ptypes = backfillData;
						}
						const backfillParams = [];
						if (this.form.develop_info.pc) {
						    backfillParams.push('电脑');
						}
						if (this.form.develop_info.console) {
						    backfillParams.push('游戏机');
						}
						if (this.form.develop_info.mobile) {
						    backfillParams.push('移动');
						}
						this.form.ptype = backfillParams;
						// 图片或文件处理
						if(this.form.base_info.credit_report_img){
							const fileInfos1 = [
							  {
								name:this.form.base_info.credit_report_img.substr(-27),
								url: this.form.base_info.credit_report_img
							  },
							];
							this.fileList1 = fileInfos1.map(fileInfo => ({
							  name: fileInfo.name,
							  url: fileInfo.url
							}));
						}
						
						if(this.form.title_info.software_proof_img){
						const fileInfos2 = [
						  {
							name:this.form.title_info.software_proof_img.substr(-36),
							url: this.form.title_info.software_proof_img
						  },
						];
						this.fileList2 = fileInfos2.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.title_info.isbn_proof_img){
						const fileInfos3 = [
						  {
							name:this.form.title_info.isbn_proof_img.substr(-36),
							url: this.form.title_info.isbn_proof_img
						  },
						];
						this.fileList3 = fileInfos3.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.title_info.copyright_proof_img){
						const fileInfos4 = [
						  {
							name:this.form.title_info.copyright_proof_img.substr(-36),
							url: this.form.title_info.copyright_proof_img
						  },
						];
						this.fileList4 = fileInfos4.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.operation_info.income_forecast_img){
						const fileInfos5 = [
						  {
							name:this.form.operation_info.income_forecast_img.substr(-36),
							url: this.form.operation_info.income_forecast_img
						  },
						];
						this.fileList5 = fileInfos5.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.operation_info.operation_data_img){
						const fileInfos6 = [
						  {
							name:this.form.operation_info.operation_data_img.substr(-36),
							url: this.form.operation_info.operation_data_img
						  },
						];
						this.fileList6 = fileInfos6.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.operation_info.third_party_attachment_img){
						const fileInfos7 = [
						  {
							name:this.form.operation_info.third_party_attachment_img.substr(-36),
							url: this.form.operation_info.third_party_attachment_img
						  },
						];
						this.fileList7 = fileInfos7.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
						if(this.form.develop_info.game_intro_file){
						const fileInfos8 = [
						  {
							name:this.form.develop_info.game_intro_file.substr(-27),
							url: this.form.develop_info.game_intro_file
						  },
						];
						this.fileList8 = fileInfos8.map(fileInfo => ({
						  name: fileInfo.name,
						  url: fileInfo.url
						}));
						}
					}
					,err=>{
						uni.showToast({
							icon:'none',
							title: err.data.msg,
							duration:1500
						})
						// this.$message(err.data.msg);
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/asset_list' // 替换为你实际的首页路径
						       });
						}, 1500);
						return;
					}
				);
			},
			goUrl(e){
				uni.showModal({
				    title: '温馨提示', 
				    content: '请先保存表单信息哦~', 
				    showCancel: true, 
				    cancelText: '取消', 
				    cancelColor: '#cccccc', 
				    confirmText: '确定', 
				    confirmColor: '#F78A30', 
				    success: function (res) {
				        if (res.confirm) {
				            window.open(e, '_blank');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    },
				    fail: function (err) {
				        console.log('调用失败：', err);
				    },
				    complete: function () {
				    }
				});
			},
			change(e) {
					this.form.operation_info.online_time = e;
					console.log(this.form.operation_info.online_time,222);
				},
			handleRemove1(file, fileList) {
				this.form.base_info.credit_report_img = '';
				this.fileList1 = [];
			  },
			 handleRemove2(file, fileList) {
			 	this.form.title_info.software_proof_img = '';
			 	this.fileList2 = [];
			   },
			handleRemove3(file, fileList) {
				this.form.title_info.isbn_proof_img = '';
				this.fileList3 = [];
			  },
			handleRemove4(file, fileList) {
			this.form.title_info.copyright_proof_img = '';
			this.fileList4 = [];
			},
			handleRemove5(file, fileList) {
			this.form.operation_info.income_forecast_img = '';
			this.fileList5 = [];
			},
			handleRemove6(file, fileList) {
			this.form.operation_info.operation_data_img = '';
			this.fileList6 = [];
			},
			handleRemove7(file, fileList) {
			this.form.operation_info.third_party_attachment_img = '';
			this.fileList7 = [];
			},
			handleRemove8(file, fileList) {
			this.form.develop_info.game_intro_file = '';
			this.fileList8 = [];
			},
			
			 handleExceed1(files, fileList1) {
				 this.save_loading = false;
			        this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList1.length} 个文件`);
			  },
			handleExceed2(files, fileList2) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList2.length} 个文件`);
			 },
			handleExceed3(files, fileList3) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList3.length} 个文件`);
			 },
			handleExceed4(files, fileList4) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList4.length} 个文件`);
			 },
			handleExceed5(files, fileList5) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList5.length} 个文件`);
			 },
			handleExceed6(files, fileList6) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList6.length} 个文件`);
			 },
			handleExceed7(files, fileList7) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList7.length} 个文件`);
			 },
			handleExceed8(files, fileList8) {
				this.save_loading = false;
			       this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList8.length} 个文件`);
			 },	   
			beforeUpload(file) {
					      // const isImage = file.type.startsWith('image/');
					      // if (!isImage) {
					      //   this.$message.error('只能上传图片文件!');
					      //   return false;
					      // }
					      const isLt2M = file.size / 1024 / 1024 < 5;
					      if (!isLt2M) {
							this.save_loading = false;
					        this.$message.error('上传的图片大小不能超过 5MB!');
					        return false;
					      }
					      return true;
			},
			beforeUploadFile(file) {
					     const allowedTypes = [
					          'application/msword',
					          'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
					          'application/pdf',
					        ];
					        if (!allowedTypes.includes(file.type)) {
					          this.$message.error('只能上传 Word 或 PDF 文件!');
					          return false;
					        }
					        const isLt2M = file.size / 1024 / 1024 < 5;
					        if (!isLt2M) {
					          this.$message.error('上传的文件大小不能超过 5MB!');
					          return false;
					        }
					    
					        return true;
			},
			beforeUploadimg(file) {
					      const isImage = file.type.startsWith('image/');
					      if (!isImage) {
							  this.save_loading = false;
					        this.$message.error('只能上传图片文件!');
					        return false;
					      }
					      const isLt2M = file.size / 1024 / 1024 < 5;
					      if (!isLt2M) {
							  this.save_loading = false;
					        this.$message.error('上传的图片大小不能超过 5MB!');
					        return false;
					      }
					      return true;
			},
			select(e){
				this.file_num = e;
			},	
			customUpload({ file, onSuccess, onError }) {
				          let filetype = "image"
						  if(this.file_num==8||this.file_num==1){
							  filetype = "pdf"
						  }
					      const formData = new FormData();
					      formData.append('iFile', file);
					      formData.append('type', filetype);
						  formData.append('app_id', '10001');
						   formData.append('token', uni.getStorageSync('token') || '');
						   this.save_loading = true;
					      // 替换成你的上传接口地址
					      const url = this.config.app_url+'/api/file.upload/file';
					      fetch(url, {
					        method: 'POST',
					        body: formData
					      })
					      .then(response => {
							  return response.json();
						  })
					      .then(data => {
					        if (data.code==1) {
								console.log(this.file_num,2222)
								if(this.file_num==1){
									this.form.base_info.credit_report_img = data.data.file_path;
								}else if(this.file_num==2){
									this.form.title_info.software_proof_img = data.data.file_path;
								}
								else if(this.file_num==3){
									this.form.title_info.isbn_proof_img = data.data.file_path;
								}
								else if(this.file_num==4){
									this.form.title_info.copyright_proof_img = data.data.file_path;
								}
								else if(this.file_num==5){
									this.form.operation_info.income_forecast_img = data.data.file_path;
								}
								else if(this.file_num==6){
									this.form.operation_info.operation_data_img = data.data.file_path;
								}
								else if(this.file_num==7){
									this.form.operation_info.third_party_attachment_img = data.data.file_path;
								}
								else if(this.file_num==8){
									this.form.develop_info.game_intro_file = data.data.file_path;
								}
								this.save_loading = false;
								this.$message.success('上传成功');
					        } else {
								console.log(this.file_num,222)
								if(this.file_num==1){
									this.fileList1 = [];
								}else if(this.file_num==2){
									this.fileList2 = [];
								}
								else if(this.file_num==3){
									this.fileList3 = [];
								}
								else if(this.file_num==4){
									this.fileList4 = [];
								}
								else if(this.file_num==5){
									this.fileList5 = [];
								}
								else if(this.file_num==6){
									this.fileList6 = [];
								}
								else if(this.file_num==7){
									this.fileList7 = [];
								}
								else if(this.file_num==8){
									this.fileList8 = [];
								}
								this.save_loading = false;
								 this.$message.error(data.msg);
					        }
					      })
					      .catch(err => {
					        onError(err);
					      });
			},
			gosteps(e){
				// if(e==1){
				// 	this.clearFormErrors();
				// }
				this.steps = e;
			},
			clearFormErrors() {
			      this.$refs.ruleForm.clearValidate();
			    },
			goBack(){
				uni.navigateTo({
				  url: '/asset_list'
				});
			},
			objectToKeyValueArray(obj) {
			    return Object.keys(obj).map(key => ({ key, value: obj[key] }));
			},
		    addAsset(e){
				// this.save_loading = true;
				if(uni.getStorageSync('apply_status')==3){
					this.$message.error('用户认证审核中');
					return false;
				}
				if(uni.getStorageSync('apply_status')==2){
					this.$message.error('用户认证失败，请重新提交审核');
					return false;
				}
				if(uni.getStorageSync('third_auth_status')==0){
					this.$message.error('请提交实名认证');
					return false;
				}
				if(uni.getStorageSync('third_auth_status')==2){
					this.$message.error('未注册天府信用通账号，请联系管理员');
					return false;
				}
				if(e=='bc'){
					if (this.form.ptypes.includes('已接入COG运营发行中枢，授权获取数据')) {
					 this.form.operation_info.is_access=true
					}
					if (this.form.ptype.includes('电脑')) {
					 this.form.develop_info.pc=true
					}
					if (this.form.ptype.includes('移动')) {
					 this.form.develop_info.mobile=true
					}
					if (this.form.ptype.includes('游戏机')) {
					 this.form.develop_info.console=true
					}
					this._post('asset.asset/add',{
					base_info: JSON.stringify(this.form.base_info),
					develop_info:JSON.stringify(this.form.develop_info),
					title_info: JSON.stringify(this.form.title_info),
					operation_info:JSON.stringify(this.form.operation_info),
					action:'',
				},res=>{
						console.log(res,3333)
						// this.save_loading = false;
						uni.showToast({
							icon:'none',
							title: '保存成功',
							duration:1500
						})
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/asset_list' // 替换为你实际的首页路径
						       });
						}, 1500);
					}
					,err=>{
						// uni.showToast({
						// 	icon:'none',
						// 	title: err.data.msg
						// })
						// this.save_loading = false;
						this.$message(err.data.msg);
						return;
					}
					);
					
				}else{
					if (this.form.ptype.length==0&&this.steps>0){
						this.$message.error('请选择产品形态');
						return false;
					}
					this.$refs.ruleForm.validate((valid) => { // 表单验证通过后执行保存操作
					  if (valid) {
						// 执行保存操作，例如提交表单数据到服务器或更新本地状态等
						//判断类型
						if (this.form.ptypes.includes('授权获取数据')) {
						 this.form.operation_info.is_access=true
						}
						if (this.form.ptype.includes('电脑')) {
						 this.form.develop_info.pc=true
						}
						if (this.form.ptype.includes('移动')) {
						 this.form.develop_info.mobile=true
						}
						if (this.form.ptype.includes('游戏机')) {
						 this.form.develop_info.console=true
						}
						this._post('asset.asset/add',{
							base_info: JSON.stringify(this.form.base_info),
							develop_info:JSON.stringify(this.form.develop_info),
							title_info: JSON.stringify(this.form.title_info),
							operation_info:JSON.stringify(this.form.operation_info),
							action:'add',
						},res=>{
								console.log(res,3333)
								uni.showToast({
									icon:'none',
									title: '新增成功',
									duration:1500
								})
								// this.save_loading = false;
								setTimeout(() => {
								   uni.reLaunch({
								           url: '/pages/asset_list' // 替换为你实际的首页路径
								       });
								}, 1500);
							}
							,err=>{
								// this.save_loading = false;
								// uni.showToast({
								// 	icon:'none',
								// 	title: err.data.msg
								// })
								this.$message(err.data.msg);
								return;
							}
							);
					  } else {
						  // this.save_loading = false;
						console.log('表单验证失败');
						this.$message.error('请完善必填项!');
						return false; // 阻止默认行为，即不进行页面跳转或其他操作
					  }
					});
				}
				 
				
			},
			editAsset(e){
				// this.save_loading = true;
				if(uni.getStorageSync('apply_status')==3){
					this.$message.error('用户认证审核中');
					return false;
				}
				if(uni.getStorageSync('apply_status')==2){
					this.$message.error('用户认证失败，请重新提交审核');
					return false;
				}
				if(uni.getStorageSync('third_auth_status')==0){
					this.$message.error('请提交实名认证');
					return false;
				}
				if(uni.getStorageSync('third_auth_status')==2){
					this.$message.error('未注册天府信用通账号，请联系管理员');
					return false;
				}
				if(e=='bc'){
					if (this.form.ptypes.includes('已接入COG运营发行中枢，授权获取数据')) {
					 this.form.operation_info.is_access=true
					}
					else{
						 this.form.operation_info.is_access=false
					}
					if (this.form.ptype.includes('电脑')) {
					 this.form.develop_info.pc=true
					}else{
						this.form.develop_info.pc=false
					}
					if (this.form.ptype.includes('移动')) {
					 this.form.develop_info.mobile=true
					}
					else{
						this.form.develop_info.mobile=false
					}
					if (this.form.ptype.includes('游戏机')) {
					 this.form.develop_info.console=true
					}
					else{
						this.form.develop_info.console=false
					}
					this._post('asset.asset/edit',{
					base_info: JSON.stringify(this.form.base_info),
					develop_info:JSON.stringify(this.form.develop_info),
					title_info: JSON.stringify(this.form.title_info),
					operation_info:JSON.stringify(this.form.operation_info),
					action:'',
					id:this.id
				},res=>{
						console.log(res,3333)
						// this.save_loading = false;
						uni.showToast({
							icon:'none',
							title: '保存成功',
							duration:1500
						})
						setTimeout(() => {
						   uni.reLaunch({
						           url: '/pages/asset_list' // 替换为你实际的首页路径
						       });
						}, 1500);
					}
					,err=>{
						// uni.showToast({
						// 	icon:'none',
						// 	title: err.data.msg
						// })
						// this.save_loading = false;
						this.$message(err.data.msg);
						return;
					}
					);
					
				}else{
					if (this.form.ptype.length==0&&this.steps>0){
						this.$message.error('请选择产品形态');
						return false;
					}
					this.$refs.ruleForm.validate((valid) => { // 表单验证通过后执行保存操作
					  if (valid) {
						// 执行保存操作，例如提交表单数据到服务器或更新本地状态等
						//判断类型
						if (this.form.ptypes.includes('已接入COG运营发行中枢，授权获取数据')) {
						 this.form.operation_info.is_access=true
						}
						else{
							 this.form.operation_info.is_access=false
						}
						if (this.form.ptype.includes('电脑')) {
						 this.form.develop_info.pc=true
						}else{
							this.form.develop_info.pc=false
						}
						if (this.form.ptype.includes('移动')) {
						 this.form.develop_info.mobile=true
						}
						else{
							this.form.develop_info.mobile=false
						}
						if (this.form.ptype.includes('游戏机')) {
						 this.form.develop_info.console=true
						}
						else{
							this.form.develop_info.console=false
						}
						this._post('asset.asset/edit',{
							base_info: JSON.stringify(this.form.base_info),
							develop_info:JSON.stringify(this.form.develop_info),
							title_info: JSON.stringify(this.form.title_info),
							operation_info:JSON.stringify(this.form.operation_info),
							action:'add',
							id:this.id
						},res=>{
								console.log(res,3333)
								uni.showToast({
									icon:'none',
									title: '提交成功',
									duration:1500
								})
								// this.save_loading = false;
								setTimeout(() => {
								   uni.reLaunch({
								           url: '/pages/asset_list' // 替换为你实际的首页路径
								       });
								}, 1500);
							}
							,err=>{
								// uni.showToast({
								// 	icon:'none',
								// 	title: err.data.msg
								// })
								this.save_loading = false;
								this.$message(err.data.msg);
								return;
							}
							);
					  } else {
						  // this.save_loading = false;
						console.log('表单验证失败');
						this.$message.error('请完善必填项!');
						return false; // 阻止默认行为，即不进行页面跳转或其他操作
					  }
					});
				}
				 
				
			}
		
		
		}
	}
</script>

<style lang="scss">
	.bg{
		width: 100%;
		background: #F1F1F1;
		min-height: 800px;
	}
	.content{
		width: 1290px;
		margin: 0 auto;
		padding-top: 14px;
		display: flex;
		justify-content: space-between;
	}
	.content_left{
		width: 245px;
		min-height: 789px;
		background: #FFFFFF;
		box-shadow: 0px 4px 10px 0px rgba(78,89,105,0.06);
		border-radius: 0px 0px 0px 0px;
	}
	.content_right{
		width: 1024px;
		min-height: 789px;
		background: #FFFFFF;
		box-shadow: 0px 4px 10px 0px rgba(78,89,105,0.06);
		border-radius: 0px 0px 0px 0px;
	}
	.mtitle{
		font-weight: 500;
		font-size: 16px;
		color: #3D3D3D;
		width: 985px;
		margin:0 auto;
		height: 48px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.lines{
		width: 985px;
		height: 0px;
		border: 1px solid #D8D8D8;
		opacity: 0.6;
		margin:0 auto;
	}
	.mimg{
		width: 20px;
		height: 20px;
		margin-right: 10px;
		margin-left: 23px;
	}
	.content_r{
		padding: 34px 22px;
	}
	.goback{
		font-weight: 400;
		font-size: 14px;
		color: #F6773C;
		cursor: pointer;
	}
	.el-icon-back{
		margin-left: 4px;
	}
	.step_one{
		width: 140px;
		cursor: pointer;
	}
	.step{
		width: 760px;
		margin: 0 auto;
	}
	.el-icon-d-arrow-right{
		color: #d4d4d4;	
	}
	.active-step{
		color: #ffc69b !important;
		width: 16px;
		height: 16px;
	}
	.step_num{
		width: 28px;
		height: 28px;
		background: #F2F3F5;
		border-radius: 14px 14px 14px 14px;
		font-weight: 400;
		font-size: 16px;
		color: #5B5B5B;
		text-align: center;
		line-height: 28px;
		margin-right: 12px;
	}
	.step_num_active{
		background: #F6773C !important;
		font-weight: 500 !important;
		color: #FFFFFF !important;
	}
	.step_num_actives{
		background: #FFEFE3 !important;
		font-weight: 500 !important;
		color: #F6773C !important;
	}
	.step_title{
		font-weight: 400;
		font-size: 16px;
		color: #1D2129;
	}
	.asset_content{
		margin-top: 44px;
		padding: 0 48px;
	}
	.asset_title{
		font-weight: 400;
		font-size: 16px;
		color: #767676;
		margin-bottom: 20px;
	}
	.el-textarea__inner {
	  height: 64px; 
	  width: 100%;
	  font-size: 14px;
	}
	::v-deep .el-input__inner {
	    background-color: #f0f0f0;
		width: 244px;
		height: 32px;
		background: #F2F3F5;
		border: none;
		font-size: 14px;
	}
	::v-deep .el-form-item__label{
		line-height: unset;
		margin-top: 14px;
		font-size: 14px;
	}
	.uploads{
		display: flex;
		align-items: center;
	}
	.lans{
		color: #3C77FF;
		cursor: pointer;
	}
	.el-upload__tip{
		margin-left: 30px;
	}
	.xzfile{
		background: #F78A30;
		border-radius: 2px 2px 2px 2px;
		border: none;
	}
	.dialog-footer{
		margin: 0 auto;
		display: flex;
		justify-content: center;
		margin-top: 64px;
	}
	.el-button+.el-button{
		margin-left: 36px !important
	}
	.push-t-40{
		margin-top: 40px !important;
	}
	::v-deep .el-checkbox__input.is-checked .el-checkbox__inner, ::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner{
		background-color: #F6773C;
		border-color: #F6773C;
	}
	::v-deep .el-checkbox__input.is-checked+.el-checkbox__label {
	    color: #F6773C;
		font-size: 14px;
	}
	::v-deep .el-button--primary:focus, .el-button--primary:hover {
	    background: #F78A30;
	    border-color: #F78A30;
	    color: #FFF;
	}
	::v-deep .el-button--primary {
	    color: #FFF;
	    background-color: #F78A30;
	    border-color: #F78A30;
		font-size: 14px;
	}
	::v-deep .el-textarea__inner{
		width: 94%;
		font-size: 14px;
	}
	::v-deep .el-date-table td.today span {
      color: #F78A30;
    }
	.uni-date{
		width: 180px;
	}
	.online_times{
		float: left;
	}
	.tips{
		font-weight: 400;
		font-size: 14px;
		color: #A1A1A1;
		width: 30%;
		float: left;
		margin-left: 20px;
	}
	::v-deep .uni-calendar-item__weeks-box .uni-calendar-item--checked{
		background-color: #F78A30;
	}
	@media screen and (max-width: 768px) {
	
	}
</style>
