<template>
  <a-spin :spinning="confirmLoading">
    <JFormContainer :disabled="disabled">
      <template #detail>
        <a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol"
          name="OrgApplyInfoForm">

          <a-row class="card-class">
            <a-col :span="12">
              <a-row>
                <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
                  <SectionDivider :title="'营业执照'" />
                </a-col>
                <a-col :span="24">
                  <a-form-item label="营业执照" v-bind="validateInfos.comBusinessLicense"
                    id="OrgApplyInfoForm-comBusinessLicense" name="comBusinessLicense">
                    <JImageUpload :fileMax="1" v-model:value="formData.comBusinessLicense" :disabled="true">
                    </JImageUpload>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="机构名称" v-bind="validateInfos.comName" id="OrgApplyInfoForm-comName" name="comName">
                    <a-input v-model:value="formData.comName" placeholder="请输入机构名称" disabled allow-clear></a-input>
                    <!-- {{ formData.comName }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="信用代码" v-bind="validateInfos.comCreditCode" id="OrgApplyInfoForm-comCreditCode"
                    name="comCreditCode">
                    <a-input v-model:value="formData.comCreditCode" placeholder="请输入信用代码" disabled
                      allow-clear></a-input>
                    <!-- {{ formData.comCreditCode }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="机构法人" v-bind="validateInfos.comLegalPerson" id="OrgApplyInfoForm-comLegalPerson"
                    name="comLegalPerson">
                    <a-input v-model:value="formData.comLegalPerson" placeholder="请输入机构法人" disabled
                      allow-clear></a-input>
                    <!-- {{ formData.comLegalPerson }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="注册地址" v-bind="validateInfos.comRegisterAddress"
                    id="OrgApplyInfoForm-comRegisterAddress" name="comRegisterAddress">
                    <a-textarea :autosize="{ minRows: 1 }" maxlength="50" disabled
                      v-model:value="formData.comRegisterAddress" allow-clear></a-textarea>
                    <!-- {{ formData.comRegisterAddress }} -->
                  </a-form-item>
                </a-col>

              </a-row>
            </a-col>
            <a-col :span="12">
              <a-row>
                <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
                  <SectionDivider :title="'机构信息'" />
                </a-col>
                <a-col :span="24">
                  <a-row>
                    <a-col :span="16">
                      <a-col :span="24">
                        <a-form-item label="机构位置" v-bind="validateInfos.cityViewValue" id="OrgApplyInfoForm-cityViewValue"
                          name="cityViewValue" :labelCol="labelCol4" :wrapperCol="wrapperCol4">
                          <a-textarea :autosize="{ minRows: 1 }" maxlength="50" disabled v-model:value="cityViewValue"
                            allow-clear></a-textarea>
                        </a-form-item>
                      </a-col>
                      <a-col :span="24">
                        <a-form-item label="机构负责人" v-bind="validateInfos.orgLeader" id="OrgApplyInfoForm-orgLeader"
                          name="orgLeader" :labelCol="labelCol4" :wrapperCol="wrapperCol4">
                          <a-input v-model:value="formData.orgLeader" placeholder="请输入机构负责人" disabled allow-clear></a-input>
                        </a-form-item>
                      </a-col>
                      <a-col :span="24">
                        <a-form-item label="负责人电话" v-bind="validateInfos.orgLeaderPhone" id="OrgApplyInfoForm-orgLeaderPhone"
                          name="orgLeaderPhone" :labelCol="labelCol4" :wrapperCol="wrapperCol4">
                          <a-input v-model:value="formData.orgLeaderPhone" disabled
                            allow-clear></a-input>
                        </a-form-item>
                      </a-col>
                    </a-col>
                    <a-col :span="8">
                      <a-col :span="24">
                      <a-form-item label="" v-bind="validateInfos.headPath" id="OrgApplyInfoForm-headPath"
                        name="headPath" style="margin-left: 40px;">
                        <JImageUpload :fileMax="1" text="无" v-model:value="formData.headPath" :disabled="true"></JImageUpload>
                      </a-form-item>
                    </a-col>
                    </a-col>
                  </a-row>
                </a-col>
                
                <a-col :span="24">
                  <a-form-item label="房屋性质" v-bind="validateInfos.orgPropertyType" id="OrgApplyInfoForm-orgPropertyType"
                    name="orgPropertyType">
                    <a-input v-model:value="formData.orgPropertyType" disabled
                      allow-clear></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="建筑面积(㎡)" v-bind="validateInfos.orgBuildingArea"
                    id="OrgApplyInfoForm-orgBuildingArea" name="orgBuildingArea">
                    <a-input v-model:value="formData.orgBuildingArea" disabled
                      allow-clear></a-input>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="详细地址" v-bind="validateInfos.orgAddress" id="OrgApplyInfoForm-orgAddress"
                    name="orgAddress">
                    <a-input v-model:value="formData.orgAddress" disabled allow-clear></a-input>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>

          <a-row class="card-class">
            <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
              <SectionDivider :title="'申请人'" />
            </a-col>
            <a-col :span="12">
              <a-row>
                <a-col :span="24">
                  <a-form-item label="人像面" v-bind="validateInfos.cardZmPath" id="OrgApplyInfoForm-cardZmPath"
                    name="cardZmPath">
                    <JImageUpload :fileMax="1" v-model:value="formData.cardZmPath" :disabled="true"></JImageUpload>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="姓名" v-bind="validateInfos.name" id="OrgApplyInfoForm-name" name="name">
                    <a-input v-model:value="formData.name" placeholder="请输入姓名" disabled allow-clear></a-input>
                    <!-- {{ formData.name }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="性别" v-bind="validateInfos.sex" id="OrgApplyInfoForm-sex" name="sex">
                    <a-input v-model:value="formData.sex" placeholder="请输入性别" disabled allow-clear></a-input>
                    <!-- {{ formData.sex }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="民族" v-bind="validateInfos.national" id="OrgApplyInfoForm-national"
                    name="national">
                    <a-input v-model:value="formData.national" placeholder="请输入民族" disabled allow-clear></a-input>
                    <!-- {{ formData.national }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="出生日期" v-bind="validateInfos.birthDate" id="OrgApplyInfoForm-birthDate"
                    name="birthDate">
                    <a-date-picker placeholder="请选择出生日期" v-model:value="formData.birthDate" disabled
                      value-format="YYYY-MM-DD" style="width: 100%" suffix-icon="" />
                    <!-- <a-input placeholder="请选择出生日期" v-model:value="formData.birthDate" disabled
                       style="width: 100%"></a-input> -->
                    <!-- {{ formData.birthDate ? formData.birthDate.substring(0, 10) : "" }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="身份证号" v-bind="validateInfos.idCard" id="OrgApplyInfoForm-idCard" name="idCard">
                    <a-input v-model:value="formData.idCard" placeholder="请输入身份证号" disabled allow-clear></a-input>
                    <!-- {{ formData.idCard }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="住址" v-bind="validateInfos.idCardAddress" id="OrgApplyInfoForm-idCardAddress"
                    name="idCardAddress">
                    <a-textarea :autosize="{ minRows: 1 }" maxlength="50" disabled
                      v-model:value="formData.idCardAddress" allow-clear></a-textarea>
                    <!-- {{ formData.idCardAddress }} -->
                  </a-form-item>
                </a-col>
              </a-row>
            </a-col>
            <a-col :span="12">
              <a-row>
                <a-col :span="24">
                  <a-form-item label="国徽面" v-bind="validateInfos.cardFmPath" id="OrgApplyInfoForm-cardFmPath"
                    name="cardFmPath">
                    <JImageUpload :fileMax="1" v-model:value="formData.cardFmPath" :disabled="true"></JImageUpload>
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="有效开始日期" v-bind="validateInfos.startTime" id="OrgApplyInfoForm-startTime"
                    name="startTime">
                    <a-date-picker placeholder="请选择有效开始日期" v-model:value="formData.startTime" disabled
                      value-format="YYYY-MM-DD" style="width: 100%" suffix-icon="" />
                    <!-- {{ formData.startTime ? formData.startTime.substring(0, 10) : "" }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="有效结束日期" v-bind="validateInfos.endTime" id="OrgApplyInfoForm-endTime"
                    name="endTime">
                    <a-input
                      v-if="formData.endTime == '9999.12.31' || formData.endTime == '9999-12-31' || formData.endTime == '9999-12-31 00:00:00'"
                      :value="'长期'" suffix-icon="" disabled></a-input>
                    <a-date-picker v-else v-model:value="formData.endTime" disabled value-format="YYYY-MM-DD"
                      style="width: 100%" suffix-icon="" />
                    <!-- {{ formData.endTime
                      ? (formData.endTime.substring(0, 10) == '9999-12-31' ? '长期' : formData.endTime.substring(0, 10))
                      : "" }} -->
                  </a-form-item>
                </a-col>
                <a-col :span="24">
                  <a-form-item label="签发机关" v-bind="validateInfos.issuingAuthority"
                    id="OrgApplyInfoForm-issuingAuthority" name="issuingAuthority">
                    <a-input v-model:value="formData.issuingAuthority" placeholder="请输入签发机关" disabled
                      allow-clear></a-input>
                    <!-- {{ formData.issuingAuthority }} -->
                  </a-form-item>
                </a-col>
                
              </a-row>
            </a-col>
          </a-row>
          <a-row class="card-class" v-show="formData.izHistory == 'Y'">
            <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
              <SectionDivider :title="'审核信息'" />
            </a-col>
            <a-col :span="12">
              <a-form-item label="审核状态" v-bind="validateInfos.status" id="OrgApplyInfoForm-status" name="status">
                <a-select v-model:value="formData.status" style="width: 200px" placeholder="请选择审核状态"
                  :disabled="sfsh != '1'">
                  <a-select-option value="2">审核通过</a-select-option>
                  <a-select-option value="3">审核驳回</a-select-option>
                  <a-select-option value="5">审核驳回</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12" v-show="formData.status == '3' || formData.status == '5'">
              <a-form-item label="驳回原因" v-bind="validateInfos.content" id="OrgApplyInfoForm-content" name="content">
                <a-textarea :autosize="{ minRows: 3 }" maxlength="50" show-count v-model:value="formData.content"
                  :disabled="formData.status != '3'" allow-clear placeholder="请输入驳回原因"></a-textarea>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row class="card-class" v-show="!disabled">
            <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
              <SectionDivider :title="'加盟审核'" />
            </a-col>
            <a-col :span="12">
              <a-form-item label="审核状态" v-bind="validateInfos.status" id="OrgApplyInfoForm-status" name="status">
                <a-select v-model:value="formData.status" style="width: 200px" placeholder="请选择审核状态"
                  :disabled="sfsh != '1'">
                  <a-select-option value="0" v-if="disabled">历史数据</a-select-option>
                  <a-select-option value="1" v-if="disabled">待审核</a-select-option>
                  <a-select-option value="2">审核通过</a-select-option>
                  <a-select-option value="3">审核驳回</a-select-option>
                  <a-select-option value="4" v-if="disabled">待审核</a-select-option>
                  <a-select-option value="5" v-if="disabled">审核驳回</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12" v-show="formData.status == '3' || formData.content">
              <a-form-item label="驳回原因" v-bind="validateInfos.content" id="OrgApplyInfoForm-content" name="content">
                <a-textarea :autosize="{ minRows: 3 }" maxlength="50" show-count v-model:value="formData.content"
                  :disabled="formData.status != '3'" allow-clear placeholder="请输入驳回原因"></a-textarea>
              </a-form-item>
            </a-col>
            <a-col :span="12" v-if="formData.auditBy_dictText">
              <a-form-item label="审核人" v-bind="validateInfos.auditBy_dictText" id="OrgApplyInfoForm-auditBy_dictText">
                <a-input v-model:value="formData.auditBy_dictText" disabled allow-clear></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12" v-if="formData.auditBy">
              <a-form-item label="审核时间" v-bind="validateInfos.auditTime" id="OrgApplyInfoForm-auditTime">
                <a-date-picker placeholder="请选择有效开始日期" v-model:value="formData.auditTime" showTime disabled
                  value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" allow-clear />
                <!-- {{ formData.auditTime }} -->
              </a-form-item>
            </a-col>
            <a-col :span="12" v-show="formData.contract">
              <a-form-item label="加盟合同" v-bind="validateInfos.contract" id="OrgApplyInfoForm-contract">
                <JUpload v-model:value="formData.contract" :maxCount="1" :buttonVisible="false" disabled="true"
                  fileType="pdf"></JUpload>
              </a-form-item>
            </a-col>
            <a-col :span="12" v-if="formData.contractNote">
              <a-form-item label="备注信息" v-bind="validateInfos.contractNote" id="OrgApplyInfoForm-contractNote">
                <a-textarea v-model:value="formData.contractNote" :autosize="{ minRows: 1 }" maxlength="50"
                  placeholder="请输入备注信息"></a-textarea>
                <!-- {{ formData.contractNote }} -->
              </a-form-item>
            </a-col>
          </a-row>
          <a-row v-show="!!formData.workOrderStatus && formData.workOrderStatus != '0' && !izApplyAudit && formData.izHistory == 'N'"
            class="card-class">
            <a-col :span="24" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
              <SectionDivider :title="'运维回执'" />
            </a-col>
            <a-col :span="12">
              <a-form-item label="运维状态">
                <a-input :value="orgStatusText" disabled allow-clear></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="反馈人">
                <a-input v-model:value="formData.handleBy" disabled allow-clear></a-input>
              </a-form-item>
            </a-col>
            <!-- <a-col :span="12">
              <a-form-item label="反馈附件">
                <JUpload v-model:value="formData.replyFile" :maxCount="1" :buttonVisible="false" disabled></JUpload>
              </a-form-item>
            </a-col> -->
            <a-col :span="12">
              <a-form-item label="反馈时间">
                <a-date-picker v-model:value="formData.replyTime" disabled value-format="YYYY-MM-DD" style="width: 100%"
                  placeholder="" allow-clear />
              </a-form-item>
            </a-col>
          </a-row>
          <a-row v-show="!!formData.netUrl" class="card-class">
            <a-col :span="22" style="border-bottom: 2px solid #f7f7f7; margin-bottom: 14px;">
              <SectionDivider :title="'平台信息'" />
            </a-col>
            <a-col :span="2" style="margin-bottom: 14px; ">
              <span @click="handleCopyPlatInfo" class="noDisabled aclk">
                <!-- <a-button class="noDisabled" type="primary" :disabled="false"> -->
                复 制
                <!-- </a-button> -->
              </span>
            </a-col>
            <a-col :span="12">
              <a-form-item label="访问地址">
                <a-input v-model:value="formData.netUrl" disabled allow-clear></a-input>
                <!-- {{ formData.netUrl }} -->
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="账号">
                <a-input v-model:value="formData.accountNo" disabled allow-clear></a-input>
                <!-- {{ formData.accountNo }} -->
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="密码">
                <a-input v-model:value="formData.passwordText" disabled allow-clear></a-input>
                <!-- {{ formData.passwordText }} -->
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </template>
    </JFormContainer>
    <!-- <a-col :span="24" v-if="!!formData.orgCoordinateLa && !!formData.orgCoordinateLo">
      <TencentMap :latitude="formData.orgCoordinateLa" :longitude="formData.orgCoordinateLo" />
    </a-col> -->
  </a-spin>
</template>

<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { getValueType } from '/@/utils';
import { applyAudit } from '../OrgApplyInfo.api';
import { Form } from 'ant-design-vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import TencentMap from '/@/components/TencentMap/TencentMap.vue';
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
import { t } from '/@/hooks/web/useI18n';
import { encryptByBase64 } from "@/utils/cipher";
import { useGlobSetting } from '/@/hooks/setting';
const glob = useGlobSetting();

const cityViewValue = ref('')
const props = defineProps({
  formDisabled: { type: Boolean, default: false },
  formData: { type: Object, default: () => ({}) },
  formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
  id: '',
  pkId: '',
  openId: '',
  wechatName: '',
  tel: '',
  status: '',
  orgStatus: '',
  content: '',
  createTime: '',
  updateTime: '',
  izEntry: '',
  name: '',
  izHistory: '',
  sex: '',
  national: '',
  birthDate: '',
  idCardAddress: '',
  idCard: '',
  issuingAuthority: '',
  startTime: '',
  endTime: '',
  cardZmPath: '',
  cardFmPath: '',
  comBusinessLicense: '',
  comName: '',
  comRegisterAddress: '',
  comCreditCode: '',
  comLegalPerson: '',
  orgAddress: '',
  orgCoordinateLo: '',
  orgCoordinateLa: '',
  orgLeader: '',
  orgLeaderPhone: '',
  orgBuildingNumber: '',
  orgPropertyType: '',
  orgBuildingArea: undefined,
  orgProvince: '',
  orgCity: '',
  orgDistrict: '',
  orgProvince_dictText: '',
  orgCity_dictText: '',
  orgDistrict_dictText: '',
  franchiseTime: null,
  contract: null,
  contractNote: null,
  replyContent: '',
  replyFile: '',
  replyTime: '',
  handleBy: '',
  workOrderStatus: '',
  workOrderStatus_dictText: '',
  auditBy: '',
  auditTime: '',
  auditBy_dictText: '',
  netUrl: '',
  accountNo: '',
  passwordText: '',
  headPath: '',
});
const tempNullVal = ref('');
const sfsh = ref<string>('0');
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 8 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const labelCol4 = ref<any>({ xs: { span: 24 }, sm: { span: 12 } });
const wrapperCol4 = ref<any>({ xs: { span: 24 }, sm: { span: 12 } });
const confirmLoading = ref<boolean>(false);
//表单验证
const validatorRules = reactive({
  status: [{ required: true, message: '请选择审核结果!' },],
  content: [
    {
      validator: async (_rule, value) => {
        if (formData.status === '3' && !value) {
          return Promise.reject('请输入驳回原因!');
        }
        // return Promise.resolve();
      },
    },
  ],
});
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });

// 表单禁用
const disabled = computed(() => {
  if (props.formBpm === true) {
    if (props.formData.disabled === false) {
      return false;
    } else {
      return true;
    }
  }
  return props.formDisabled;
});

const orgStatusMap = {
  '3': '待确认',
  '4': '平台搭建中',
  '5': '搭建完成',
};

// 计算属性转换状态值
const orgStatusText = computed(() => {
  const status = formData.orgStatus?.toString();
  return orgStatusMap[status] || status || '-';
});

/**
 * 预览
 */
function handleView(record) {
  if (record && record.url) {
    console.log('glob.onlineUrl', glob.viewUrl);
    let url = encodeURIComponent(encryptByBase64(record.url));
    let previewUrl = `${glob.viewUrl}?url=` + url;
    window.open(previewUrl, '_blank');
  }
}
/**
 * 新增
 */
function add() {
  edit({});
}
const izApplyAudit = ref(true)
/**
 * 编辑
 */
function edit(record) {
  console.log("🌊 ~ edit ~ record:", record)
  if (record.optType == 'rz' && record.status == '1') {
    izApplyAudit.value = true;
  } else {
    izApplyAudit.value = false;
  }
  nextTick(() => {
    resetFields();
    let tmpData = {};
    Object.keys(formData).forEach((key) => {
      if (record.hasOwnProperty(key)) {
        tmpData[key] = record[key]
      }
    })
    var lsbl = tmpData.status;
    if (!props.formData.disabled && tmpData.status == 1) {
      tmpData.status = null
    }
    cityViewValue.value = record.orgProvince_dictText
      + (!!record.orgCity_dictText ? record.orgCity_dictText : '')
      + (!!record.orgDistrict_dictText ? record.orgDistrict_dictText : '')
      if(!tmpData.headPath){
        if(tmpData.sex == '女'){
          tmpData.headPath = 'https://www.focusnu.com/media/directive/index/nv.png';
        }else{
          tmpData.headPath = 'https://www.focusnu.com/media/directive/index/nan.png';
        }
      }
    //赋值
    Object.assign(formData, tmpData);
    if (lsbl == '1') {
      sfsh.value = '1'
    } else {
      sfsh.value = '0'
    }
  });
}

/**
 * 提交数据
 */
async function submitForm() {
  try {
    // 触发表单验证
    await validate();
  } catch ({ errorFields }) {
    if (errorFields) {
      const firstField = errorFields[0];
      if (firstField) {
        // formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
          // 延迟滚动到表单底部，显示完整的错误区域
        // const formElement = formRef.value.$el;
        // if (formElement) {
        //   formElement.scrollIntoView({ 
        //     behavior: 'smooth', 
        //     block: 'end'  // 滚动到表单底部
        //   });
        // }
      }
    }
    return Promise.reject(errorFields);
  }
  confirmLoading.value = true;
  const isUpdate = ref<boolean>(false);
  //时间格式化
  let model = formData;
  if (model.id) {
    isUpdate.value = true;
  }
  //循环数据
  for (let data in model) {
    //如果该数据是数组并且是字符串类型
    if (model[data] instanceof Array) {
      let valueType = getValueType(formRef.value.getProps, data);
      //如果是字符串类型的需要变成以逗号分割的字符串
      if (valueType === 'string') {
        model[data] = model[data].join(',');
      }
    }
  }
  await applyAudit(model, isUpdate.value)
    .then((res) => {
      if (res.success) {
        createMessage.success(res.message);
        emit('ok');
      } else {
        createMessage.warning(res.message);
      }
    })
    .finally(() => {
      confirmLoading.value = false;
    });
}

function handleCopyPlatInfo() {
  const { netUrl, accountNo, passwordText } = formData;
  let copyText = '';

  if (netUrl) copyText += `访问地址：${netUrl}\n`;
  if (accountNo) copyText += `账号：${accountNo}\n`;
  if (passwordText) copyText += `密码：${passwordText}\n`;

  navigator.clipboard
    .writeText(copyText.trim())
    .then(() => {
      createMessage.success('已复制平台信息');
    })
}

defineExpose({
  add,
  edit,
  submitForm,
});
</script>

<style lang="less" scoped>
.antd-modal-form {
  padding: 14px;
}

.card-class {
  padding-top: 24px;
  padding-bottom: 24px;
  padding-left: 14px;
  padding-right: 14px;
  // background-color: rgba(255, 255, 255, 0.9);
  background-color: #fcfdff;
  border-radius: 10px;
  // box-shadow: rgba(0, 0, 0, 0.1) 0px 2px 12px;
  margin-bottom: 14px;

}

/* 1. 基础样式：包含定位和裁剪，防止布局错乱 */
.aclk {
  background: linear-gradient(to right, #1ea0fa, #017de9);
  padding: 4px 15px;
  border-radius: 8px;
  font-size: 14px;
  height: 32px;
  color: #fff !important;

  /* 【关键修复】建立定位上下文，防止伪元素错位导致上方空白 */
  position: relative;

  /* 【关键修复】隐藏溢出部分，防止动画撑大组件宽度 */
  overflow: hidden;

  /* 确保显示模式正确，避免行高问题 */
  display: inline-block;
  line-height: 24px;
  /* 根据高度微调，让文字垂直居中 */
  text-decoration: none;
  border: none;
  cursor: pointer;

  /* 可选：防止点击时的默认高亮背景干扰 */
  -webkit-tap-highlight-color: transparent;
}

/* 2. 伪元素：定义那道白光 */
.aclk::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  /* 初始状态：藏在按钮左侧外面 */

  /* 光带宽度：设为 50%~100% 均可，这里用 100% 配合动画终点 */
  width: 100%;
  height: 100%;

  /* 渐变效果：中间亮，两头透明 */
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.4) 50%,
      transparent 100%);

  /* 倾斜角度：-25deg 会让光看起来更有速度感，如果不想要倾斜改为 0deg */
  transform: skewX(0deg);

  /* 确保光在文字下面，虽然背景是透明的，但这是个好习惯 */
  z-index: 1;

  /* 初始不执行动画，等待 hover */
}

/* 3. 悬停触发：执行动画 */
.aclk:hover::before {
  animation: light-sweep 1.15s ease-in-out forwards;
}

/* 4. 关键帧定义 */
@keyframes light-sweep {
  to {
    left: 100%;
  }
}

.noDisabled {
  pointer-events: auto !important;
  cursor: pointer !important;

  *:not(.ant-select-selection-placeholder) {
    color: #fff !important;
  }
}
</style>
