<template>
  <div class="detail-container">
    <el-form ref="formRef" :model="form" label-position="right" label-width="150px"
      style="max-height: 60vh; overflow-y: auto; padding-right: 50px" :rules="rules">
      <div class="basic-info">
        <el-row>
          <h4 style="margin: 0 0 20px 50px;">基本信息</h4>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="区县名称" prop="区县名称">
              <el-input disabled v-model="form.districtName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="路线编码" prop="路线编码">
              <el-input disabled v-model="form.routeNo"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="实施里程" prop="实施里程">
              <el-input-number disabled v-model="form.implementMileage" :controls="false">
                <template #suffix>
                  <span>公里</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="塌方及损失" prop="塌方及损失">
              <el-input-number disabled v-model="form.earthworkLoss" :controls="false">
                <template #suffix>
                  <span>方/万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="起点桩号" prop="起点桩号">
              <el-input disabled v-model="form.startStakeNo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="止点桩号" prop="止点桩号">
              <el-input disabled v-model="form.endStakeNo"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="路况位置" prop="路况位置">
              <el-input disabled v-model="form.roadLocation"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="阻断点小地名" prop="阻断点小地名">
              <el-input disabled v-model="form.blockedPointName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="灾害类型" prop="灾害类型">
              <el-input disabled v-model="form.disasterType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预估费用" prop="预估费用">
              <el-input-number disabled v-model="form.estimatedCost" :controls="false">
                <template #suffix>
                  <span>万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="技术等级" prop="技术等级">
              <el-select v-model="form.technicalGrade">
                <el-option
                  v-for="item in [{ value: '三级', label: '三级' }, { value: '二级', label: '二级' }, { value: '一级', label: '一级' }]"
                  :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资金来源" prop="资金来源">
              <el-input v-model="form.fundingSource"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="处置灾毁处数" prop="处置灾毁处数">
              <el-input-number v-model="form.disposalCount" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已完工处数" prop="已完工处数">
              <el-input-number v-model="form.completedCount" :controls="false"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="总投资" prop="总投资">
              <el-input-number v-model="form.totalInvestment" :controls="false">
                <template #suffix>
                  <span>万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目费用类型" prop="项目费用类型">
              <el-radio-group v-model="form.projectExpenseType">
                <el-radio value="自费重修">自费重修</el-radio>
                <el-radio value="申报重修">申报重修</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="performance-info">
        <el-row>
          <h4 style="margin: 0 0 20px 50px;">实施情况</h4>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="主要建设内容" prop="主要建设内容">
              <el-input disabled type="textarea" v-model="form.mainConstructionContent" clearable>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开工或预计开工时间" prop="开工或预计开工时间">
              <el-date-picker disabled type="date" v-model="form.startTime" clearable format="YYYY-MM-DD"
                value-format="YYYY-MM-DD">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完工或预计完工时间" prop="完工或预计完工时间">
              <el-date-picker disabled type="date" v-model="form.endTime" clearable format="YYYY-MM-DD"
                value-format="YYYY-MM-DD">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否在部交通统计报表管理系统报送投资" prop="是否在部交通统计报表管理系统报送投资" label-width="300px">
              <el-radio-group disabled v-model="form.isReportedToMinistry">
                <el-radio :value="0">是</el-radio>
                <el-radio :value="1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已报送投资额" prop="已报送投资额">
              <el-input-number disabled v-model="form.reportedInvestment" :controls="false">
                <template #suffix>
                  <span>万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目实施进度" prop="项目实施进度">
              <el-select disabled v-model="form.projectProgress">
                <el-option v-for="item in [
                  { value: '立项', label: '立项' },
                  { value: '财政评审', label: '财政评审' },
                  { value: '开展施工图设计', label: '开展施工图设计' },
                  { value: '完成施设于批复', label: '完成施设于批复' },
                ]" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="建设单位名称" prop="建设单位名称">
              <el-input disabled v-model="form.constructionUnit"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="建设单位联系人" prop="建设单位联系人">
              <el-input disabled v-model="form.constructionUnitContact"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="建设单位联系人电话" prop="建设单位联系人电话">
              <el-input disabled v-model="form.constructionUnitPhone"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="施工单位名称" prop="施工单位名称">
              <el-input disabled v-model="form.executionUnit"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="施工单位联系人" prop="施工单位联系人">
              <el-input disabled v-model="form.executionUnitContact"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="施工单位联系电话" prop="施工单位联系电话">
              <el-input disabled v-model="form.executionUnitPhone"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设计单位名称" prop="设计单位名称">
              <el-input disabled v-model="form.designUnit"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计单位联系人" prop="设计单位联系人">
              <el-input disabled v-model="form.designUnitContact"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设计单位联系人电话" prop="设计单位联系人电话">
              <el-input disabled v-model="form.designUnitPhone"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="监理单位名称" prop="监理单位名称">
              <el-input disabled v-model="form.supervisionUnit"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="监理单位联系人" prop="监理单位联系人">
              <el-input disabled v-model="form.supervisionUnitContact"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="监理单位联系电话" prop="监理单位联系电话">
              <el-input disabled v-model="form.supervisionUnitPhone"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="施工图批复时间" prop="施工图批复时间">
              <el-date-picker disabled type="date" v-model="form.designApprovalTime" clearable format="YYYY-MM-DD"
                value-format="YYYY-MM-DD">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="施工图设计批复文件(附件)" prop="施工图设计批复文件" label-width="200px">
              <FileUpload type="image" :limit="9" v-model="form.designApprovalFiles" :fileType=2 />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="施工合同时间" prop="施工合同时间">
              <el-date-picker disabled type="date" v-model="form.contractTime" clearable format="YYYY-MM-DD"
                value-format="YYYY-MM-DD">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="施工合同金额" prop="施工合同金额">
              <el-input-number disabled v-model="form.contractAmount" :controls="false">
                <template #suffix>
                  <span>万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="施工合同(附件)" prop="施工合同">
              <FileUpload type="image" :limit="9" v-model="form.contractFiles" :fileType=3 />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="建设完成投资" prop="建设完成投资">
              <el-input-number disabled v-model="form.completedInvestment" :controls="false">
                <template #suffix>
                  <span>万元</span>
                </template>
              </el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交竣工验收时间" prop="交竣工验收时间">
              <el-date-picker disabled type="date" v-model="form.acceptanceTime" clearable format="YYYY-MM-DD"
                value-format="YYYY-MM-DD">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="交竣工证书(附件)" prop="交竣工证书" label-width="200px">
              <FileUpload type="image" :limit="9" v-model="form.acceptanceFiles" :fileType=4 />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="其他佐证文件" prop="其他佐证文件">
              <FileUpload type="image" :limit="9" v-model="form.otherFiles" :fileType=6 />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完工项目上传图片(附件)" prop="完工项目上传图片" label-width="200px">
              <FileUpload type="image" :limit="9" v-model="form.completedFiles" :fileType=5 />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
  </div>
</template>

<script setup>
import { ref, onMounted, watch, computed } from "vue";
import { request } from "@/utils/request";
import FileUpload from '@/component/FileUpload/FileUpload.vue'

const formRef = ref(null);
defineExpose({ formRef });

const props = defineProps({
  form: {
    type: Object,
    default: () => ({}),
  },
});

const rules = computed(() => {
  return {
    技术等级: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.technicalGrade) {
            callback();
          } else {
            callback(new Error("请选择技术等级"));
          }
        },
        trigger: "blur",
      },
    ],
    资金来源: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.fundingSource) {
            callback();
          } else {
            callback(new Error("请填写资金来源"));
          }
        },
        trigger: "blur",
      },
    ],
    处置灾毁处数: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.disposalCount) {
            callback();
          } else {
            callback(new Error("请填写处置灾毁处数"));
          }
        },
        trigger: "blur",
      },
    ],
    已完工处数: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.completedCount) {
            callback();
          } else {
            callback(new Error("请填写已完工处数"));
          }
        },
        trigger: "blur",
      },
    ],
    总投资: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.totalInvestment) {
            callback();
          } else {
            callback(new Error("请填写总投资数"));
          }
        },
        trigger: "blur",
      },
    ],
    项目费用类型: [
      {
        required: true,
        validator: (rule, value, callback) => {
          if (props.form.projectExpenseType) {
            callback();
          } else {
            callback(new Error("请选择项目费用类型"));
          }
        },
        trigger: "blur",
      },
    ],
  };
});
</script>

<style></style>