<template>
    <div class="pd-16" style="overflow: auto;">
        <div class="d-flexflex-cln">
            <div class="info-title mb-10">可参会单位类型</div>
            <div class="bg-#fafafa pd-16 mb-20">
                <template v-for="item, index in form?.conditions?.typeCheck" :key="index">
                    <span class="pr-5" v-if="item.check == '1'">
                        {{ selectDictLabel(dm_check_join_type, item?.vipLevel)}}
                    </span>
                </template>
            </div>
            <div class="info-title mb-10">报名限制条件</div>
            <div class="bg-#fafafa pd-16 mb-20" v-if="form?.conditions?.totalCheck == '0' || !form?.conditions?.totalCheck">无</div>
            <div class="bg-#fafafa pd-16 d-flex flex-cln" v-else>
                <div class="pd-5 pb-15" v-if="form?.conditions?.total">报名总人数 ： {{ form?.conditions?.total }}人</div>
                <div class="d-flex">
                    <div>
                        <template v-for="(item, index) in form?.conditions?.levelCheck" :key="index">
                            <div class="d-flex a-c pd-5" v-if="+item.check">
                                <span>
                                    所有
                                    <span class="f-w-6">
                                        {{ selectDictLabels(dm_check_join_type, item.vipLevel, ',') }}
                                    </span>
                                    参会人数 ≤{{ item.total }}
                                </span>
                            </div>
                        </template>
                    </div>
                    <div>
                        <template v-for="(item, index) in form?.conditions?.cpyCheck" :key="index">
                            <div class="d-flex a-c pd-5" v-if="+item.check">
                                <span>
                                    <span class="f-w-6">{{ selectDictLabels(dm_check_join_type, item.vipLevel, ',') }}</span>
                                    限制每家单位人数≤{{ item.total }}
                                </span>
                            </div>
                        </template>
                    </div>
                </div>
            </div>
            <div class="info-title mb-10">参会费用</div>
            <div class="bg-#fafafa pd-16 d-flex flex-cln">
                <div class="pd-5 pb-15">是否收取费用 ： {{ form?.meetingCharge?.hasFee == '1' ? '是' : '否' }}</div>
                <div class="pd-5 pb-15" v-if="form?.meetingCharge?.hasFee == '1'">收费标准 ： {{ form?.meetingCharge?.pricing }}元/每人</div>
                <div class="pd-5 pb-15" v-if="form?.meetingCharge?.hasFee == '1'&& form?.meetingCharge?.hasFlatFee =='0'">所有人统一收取标准费用</div>
                <div class="pd-5 pb-15" v-if="form?.meetingCharge?.hasFee == '1' && form?.meetingCharge?.hasFlatFee =='1'">按报名人员类型收取，不同人员收取不同费用</div>
                <div class="d-flex flex-cln" v-if="form?.meetingCharge?.hasFee == '1' && form?.meetingCharge?.hasFlatFee =='1'">
                    <template v-for="(item, index) in form?.meetingCharge?.typeCharge" :key="index">
                        <view v-if="+item?.check && +form?.conditions?.typeCheck?.find(items => items?.vipLevel ==item?.vipLevel)?.check" class="pd-5">
                            <span class="f-w-6">
                                {{ selectDictLabels(dm_check_join_type, item?.vipLevel, ',') }}
                            </span>
                            <span v-if="!+item?.certType">不收取费用</span>
                            <span v-if="+item?.certType">
                                <span v-if="item?.vipLevel !== 'P'">每个单位</span>
                                免除费用{{ item?.total }}人，其余报名人员每人收取费用{{ item?.cost }}元
                            </span>
                        </view>
                        <div class="pd-5" v-if="!+item?.check && +form?.conditions?.typeCheck?.find(items => items?.vipLevel ==item?.vipLevel)?.check">
                            <span class="f-w-6">
                                {{ selectDictLabels(dm_check_join_type, item?.vipLevel, ',') }}
                            </span>
                            <span v-if="item?.vipLevel !== 'P'">每个单位</span>
                            <span>每人收取费用{{ form?.meetingCharge?.pricing }}元</span>
                        </div>
                    </template>
                </div>
            </div>
        </div>
        <div class="d-flex mb-16 ">
            <div class="info-title">
                <span>参会人员信息</span>
                <span class="f-s-14 c-666">(提交报名:{{ form?.submitCount || 0 }}人 | 已缴费:{{ form?.payCount || 0 }} 人 | 待审核:{{ form?.resWaitingCount || 0 }}人 ｜ 审核通过:{{ form?.joinCount || 0 }}人 | 签到:{{ form?.signCount || 0 }}人 | 领取证书:{{ form?.certCount || 0 }}人)</span>
            </div>
        </div>
        <div class="d-flex j-sb">
            <!-- <div>
                <searchTabs v-if="form?.conditions?.totalCheck == '1'" v-model="queryParams.res" @change="handleQuery" :list="tabs" key-label="name" key-count="num" key-value="type"></searchTabs>
            </div> -->
            <span style="width: 1px;"></span>
            <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="auto">
                <el-form-item label="是否设置一对一联系人" prop="hasContact">
                    <el-select v-model="queryParams.hasContact" placeholder="请选择" clearable style="width: 180px">
                        <el-option v-for="item in [{value:'0',label:'否'},{value:'1',label:'是'}]" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="标签" prop="tags">
                    <el-select v-model="queryParams.tags" placeholder="请选择" clearable style="width: 180px">
                        <el-option v-for="item in signup_tags_type" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="企业名称：" prop="company">
                    <el-input v-model="queryParams.company" placeholder="请输入企业名称" clearable style="width: 180px" />
                </el-form-item>
                <el-form-item label="姓名：" prop="name">
                    <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable style="width: 180px" />
                </el-form-item>
                <el-form-item label="参会状态：" prop="signupStatus">
                    <el-select v-model="queryParams.signupStatus" placeholder="请选择参会状态" clearable style="width: 180px">
                        <el-option v-for="item in lm_signup_status_app_query" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="报名方式：" prop="tempJoin">
                    <el-select v-model="queryParams.tempJoin" placeholder="请选择报名方式" clearable style="width: 180px">
                        <el-option v-for="item in temp_join_type" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="审核状态：" prop="res">
                    <el-select v-model="queryParams.res" placeholder="请选择审核状态" clearable style="width: 180px">
                        <el-option v-for="item in cpy_res_status" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="支付状态：" prop="payStatus">
                    <el-select v-model="queryParams.payStatus" placeholder="请选择支付状态" clearable style="width: 180px">
                        <el-option v-for="item in dm_pay_status" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="支付方式：" prop="payType">
                    <el-select v-model="queryParams.payType" placeholder="请选择支付方式" clearable style="width: 180px">
                        <el-option v-for="item in [{value:'1',label:'微信支付'},{value:'2',label:'对公转账/现场支付'},{value:'3',label:'对公转账'},{value:'4',label:'现场支付'}]" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="是否需要开票：" prop="hasInvoice">
                    <el-select v-model="queryParams.hasInvoice" placeholder="请选择" clearable style="width: 180px">
                        <el-option v-for="item in [{value:'0',label:'不需要'},{value:'1',label:'需要'}]" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="所在地区" label-width="70" prop="adcode">
                    <AreaCascader v-model="queryParams.adcode" :zlevel="2" checkStrictly @change="handleQuery"></AreaCascader>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                    <el-button icon="Refresh" @click="resetQuery">重置</el-button>
                    <el-button icon="Download" @click="exportSearch">导出参会人员信息</el-button>
                </el-form-item>
            </el-form>
        </div>
        <vxe-table v-if="form" :loading="loading" border :data="list" min-height="0">
            <!-- 序号 -->
            <vxe-column type="seq" width="60" title="序号" align="center" />
            <vxe-column title="企业名称" field="company" min-width="100" :formatter="colNoData" />
            <vxe-column title="所在地区" field="adcodeName" min-width="100" :formatter="colNoData" />
            <vxe-column title="单位类型" field="vipLevel" min-width="100" :formatter="colNoData" align="center">
                <template #default="{ row }">
                    <div class="d-flex a-c j-c">
                        <DictTag :options="dm_check_join_type" :value="row?.vipLevel"></DictTag>
                    </div>
                </template>
            </vxe-column>
            <vxe-column title="姓名" field="name" min-width="100" :formatter="colNoData">
                <template #default="{ row }">
                    <div class="f-w-5">{{ row?.name }}</div>
                    <div v-if="row?.extendInfo?.tags" class="d-flex flex-cln">
                        <el-tag class="mb-5" type="warning" v-for="(item,index) in row?.extendInfo?.tags.split(',')" :key="index">{{ item }}</el-tag>
                    </div>
                </template>
            </vxe-column>
            <!-- <vxe-column title="职务" field="position" min-width="100" :formatter="colNoData" /> -->
            <vxe-column title="联系方式" field="contact" min-width="100" :formatter="colNoData" />
            <vxe-column title="备注" field="remark" min-width="100" :formatter="colNoData">
                <template #default="{ row}">
                    <el-tooltip class="box-item" effect="dark" :content="row?.extendInfo?.remark" placement="top" :offset="-10">
                        <div class="pt-20 c-primary c-s-p" v-if="row?.extendInfo?.remark" style="position: absolute;top: -10px;right: 10px;">会务备注</div>
                    </el-tooltip>
                    <div>{{ row?.remark || '-' }}</div>
                </template>
            </vxe-column>
            <vxe-column title="参会费用" field="joinFee" min-width="100" :formatter="colNoData" v-if="form?.meetingCharge?.hasFee =='1'">
                <template #default="{ row }">
                    <div class="f-w-5 c-red">{{ row?.joinFee }}</div>
                </template>
            </vxe-column>
            <vxe-column title="支付方式" field="payType" min-width="100" :formatter="colNoData" v-if="form?.meetingCharge?.hasFee =='1'">
                <template #default="{ row }">
                    <div v-if="row.payType === '1' && +row?.joinFee" class="f-w-5">微信支付</div>
                    <div v-if="row.payType === '2' && +row?.joinFee" class="f-w-5">对公转账/现场支付</div>
                    <div v-if="row.payType === '3' && +row?.joinFee" class="f-w-5">对公转账</div>
                    <div v-if="row.payType === '4' && +row?.joinFee" class="f-w-5">现场支付</div>
                    <div v-if="(row?.payType !=='1'&& row?.payType !=='2' && row?.payType !=='3' && row?.payType !=='4') || !+row?.joinFee">-</div>
                </template>
            </vxe-column>
            <vxe-column title="开票信息" field="remark" min-width="100" :formatter="colNoData" v-if="form?.meetingCharge?.hasFee =='1'">
                <template #default="{ row }">
                    <div v-if="row.payStatus == '1'&& !+row?.invoiceStatus && +row?.hasInvoice" @click="checkInvoiceData(row?.invoiceInfo)" class="pointer">查看</div>
                    <div v-if="row.payStatus == '1' && +row?.invoiceStatus && +row?.hasInvoice" @click="openPDF(row?.invoiceUrl?.url)" class="pointer" style="color: red;">已开票，点击查看</div>
                    <div v-if="row?.payStatus == '0'">{{ '-' }}</div>
                    <div v-if="row?.payStatus !== '0' &&!+row?.hasInvoice">{{ '不需要' }}</div>
                </template>
            </vxe-column>
            <vxe-column title="报名时间" align="center" field="createTime" min-width="100" :formatter="colNoData" />
            <vxe-column title="特殊说明" min-width="100" field="tempJoin">
                <template #default="{ row }">
                    {{ +row?.tempJoin?'通过临时报名通道报名':'-' }}
                </template>
            </vxe-column>
            <vxe-column title="支付状态" field="payStatus" min-width="100" :formatter="colNoData" v-if="form?.meetingCharge?.hasFee =='1'" fixed="right">
                <template #default="{ row }">
                    <div class="f-w-5">{{ selectDictLabel(dm_pay_status, row?.payStatus)}}</div>
                    <el-tooltip :content="`系统单号${row?.outTradeNo}`" placement="top" effect="light">
                        <el-icon v-if="row.payStatus == '1'"><QuestionFilled /></el-icon>
                    </el-tooltip>
                </template>
            </vxe-column>
            <vxe-column title="报名信息" min-width="80" fixed="right">
                <template #default="{ row }">
                    <div class="c-s-p"><u @click="checkRegostrationInfo(row)">查看报名信息</u></div>
                </template>
            </vxe-column>
            <vxe-column title="参会状态" min-width="100" fixed="right">
                <template #default="{ row }">
                    <DictTag v-if="row?.signupStatusForPc" :options="lm_signup_status_app_show" :value="row?.signupStatusForPc"></DictTag>
                    <div v-else>-</div>
                </template>
            </vxe-column>

            <vxe-column v-if="form?.conditions?.totalCheck == '1'" title="审核状态" min-width="100" fixed="right">
                <template #default="{ row }">
                    <div v-if="row?.res == '3'||row?.res == '4'||row?.res == '5'">{{ '-' }}</div>
                    <div v-else class="d-flex a-c">
                        <DictTag :class="{ 'c-red': row?.res === '0' }" :options="cpy_res_status" :value="row?.res" />
                        <el-tooltip class="box-item" effect="dark" :content="row?.msg" placement="top">
                            <el-icon v-show="row?.res == '2'">
                                <QuestionFilled />
                            </el-icon>
                        </el-tooltip>
                    </div>
                </template>
            </vxe-column>
            <vxe-column v-if="form?.conditions?.totalCheck == '1' || form?.meetingCharge?.hasFee == '1'" title="操作" width="140" align="center" fixed="right">
                <template #default="{ row }">
                    <div class="d-flex flex-cln">
                        <el-button v-if="!row?.extendInfo?.remark" class="mb-10" size="small" @click="openRemark(row)">添加会务备注</el-button>
                        <span></span>
                        <el-button v-if="row?.extendInfo?.remark" class="mb-10" size="small" @click="openRemark(row)">修改会务备注</el-button>
                        <span></span>
                        <el-button class="mb-10" size="small" v-if="row?.res == '5'" @click="openSignup(row)">关闭报名</el-button>
                        <span></span>
                        <el-button class="mb-10" type="danger" size="small" v-if="row?.res !== '0' && row?.signInFlag !=='1' && form?.conditions?.totalCheck == '1'&& row?.payStatus == '1' && form?.meetingCharge?.hasFee !== '1'" @click="openDialog(row)" style="color: white">重审</el-button>
                        <span></span>
                        <el-button class="mb-10" size="small" color="#33aeeb" @click="openDialog(row)" style="color: white" v-if="row?.res == '0' && form?.conditions?.totalCheck == '1' &&form?.trainingStatus !== '2'">审核</el-button>
                        <span></span>
                        <el-button class="mb-10" v-if="row.res=='3' || row.res== '5'" size="small" color="#e99d42" style="color: white;" @click="openModification(row)">修改费用金额</el-button>
                        <span></span>
                        <el-button class="mb-10" v-if="row.res== '5' && row?.payType=='2'" size="small" color="#81b337" style="color: white;" @click="openTransfer(row)">确认收到款项</el-button>
                        <span></span>
                        <div v-if="row.payStatus == '1' && (row?.res == '0'|| row?.res == '2') && form?.trainingStatus == '2' && +row?.joinFee && row.payStatus !== '10'">用户报名未成功，请至微信商户号进行退款</div>
                        <div v-if="row.payStatus === '10'">该报名已退款</div>
                        <el-upload v-if="form?.trainingStatus == '2' && +row.joinFee && +row?.hasInvoice && !+row?.invoiceStatus && row.payStatus == '1' &&form?.meetingCharge?.hasFee =='1' && row?.res !== '0' && row?.res !== '2'" class="upload-demo" :action="uploadFileUrl" multiple :limit="1" :on-success="handleSuccess" :headers="headers" :show-file-list="false" accept=".pdf,.PDF">
                            <el-button class="mb-10" size="small" color="#33aeeb" style="color: white" @click=" invoiceId = row.id">上传发票</el-button>
                        </el-upload>
                        <span></span>
                        <el-upload v-if="form?.trainingStatus == '2' && +row.joinFee && +row?.hasInvoice && +row?.invoiceStatus && row.payStatus == '1' &&form?.meetingCharge?.hasFee =='1'&& row?.res !== '0' && row?.res !== '2'" class="upload-demo" :action="uploadFileUrl" multiple :limit="1" :on-success="handleSuccess" :headers="headers" :show-file-list="false" accept=".pdf,.PDF">
                            <el-button size="small" class="mb-10" type="primary" color="#33aeeb" style="color: white" @click=" invoiceId = row.id">重新上传</el-button>
                        </el-upload>
                        <el-button size="small" class="mb-10" @click="openPersonnelLabel(row?.id)">设置人员标签</el-button>
                        <span></span>
                        <el-button size="small" class="mb-10" @click="opencontactPerson(row?.id,row)" v-if="!+row?.extendInfo?.contactInfo?.specifyConcatTel">设置联系人</el-button>
                        <el-button type="primary" size="small" class="mb-10" @click="opencontactPerson(row?.id,row)" v-else>查看联系人</el-button>
                    </div>
                </template>
            </vxe-column>
        </vxe-table>
        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" :pageSizes="[50, 100, 150, 500, 1000]" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </div>

    <el-dialog v-model="dialogVisible" title="审核信息" width="500" center>
        <el-form ref="formRef" :model="fromvalue" :rules="rules" label-width="80px">
            <el-form-item label="审核结果" prop="res">
                <el-radio-group v-model="fromvalue.res">
                    <el-radio value="1" border>通过</el-radio>
                    <el-radio value="2" border :class="{ 'reject-radio': fromvalue.res === '2' }">不通过</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="理由" prop="msg" :rules="fromvalue.res === '2' ? rules.msgRequired : rules.msgOptional">
                <el-input v-model="fromvalue.msg" type="textarea" :rows="4" placeholder="请填写不通过的理由" maxlength="50" show-word-limit />
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="signupApprovals()">确认</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="modiFication" title="修改费用金额" width="300" center>
        <div class="d-flex a-c">
            <span class="flex1" style="white-space: nowrap;">参会费用：</span>
            <el-input v-model="(participationFee)" placeholder="请填写费用金额" type="number" />
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="modiFication = false">我再看看</el-button>
                <el-button type="primary" @click="changeEditPrice">确认修改</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="showTransfer" title="系统提示" width="760" center>
        <template #header="{ titleId, titleClass }">
            <div :id="titleId" :class="titleClass" class="titleClass">系统提示</div>
        </template>
        <div class="d-flex a-c flex-cln" style="align-items: flex-start;">
            <div class="f-s-26" style="margin-bottom: 40px;margin-top: 20px;">请选择具体的收款方式:</div>
            <!-- <el-form-item label="" prop="res">
                <el-radio-group v-model="collectiontype">
                    <el-radio size="large" value="3" border :class="{ 'orange-radio': collectiontype === '4' }" style="height: 100px;width: 300px;">对公转账收款</el-radio>
                    <el-radio size="large" value="4" border style="height: 100px;width: 300px;">现场支付</el-radio>
                </el-radio-group>
            </el-form-item> -->
            <div class="d-flex">
                <div class="orange-button" :class="{'orange-active': collectiontype === '3'}" @click="collectiontype = '3'">对公转账收款</div>
                <div class="green-button" :class="{'green-active': collectiontype === '4'}" @click="collectiontype = '4'">现场收款</div>
            </div>
            <div class="f-s-24">确认收款后将直接改为已支付状态，并进入报名审核流程，操作无法撤回请慎重操作。</div>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="showTransfer = false" size="large" class="mr-20">我再看看</el-button>
                <el-button type="primary" @click="confirmTransfer" size="large">确认收款</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="invoicingInformation" title="开票信息" width="600" center>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>名称:</div>
            <div>{{ invoiceData?.headTitle || '-' }}</div>
        </div>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>税号:</div>
            <div>{{ invoiceData?.taxSn || '-'}}</div>
        </div>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>单位地址:</div>
            <div>{{ invoiceData?.address || '-'}}</div>
        </div>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>电话号码:</div>
            <div>{{ invoiceData?.contactPhone || '-'}}</div>
        </div>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>开户银行:</div>
            <div>{{ invoiceData?.bankName || '-'}}</div>
        </div>
        <div class="d-flex a-c j-sb pt-10 pb-10 f-s-16">
            <div>银行账户:</div>
            <div>{{ invoiceData?.bankAccount || '-'}}</div>
        </div>
    </el-dialog>
    <el-dialog v-model="personnelLabel" title="设置人员标签" width="600" center>
        <el-checkbox-group v-model="radioLabel">
            <el-checkbox v-for="(item,index) in signup_tags_type" :key="index" :label="item?.label" :value="item.value" />
        </el-checkbox-group>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="personnelLabel = false">取消</el-button>
                <el-button type="primary" @click="confirmPersonnelLabel()">确认添加</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="contactPerson" title="设置1对1联系人" width="600" center>
        <template #header="{titleId }">
            <div class="my-header">
                <div :id="titleId" class="f-s-20">
                    为
                    <span class="c-primary">{{contactData?.name}}({{ contactData?.contact}})</span>
                    设置1对1联系人
                </div>
            </div>
        </template>
        <el-form :model="contactPersonData">
            <el-form-item prop="contactName" :rules="[{ required: true, message: '请填写指定联系人名称' }]">
                <div class="d-flex a-c">
                    <div class="pr-20">指定联系人名称</div>
                    <el-input v-model="contactPersonData.contactName" style="width: 300px;"></el-input>
                </div>
            </el-form-item>
            <el-form-item prop="contactTel" :rules="phoneRules">
                <div class="d-flex pt-20 a-c">
                    <div class="pr-20">指定联系人电话</div>
                    <el-input v-model.number="contactPersonData.contactTel" style="width: 300px;"></el-input>
                </div>
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="contactPerson = false">取消</el-button>
                <el-button type="primary" @click="confirmContactPerson()" v-if="!+contactData?.extendInfo?.contactInfo?.specifyConcatTel">确认添加</el-button>
                <el-button type="primary" @click="confirmContactPerson()" v-else>确认修改</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="showopenRemark" title="" width="500" @opened="onDialogOpened">
        <template #header>
            <div class="f-s-18 f-w-5">会务备注</div>
        </template>
        <el-input ref="remarkInputRef" type="textarea" v-model="taskRemark" autofocus></el-input>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="showopenRemark = false">取消</el-button>
                <el-button type="primary" @click="cancelRemark()">确认</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog v-model="showcloseSignup" title="" width="500">
        <template #header>
            <div class="f-s-18 f-w-5">系统提示</div>
        </template>
        <div class="f-s-16 c-333">此人待缴费，报名暂未成功，确认要关闭他的报名信息吗？</div>
        <div class="h-10"></div>
        <div class="f-s-12">关闭后在报名截止之前，对方仍可再次进行报名。</div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="showcloseSignup = false">取消</el-button>
                <el-button type="primary" @click="cancelSignup()">确认关闭</el-button>
            </div>
        </template>
    </el-dialog>
    <registrationInfo v-if="showTemporary" v-model:show="showTemporary" :info="temporaryRegistration"></registrationInfo>
</template>
<script setup name="MeetingDetailInfo" lang="ts">
import { exportTrainingMembers, signupApproval, signupCount, trainingMembers,editPrice,confirmSigPublicPay,uploadInvoice,markTags,signupContact,cancelTrainingSignup} from '@/api/training';
import { colNoData } from '@/utils/noData';
import { searchTabs } from '@/views/models';
import { debounce } from 'lodash';
import { onMounted, reactive, ref ,ComponentPublicInstance} from 'vue';
import registrationInfo from './registration-info.vue';
import { AreaCascader } from '@/views/components';
import { globalHeaders } from '@/utils/request';
import { ElLoading,ElMessage } from 'element-plus'
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { cpy_res_status, lm_signup_status_app_show, dm_check_join_type,temp_join_type,dm_pay_status,lm_signup_status_app_query,signup_tags_type} = toRefs<any>(proxy?.useDict('cpy_res_status', 'lm_signup_status_app_show', 'dm_check_join_type','temp_join_type','dm_pay_status',"lm_signup_status_app_query","signup_tags_type"));
// 获取详情
const props = defineProps({
    form: {
        type: Object,
        default: () => ({})
    }
});
const phoneRules = [
  {
    required: true,
    message: '请填写指定联系人电话'
  },
  {
    validator: (rule, value, callback) => {
      // 去除所有点号
      const cleanValue = value ? value.toString().replace(/\./g, '') : '';

      // 验证是否为11位数字
      if (cleanValue && /^\d{11}$/.test(cleanValue)) {
        callback();
      } else {
        callback(new Error('请输入11位数字的电话号码'));
      }
    }
  }
];
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + '/resource/oss/upload'); // 上传文件服务器地址
const rules = reactive({
    res: [
        { required: true, message: '请选择审核结果', trigger: 'blur' }
    ],
    msgRequired: [ // For "不通过" (value="2")
        { required: true, message: '请填写不通过的理由', trigger: 'blur' }
    ],
    msgOptional: [ // For "通过" (value="1")
        { required: false, trigger: 'blur' }
    ]
})
const taskRemark = ref()
const remarkInputRef = ref(null)
const showcloseSignup = ref(false)
const showTemporary = ref(false);
const dialogVisible = ref(false);
const temporaryRegistration = ref();
const modiFication=ref<any>(false)
const showTransfer = ref(false)
const participationFee = ref()
const editPricedata = ref()
const invoicingInformation = ref(false)
const invoiceData = ref()
const invoiceId = ref()
const headers = ref(globalHeaders());
const fromvalue = ref<any>({
    targetId: '',
    msg: ''
})
const collectiontype =ref()
const personnelLabel = ref(false)
const radioLabel = ref()
const radioLabelId = ref()
const contactPerson = ref(false)
const contactId = ref()
const contactData = ref()
const contactPersonData = ref({
    contactName:'',
    contactTel:''
})
const SignupId = ref()
const showopenRemark = ref()
const openPersonnelLabel = (id)=>{
    radioLabel.value = []
    personnelLabel.value = true
    radioLabelId.value = id
}
const confirmPersonnelLabel = async()=>{
    personnelLabel.value = false
    await markTags({id:radioLabelId.value,tags:radioLabel.value.join(',')})
    radioLabel.value = []
    getList()
}
const opencontactPerson = (id,data)=>{
    contactId.value = id
    contactData.value= data
    contactPerson.value = true
    if(data?.extendInfo?.contactInfo?.specifyContact && data?.extendInfo?.contactInfo?.specifyConcatTel){
        contactPersonData.value.contactName = data.extendInfo.contactInfo.specifyContact
        contactPersonData.value.contactTel = data.extendInfo.contactInfo.specifyConcatTel
    }else{
        contactPersonData.value.contactName = ''
        contactPersonData.value.contactTel = ''
    }

}
const confirmContactPerson = async()=>{
    await signupContact({id:contactId.value,contactInfo:{specifyConcatTel:contactPersonData.value?.contactTel,specifyContact:contactPersonData.value?.contactName}})
    contactPerson.value = false
    getList()
}
const checkInvoiceData = (row)=>{
    invoicingInformation.value = true
    invoiceData.value = row
}
const checkRegostrationInfo = (row) => {
    temporaryRegistration.value = row;
    showTemporary.value = true;
};
const openDialog = (row) => {
    fromvalue.value.targetId = row.id; // 保存当前行数据
    fromvalue.value.msg = ''
    dialogVisible.value = true;
};
const query = useRoute().query;

const queryParams = ref<any>({
    pageNum: 1,
    pageSize: 50,
    trainingId: query?.id || '',
    payStatus:'',
    payType:'',
    invoiceStatus:''
});
const loading = ref(false);
const total = ref(0);
const list = ref<any>([]);
const tabs = ref([]);
const formRef = ref()
const getExpertPersonCount = async () => {
    const res = await signupCount(query?.id);
    if (res?.code === 200) {
        tabs.value = res.data;
    }
};
const getList = async () => {
    loading.value = true;
    const res = await trainingMembers(queryParams.value);
    if (!res || res.code !== 200) return;
    list.value = res.rows;
    total.value = res.total;
    loading.value = false;
};
const signupApprovals = async () => {
    await formRef.value.validate()
    const res = await signupApproval(fromvalue.value);
    dialogVisible.value = false;
    handleQuery();
};
const handleQuery = () => {
    queryParams.value.pageNum = 1;
    getList();
    getExpertPersonCount()
};
const queryFormRef = ref<ElFormInstance>();
const resetQuery = () => {
    queryFormRef.value?.resetFields();
    handleQuery();
};
const exportSearch = debounce(() => {
    const params = {
        ...queryParams.value
    };
    delete params.pageNum;
    delete params.pageSize;
    exportTrainingMembers(params);
}, 500);
// 打开修改金额的按钮
const openModification = (row)=>{
    modiFication.value = true;
    participationFee.value = row.joinFee
    editPricedata.value = row
}
const openTransfer = (row)=>{
    showTransfer.value = true
    editPricedata.value = row
}
const confirmTransfer = async()=>{
    await confirmSigPublicPay(editPricedata.value?.id,collectiontype.value)
    showTransfer.value = false
    getList();
}
const changeEditPrice = async ()=>{
    await editPrice({
        id:editPricedata.value?.id,
        price:participationFee.value
    });
    modiFication.value = false
    getList();
}
const handleSuccess = async (res, uploadFile) => {
    const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        background: 'rgba(0, 0, 0, 0.7)',
    })
    const data = await uploadInvoice({
        id: invoiceId.value,
        invoiceUrl: {
            fileName: res.data.fileName,
            url: res.data.url,
            fileSize: uploadFile.raw.size
        }
    })
    loading.close()
    if (data.code == 200) {
        ElMessage({
            message: '发票上传成功',
            type: 'success',
        })
    }else{
        ElMessage.error('发票上传失败')
    }
    getList();
}
const openSignup = (row)=>{
    showcloseSignup.value = true
    SignupId.value = row?.id
}
const cancelSignup = async()=>{
  const res =  await cancelTrainingSignup(SignupId.value)
  showcloseSignup.value = false
  SignupId.value = ''
  if(res.code ==200){
    ElMessage({
            message: '关闭报名成功',
            type: 'success',
        })
  }
    getList();
}
const openRemark = (row)=>{
    showopenRemark.value = true
    SignupId.value = row?.id
    taskRemark.value = row?.extendInfo?.remark
}
const cancelRemark = async()=>{
  const res =  await markTags({id:SignupId.value,remark:taskRemark.value})
  showopenRemark.value = false
  SignupId.value = ''
    getList();
}
const onDialogOpened = () => {
  nextTick(() => {
    const inputInstance = remarkInputRef.value
    if (inputInstance) {
      // 获取原生 textarea 元素
      const textarea = inputInstance.textarea // Element Plus el-input 暴露的 textarea 引用

      // 聚焦
      textarea?.focus()

      // 将光标定位到文本末尾
      const len = textarea.value.length
      textarea?.setSelectionRange(len, len)
    }
  })
}
const openPDF = (url)=>{
    window.open(url)
}
onMounted(() => {
    getList();
    getExpertPersonCount();
});
</script>
<style scoped lang="scss">
.tabs-item {
    margin-right: 20px;
    padding: 8px 20px;
    font-size: 14px;
    border-color: #d7d7d7;
    border-style: solid;
    border-width: 1px 1px 0 1px;
    cursor: pointer;
    user-select: none;

    &.checked {
        color: #fff;
        border-color: var(--el-color-primary);
        background-color: var(--el-color-primary);
    }
}

.border-botttom {
    border-bottom: 1px solid #d7d7d7;
}

.reject-radio :deep(.el-radio__label) {
    color: #F56C6C;
}
.orange-radio :deep(.el-radio__label) {
    color: orange;
}
.reject-radio :deep(.el-radio__inner) {
    border-color: #F56C6C;
    background: #F56C6C;
}

.reject-radio :deep(.el-radio__border) {
    border-color: #F56C6C;
}

:deep(.reject-radio.el-radio.is-bordered.is-checked) {
    border-color: #F56C6C !important;
}
.single{
    position: absolute;
    top: -20px;
    right: 30px;
    width: 200px;
    left: 70px;
}
.orange-button{
    border:1px solid #d7d7d7;
    height: 100px;
    width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 36px;
    margin-right: 40px;
    margin-bottom: 40px;
    font-weight: 600;
}
.orange-button:hover{
    color: white;
    background-color: orange;
    border: 1px solid orange;
    opacity: 0.5;
}
.green-button:hover{
    color: white;
    background-color: green;
    border: 1px solid green;
    opacity: 0.5;
}
.green-button{
    border:1px solid #d7d7d7;
    height: 100px;
    width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 36px;
    margin-right: 40px;
    margin-bottom: 40px;
    font-weight: 600;
}

.orange-active{
    color: white;
    background-color: orange;
    border: 1px solid orange;
}
.green-active{
    color: white;
    background-color: green;
    border: 1px solid green;
}
.titleClass{
    font-size: 30px !important;
}
</style>
