<template>
	<view class="p-root-detail-apply g_w_all g_bg_f_5 g_kuaishou g_pb_10">
		<view v-if="speed == 0">
			<rh-loading />
		</view>
		<view class="g_mr_10 g_ml_10" v-if="speed > 0">
			<!-- {{orderDetail.upAgencyName}} -->

			<!-- 状态信息 -->
			<view class="m-state g_pt_10" v-if="from == 'tob'">
				<view class="link g_bg_f g_radius_8 g_fs_16 g_p_16">
					<view class="g_flex_row_between">
						<view class="g_c_9"> 状态 </view>
						<view class="g_flex_row_end flex_center g_flex_1" :style="{color: themeColor}" @click="editNewResume"> {{ orderDetail.status_text }} <i class="iconfont icon-gengduo11 g_c_9 g_ml_4" v-if="orderDetail.status == 0 && isMember && hasPermission"></i></view>
					</view>
				</view>
			</view>

			<view class="m-state g_pt_10" v-if="from == 'tob' && isAdmin && orderDetail.followUser" @click="handleOpenPeopleModal">
				<view class="link g_bg_f g_radius_8 g_fs_16 g_p_16">
					<view class="g_flex_row_between">
						<view class="g_c_9"> 跟进人 </view>
						<view class="g_flex_row_end flex_center g_flex_1" :style="{color: themeColor}"> {{ orderDetail.followUser.aliasName || "-" }} <i class="iconfont icon-gengduo11 g_c_9 g_ml_4"></i></view>
					</view>
				</view>
			</view>

			<!-- 用户信息 -->
			<view class="m-user g_pt_10">
				<view class="g_bg_f g_pl_15 g_pr_15 g_pt_10 g_radius_8">
					<view class="g_flex_row_between g_pb_4">
						<view class="g_flex_1 g_flex_column_center g_mr_10">
							<view class="g_ell_1 g_fs_16 g_fw_bold"> {{ orderDetail.userName }}{{ orderDetail.setTitle }} </view>
						</view>
						<view class="g_flex_none g_flex_row_end">
							<view class="g_flex_row_end flex_center g_flex_1" :style="{color: themeColor}" v-if="from == 'toc'"> {{ orderDetail.status_text }}</view>
							<view class="g_flex_row_end g_pr_16 g_pl_16 g_pt_9 g_pb_9" style="background-color: #f5f5f5; border-radius: 17px">
								<view class="g_flex_row_end" @click="goFellow">
									<view class="g_flex_column_center">
										<i class="iconfont icon-bianji g_c_3 g_fsi_14"></i>
									</view>
									<view class="g_fs_12 g_c_3 g_ml_8">编辑</view>
								</view>
							</view>
						</view>
					</view>
					<!-- <view class="g_pb_10 g_c_9">{{ orderDetail.address ? orderDetail.address : "-" }}</view> -->
					<view class="g_flex_row_start g_pb_10">
						<view class="g_flex_none g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
							<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/id_card.svg" class="g_w_24 g_h_24"></image>
						</view>
						<view class="g_flex_column_center g_fs_15 g_c_6">{{ orderDetail.idCard ? orderDetail.idCard : "-" }}</view>
					</view>
					<view class="g_flex_row_start g_pb_15">
						<view class="g_flex_row_end" @click="goTel(orderDetail.tel)">
							<view class="g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
								<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/call.svg" class="g_w_24 g_h_24"></image>
							</view>
							<view class="g_flex_column_center g_text_r g_fs_15 g_c_6">{{ orderDetail.tel ? orderDetail.tel : "-" }}</view>
						</view>
						<view class="g_flex_row_start g_ml_24">
							<view class="g_flex_none g_mr_4 g_w_24 g_h_24 g_radius_50 g_flex_c">
								<image src="https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/wechat1.svg" class="g_w_24 g_h_24"></image>
							</view>
							<view class="g_flex_column_center g_fs_15 g_c_6">{{ orderDetail.weChat ? orderDetail.weChat : "-" }}</view>
						</view>
					</view>
					<view class="g_pb_17" v-if="orderDetail.idCardImageUrl">
						<g-panel-image :url="orderDetail.idCardImageUrl" radius="8" size="152" @clickItem="handleClickIDcard" />
					</view>
				</view>
			</view>
			<!-- 费用 -->
			<!-- <view class="m-price">
				<view class="g_h_12"></view>
				<view class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="政策模式" v-if="isCreator" :value="orderDetail.zhengceTextShow" afterIcon="icon-gengduo11" @clickItem="handleOpenZhengceModal" from="zhengce-info" />
					<g-panel-detail-item label="报名备注" :value="orderDetail.desp" />
					<view class="g_h_15"></view>
				</view>
			</view> -->
			<!-- 职位信息 -->
			<view class="m-job">
				<view class="link g_bg_f g_pt_10 g_radius_8 g_mt_12" style="overflow: hidden">
					<!-- <g-panel-detail-item label="报名企业" :value="orderDetail.storeName" /> -->
					<g-panel-detail-item label="报名职位" :value="orderDetail.showJobName" />
					<g-panel-detail-item label="报名企业" v-if="resumeFlag == 1" :value="orderDetail.storeName" />
					<view v-if="isMember && hasPermission && resumeFlag == 2">
						<g-panel-detail-item label="代理费" :value="setReturnFee(orderDetail.agencyReturnFee, orderDetail.agencyReturnFeeType)" />
						<g-panel-detail-item label="代理费详情" :value="orderDetail.agencyReturnFeeDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.agencyReturnFeeDesp, '代理费详情', 'view')" />
					</view>
					<!-- <div v-if="(!orderDetail.nextRecordId && !orderDetail.prevRecordId) || orderDetail.prevRecordId || agencyId == orderDetail.agencyId">
						<g-panel-detail-item :label="isCreator ? '代理费' : '服务费'" :value="setReturnFee(orderDetail.agencyReturnFee, orderDetail.agencyReturnFeeType)" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.agencyReturnFee / 100, '代理费', 'form', orderDetail.agencyReturnFeeType)" />
						<g-panel-detail-item :label="isCreator ? '代理费详情' : '服务费详情'" :value="orderDetail.agencyReturnFeeDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.agencyReturnFeeDesp, '代理费详情', 'edit')" />
					</div> -->

					<view class=" ">
						<view v-if="orderDetail.status == 10 || orderDetail.status == 20 || orderDetail.status == 25">
							<g-panel-detail-item from="times" label="面试时间" :value="orderDetail.interview_time" />
						</view>
						<view v-if="orderDetail.status == 30">
							<g-panel-detail-item from="times" label="约入职时间" :value="orderDetail.willEntry_time" />
						</view>
						<view v-if="orderDetail.status == 40">
							<g-panel-detail-item from="times" label="入职时间" :value="orderDetail.entry_time" />
						</view>
						<view v-if="orderDetail.status == 48">
							<g-panel-detail-item from="times" label="约离职时间" :value="orderDetail.willLeave_time" />
						</view>
						<view v-if="orderDetail.status == 50">
							<g-panel-detail-item from="times" label="离职时间" :value="orderDetail.leave_time" />
						</view>
						<view v-if="orderDetail.status == 21 || orderDetail.status == 26 || orderDetail.status == 35 || orderDetail.status == 45">
							<g-panel-detail-item from="times" label="完成时间" :value="orderDetail.update_time" />
						</view>
					</view>

					<g-panel-detail-item label="面试地址" v-if="resumeFlag == 2" :value="orderDetail.interviewAddress" maxWidth="230px" :afterIcon="'icon-dizhi1'" :afterIconColor="themeColor" @clickItem="handleChooseAddressModal" />
					<!-- 服务费 最上游或者不是管理人员不显示 orderDetail.nextRecordId为空 是最上游 -->
					<!-- 代理费/服务费 最下游不显示 orderDetail.prevRecordId为空 是最下游 -->
					<g-panel-detail-item label="驻场信息" v-if="resumeFlag == 2" :value="orderDetail.totalZC || '-'" maxWidth="230px" from="resident-info" :afterIcon="orderDetail.upOnSiteInfo || orderDetail.onSiteInfo ? 'icon-fuzhi' : ''" :iconColor="themeColor" afterType="multi" @clickItem="handleClickLabelBtn(orderDetail.totalZC || '-')" />
					<g-panel-detail-item label="其他说明" v-if="resumeFlag == 2" :value="orderDetail.interviewDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.interviewDesp, '其他说明', 'view')" />
					<!-- <g-panel-detail-item label="职位说明" :value="orderDetail.employeeSalary" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.employeeSalary, '职位说明', 'edit')" /> -->
					<!-- <view class="g_h_15"></view> -->
				</view>
			</view>
			<!-- 企业信息 -->
			<!-- <view class="m-boss">
				<view class="g_h_10"></view>
				<view class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="企业地址" :value="orderDetail.storeAddr" afterIcon="icon-gengduo11" @clickItem="handleChooseAddressModal" />
					<g-panel-detail-item label="驻场信息" :value="orderDetail.onSiteUsers" :beforeIcon="type == 2 ? 'icon-bianji' : ''" afterType="list" @clickItem="handleOpenModal" from="resident-info" />
				</view>
			</view> -->
			<view class="g_h_10 g_bg_f_5"></view>
			<!-- 跟进记录 -->
			<view class="m-reord" v-if="isMember && hasPermission && from == 'tob'">
				<view class="g_bg_f g_radius_8" style="padding-bottom: 10px; margin-bottom: 60px; padding-top: 32rpx">
					<view class="g_flex_row_between" style="padding-top: 0; padding-bottom: 0; padding-right: 32rpx; position: relative; margin-left: 20px; margin-bottom: 36rpx">
						<view class="g_fs_16 g_c_3 g_flex_column_center">跟进记录</view>
						<view @click="handleOpenRemarkModal">
							<view class="g_flex_row_end g_pl_12 g_pr_12 g_pt_9 g_pb_9" style="background-color: #f8f8f8; border-radius: 17px">
								<view class="g_flex_row_end">
									<view class="g_flex_column_center">
										<i class="iconfont icon-bianji g_c_3" style="font-size: 14px"></i>
									</view>
									<view class="g_fs_12 g_c_3 g_ml_8">写跟进</view>
								</view>
							</view>
						</view>
					</view>
					<!-- {{ orderDetail.records }}
          ---------------------- resumeFlag
          {{ resumeFlag }} -->
					<g-panel-record :item="orderDetail.records" @clickInfo="goRecordInfo" :isResume="false" v-if="resumeFlag == 2" />
					<g-panel-record :item="orderDetail.records" @clickInfo="goRecordInfo" :isResume="true" v-else />
				</view>
			</view>
		</view>
		<g-panel-fixed v-if="orderDetail.status == 1 && isMember && hasPermission">
			<view class="g_pl_20 g_pr_20 g_flex_row_center flex_center flex_nw" style="width: 100%; box-sizing: border-box">
				<rh-button  btnText="立即报名" class="g_flex_1 g_fw_600" size="small_auto" type="primary" @clickBtn="record(orderDetail.resume)"></rh-button>
			</view>
		</g-panel-fixed>

		<u-popup v-model="recordModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true">
			<view>
				<view class="g_flex_row_between g_border_e_b">
					<view class="g_pl_12 g_c_3 g_fs_15 g_pt_18 g_pb_18" @click="recordModal.isShow = false">取消</view>
					<view class="g_pr_12 g_fs_15 g_pt_18 g_pb_18" :style="{color: themeColor}" @click="handleSubmitRemark">确定</view>
				</view>
				<view class="g_p_16">
					<view class="g_fs_15 g_c_6 g_pb_16">备注</view>
					<view class="">
						<u-input v-model="recordModal.remark" type="textarea" :height="600" :clearable="false" />
					</view>
				</view>
			</view>
		</u-popup>

		<u-popup v-model="peopleModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true" :closeable="true">
			<view class="g_fs_18 g_c_3 g_flex_row_center g_pt_16"> 跟进人选择 </view>
			<scroll-view scroll-y="true" style="height: 450px">
				<view class="g_pl_12 g_pr_12">
					<view class="g_flex_row_between g_pt_16 g_pb_16 g_border_d_b" v-for="(item, index) in peopleData.recordList" :key="index" @click="handleChoosePeople(item, index)">
						<view class="g_fs_17 g_c_3">{{ item.aliasName || item.userName || item.tel }}</view>
						<view class="g_flex_column_center">
							<i
								class="iconfont icon-a-duigoubeifen2"
								v-if="applyInfo.applyUserId == item.id"
								style="font-size: 24px"
								:style="{
									color: applyInfo.applyUserId == item.id ? '#6A81FF' : '#fff',
								}"
							></i>
						</view>
					</view>
				</view>
			</scroll-view>
		</u-popup>

		<u-popup v-model="infoModal.isShow" mode="center" border-radius="16" width="630" :mask-close-able="true">
			<view class="g_flex_column_center">
				<view class="g_flex_row_center g_pt_32 g_fs_18 g_fw_600 g_mb_20">报名信息</view>
				<scroll-view scroll-y class="g_pb_32 g_pr_16 g_pl_16 g_flex_row_center g_flex_1" style="max-height: 600px; box-sizing: border-box">
					<view class="g_pb_48">
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">姓名：</view>
							<view class="label g_fs_16 g_fw_600 g_c_3 g_flex_1 g_ell_1"> {{ orderDetail.userName }}{{ orderDetail.setTitle }} </view>
						</view>
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">电话：</view>
							<view class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.tel ? orderDetail.tel : "-" }}
							</view>
						</view>
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">身份证号：</view>
							<view class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.idCard ? orderDetail.idCard : "-" }}
							</view>
						</view>
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">家庭住址：</view>
							<view class="label g_fs_16 g_c_3 g_flex_1 g_ell_1">
								{{ orderDetail.address ? orderDetail.address : "-" }}
							</view>
						</view>
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">报名职位：</view>
							<view class="label g_fs_16 g_c_3 g_fw_600 g_flex_1 g_ell_1">
								{{ orderDetail.storeJobName ? orderDetail.storeJobName : "-" }}
							</view>
						</view>
						<view class="item g_flex_row_start g_mb_8">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">员工薪资：</view>
							<view class="label g_fs_16 g_c_3 g_flex_1 g_white_p">
								{{ orderDetail.employeeSalary ? orderDetail.employeeSalary : "-" }}
							</view>
						</view>
						<view class="item g_flex_row_start g_mb_8" v-if="isCreator">
							<view class="label g_fs_16 g_c_3 g_flex_none g_flex_row_end" style="width: 98px">代理政策：</view>
							<view class="label g_fs_16 g_c_3 g_flex_1 g_white_p">
								{{ orderDetail.policy ? orderDetail.policy : "-" }}
							</view>
						</view>
					</view>
				</scroll-view>
				<view class="g_flex_row_between g_border_e_t g_bg_f" style="position: absolute; bottom: 0; width: 100%">
					<view class="g_c_3 g_fs_18 g_pt_18 g_pb_18 g_flex_c g_fw_700" style="width: 50%; height: 49px" @click="handleCopy">复制文本</view>
					<view class="g_fs_18 g_pt_18 g_pb_18 g_flex_c" :style="{color: themeColor}" style="width: 50%; height: 49px; border-left: 1rpx solid #eee" @click="infoModal.isShow = false">知道了</view>
				</view>
			</view>
		</u-popup>
		<!-- height="830" -->
		<u-popup v-model="editNewResumeShow" mode="bottom" border-radius="16" closeable :mask-close-able="true">
			<view class="g_flex_row_center g_pt_16 g_fs_18">联系状态</view>
			<view class="g_p_25 g_pt_40">
				<view class="g_flex_row_start">
					<block v-for="item in statusList.unadd" :key="item.id">
						<view class="g_mb_32 g_flex_column_center flex_center" style="width: 25%" @click="markResume(item.id)">
							<view class="iconfont g_mb_10 g_fsi_22" style="color: #ff4d4f" :class="item.icon"> </view>
							{{ item.name }}
						</view>
					</block>
				</view>
				<view class="g_flex_row_start">
					<block v-for="item in statusList.adding" :key="item.id">
						<view class="g_mb_32 g_flex_column_center flex_center" style="width: 25%" @click="markResume(item.id)">
							<view class="iconfont g_mb_10 g_fsi_22" style="color: #faad14" :class="item.icon"> </view>
							{{ item.name }}
						</view>
					</block>
				</view>
				<view class="g_flex_row_start">
					<block v-for="item in statusList.added" :key="item.id">
						<view class="g_mb_32 g_flex_column_center flex_center" style="width: 25%" @click="markResume(item.id)">
							<view class="iconfont g_mb_10 g_fsi_22" style="color: #52c41a" :style="{ color: (item.id == 9 && !orderDetail.weChat) || (item.id == 100 && !orderDetail.tel) ? '#ccc' : '#52c41a' }" :class="item.icon"> </view>
							{{ item.name }}
						</view>
					</block>
				</view>
			</view>
		</u-popup>

		<u-popup v-model="residentModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true">
			<view class="g_fs_18 g_c_3 g_flex_row_center g_pt_16"> 选择驻场 </view>
			<scroll-view scroll-y="true" style="height: 710rpx">
				<view class="g_pl_12 g_pr_12">
					<view class="g_flex_row_between g_pt_16 g_pb_16 g_border_d_b" v-for="(item, index) in residentList" :key="index" @click="handleChooseResident(item, index)">
						<view class="g_fs_17 g_c_3">{{ item.aliasName || item.userName }}</view>
						<view class="g_flex_column_center">
							<i
								class="iconfont icon-a-duigoubeifen2"
								style="font-size: 24px"
								:style="{
									color: item.isSelected ? '#6A81FF' : '#fff',
								}"
							></i>
						</view>
					</view>
				</view>
			</scroll-view>
			<g-panel-fixed>
				<slot>
					<view class="g_flex_row_center">
						<rh-button  btnText="确定" type="primary" @clickBtn="submitRes" />
					</view>
				</slot>
			</g-panel-fixed>
		</u-popup>

		<u-popup v-model="zhengceModal.isShow" mode="bottom" border-radius="16" height="980" :mask-close-able="true">
			<view class="g_fs_18 g_c_3 g_flex_row_center g_pt_16"> 选择政策 </view>
			<scroll-view scroll-y="true" style="height: 710rpx">
				<view class="g_pl_12 g_pr_12">
					<view class="g_flex_row_between g_pt_16 g_pb_16 g_border_d_b" v-for="(item, index) in zhengceList" :key="index" @click="handleChooseZhengce(item, index)">
						<view class="g_fs_17 g_c_3">{{ item.name }}</view>
						<view class="g_flex_column_center">
							<i
								class="iconfont icon-a-duigoubeifen2"
								style="font-size: 24px"
								:style="{
									color: item.isSelected ? '#6A81FF' : '#fff',
								}"
							></i>
						</view>
					</view>
				</view>
			</scroll-view>
			<g-panel-fixed>
				<slot>
					<view class="g_flex_row_center">
						<rh-button  btnText="确定" type="primary" @clickBtn="submitZhengce" />
					</view>
				</slot>
			</g-panel-fixed>
		</u-popup>
	</view>
</template>

<script>
import gPanelRecord from "./components/record.vue";
export default {
	components: {
		gPanelRecord,
	},
	onReady() {
		this.G.setNavStyle();
	},
	onShareAppMessage() {
		return this.G.shareFun();
	},
	data() {
		return {
			themeColor: getApp().globalData.themeColor,
			from: "", // 判断来源
			cdnBaseImg: this.G.store().cdnBaseImg,
			agencyId: uni.getStorageSync("apply-agencyId"),
			isAdmin: uni.getStorageSync("apply-userinfo").admin,
			isMember: uni.getStorageSync("IS_MINIAPP_MEMBER"), // 是否是该小程序对应代理的成员
			hasPermission: uni.getStorageSync("HAS_PERMISSION") == 1 ? true : false, // 登陆者是否有权限查看

			isCreator: false, //管理人员判断
			speed: 0,
			applyInfo: {}, // 提交更改的对象
			oid: 0,
			relationId: 0,
			type: 0,
			orderDetail: {},
			peopleData: {
				recordList: [],
			},
			residentList: [],

			peopleModal: {
				isShow: false,
				uid: 0,
			},
			infoModal: {
				isShow: false,
			},
			recordModal: {
				isShow: false,
				remark: "",
			},
			residentModal: {
				isShow: false,
			},
			zhengceModal: {
				isShow: false,
			},
			zhengceList: [
				{
					name: "政策一",
					id: 1,
					isSelected: false,
				},
				{
					name: "政策二",
					id: 2,
					isSelected: false,
				},
				{
					name: "政策三",
					id: 3,
					isSelected: false,
				},
				{
					name: "政策四",
					id: 4,
					isSelected: false,
				},
				{
					name: "政策五",
					id: 5,
					isSelected: false,
				},
				{
					name: "政策六",
					id: 6,
					isSelected: false,
				},
				{
					name: "政策七",
					id: 7,
					isSelected: false,
				},
				{
					name: "政策八",
					id: 8,
					isSelected: false,
				},
				{
					name: "政策九",
					id: 9,
					isSelected: false,
				},
			],
			resumeFlag: 0,
			editNewResumeShow: false,
			statusList: {
				unadd: [
					{
						name: "空号",
						icon: "icon-konghao",
						id: 1,
					},
					{
						name: "停机",
						icon: "icon-tingji",
						id: 2,
					},
					{
						name: "无法添加",
						icon: "icon-wufatianjia",
						id: 8,
					},
				],
				adding: [
					{
						name: "无人接听",
						icon: "icon-wurenjieting",
						id: 3,
					},
					{
						name: "拒接",
						icon: "icon-jujie",
						id: 4,
					},
					{
						name: "通话中",
						icon: "icon-tonghuazhong",
						id: 5,
					},
					{
						name: "无法接通",
						icon: "icon-wufajietong",
						id: 6,
					},
					{
						name: "关机",
						icon: "icon-guanji",
						id: 7,
					},
					{
						name: "已申请",
						icon: "icon-yishenqing",
						id: 10,
					},
				],
				added: [
					{
						name: "已接通",
						icon: "icon-yijietong",
						id: 100,
					},
					{
						name: "已添加",
						icon: "icon-yitianjia",
						id: 9,
					},
				],
			},
		};
	},
	onLoad(options) {
		// console.log("options", options);
		this.oid = options.id;
		this.relationId = options.relationId;
		this.type = options.type;
		this.resumeFlag = options.resumeFlag; // 1简历 2工单
		this.from = options.from; // 1简历 2工单

		uni.setNavigationBarTitle({
			title: "详情",
		});
	},
	onShow() {
		this.themeColor = getApp().globalData.themeColor;
		this.isCreator = uni.getStorageSync("IS_CREATOR") == 1 ? true : false;
		this.getResident();
		this.getPeople();
		this.getDetail();
	},
	methods: {
		handleClickLabelBtn($data) {
			var that = this;
			var text = "";
			let copy = "";
			// console.log("$data", $data);
			if (!this.orderDetail.totalZC) {
				return false;
			}

			if (that.orderDetail.upOnSiteInfo || !that.orderDetail.prevRecordId) {
				copy = that.orderDetail.upOnSiteInfo.slice(-11);
			}
			if (that.orderDetail.prevRecordId || (!that.orderDetail.prevRecordId && !that.orderDetail.nextRecordId)) {
				copy = that.orderDetail.onSiteInfo.slice(-11);
			}

			if (that.orderDetail.upAgencyName == "江西人海") {
				text = that.orderDetail.storeJobName + "\n\n⚠驻场接人：" + copy + "(接待面试，优先联系）\n\n服务投诉：19036980065";
			} else {
				text = that.orderDetail.storeJobName + "\n\n⚠驻场接人：" + copy;
			}
			wx.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							// console.log(res.data); // data
							wx.showToast({
								title: "内容已复制",
								icon: "none",
								duration: 1500,
							});
						},
					});
				},
			});
		},

		getResident() {
			let that = this;
			that.G.Post(
				that.api.order_residentList,
				{
					agencyId: uni.getStorageSync("apply-agencyId"),
					keys: "",
					pageNum: 1,
					pageSize: 1000,
				},
				(res) => {
					// console.log("驻场列表：", res);
					if (res.recordCount == 0) {
						that.residentList = [];
					} else {
						res.recordList.forEach((item) => {
							item.isSelected = false;
						});
						that.residentList = res.recordList;
					}
				}
			);
		},
		getPeople() {
			let that = this;
			that.G.Get(that.api.order_peopleList, {}, (res) => {
				// console.log("报名人列表：", res);
				that.peopleData = res;
			});
		},
		getDetail() {
			let that = this;
			that.speed = 0;
			if (this.resumeFlag == 1) {
				that.G.Post(that.api.resume_detail_new + "/" + that.oid, {}, (res) => {
					// console.log("简历详情", res);
					res = { ...res.resume, ...res };
					// console.log("that.G.getOrderStatus()", that.G.getOrderStatus());
					if (that.from == "toc") {
						res.status_text = that.G.getOrderStatusNew().filter((itm, inx) => {
							return itm.id == res.status;
						})[0].name;
					} else {
						res.status_text = that.G.getOrderStatus().filter((itm, inx) => {
							return itm.id == res.status;
						})[0].name;
					}

					res.serveRecords.forEach((item) => {
						item.create_time = that.G.getPointTime(item.createTime, "YY--MM--DD HH:MM");
					});
					res.setTitle = that.G.titleToStr(res);
					res.records = res.serveRecords;
					res.showJobName = that.resumeFlag == 1 && res.clueType == 9 ? `${res.jobName || res.showJobName || "-"}@${res.address}` : `${res.jobName || res.showJobName}`;
					that.orderDetail = res;
					that.speed = 1;
					// console.log("res", res);
				});
			} else {
				that.G.Get(
					that.api.order_detail_newTob,
					{
						orderId: that.oid,
						relationId: that.relationId,
					},
					(res) => {
						// console.log("工单详情：", res);
						// return;
						// console.log("res", res);
						res = { ...res.applyOrder, ...res };
						if (res.policyNum === "" || res.policyNum === 0) {
							res.policyNum = 1;
						}
						if (res.policyIdx === "" || res.policyIdx === 0) {
							res.policyIdx = 1;
						}
						if (res.policyIdx) {
							let list = [];
							for (let i = 0; i < res.policyNum; i++) {
								let pickerStr = that.G.policyNumToHanZi(i + 1);
								list[i] = { value: i + 1, name: pickerStr, isSelected: false };
							}
							// console.log("list", list);
							// console.log("res.policyIdx - 1 ", res.policyIdx);
							list[res.policyIdx - 1 >= 0 ? res.policyIdx - 1 : 0].isSelected = true;
							that.zhengceList = list;
						} else {
							that.zhengceList = [{ name: "政策一", value: 1, isSelected: true }];
						}
						res.zhengceTextShow = that.G.policyNumToHanZi(res.policyIdx);
						// 驻场信息样式统一
						// res.newZhuchang = res.onSiteInfo.replaceAll("；", "\n");
						// console.log("res.newZhuchang", res.newZhuchang);
						// console.log("res.onSiteInfo", res.onSiteInfo);
						res.totalZC = "";
						if (res.prevRecordId || (!res.prevRecordId && !res.nextRecordId)) {
							res.totalZC = "我的驻场:" + (res.onSiteInfo.slice(-11) || " -");
						}
						if (res.upOnSiteInfo || !res.prevRecordId) {
							res.totalZC = res.totalZC ? res.totalZC + "\n项目方:" + (res.upOnSiteInfo.slice(-11) || " -") : "项目方:" + (res.upOnSiteInfo.slice(-11) || " -");
						}

						// if (res.upOnSiteInfo) {
						// 	res.totalZC = res.upOnSiteInfo || !res.prevRecordId ? res.upOnSiteInfo.replaceAll("；", "\n") + "\n" + res.totalZC : res.totalZC;
						// 	// // console.log("newZhuchang upZhuchang", res.upZhuchang + "123" + res.newZhuchang);
						// }
						// // console.log("res.totalZC", res.totalZC);
						// // console.log(res.totalZC.match(/\d+/g));
						// // console.log(/\d+/g.test(res.totalZC));
						// console.log("res.upAgencyName ", res.upAgencyName);
						// if (res.upAgencyName == "江西人海" && /\d+/g.test(res.totalZC)) {
						// 	if (res.totalZC.indexOf(" ") > -1) {
						// 		res.totalZC = res.totalZC.split(" ")[1];
						// 		res.zhuchangTel = res.totalZC.replace(/\s+/g, "");
						// 	} else {
						// 		res.totalZC = res.zhuchangTel = res.totalZC.match(/\d+/g)[0];
						// 	}
						// }
						// console.log("res.zhuchangTel", res.zhuchangTel);
						// console.log("res.totalZC", res.totalZC);
						if (that.from == "toc") {
							res.status_text = that.G.getOrderStatusNew().filter((itm, inx) => {
								return itm.id == res.status;
							})[0].name;
						} else {
							res.status_text = that.G.getOrderStatus().filter((itm, inx) => {
								return itm.id == res.status;
							})[0].name;
						}

						if (res.createTime) {
							res.create_time = that.G.getPointTime(res.createTime, "YY--MM--DD HH:MM");
						}
						if (res.interviewTime) {
							res.interview_time = that.G.getPointTime(res.interviewTime, "YY--MM--DD HH:MM");
						}
						if (res.willEntryTime) {
							res.willEntry_time = that.G.getPointTime(res.willEntryTime, "YY--MM--DD HH:MM");
						}
						if (res.entryTime) {
							res.entry_time = that.G.getPointTime(res.entryTime, "YY--MM--DD HH:MM");
						}
						if (res.willLeaveTime) {
							res.willLeave_time = that.G.getPointTime(res.willLeaveTime, "YY--MM--DD HH:MM");
						}
						if (res.leaveTime) {
							res.leave_time = that.G.getPointTime(res.leaveTime, "YY--MM--DD HH:MM");
						}
						if (res.updateTime) {
							res.update_time = that.G.getPointTime(res.updateTime, "YY--MM--DD HH:MM");
						}
						that.orderDetail.serveRecords = {};
						for (var key in res.records) {
							res.records[key].forEach((item, index) => {
								if (item.desp.substr(item.desp.length - 3, 3) == "备注：") {
									item.desp = item.desp.replace(/备注：/g, "");
								}
								if (item.type == 1) {
									item["statusText"] = "报名审核中";
								} else if (item.type == 2) {
									item["statusText"] = "待接待";
								} else if (item.type == 3) {
									item["statusText"] = "待入职";
								} else if (item.type == 4) {
									item["statusText"] = "在职中";
								} else if (item.type == 5) {
									item["statusText"] = "已离职";
								} else if (item.type == 9) {
									item["statusText"] = "约离职";
								} else if (item.type == 6) {
									item["statusText"] = "已完成";
								} else if (item.type == 11) {
									item["statusText"] = "审核未通过";
								} else if (item.type == 12) {
									item["statusText"] = "已接到";
								} else if (item.type == 13) {
									item["statusText"] = "未接到";
								} else if (item.type == 14) {
									item["statusText"] = "面试未通过";
								} else if (item.type == 15) {
									item["statusText"] = "未入职";
								}

								if (item.createTime) {
									item.create_time = that.G.getPointTime(item.createTime, "YY--MM--DD HH:MM");
								}
							});
						}

						res.setTitle = that.G.titleToStr(res);
						that.orderDetail = res;
						// console.log("that.orderDetail", that.orderDetail.onSiteInfo);
						that.applyInfo = {
							orderId: res.id,
							relationId: res.relationId,
							applyUserId: res.applyUserId,
							agencyReturnFee: res.agencyReturnFee,
							agencyReturnFeeType: res.agencyReturnFeeType,
							agencyReturnFeeDesp: res.agencyReturnFeeDesp,
							policyIdx: res.policyIdx,
							interviewDesp: res.interviewDesp,
							employeeSalary: res.employeeSalary,
							version: res.version,
						};
						// console.log("that.orderDetail", that.orderDetail);
						that.$forceUpdate();
						that.speed = 1;
					}
				);
			}
		},

		editNewResume() {
			if (this.orderDetail.status === 0 && this.isMember && this.hasPermission) {
				// console.log("editNewResume");
				this.editNewResumeShow = true;
			}
		},

		handleClickIDcard() {
			this.G.viewBigImage(this.orderDetail.idCardImageUrl);
		},
		goTel($item) {
			if ($item) {
				uni.makePhoneCall({
					phoneNumber: $item,
				});
			}
		},

		goBossDetail() {
			let that = this;
			let agencyId = uni.getStorageSync("apply-agencyId");
			if (agencyId == that.orderDetail.agencyId) {
				return false;
			}
			let params = {
				id: that.orderDetail.agencyId,
				// type: 2,
				isShowMore: true,
				isShowJob: false,
			};
			uni.navigateTo({
				url: "/root/detail/user?" + that.G.objToStr(params),
			});
		},

		handleOpenPeopleModal() {
			this.peopleModal.uid = this.orderDetail.applyUserId;
			this.peopleModal.isShow = true;
		},
		handleChoosePeople($item, $index) {
			let that = this;
			// console.log("$item", $item);
			that.applyInfo.applyUserId = $item.id;
			// that.G.Post(
			// 	that.api.order_update_detail,
			// 	{
			// 		...that.applyInfo,
			// 	},
			// 	(res) => {
			// 		// console.log("res", res);
			// 		that.peopleModal.isShow = false;
			// 		uni.showToast({
			// 			title: "修改成功",
			// 			icon: "success",
			// 		});
			// 		that.getDetail();
			// 	}
			// );
			that.G.Get(
				that.api.order_follow + "/" + that.oid,
				{
					userId: $item.id,
				},
				() => {
					that.peopleModal.isShow = false;
					uni.showToast({
						title: "分配成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
		},

		handleCopy() {
			let that = this;
			var text = "姓名：" + that.orderDetail.userName + "/" + (that.orderDetail.sex == 1 ? "男" : "女") + "/" + that.orderDetail.age + "岁" + (that.orderDetail.nation == "族" ? "" : "/" + that.orderDetail.nation) + "\n电话：" + (that.orderDetail.tel == "" || that.orderDetail.tel == undefined || that.orderDetail.tel == null ? "-" : that.orderDetail.tel) + "\n身份证号：" + (that.orderDetail.idCard == "" ? "-" : that.orderDetail.idCard) + "\n家庭地址：" + (that.orderDetail.address == "" || that.orderDetail.address == undefined || that.orderDetail.address == null ? "-" : that.orderDetail.address) + "\n报名岗位：" + that.orderDetail.storeJobName + "\n员工薪资：" + (that.orderDetail.employeeSalary || "-") + (that.isCreator ? "\n代理政策：" + that.orderDetail.policy : "");
			uni.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							// console.log(res.data); // data
							uni.showToast({
								title: "复制成功",
								icon: "success",
							});
						},
					});
				},
			});
		},
		goFellow() {
			let that = this,
				params = {};
			// console.log("that.orderDetail", that.orderDetail);
			params = {
				name: this.orderDetail.userName,
				sex: this.orderDetail.sex,
				age: this.orderDetail.age,
				nation: this.orderDetail.nation,
				tel: this.orderDetail.tel ? this.orderDetail.tel : "",
				idCard: this.orderDetail.idCard ? this.orderDetail.idCard : "",
				idCardImageUrl: this.orderDetail.idCardImageUrl ? this.orderDetail.idCardImageUrl : "",
				address: this.orderDetail.address ? this.orderDetail.address : "",
				imgs: "",
				userName: this.orderDetail.userName,
				userId: that.orderDetail.userId,
				resumeFlag: this.resumeFlag,
				weChat: that.orderDetail.weChat,
			};
			// if (this.resumeFlag == 1) {
			// } else {
			// 	params.weChat = "";
			// }
			uni.navigateTo({
				url: "/root/detail/fellow?" + that.G.objToStr(params),
			});
		},
		goRecordInfo(e) {
			let that = this,
				params = {};
			params = {
				info: e.info ? JSON.parse(e.info).policy : "-",
				time: e.time,
				title: e.title,
				type: e.type,
			};
			that.orderDetail.policy = params.info;
			that.infoModal.isShow = true;

			// uni.navigateTo({
			// 	url: "/root/detail/jobDesp?" + that.G.objToStr(params),
			// });
		},
		goInfo($info, $title, $type, $dis) {
			uni.setStorageSync("APPLY_OBJ", this.orderDetail);
			uni.navigateTo({
				url: "/root/detail/jobDesp?info=" + $info + "&time=" + this.orderDetail.create_time + "&title=" + $title + "&type=" + $type + "&dis=" + $dis,
			});
		},
		handleOpenRemarkModal() {
			// console.log("备注点击事件");
			this.recordModal.remark = "";
			this.recordModal.isShow = true;
		},
		handleChooseAddressModal() {
			let that = this;
			// console.log("经纬度：", that.orderDetail);
			if (that.orderDetail.interviewLat && that.orderDetail.interviewLng) {
				uni.openLocation({
					name: that.orderDetail.interviewAddress,
					latitude: Number(that.orderDetail.interviewLat),
					longitude: Number(that.orderDetail.interviewLng),
					success: function () {},
				});
			} else {
				uni.showToast({
					icon: "none",
					title: "请检查地址",
				});
			}
		},
		handleSubmitRemark() {
			let that = this;
			if (that.recordModal.remark == "") {
				uni.showToast({
					title: "请输入备注",
					icon: "none",
				});
				return false;
			}
			let params = {
				type: that.resumeFlag,
				desp: that.recordModal.remark,
			};
			if (that.resumeFlag == 1) {
				params.resumeId = that.oid;
			} else {
				params.orderId = that.oid;
			}
			that.G.Post(that.api.resume_follow, params, () => {
				that.recordModal.isShow = false;
				uni.showToast({
					title: "修改成功",
					icon: "success",
				});
				that.getDetail();
			});
		},

		handleMianshi(e) {
			this.submitTime(1, e);
		},
		handleYueruzhi(e) {
			this.submitTime(2, e);
		},
		handleRuzhi(e) {
			this.submitTime(3, e);
		},
		handleYuelizhi(e) {
			this.submitTime(4, e);
		},
		handleLizhi(e) {
			this.submitTime(5, e);
		},
		submitTime($type, $time) {
			let that = this;
			that.G.Post(
				that.api.order_submitTime,
				{
					orderId: that.oid,
					timeStr: $time,
					type: $type,
				},
				() => {
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
		},

		handleOpenModal() {
			let that = this;
			if (that.type == 1) {
				return false;
			}
			// 处理回显
			let ids =
				that.orderDetail.onSiteUsers.length == 0
					? ""
					: that.orderDetail.onSiteUsers
							.map((item) => {
								return item.userId;
							})
							.join(",");
			that.residentList
				.filter((item) => {
					item.isSelected = false;
					return ids.indexOf(item.userId) > -1;
				})
				.forEach((item, index) => {
					item.isSelected = true;
				});
			that.residentModal.isShow = true;
		},
		handleChooseResident($item, $index) {
			let that = this;
			that.residentList.forEach((item, index) => {
				if (index == $index) {
					if (item.isSelected) {
						item.isSelected = false;
					} else {
						item.isSelected = true;
					}
				}
			});
		},
		submitRes() {
			let that = this;
			let ids = [];
			ids = that.residentList
				.filter((item) => {
					return item.isSelected;
				})
				.map((item) => {
					return item.userId;
				});
			if (ids.length == 0) {
				uni.showToast({
					title: "最少选择一个驻场人员",
					icon: "none",
				});
				return false;
			}
			if (ids.length > 3) {
				uni.showToast({
					title: "最多选择3个驻场人员",
					icon: "none",
				});
				return false;
			}
			that.G.Post(
				that.api.order_residentSubmit_new,
				{
					onSiteUserIds: ids.join(","),
					relationId: that.relationId,
					orderId: that.oid,
				},
				() => {
					that.residentModal.isShow = false;
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
		},

		handleOpenZhengceModal() {
			let that = this;
			// 处理回显
			let ids = "";
			that.zhengceList
				.filter((item) => {
					return ids.indexOf(item.id) > -1;
				})
				.forEach((item, index) => {
					item.isSelected = true;
				});
			that.zhengceModal.isShow = true;
		},
		handleChooseZhengce($item, $index) {
			let that = this;
			that.zhengceList.forEach((item, index) => {
				if (index == $index) {
					if (item.isSelected) {
						item.isSelected = false;
					} else {
						item.isSelected = true;
					}
				} else {
					item.isSelected = false;
				}
			});
		},
		submitZhengce() {
			let that = this;
			let ids = [];
			ids = that.zhengceList
				.filter((item) => {
					return item.isSelected;
				})
				.map((item) => {
					return item.value;
				});
			if (ids.length == 0) {
				uni.showToast({
					title: "请选择一个政策",
					icon: "none",
				});
				return false;
			}
			that.applyInfo.policyIdx = ids[0];
			that.G.Post(
				that.api.order_update_detail,
				{
					...that.applyInfo,
				},
				(res) => {
					// console.log("res", res);
					that.zhengceModal.isShow = false;
					uni.showToast({
						title: "修改成功",
						icon: "success",
					});
					that.getDetail();
				}
			);
		},
		setReturnFee(returnFee, returnFeeType) {
			return this.G.setReturnFee(returnFee, returnFeeType);
		},
		// 标记简历
		markResume(e) {
			let that = this;
			let obj = {
				resumeId: that.oid,
				markTag: "",
			};
			if ((e == 9 && !this.orderDetail.weChat) || (e == 100 && !this.orderDetail.tel)) {
				uni.showToast({
					title: e == 9 && !this.orderDetail.weChat ? "请添加微信号" : "请添加手机号",
					icon: "none",
				});
				return false;
			}
			// 8,9,10 是微信相关的标记, 需要额外对应
			if (e != 8 && e != 9 && e != 10) {
				obj.telMark = e;
				obj.markTag = 0;
			} else {
				obj.markTag = 1;
				switch (e) {
					case 8:
						obj.weChatMark = 1;
						break;
					case 9:
						obj.weChatMark = 100;
						break;
					case 10:
						obj.weChatMark = 2;
						break;
				}
			}
			that.G.Post(that.api.mark_resume, obj, (res) => {
				// console.log("res", res);
				that.editNewResumeShow = false;
				uni.showToast({
					title: "操作成功",
					icon: "success",
				});
				that.getDetail();
			});
		},
		record($item) {
			// console.log("$item", $item);
			uni.navigateTo({
				url: "/root/home/quickApplication?resumeInfo=" + JSON.stringify($item),
				// 小程序页面间通信, 确保页面渲染完再获取简历信息
				events: {
					ceshi: function (data) {
						// setTimeout(() => {
						// 	uni.$emit("getTownsman", { info: $item });
						// }, 4000);
						// console.log(data);
					},
				},
			});
		},
	},
};
</script>

<style lang="scss">
.p-root-detail-apply {
	min-height: 100%;
	.g-components-panel-fixed {
		border-top: 1rpx solid #fff;
	}
}
</style>
