<template>
	<view class="p-root-detail-apply g_w_all g_h_all g_bg_f_5 g_kuaishou">
		<view v-if="speed == 0">
			<g-loading />
		</view>
		<view v-if="speed > 0">
			<!-- 状态信息 -->
			<view class="m-state">
				<view class="g_h_10"></view>
				<view class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="状态" :value="orderDetail.status_text" valueColor="#ff4400" />
					<!-- afterIcon="icon-gengduo11"  @clickItem="goBossDetail" -->
					<g-panel-detail-item label="项目方" :value="orderDetail.upFullName || orderDetail.upAgencyName" valueColor="#333" />
					<!-- @clickItem="handleOpenPeopleModal"  -->
					<g-panel-detail-item label="报名人" from="resident-info" beforeIcon="icon-phone" @clickItem="goTel(orderDetail.agencyTel)" :remarkValue="orderDetail.agencyTel" v-if="!orderDetail.prevRecordId" :value="orderDetail.applyUserName" />
					<g-panel-detail-item label="报名人" from="resident-info" beforeIcon="icon-phone" @clickItem="goTel(orderDetail.agencyTel)" :remarkValue="orderDetail.agencyTel" v-else :value="orderDetail.applyUserName" />

					<view>
						<view class="g_pt_10 g_border_d_t" v-if="orderDetail.canEdit || (!orderDetail.canEdit && (orderDetail.statusId == 10 || orderDetail.statusId == 20 || orderDetail.statusId == 25))">
							<g-panel-detail-item from="times" label="面试时间" :value="orderDetail.interview_time" afterType="time" @confirmChooseTime="handleMianshi" />
						</view>
						<view class="g_pt_10 g_border_d_t" v-if="orderDetail.status == 30">
							<g-panel-detail-item from="times" label="约入职时间" :value="orderDetail.willEntry_time" afterType="time" @confirmChooseTime="handleYueruzhi" />
						</view>
						<view class="g_pt_10 g_border_d_t" v-if="orderDetail.status == 40">
							<g-panel-detail-item from="times" label="入职时间" :value="orderDetail.entry_time" afterType="time" @confirmChooseTime="handleRuzhi" />
						</view>
						<view class="g_pt_10 g_border_d_t" v-if="orderDetail.status == 48">
							<g-panel-detail-item from="times" label="约离职时间" :value="orderDetail.willLeave_time" afterType="time" @confirmChooseTime="handleYuelizhi" />
						</view>
						<view class="g_pt_10 g_border_d_t" v-if="orderDetail.status == 50">
							<g-panel-detail-item from="times" label="离职时间" :value="orderDetail.leave_time" afterType="time" @confirmChooseTime="handleLizhi" />
						</view>
						<view class="g_pt_10 g_border_d_t" 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>
				</view>
			</view>
			<!-- 用户信息 -->
			<view class="m-user">
				<view class="g_h_10"></view>
				<view class="g_bg_f g_pl_15 g_pr_15 g_pt_10">
					<view class="g_pb_10 g_flex_row_between">
						<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 g_pl_16 g_pr_16 g_pt_9 g_pb_9" style="background-color: #f0fff8; border-radius: 17px">
								<view class="g_flex_row_end" @click="handleOpenInfoModal">
									<view class="g_flex_column_center">
										<i class="iconfont icon-yulan g_c_3"></i>
									</view>
									<view class="g_fs_16 g_c_3 g_ml_8">预览</view>
								</view>
								<view class="g_flex_row_end g_ml_20" @click="goFellow">
									<view class="g_flex_column_center">
										<i class="iconfont icon-bianji g_c_3"></i>
									</view>
									<view class="g_fs_16 g_c_3 g_ml_8">编辑</view>
								</view>
							</view>
						</view>
					</view>
					<view class="g_pb_10">{{ orderDetail.address ? orderDetail.address : "-" }}</view>
					<view class="g_flex_row_between g_pb_15">
						<view class="g_flex_row_start g_mr_14">
							<view class="g_flex_none g_mr_4 g_w_28 g_h_28 g_radius_50 g_flex_c">
								<image :src="cdnBaseImg + 'order_idcard.svg'" v-if="orderDetail.idCard" class="g_w_28 g_h_28"></image>
								<image :src="cdnBaseImg + 'idCard_gray.svg'" v-else class="g_w_28 g_h_28"></image>
							</view>
							<view class="g_flex_column_center">{{ orderDetail.idCard ? orderDetail.idCard : "-" }}</view>
						</view>
						<view class="g_flex_row_end" @click="goTel(orderDetail.tel)">
							<view class="g_mr_4 g_w_28 g_h_28 g_radius_50 g_flex_c">
								<image :src="cdnBaseImg + 'order_tel.svg'" class="g_w_28 g_h_28" v-if="orderDetail.tel"></image>
								<image :src="cdnBaseImg + 'order_tel_gray.svg'" class="g_w_28 g_h_28" v-else></image>
							</view>
							<view class="g_flex_column_center g_text_r">{{ orderDetail.tel ? orderDetail.tel : "-" }}</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">
					<!-- v-if="(!orderDetail.nextRecordId && !orderDetail.prevRecordId && isCreator) || (isCreator && orderDetail.nextRecordId)" -->
					<view>
						<g-panel-detail-item label="服务费" :value="setReturnFee(orderDetail.returnFee, orderDetail.returnFeeType)" />
						<g-panel-detail-item label="服务费详情" :value="orderDetail.returnFeeDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.returnFeeDesp, '服务费详情', '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> -->
					<!-- <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="g_h_12"></view>
				<view class="link g_bg_f g_pt_10">
					<!-- <g-panel-detail-item label="报名企业" :value="orderDetail.storeName" /> -->
					<g-panel-detail-item label="报名岗位" :value="orderDetail.storeJobName" fontWeight="bold" />
					<!-- 服务费 最上游或者不是管理人员不显示 orderDetail.nextRecordId为空 是最上游 -->
					<!-- 代理费/服务费 最下游不显示 orderDetail.prevRecordId为空 是最下游 -->

					<!-- <g-panel-detail-item label="报名时间" :value="orderDetail.create_time" /> -->
					<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-price">
				<view class="g_h_12"></view>
				<view class="link g_bg_f g_pt_10">
					<g-panel-detail-item label="面试地址" :value="orderDetail.interviewAddress" afterIcon="icon-gengduo11" @clickItem="handleChooseAddressModal" />
					<g-panel-detail-item label="驻场信息" v-if="orderDetail.prevRecordId || (!orderDetail.prevRecordId && !orderDetail.nextRecordId)" :value="orderDetail.totalZC || '-'" afterIcon="icon-gengduo11" @clickItem="handleOpenModal" from="resident-info" afterType="multi" @clickLabelBtn="handleClickLabelBtn(orderDetail.totalZC || '-')" labelSubStr="复制" />
					<g-panel-detail-item label="驻场信息" v-else labelSubStr="复制" :value="orderDetail.totalZC || '-'" from="resident-info" afterType="multi" @clickLabelBtn="handleClickLabelBtn(orderDetail.totalZC || '-')" />
					<g-panel-detail-item label="其他说明" :value="orderDetail.interviewDesp" afterIcon="icon-gengduo11" @clickItem="goInfo(orderDetail.interviewDesp, '其他信息', '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">
				<view class="g_bg_f" 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_16 g_pr_16 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>
					<g-panel-record :item="orderDetail.records" @clickInfo="goRecordInfo" />
				</view>
			</view>
		</view>

		<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_c_main g_fs_15 g_pt_18 g_pb_18" @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: 700rpx">
				<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 ? '#00b666' : '#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>
				<view class="g_flex_row_center g_pt_32 g_fs_18 g_fw_600 g_mb_20">老乡信息</view>
				<view class="g_pb_32 g_pr_16 g_pl_16 g_flex_row_center">
					<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_none 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_none 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_none g_ell_1">
								{{ orderDetail.storeJobName ? orderDetail.storeJobName : "-" }}
							</view>
						</view>

						<view v-if="orderDetail.status == 10 || orderDetail.status == 20 || orderDetail.status == 25">
							<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_none g_ell_1">
									{{ orderDetail.interview_time ? orderDetail.interview_time : "-" }}
								</view>
							</view>
						</view>
						<view v-if="orderDetail.status == 30">
							<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_none g_ell_1">
									{{ orderDetail.willEntry_time ? orderDetail.willEntry_time : "-" }}
								</view>
							</view>
						</view>
						<view v-if="orderDetail.status == 40">
							<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_none g_ell_1">
									{{ orderDetail.entry_time ? orderDetail.entry_time : "-" }}
								</view>
							</view>
						</view>
						<view v-if="orderDetail.status == 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_c_3 g_flex_none g_ell_1">
									{{ orderDetail.willLeave_time ? orderDetail.willLeave_time : "-" }}
								</view>
							</view>
						</view>
						<view v-if="orderDetail.status == 50">
							<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_none g_ell_1">
									{{ orderDetail.leave_time ? orderDetail.leave_time : "-" }}
								</view>
							</view>
						</view>
						<view v-if="orderDetail.status == 21 || orderDetail.status == 26 || orderDetail.status == 35 || orderDetail.status == 45">
							<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_none g_ell_1">
									{{ orderDetail.update_time ? orderDetail.update_time : "-" }}
								</view>
							</view>
						</view>

						<view class="item g_flex_row_start g_mb_0">
							<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_none g_ell_1">
								{{ orderDetail.tel ? orderDetail.tel : "-" }}
							</view>
						</view>
					</view>
				</view>
				<view class="g_flex_row_between g_border_e_t">
					<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_c_main g_fs_18 g_pt_18 g_pb_18 g_flex_c" style="width: 50%; height: 49px; border-left: 1rpx solid #eee" @click="infoModal.isShow = false">知道了</view>
				</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 ? '#00b666' : '#fff',
								}"
							></i>
						</view>
					</view>
				</view>
			</scroll-view>
			<g-panel-fixed>
				<slot>
					<view class="g_flex_row_center">
						<g-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 ? '#00b666' : '#fff',
								}"
							></i>
						</view>
					</view>
				</view>
			</scroll-view>
			<g-panel-fixed>
				<slot>
					<view class="g_flex_row_center">
						<g-button btnText="确定" type="primary" @clickBtn="submitZhengce" />
					</view>
				</slot>
			</g-panel-fixed>
		</u-popup>
	</view>
</template>

<script>
export default {
	onReady() {
		this.G.setNavStyle();
	},
	onShareAppMessage() {
		return this.G.shareFun();
	},
	data() {
		return {
			cdnBaseImg: this.G.store().cdnBaseImg,
			agencyId: uni.getStorageSync("apply-agencyId"),
			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,
				},
			],
		};
	},
	onLoad(options) {
		this.oid = options.id;
		this.relationId = options.relationId;
		this.type = options.type;
	},
	onShow() {
		this.isCreator = uni.getStorageSync("IS_CREATOR") == 1 ? true : false;
		this.getResident();
		this.getPeople();
		this.getDetail();
	},
	methods: {
		handleClickLabelBtn($data) {
			var that = this;
			var text = "";
			if (that.orderDetail.upAgencyName == "江西人海") {
				text = that.orderDetail.storeJobName + "\n\n⚠驻场接人：" + that.orderDetail.zhuchangTel + "(接待面试，优先联系）\n\n服务投诉：19036980065";
			} else {
				text = that.orderDetail.totalZC;
			}
			wx.setClipboardData({
				data: text,
				success(res) {
					uni.getClipboardData({
						success(res) {
							console.log(res.data); // data
							wx.showToast({
								title: "内容已复制",
								icon: "none",
								duration: 1500,
							});
						},
					});
				},
			});
			// uni.setClipboardData({
			// 	data: $data,
			// 	success: function () {
			// 		uni.showToast({
			// 			title: "复制成功",
			// 		});
			// 	},
			// });
		},
		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;
			that.G.Get(
				that.api.order_detail_new,
				{
					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");
					res.totalZC = res.prevRecordId || (!res.prevRecordId && !res.nextRecordId) ? res.newZhuchang : "";
					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);
					}
					if (res.upAgencyName == "江西人海" && res.totalZC.indexOf(" ") != -1) {
						res.totalZC = res.totalZC.split(" ")[1];
						res.zhuchangTel = res.totalZC.replace(/\s+/g, "");
					}
					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;
				}
			);
		},
		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);
			// return;
			// that.peopleModal.uid = $item.id;
			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.Post(
			// 	that.api.order_submitPeople,
			// 	{
			// 		userApplyOrderId: that.oid,
			// 		userId: that.peopleModal.uid,
			// 		statistic: 1,
			// 		agree: 1,
			// 	},
			// 	() => {
			// 		that.peopleModal.isShow = false;
			// 		uni.showToast({
			// 			title: "修改成功",
			// 			icon: "success",
			// 		});
			// 		that.getDetail();
			// 	}
			// );
		},

		handleOpenInfoModal() {
			let that = this;
			that.infoModal.isShow = true;
		},
		handleCopy() {
			let that = this,
				params = {};
			params = {
				"姓名：": this.orderDetail.userName + "/" + this.orderDetail.sex == 1 ? "男" : "女" + "/" + this.orderDetail.age + "岁/" + this.orderDetail.nation,
				"身份证号：": this.orderDetail.idCard ? this.orderDetail.idCard : "-",
				"企业岗位：": this.orderDetail.storeJobName ? this.orderDetail.storeJobName : "-",
				电话: this.orderDetail.tel ? this.orderDetail.tel : "-",
			};
			if (this.orderDetail.status == 10 || this.orderDetail.status == 20 || this.orderDetail.status == 25) {
				params["面试时间"] = this.orderDetail.interview_time ? this.orderDetail.interview_time : "-";
			}
			if (this.orderDetail.status == 30) {
				params["约入职时间"] = this.orderDetail.willEntry_time ? this.orderDetail.willEntry_time : "-";
			}
			if (this.orderDetail.status == 40) {
				params["入职时间"] = this.orderDetail.entry_time ? this.orderDetail.entry_time : "-";
			}
			if (this.orderDetail.status == 48) {
				params["约离职时间"] = this.orderDetail.willLeave_time ? this.orderDetail.willLeave_time : "-";
			}
			if (this.orderDetail.status == 50) {
				params["离职时间"] = this.orderDetail.leave_time ? this.orderDetail.leave_time : "-";
			}
			if (this.orderDetail.status == 21 || this.orderDetail.status == 26 || this.orderDetail.status == 35 || this.orderDetail.status == 45) {
				params["完成时间"] = this.orderDetail.update_time ? this.orderDetail.update_time : "-";
			}
			that.G.copyText(that.G.objToStr(params, "copy"));
		},
		goFellow() {
			let that = this,
				params = {};
			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,
			};
			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,
			};
			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;
			}
			that.G.Post(
				that.api.order_submitRemark,
				{
					orderId: that.oid,
					desp: that.recordModal.remark,
				},
				() => {
					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);
		},
	},
};
</script>

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