<script setup>
import useUserStore from "@/stores/modules/user";
import {FlowWarningEnum} from '@/enums/flowWarningEnums'
import {getDetail} from "@/api/report/index";
import {getReportFlow} from "@/api/report/flow";
import {
  addOrUpData,
  getWarningDetail,
  getWarningRecord,
  getWarningAudit,
  getWarningInformList,
  auditEndWarningApi
} from '@/api/warning/index'
import useCatchStore from "@/stores/modules/catch";
import {listPolice} from "@/api/system/police";
import {timeFormat} from "@/utils/util";
import {useRoute, useRouter} from "vue-router";
import {AuditRuleEnums} from "@/enums/AuditRuleEnums.ts"
import useTabsStore from "@/stores/modules/multipleTabs";
import reportAudit from '@/components/reportAudit/start.vue';
import feedback from "@/utils/feedback";
import reportAuditEnd from '@/components/reportAudit/end.vue';
import finishDistrbute from '@/components/reportAudit/finishDistrbute.vue'
import warningDetail from './components/detail.vue'
import dayjs from "dayjs";


const warningCode = ref("warning")
const dialog = ref(false)
const endDialog = ref(false)
const finishDialog = ref(false)
const catchStore = useCatchStore();
const dict = catchStore.getDicts(["procurementMethod"]);
const userStore = useUserStore();
const reportFlowDialog = ref(false)
const reportFlowLoading = ref(false)
const isAudit = ref(false)
const reportFlowTable = ref([])
const loading = ref(false)
const rejectDialog = ref(false)
const node = ref()
const formData = ref({
  reportProject: {},
  record: {
    warningSupervision: null,
    supervisionTime: null,
    evidenceOffer: null
  },
  contents: []
})
const formDataRef = ref()

const isDisabled = ref(true)
const isEndData = ref(false)
const activeName = ref(false)
const route = useRoute()
const router = useRouter();
const rules = ref({
  // evidenceOffer:[ {required: true, message: '请选择证据提供者', trigger: 'blur'}],
  supervisionTime: [{required: true, message: '请选择预警监督日期 ', trigger: 'blur'}],
  warningSupervision: [{required: true, message: '请选择预警监督人员', trigger: 'blur'}],
})

const tableRowClassName = ({row}) => {
  if (row.remark) {
    return 'warning-row'
  }
  return ''
}
//获取用户信息
const getReportDetailFun = async (id) => {
  const res = await getDetail({id: id})
  isEndData.value = res.project.reportType === '结算项目'
  formData.value.reportProject = res.project;
  //获取最新审计
  const data = await getWarningRecord(id);
  if (data) {
    await getWarningDetailFun(data.id)
  } else {
    //获取历史记录
    console.log("==============")
    console.log(res.project)
    res.project.warningState == "1" ? recordDisplay.value = true : recordDisplay.value = false
  }
}

//根据输入值获取信息
const inputGetList = (val) => {
  query.value.name = val;
  getPoliceList()
}
//审核人
const query = ref({
  current: 1,
  departBranch: false
});
let polices = ref([])

function getPoliceList() {
  listPolice(query.value).then((data) => {
    polices.value = data.records;
  });
}

getPoliceList()

const detailProps = ref({})

const DetailReport = () => {
  //判断是否为报审人
  detailProps.value = {
    isEnd: formData.value.reportProject.reportType === "项目控制价",
    id: formData.value.reportProject.id,
    backPath: '/entryWindow',
    node: formData.value.reportProject.node
  }
  detailShow.value = true;
}

const closeDialogFun = () => {
  dialog.value = false
  rejectDialog.value = false
}

const closeAuditDialogFun = () => {
  dialog.value = false
  rejectDialog.value = false
  finishDialog.value = false
  // isAudit.value=false
  endDialog.value = false;
}
//通知报审人
const warningInformFun = async () => {
  await formDataRef.value.validate();
  loading.value = true;
  formData.value.isSubmit = 1;
  formData.value.code = "inform";
  formData.value.node = "inform";
  node.value = "inform";
  const res = await addOrUpData(formData.value)
  formData.value = res;
  warningCode.value = "inform";
  feedback.msgSuccess("保存成功")
  delete formData.value.isSubmit;
  delete formData.value.code;
  loading.value = false;
  dialog.value = true
}
//结束预警
const auditEndWarning = async () => {
  await formDataRef.value.validate();
  loading.value = true;
  const body = {
    reportId: formData.value.reportProject.id
  }
  const res = await auditEndWarningApi(body)
  feedback.msgSuccess("操作成功")
  router.push({
    path: "/warning",
    query: {
      refresh: Date.now()
    }
  })
  loading.value = false;
}

const closePage = () => {
  if (route.query.isEdit) {
    //回到列表页
    router.push({path: route.query.backPath})
  } else {
    router.push({path: "/work", query: {"load": true}})
  }
}
//保存
const addOrUpDataFun = async () => {
  try {
    await formDataRef.value.validate();
    loading.value = true;
    formData.value.code = "warning";
    const res = await addOrUpData(formData.value)
    formData.value = res;
    feedback.msgSuccess("保存成功")
    delete formData.value.code;
    loading.value = false;
  } catch (err) {
    // ② 校验不通过的提示
    feedback.msgError("请完善必填项后再提交");

    // 可选：控制台看看是哪个字段没过
    console.warn("表单校验失败：", err);
  } finally {
    loading.value = false;
  }

}

//提交至领导
async function SubmitFun() {
  await formDataRef.value.validate();
  await feedback.confirm("是否提交审计数据？");
  loading.value = true;
  formData.value.isSubmit = 1;
  formData.value.code = "warning";
  formData.value.node = "leader";
  const res = await addOrUpData(formData.value)
  formData.value = res;
  delete formData.value.isSubmit;
  delete formData.value.code;
  loading.value = false;
  dialog.value = true
}

//获取审计信息
const getWarningDetailFun = async (warningId) => {
  loading.value = true;
  const res = await getWarningDetail(warningId);
  formData.value.reportProject = res.reportProject
  formData.value.record = res.record;
  formData.value.contents = res.contents;
  //已提交的数据
  if ((formData.value.record.node && formData.value.record.node != 'stat')
      || (formData.value.record.informNode && formData.value.record.informNode != 'state' && formData.value.record.informNode != 'end')
  ) {
    recordDisplay.value = true
  }
  console.log('recordDisplay', recordDisplay.value)
  //如果为审核页面
  if (route.query.isAudit) {
    isAudit.value = true
    isDisabled.value = true
    switch (formData.value.record.node) {
      case "leader":
        node.value = "end";
        break;
    }
  }
  ensureSupervisionTime();
  loading.value = false
}
const rejectFun = () => {
  rejectDialog.value = true;
}

const passFun = () => {
  finishDialog.value = true;
}

const passInformFun = () => {
  endDialog.value = true;
}
const FinishSubmitFeedback = () => {
  finishDialog.value = false
  closePage()
}

const endSubmitFeedback = () => {
  endDialog.value = false;
  closePage()
}

const FinishCloseAuditDialogFun = () => {
  finishDialog.value = false
  closePage()
}
//审批通过
const submitFeedback = () => {
  dialog.value = false
  closePage()
}
//审批记录
async function getAuditTableFun() {
  //打开审批记录
  reportFlowDialog.value = true
  reportFlowLoading.value = true
  const res = await getReportFlow({id: formData.value.record.id, code: 'warning'});
  reportFlowLoading.value = false
  reportFlowTable.value = res;
}

async function getAuditTableInformFun(type) {
  //打开审批记录
  reportFlowDialog.value = true
  reportFlowLoading.value = true
  let res;
  if (type) {
    res = await getReportFlow({id: formData.value.reportProject.id, code: type});
  } else {
    res = await getReportFlow({id: formData.value.record.id, code: 'inform'});
  }
  reportFlowLoading.value = false
  reportFlowTable.value = res;
}


//打开督审记录窗口
const warningDetailDiaglog = ref(false)
const warningTable = ref()
const getWarningRecordFun = async () => {
  warningDetailDiaglog.value = true;
  const res = await getWarningAudit(formData.value.reportProject.id);
  warningTable.value = res;
}


const informDialog = ref(false)
const getWarningInformDataFun = () => {
  informDialog.value = true;
}

//获取反馈内容
const informTable = ref([])
const informLoading = ref(false);
const getWarningInformFun = async (id) => {
  informLoading.value = true;
  const res = await getWarningInformList(id);
  informTable.value = res;
  informLoading.value = false;
}

const closeDetailShow = () => {
  detailShow.value = false

}


const detailShow = ref(false)
const recordDisplay = ref(false);
const codeData = ref();
getPoliceList();


onMounted(() => {
  //获取项目信息
  if (route.query.reportId) {
    //判断是否为编辑状态
    if (route.query.isEnd) {
      formData.value.contents = AuditRuleEnums
    }
    if (route.query.warningCode && route.query.warningCode === "inform") {
      codeData.value = "inform"
      warningCode.value = "inform"
    }
    formData.value.record.warningSupervisionId = userStore.user.userName;
    formData.value.record.warningSupervision = userStore.user.nickName;
    query.value.name = formData.value.record.warningSupervision;
    ensureSupervisionTime();
    getReportDetailFun(route.query.reportId)
    getWarningInformFun(route.query.reportId)
  } else {
    closePage();
  }
})


watch(() => formData.value.record.warningSupervisionId, (val) => {

  if (val && polices.value.length > 0 && polices.value.filter(s => s.idCode === val).length > 0) {
    formData.value.record.warningSupervision = polices.value.filter(s => s.idCode === val)[0].name;
  }
}, {deep: true, immediate: true})
//缺少项目id以后，关闭tab
// watch(() => route.query.reportId, (val) => {
//   if(!val){
//     useTabsStore().removeTab('/warning/edit', router);
//   }
// }, {deep: true, immediate: true})
//结算项目情况下 todo
const timeAlertFun = (rowName) => {
  const {reportProject} = formData.value;
  if (!reportProject?.[rowName]) return false;
  // 时间校验逻辑
  const timeChain = {
    applyGovernmentTime: ['projectApprovalTime'],
    purchaseTime: ['projectApprovalTime', 'applyGovernmentTime'],
    contractTime: ['projectApprovalTime', 'applyGovernmentTime', 'purchaseTime']
  };
  const dependencies = timeChain[rowName];
  if (!dependencies) return false;
  return !dependencies.every((dep, index) => {
    const prevTime = reportProject[dep];
    const nextTime = index === dependencies.length - 1
        ? reportProject[rowName]
        : reportProject[dependencies[index + 1]];
    return prevTime && nextTime && prevTime < nextTime;
  });
}

const ensureSupervisionTime = () => {
  const r = formData.value.record || (formData.value.record = {});
  if (!r.supervisionTime) {
    r.supervisionTime = dayjs().format("YYYY-MM-DD HH:mm");
  }
};

</script>

<template>
  <div class="wrapper" v-loading="loading">
    <main>
      <!--      <el-header>-->
      <!--        <h2 style="text-align: center">{{ isEndData ? '结算项目报审' : '控制价项目报审' }}</h2>-->
      <!--      </el-header>-->
      <el-main>
        <div class="flex v-center" style="height:30px;margin-bottom: 10px">
          <h5>报审信息</h5>
        </div>
        <div>


          <el-form :loading="loading" :model="formData.record" :rules="rules" ref="formDataRef" label-width="140">
            <el-row>
              <el-col :span="6">
                <el-form-item label="报审类型" prop="reportType">
                  <!-- 查看态：外观=禁用 el-select，但可复制 -->
                  <el-input
                      v-if="isDisabled"
                      :model-value="formData.reportProject.reportType"
                      readonly
                      class="select-disabled-like"
                  />

                  <!-- 编辑态：正常 el-select -->
                  <el-select
                      v-else
                      v-model="formData.reportProject.reportType"
                  >
                    <el-option label="项目控制价" value="项目控制价"/>
                    <el-option label="结算项目" value="结算项目"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="项目名称" prop="reportName">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.reportName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="项目类别">
                  <el-input
                      v-if="isDisabled"
                      :model-value="formData.reportProject.projectType"
                      readonly
                      class="select-disabled-like"
                  />
                  <el-select
                      v-else
                      v-model="formData.reportProject.projectType"
                  >
                    <el-option label="服务类" value="服务类"/>
                    <el-option label="工程类" value="工程类"/>
                    <el-option label="货物类" value="货物类"/>
                    <el-option label="信息化类" value="信息化类"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="审计单位" prop="auditUnitId">
                  <!-- 查看态：可复制 -->
                  <el-input v-if="isDisabled" :model-value="formData.reportProject.auditUnit" readonly
                            class="select-disabled-like"/>
                  <depart-tree-select v-else :auth="false" v-model="formData.reportProject.auditUnitId" clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item label="项目单位" prop="projectUnitId">
                  <el-input
                      v-if="isDisabled"
                      :model-value="formData.reportProject.projectUnit"
                      readonly
                      class="select-disabled-like"
                  />
                  <depart-tree-select
                      v-else
                      :auth="false"
                      v-model="formData.reportProject.projectUnitId"
                      clearable
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="项目负责人" prop="projectPrincipal">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.projectPrincipal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="负责人联系方式" prop="projectPhone">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.projectPhone"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item v-if="isEndData" label="报审金额（元）" prop="reportMoney">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.reportMoney"></el-input>
                </el-form-item>
                <el-form-item v-else label="采购方式" prop="purchaseMethod">
                  <el-input
                      v-if="isDisabled"
                      :model-value="
    (dict.procurementMethod || []).find(
      d => d.dictValue === formData.reportProject.purchaseMethod
    )?.dictLabel
  "
                      readonly
                      class="select-disabled-like"
                  />
                  <el-select v-else v-model="formData.reportProject.purchaseMethod">
                    <el-option
                        v-for="item in dict.procurementMethod"
                        :key="item.dictValue"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6">
                <el-form-item v-if="isEndData" label="立项日期" prop="projectApprovalTime">
                  <el-date-picker
                      :disabled="isDisabled"
                      v-model="formData.reportProject.projectApprovalTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择立项日期"
                  />
                </el-form-item>
                <el-form-item v-else label="报审金额（元）" prop="reportMoney">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.reportMoney"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="立项金额（元）" prop="projectApprovalMoney">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.projectApprovalMoney"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="立项审批领导" prop="projectApprovalLead">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.projectApprovalLead"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="报审人" prop="applicant">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.applicant"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="6" v-if="isEndData">
                <el-form-item label="申报政府采购日期" prop="applyGovernmentTime">
                  <el-date-picker
                      :class="{'border_red':timeAlertFun('applyGovernmentTime')}"
                      :disabled="isDisabled"
                      v-model="formData.reportProject.applyGovernmentTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择申报政府采购日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="isEndData">
                <el-form-item label="采购方式" prop="purchaseMethod">
                  <el-select :disabled="isDisabled" v-model="formData.reportProject.purchaseMethod">
                    <el-option v-for="(item,index) in dict.procurementMethod" :key="index"
                               :label="item.dictLabel"
                               :value="item.dictValue"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="isEndData">
                <el-form-item label="采购日期" prop="purchaseTime">
                  <el-date-picker
                      :disabled="isDisabled"
                      :class="{'border_red':timeAlertFun('purchaseTime')}"
                      v-model="formData.reportProject.purchaseTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择采购日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="报审日期" prop="applicantTime">
                  <el-date-picker
                      :disabled="isDisabled"
                      v-model="formData.reportProject.applicantTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择报审日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="文号">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.referenceNumber"/>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="发文日期">
                  <el-date-picker
                      :disabled="isDisabled"
                      v-model="formData.reportProject.publicationDate"
                      style="width: 100%"
                      type="date"
                      placeholder="选择发文日期"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="isEndData">
              <el-col :span="6">
                <el-form-item label="合同签订日期" prop="contractTime">
                  <el-date-picker
                      :disabled="isDisabled"
                      :class="{'border_red':timeAlertFun('contractTime')}"
                      v-model="formData.reportProject.contractTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择报合同签订日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="合同金额" prop="contractMount">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.contractMount"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="服务单位" prop="serviceUnit">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.serviceUnit"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="服务单位负责人" prop="serviceUnitManager">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.serviceUnitManager"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="isEndData">
              <el-col :span="6">
                <el-form-item label="服务日期" prop="serviceTime">
                  <el-date-picker
                      ref="datePicker"
                      :disabled="isDisabled"
                      v-model="formData.reportProject.serviceTime"
                      type="daterange"
                      range-separator="-"
                      start-placeholder="开始服务日期"
                      end-placeholder="结束服务日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="服务单位联系电话" prop="serviceUnitPhone">
                  <el-input :disabled="isDisabled" v-model="formData.reportProject.serviceUnitPhone"></el-input>
                </el-form-item>
              </el-col>
              <!--              <el-col :span="6" >-->
              <!--                <el-form-item label="文号" >-->
              <!--                  <el-input :disabled="isDisabled"  v-model="formData.reportProject.referenceNumber" />-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
              <!--              <el-col :span="6" >-->
              <!--                <el-form-item label="发文日期" >-->
              <!--                  <el-date-picker-->
              <!--                      :disabled="isDisabled"-->
              <!--                      v-model="formData.reportProject.publicationDate"-->
              <!--                      style="width: 100%"-->
              <!--                      type="date"-->
              <!--                      placeholder="选择发文日期"-->
              <!--                  />-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
              <el-col :span="6">
                <el-form-item label="归档时间">
                  <el-date-picker
                      :disabled="isDisabled"
                      v-model="formData.reportProject.archiving"
                      type="date"
                  />
                </el-form-item>
              </el-col>
            </el-row>


            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="审定金额（元）">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.archivingMoney"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="审减金额（元）">
                  <el-input :disabled="isDisabled" type="number"
                            v-model="formData.reportProject.archivingReduceMoney"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="预警监督状态">
                  <el-select :disabled="recordDisplay" v-model="formData.reportProject.warningState">
                    <el-option label="已预警监督" value="1"></el-option>
                    <el-option label="未预警监督" value="0"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="预警监督人员" prop="warningSupervision">
                  <el-select :disabled="recordDisplay" v-model="formData.record.warningSupervision"
                             :remote-method="inputGetList"
                             filterable>
                    <el-option v-for="(item,index) in polices" :key="index" :value="item.idCode"
                               :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">

              <el-col :span="6">
                <el-form-item label="预警监督日期" prop="supervisionTime">
                  <el-date-picker
                      value-format="YYYY-MM-DD HH:mm"
                      time-format="HH:mm"
                      :disabled="recordDisplay"
                      v-model="formData.record.supervisionTime"
                      style="width: 100%"
                      type="date"
                      placeholder="选择预警监督日期"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="证据提供者" prop="evidenceOffer">
                  <el-input placeholder="请输入证据提供者" :disabled="recordDisplay"
                            v-model="formData.record.evidenceOffer"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-button type="primary" style="width: 100%" @click="DetailReport">详情</el-button>
              </el-col>
              <el-col :span="3">
                <el-button type="primary" style="width: 100%" @click="getWarningRecordFun">督审记录</el-button>
              </el-col>
              <el-col :span="3">
                <el-button type="primary" style="width: 100%" @click="getWarningInformDataFun">反馈记录</el-button>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <hr style="border-color: rgba(232,232,232,0.67);opacity: 0.2">
        <div class="flex v-center" style="height:30px;margin-bottom: 10px">
          <h5>审计信息</h5>
        </div>
        <div class="table-container">
          <el-tabs v-model="activeName">
            <el-tab-pane label="预警监督情况" name="initial"></el-tab-pane>
          </el-tabs>
          <el-table :data=" formData.contents">
            <el-table-column label="序号" type="index" :index="(index)=> index+1"></el-table-column>
            <el-table-column label="预警类型" prop="type"></el-table-column>
            <el-table-column label="预警类型" prop="title"></el-table-column>
            <el-table-column label="预警内容" prop="content"></el-table-column>
            <el-table-column label="问题详情" prop="remark">
              <template #default="{row}">
                <el-input v-model="row.remark" :disabled="recordDisplay"></el-input>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="flex end mt-20" v-if="route.query.isEdit && !recordDisplay ">
          <el-button type="primary" @click="addOrUpDataFun">保存</el-button>
          <!--          <el-button type="primary" @click="warningInformFun">通知报审单位</el-button>-->
          <el-button type="primary" @click="getAuditTableInformFun('end')">签收审批记录</el-button>
          <el-button type="warning" @click="auditEndWarning">结束</el-button>
          <el-button type="primary" @click="SubmitFun">提交至领导</el-button>
          <el-button @click="closePage">取消</el-button>
        </div>
        <div class="flex end mt-20" v-else>
          <el-button type="primary" @click="getAuditTableFun">领导审批记录</el-button>
          <el-button type="primary" @click="getAuditTableInformFun('end')">签收审批记录</el-button>
          <el-button type="primary" v-if="isAudit && (codeData !='inform')" @click="passFun">通过</el-button>
          <el-button type="primary" v-if="isAudit && (codeData =='inform')" @click="passInformFun">签收</el-button>
          <el-button type="danger" v-if="isAudit" @click="rejectFun">驳回</el-button>
          <el-button @click="closePage">取消</el-button>
        </div>


        <el-dialog v-model="warningDetailDiaglog" title="督审记录" width="80vw">
          <div class="table-container">
            <el-table :data="warningTable" preserve-expanded-content>
              <el-table-column type="expand">
                <template #default="props">
                  <el-table :data="JSON.parse(props.row.warning).contents" :row-class-name="tableRowClassName">
                    <el-table-column label="序号" type="index" :index="(index)=> index+1"></el-table-column>
                    <el-table-column label="预警类型" prop="type"></el-table-column>
                    <el-table-column label="预警类型" prop="title"></el-table-column>
                    <el-table-column label="预警内容" prop="content"></el-table-column>
                    <el-table-column label="问题详情" prop="remark">
                    </el-table-column>
                  </el-table>
                </template>
              </el-table-column>
              <el-table-column label="预警监督人员" prop="warningSupervision"></el-table-column>
              <el-table-column label="预警监督日期" prop="supervisionTime"/>
              <el-table-column label="证据提供者" prop="evidenceOffer"/>
              <el-table-column label="预警下发时间" prop="archiving"/>

            </el-table>
          </div>
        </el-dialog>

        <el-dialog v-model="reportFlowDialog" title="审批记录" width="80vw">
          <div class="table-container">
            <el-table :data="reportFlowTable" v-loading="reportFlowLoading">
              <el-table-column width="50" type="index" label="序号" :index="(index)=> index+1"></el-table-column>
              <el-table-column label="操作" prop="reportCode"></el-table-column>
              <el-table-column label="办理人" prop="approver"></el-table-column>
              <el-table-column label="提交时间" prop="areportTime">
                <template #default="{row}">
                  {{ timeFormat(row.areportTime, 'yyyy-mm-dd hh:MM:ss') }}
                </template>
              </el-table-column>
              <el-table-column label="完成时间" prop="approverTime">
                <template #default="{row}">
                  {{ timeFormat(row.approverTime, 'yyyy-mm-dd hh:MM:ss') }}
                </template>
              </el-table-column>
              <el-table-column label="办理结果" prop="approverState">
                <template #default="{row}">
                  <el-tag type="primary" v-if="row.approverState === '开始'">开始</el-tag>
                  <el-tag type="success" v-if="row.approverState === '结束'">完成</el-tag>
                  <el-tag type="danger" v-if="row.approverState === '驳回'">驳回</el-tag>
                </template>
              </el-table-column>
              <el-table-column label="办理意见" prop="approverMessage" show-overflow-tooltip></el-table-column>
              <el-table-column label="办理状态" prop="approverState"></el-table-column>
            </el-table>
          </div>
        </el-dialog>


        <el-dialog v-model="informDialog" title="签收反馈记录" width="80vw">
          <div class="table-container">
            <el-table :data="informTable" v-loading="informLoading">
              <el-table-column width="50" type="index" label="序号" :index="(index)=> index+1"></el-table-column>
              <el-table-column width="150" label="报审单位" prop="unit"></el-table-column>
              <el-table-column label="办理人" prop="message" show-overflow-tooltip></el-table-column>
              <el-table-column width="150" label="反馈时间" prop="approverTime">
                <template #default="{row}">
                  {{ timeFormat(row.approverTime, 'yyyy-mm-dd hh:MM:ss') }}
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-dialog>


        <el-dialog v-model="detailShow" width="90vw" @close="closeDetailShow">
          <warningDetail @close-page-fun="closeDetailShow" :node="detailProps.node" :id="detailProps.id"
                         :back-path="detailProps.backPath" :is-end="detailProps.isEnd"></warningDetail>
        </el-dialog>

        <report-audit @submitFeedback="submitFeedback" @closeFun="closeAuditDialogFun"
                      :isWarning="warningCode"
                      :reportId="formData.record.id"
                      :dialog="dialog"
                      :nextNode="node"
                      :reportProject="formData.reportProject"
        />
        <finish-distrbute
            @submitFeedback="FinishSubmitFeedback" @closeFun="closeAuditDialogFun"
            :isWarning="warningCode"
            :reportId="formData.record.id"
            :dialog="finishDialog"
            :nextNode="node"
        />

        <report-audit-end
            @submitFeedback="endSubmitFeedback" @closeFun="closeAuditDialogFun"
            :isWarning="warningCode"
            :reportId="formData.record.id"
            :dialog="endDialog"
            :isAudit="true"
        ></report-audit-end>

        <report-audit-reject @submitFeedback="submitFeedback" @closeFun="closeDialogFun" :node="formData.record.node"
                             :isWarning="warningCode" :reportId="formData.record.id" :dialog="rejectDialog"
                             :isAudit="false"></report-audit-reject>
      </el-main>
    </main>
  </div>
</template>

<style lang="scss">
.el-table .warning-row {
  --el-table-tr-bg-color: var(--el-color-warning-light-9);
}

.el-table .el-table__cell {
  position: initial !important;
}


.border_red {
  border: red 2px solid;
}

/* 让 el-input 看起来和 el-select 禁用态一模一样 */
.select-disabled-like {
  --el-input-bg-color: var(--el-disabled-bg-color);
  --el-input-border-color: var(--el-disabled-border-color);
  --el-input-text-color: var(--el-text-color-regular);

  .el-input__wrapper {
    background-color: var(--el-disabled-bg-color);
    box-shadow: 0 0 0 1px var(--el-disabled-border-color) inset;
    cursor: not-allowed;
  }

  .el-input__inner {
    color: #a8abb2;
    cursor: text; /* 允许选中复制 */
  }
}

</style>
