<template>
  <!--  竣工验收-->
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="标段名称" prop="sectionName">
        <el-input
          v-model="queryParams.cv.value"
          placeholder="请输入标段名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        >
          <el-button
            type="primary"
            slot="append"
            icon="el-icon-search"
            size="small"
            @click="handleQuery"
          ></el-button>
        </el-input>
      </el-form-item>

      <el-form-item>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['build:projectAcceptance:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['build:projectAcceptance:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['build:projectAcceptance:remove']"
          >删除</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="accList"
      @selection-change="handleSelectionChange"
      tooltip-effect="dark myTooltips"
    >
      <el-table-column type="selection" width="55" align="center" fixed />
      <el-table-column
        label="序号"
        type="index"
        width="50"
        align="center"
        fixed
      />
      <el-table-column
        label="标段名称"
        align="center"
        prop="sectionName"
        min-width="120"
      />
      <el-table-column
        label="所属项目"
        align="center"
        prop="projectName"
        min-width="120"
      />
      <el-table-column
        label="标段项目编码"
        align="center"
        prop="proCode"
        min-width="120"
      />

      <el-table-column
        label="项目法人"
        align="center"
        prop="projectLegal"
        min-width="120"
      />
      <el-table-column
        label="合同名称"
        align="center"
        prop="contractName"
        min-width="120"
      />
      <el-table-column
        label="完工验收时间"
        align="center"
        prop="contractAcceptTime"
        min-width="120"
      />

      <el-table-column
        label="验收结论"
        align="center"
        prop="contractResult"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="验收人员"
        align="center"
        prop="acceptancePerson"
        min-width="120"
      >
        <template slot-scope="scope">
          {{ acceptancePersonFarmat(scope.row.acceptancePerson) }}
        </template>
      </el-table-column>
      <el-table-column
        label="合同完工验收鉴定书"
        align="center"
        prop="acceptanceDecisionLetter"
        min-width="150"
      >
        <template slot-scope="scope">
          <div
            v-for="(item, index) in JSON.parse(
              scope.row.acceptanceDecisionLetter
            )"
            :key="item + index"
          >
            <i class="el-icon-document"></i>
            {{ item.name }}
            <i
              class="el-icon-download"
              @click="downloadFile2(scope, index)"
              style="cursor: pointer"
            ></i>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="180"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="viewInfo(scope.row)"
            v-hasPermi="['build:projectAcceptance:view']"
            >查看</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['build:projectAcceptance:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['build:projectAcceptance:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1200px"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-row :gutter="15">
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          label-width="110px"
          label-position="top"
        >
          <div class="listTitle" style="margin-top: 0">
            <span>合同工程完工验收管理</span>
          </div>
          <el-row :gutter="15" class="pad12">
            <!-- ===============合同工程完工验收管理==================== -->
            <!-- <el-col :span="24">
              <div class="listTitle" style="margin-top: 0">
                <span>合同工程完工验收管理</span>
              </div>
            </el-col> -->
            <el-col :span="24">
              <el-form-item label="标段名称" prop="sectionName">
                <chooseSection :form="form" :proCode="proCode" :proNo="proNo" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所属项目" prop="projectName">
                <el-input
                  v-model="form.projectName"
                  placeholder="请输入所属项目"
                  readonly
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="标段项目编码" prop="proCode">
                <el-input
                  v-model="form.proCode"
                  placeholder="请输入标段项目编码"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="项目法人" prop="projectLegal">
                <el-input
                  v-model="form.projectLegal"
                  placeholder="请输入项目法人"
                  readonly
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="合同名称" prop="contractName">
                <el-input
                  v-model="form.contractName"
                  placeholder="请输入合同名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="完工验收时间" prop="contractAcceptTime">
                <!-- <el-input
              v-model="form.contractAcceptTime"
              placeholder="请选择完工验收时间"
            /> -->
                <el-date-picker
                  clearable
                  size="small"
                  style="width: 100%"
                  v-model="form.contractAcceptTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择完工验收时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="验收结论" prop="contractResult">
                <el-input
                  v-model="form.contractResult"
                  placeholder="请输入验收结论"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="验收人员" prop="acceptancePerson">
                <!-- <el-input
              v-for="(item, index) in 2"
              :key="item"
              v-model="form.acceptancePerson"
              placeholder="请输入验收人员"
            /> -->
                <el-button
                  type="primary"
                  class="button-new-tag"
                  size="small"
                  @click="showInput1"
                  >添加人员</el-button
                >
                <el-tag
                  :key="tag + index"
                  v-for="(tag, index) in dynamicTags1"
                  closable
                  :disable-transitions="false"
                  @close="handleClose1(tag)"
                >
                  {{ tag }}
                </el-tag>
                <el-input
                  class="input-new-tag"
                  v-if="inputVisible1"
                  v-model="inputValue1"
                  ref="saveTagInput1"
                  size="small"
                  @keyup.enter.native="handleInputConfirm1"
                  @blur="handleInputConfirm1"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="合同完工验收鉴定书"
                prop="acceptanceDecisionLetter"
              >
                <!-- <el-input v-model="form.acceptanceDecisionLetter" placeholder="请输入合同完工验收鉴定书" /> -->
                <el-upload
                  class="upload-demo"
                  action="thinking/common/upload"
                  :headers="headers"
                  :before-upload="
                    (file) => $fileBeforeUpload(file, 'fileList1')
                  "
                  :on-preview="handlePreview"
                  :on-remove="handleRemove1"
                  :before-remove="beforeRemove"
                  multiple
                  :on-success="submitUpload1"
                  :file-list="fileList1"
                >
                  <el-button size="small" type="primary" plain>
                    <i class="el-icon-upload el-icon--right"></i>
                    点击上传
                  </el-button>
                  <div slot="tip" class="el-upload__tip">
                    支持jpg/png/pdf/word/excel文件等，不超过200M
                  </div>
                </el-upload>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
          <el-form-item label="竣工验收影像质量" prop="contractVideo">
            <el-upload
              class="upload-demo"
              action="thinking/common/upload"
              :headers="headers"
               :before-upload="(file) => $fileBeforeUpload(file, 'fileList2')"
              :on-preview="handlePreview"
              :on-remove="handleRemove2"
              :before-remove="beforeRemove"
              multiple
              :on-success="submitUpload2"
              :file-list="fileList2"
            >
              <el-button size="small" type="primary" plain>
                <i class="el-icon-upload el-icon--right"></i>
                点击上传
              </el-button>
              <div slot="tip" class="el-upload__tip">
                支持jpg/png/pdf/word/excel文件等，不超过200M
              </div>
            </el-upload>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="验收资料" prop="contractDocument">
            <el-upload
              class="upload-demo"
              action="thinking/common/upload"
              :headers="headers"
               :before-upload="(file) => $fileBeforeUpload(file, 'fileList3')"
              :on-preview="handlePreview"
              :on-remove="handleRemove3"
              :before-remove="beforeRemove"
              multiple
              :on-success="submitUpload3"
              :file-list="fileList3"
            >
              <el-button size="small" type="primary" plain>
                <i class="el-icon-upload el-icon--right"></i>
                点击上传
              </el-button>
              <div slot="tip" class="el-upload__tip">
                支持jpg/png/pdf/word/excel文件等，不超过200M
              </div>
            </el-upload>
          </el-form-item>
        </el-col> -->
          </el-row>

        </el-form>
      </el-row>
      <div class="dialog-footer" slot="footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--查看 -->
    <el-dialog
      :title="viewTitle"
      :visible.sync="viewOpen"
      width="1200px"
      append-to-body
      @close="closeView"
      :close-on-click-modal="false"
    >
      <div class="listTitle">
        <span>合同工程完工验收管理</span>
      </div>
      <el-descriptions
        class="margin-top"
        :column="2"
        border
        :labelStyle="{
          'text-align': 'left',
          width: '180px',
          height: '50px',
        }"
        :contentStyle="{ minWidth: '250px' }"
      >
        <el-descriptions-item>
          <template slot="label"> 标段名称 </template>
          {{ this.projectAcceptanceMsg.sectionName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 所属项目 </template>
          {{ this.projectAcceptanceMsg.projectName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 项目编码 </template>
          {{ this.projectAcceptanceMsg.proCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 项目法人 </template>
          {{ this.projectAcceptanceMsg.projectLegal }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 合同名称 </template>
          {{ this.projectAcceptanceMsg.contractName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 完工验收时间 </template>
          {{ this.projectAcceptanceMsg.contractAcceptTime }}
        </el-descriptions-item>

        <el-descriptions-item span="2">
          <template slot="label"> 验收结论 </template>
          {{ this.projectAcceptanceMsg.contractResult }}
        </el-descriptions-item>
        <el-descriptions-item span="2">
          <template slot="label"> 验收人员 </template>
          {{
            acceptancePersonFarmat(this.projectAcceptanceMsg.acceptancePerson)
          }}
        </el-descriptions-item>

        <el-descriptions-item span="2">
          <template slot="label"> 合同完工验收鉴定书 </template>
          <template v-if="this.projectAcceptanceMsg.acceptanceDecisionLetter">
            <div
              v-for="(item, index) in JSON.parse(
                this.projectAcceptanceMsg.acceptanceDecisionLetter
              )"
              :key="item + index"
            >
              {{ item.name }}

              <i
                class="el-icon-download"
                @click="downloadFile2(item, index)"
                style="cursor: pointer"
              ></i>
            </div>
          </template>
        </el-descriptions-item>
      </el-descriptions>

<!--      <div class="listTitle">-->
<!--        <span>竣工验收</span>-->
<!--      </div>-->
<!--      <el-descriptions-->
<!--        class="margin-top"-->
<!--        :column="3"-->
<!--        border-->
<!--        :labelStyle="{-->
<!--          'text-align': 'left',-->
<!--          width: '180px',-->
<!--          height: '50px',-->
<!--        }"-->
<!--        :contentStyle="{ minWidth: '250px' }"-->
<!--      >-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 竣工技术鉴定时间 </template>-->
<!--          {{ this.projectAcceptanceMsg.completionTechnicalTime }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 竣工技术预验收时间 </template>-->
<!--          {{ this.projectAcceptanceMsg.technicalPreAcceptanceTime }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 竣工验收时间 </template>-->
<!--          {{ this.projectAcceptanceMsg.completionAcceptanceTime }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 验收结果 </template>-->
<!--          {{ this.projectAcceptanceMsg.acceptanceResults }}-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 验收人员 </template>-->
<!--          {{-->
<!--            acceptancePersonFarmat(-->
<!--              this.projectAcceptanceMsg.acceptancePersonnel-->
<!--            )-->
<!--          }}-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 是否完成环保验收 </template>-->
<!--          {{-->
<!--            whetherFarmet(this.projectAcceptanceMsg.isEnvironmentalAcceptance)-->
<!--          }}-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 环保验收文件 </template>-->
<!--          <template-->
<!--            v-if="this.projectAcceptanceMsg.environmentalAcceptanceDocuments"-->
<!--          >-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.environmentalAcceptanceDocuments-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 竣工验收鉴定书 </template>-->
<!--          <template-->
<!--            v-if="this.projectAcceptanceMsg.acceptanceAppraisalCertificate"-->
<!--          >-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.acceptanceAppraisalCertificate-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 是否完成移民安置验收 </template>-->
<!--          {{-->
<!--            whetherFarmet(this.projectAcceptanceMsg.isResettlementAcceptance)-->
<!--          }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 移民安置验收文件 </template>-->
<!--          <template v-if="this.projectAcceptanceMsg.resettlementAcceptanceFile">-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.resettlementAcceptanceFile-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item>-->
<!--          <template slot="label"> 竣工验收影像质量 </template>-->
<!--          <template v-if="this.projectAcceptanceMsg.acceptanceImageData">-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.acceptanceImageData-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 是否完成水土保持验收 </template>-->
<!--          {{ whetherFarmet(this.projectAcceptanceMsg.isWaterConservation) }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 水土保持验收文件 </template>-->
<!--          <template v-if="this.projectAcceptanceMsg.waterConservationFile">-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.waterConservationFile-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 是否完成工程档案验收 </template>-->
<!--          {{ whetherFarmet(this.projectAcceptanceMsg.isEngineeringArchives) }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 工程档案验收文件 </template>-->
<!--          <template v-if="this.projectAcceptanceMsg.engineeringArchivesFile">-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.engineeringArchivesFile-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->

<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 是否完成竣工决算验收 </template>-->
<!--          {{ whetherFarmet(this.projectAcceptanceMsg.isEngineeringArchives) }}-->
<!--        </el-descriptions-item>-->
<!--        <el-descriptions-item span="1.5">-->
<!--          <template slot="label"> 竣工决算验收文件 </template>-->
<!--          <template v-if="this.projectAcceptanceMsg.completionFinalFile">-->
<!--            <div-->
<!--              v-for="(item, index) in JSON.parse(-->
<!--                this.projectAcceptanceMsg.completionFinalFile-->
<!--              )"-->
<!--              :key="item + index"-->
<!--            >-->
<!--              {{ item.name }}-->

<!--              <i-->
<!--                class="el-icon-download"-->
<!--                @click="downloadFile2(item, index)"-->
<!--                style="cursor: pointer"-->
<!--              ></i>-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-descriptions-item>-->
<!--      </el-descriptions>-->
    </el-dialog>

    <!-- <div>
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div> -->
  </div>
</template>

<script>
import {
  listAcc,
  getAcc,
  delAcc,
  addAcc,
  updateAcc,
  exportAcc,
} from "@/api/build/comAcc";
import { getToken } from "@/utils/auth";
import { getFileStream } from "@/api/system/upload";

export default {
  name: "Acc",
  props: ["projectName", "proNo", "proCode", "projectLegalPerson"],
  data() {
    return {
      dynamicTags1: [],
      dynamicTags2: [],
      inputVisible1: false,
      inputVisible2: false,
      inputValue1: "",
      inputValue2: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 竣工验收表格数据
      accList: [],
      // 弹出层标题
      title: "",
      viewTitle: "",
      // 是否显示弹出层
      open: false,
      viewOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ids: null,
        data: {
          type:"0",
          sectionName: null,
          projectName: null,
          completionTechnicalTime: null,
          technicalPreAcceptanceTime: null,
          completionAcceptanceTime: null,
          acceptanceResults: null,
          acceptancePersonnel: null,
          acceptanceAppraisalCertificate: null,
          isEnvironmentalAcceptance: null,
          environmentalAcceptanceDocuments: null,
          isWaterConservation: null,
          waterConservationFile: null,
          isResettlementAcceptance: null,
          resettlementAcceptanceFile: null,
          acceptanceImageData: null,
          isEngineeringArchives: null,
          engineeringArchivesFile: null,
          isCompletionFinal: null,
          completionFinalFile: null,
          proCode: null,
          proNo: null,
          createUid: null,
          createTime: null,
          updateUid: null,
          updateTime: null,
          owerDept: null,
        },
        cv: {
          name: "sectionName",
          type: "like",
          value: null,
        },
        // 排序方式
        params: {
          // 按哪个字段排序
          orderBy: "create_time",
          // desc降序，升序asc
          sortBy: "desc",
        },
      },
      // 表单参数
      form: {},
      projectAcceptanceMsg: {},
      // 表单校验
      rules: {
        sectionName: [
          {
            required: true,
            message: "请选择标段名称",
            trigger: "blur",
          },
        ],
        contractName: [
          { max: 100, message: "字符长度最大为100", trigger: "blur" },
        ],
        contractAcceptTime: [
          {
            required: true,
            message: "请选择完工验收时间",
            trigger: "change",
          },
        ],
        contractResult: [
          {
            required: true,
            message: "请输入验收结论",
            trigger: "blur",
          },
          { max: 250, message: "字符长度最大为250", trigger: "blur" },
        ],
        acceptancePerson: [
          {
            required: true,
            message: "请添加验收人员",
            trigger: "input",
          },
        ],
        acceptanceDecisionLetter: [
          {
            required: true,
            message: "请上传合同完工验收鉴定书",
            trigger: "blur",
          },
        ],
        completionTechnicalTime: [
          {
            required: true,
            message: "请选择竣工技术鉴定时间",
            trigger: "blur",
          },
        ],
        technicalPreAcceptanceTime: [
          {
            required: true,
            message: "请选择竣工技术预验收时间",
            trigger: "blur",
          },
        ],
        completionAcceptanceTime: [
          {
            required: true,
            message: "请选择竣工验收时间",
            trigger: "blur",
          },
        ],

        acceptanceResults: [
          {
            required: true,
            message: "请输入验收结果",
            trigger: "blur",
          },
          { max: 250, message: "字符长度最大为250", trigger: "blur" },
        ],
        acceptancePersonnel: [
          {
            required: true,
            message: "请添加验收人员",
            trigger: "input",
          },
        ],
      },
      // 附件
      fileList1: [],
      fileList2: [],
      fileList3: [],
      fileList4: [],
      fileList5: [],
      fileList6: [],
      fileList7: [],
      fileList8: [],
      fileList9: [],
      fileList10: [],
      // 请求头
      headers: {
        jianwei: "jwtech " + getToken(),
      },
      // 是否字典
      whetherOptions: [],
    };
  },
  created() {
    this.getList();
    this.getDicts("whether").then((response) => {
      this.whetherOptions = response.data;
    });
  },
  methods: {
    whetherFarmet(key) {
      if (key == 0) {
        return "否";
      } else if (key == 1) {
        return "是";
      } else {
        return "";
      }
    },
    acceptancePersonFarmat(data) {
      if (data) {
        // console.log(data);
        let arr = JSON.parse(data);
        if (arr.length == 0) {
          return "";
        } else {
          // console.log(1111, arr);
          return arr.join("、");
        }
      }
    },
    // 合同工程完工验收管理---验收人员
    handleClose1(tag) {
      this.dynamicTags1.splice(this.dynamicTags1.indexOf(tag), 1);
      this.form.acceptancePerson = this.dynamicTags1.length
        ? JSON.stringify(this.dynamicTags1)
        : null;
      this.$refs.form.validateField("acceptancePerson");
    },

    showInput1() {
      this.inputVisible1 = true;
      this.$nextTick((_) => {
        this.$refs.saveTagInput1.$refs.input.focus();
      });
    },

    handleInputConfirm1() {
      let inputValue1 = this.inputValue1;
      if (inputValue1) {
        this.dynamicTags1.push(inputValue1);
      }
      this.form.acceptancePerson = this.dynamicTags1.length
        ? JSON.stringify(this.dynamicTags1)
        : null;
      this.$refs.form.validateField("acceptancePerson");
      this.inputVisible1 = false;
      this.inputValue1 = "";
    },
    // 竣工验收---验收人员
    handleClose2(tag) {
      this.dynamicTags2.splice(this.dynamicTags2.indexOf(tag), 1);
      this.form.acceptancePersonnel = this.dynamicTags2.length
        ? JSON.stringify(this.dynamicTags2)
        : null;
      this.$refs.form.validateField("acceptancePersonnel");
    },

    showInput2() {
      this.inputVisible2 = true;
      this.$nextTick((_) => {
        this.$refs.saveTagInput2.$refs.input.focus();
      });
    },

    handleInputConfirm2() {
      let inputValue2 = this.inputValue2;
      if (inputValue2) {
        this.dynamicTags2.push(inputValue2);
      }
      this.form.acceptancePersonnel = this.dynamicTags2.length
        ? JSON.stringify(this.dynamicTags2)
        : null;
      this.$refs.form.validateField("acceptancePersonnel");
      this.inputVisible2 = false;
      this.inputValue2 = "";
    },
    /** 查询竣工验收列表 */
    getList() {
      this.loading = true;
      // this.projectAcceptanceMsg.projectName =
      //   this.projectName + "[" + this.proCode + "]";
      this.projectAcceptanceMsg.projectName = this.projectName;
      this.projectAcceptanceMsg.proNo = this.proNo;
      this.projectAcceptanceMsg.proCode = this.proCode;
      this.projectAcceptanceMsg.projectLegal = this.projectLegalPerson;
      console.log(this.projectName,this.proNo,this.proCode,this.projectLegalPerson)
      this.queryParams.data.proNo = this.proNo;
      this.queryParams.data.proCode = this.proCode;
      listAcc(this.queryParams).then((response) => {
        // // this.projectAcceptanceMsg.projectName = this.projectName;
        // // this.projectAcceptanceMsg.projectLegal = this.projectLegalPerson;
        // if (response.records[0]) {
        //   this.projectAcceptanceMsg = response.records[0];
        //   // this.projectAcceptanceMsg.projectName =
        //   //   this.projectAcceptanceMsg.projectName +
        //   //   "[" +
        //   //   this.projectAcceptanceMsg.proCode +
        //   //   "]";
        //   // this.projectAcceptanceMsg.projectName = this.projectName;
        //   // this.projectAcceptanceMsg.projectLegal = this.projectLegalPerson;
        //   // console.log(8888888888888, this.projectLegalPerson);
        //   // console.log("this.projectAcceptanceMsg", this.projectAcceptanceMsg);

        // }
        this.accList = response.records;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleUpdate(row) {
      this.reset();
      // this.form = { ...this.form, ...this.projectAcceptanceMsg };
      const id = row.id || this.ids;
      getAcc(id).then((response) => {
        this.form = response.data;
        // 验收人员
        if (this.form.acceptancePerson) {
          this.dynamicTags1 = JSON.parse(this.form.acceptancePerson);
        }
        if (this.form.acceptancePersonnel) {
          this.dynamicTags2 = JSON.parse(this.form.acceptancePersonnel);
        }
        // 文件
        if (this.form.acceptanceDecisionLetter) {
          this.fileList1 = JSON.parse(this.form.acceptanceDecisionLetter);
        }
        if (this.form.contractVideo) {
          this.fileList2 = JSON.parse(this.form.contractVideo);
        }
        if (this.form.contractDocument) {
          this.fileList3 = JSON.parse(this.form.contractDocument);
        }
        if (this.form.environmentalAcceptanceDocuments) {
          this.fileList4 = JSON.parse(
            this.form.environmentalAcceptanceDocuments
          );
        }
        if (this.form.acceptanceAppraisalCertificate) {
          this.fileList5 = JSON.parse(this.form.acceptanceAppraisalCertificate);
        }
        if (this.form.waterConservationFile) {
          this.fileList6 = JSON.parse(this.form.waterConservationFile);
        }
        if (this.form.resettlementAcceptanceFile) {
          this.fileList7 = JSON.parse(this.form.resettlementAcceptanceFile);
        }
        if (this.form.acceptanceImageData) {
          this.fileList8 = JSON.parse(this.form.acceptanceImageData);
        }
        if (this.form.engineeringArchivesFile) {
          this.fileList9 = JSON.parse(this.form.engineeringArchivesFile);
        }
        if (this.form.completionFinalFile) {
          this.fileList10 = JSON.parse(this.form.completionFinalFile);
        }
      });
      this.open = true;
      this.title = "修改项目验收信息";
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.dynamicTags1 = [];
      this.dynamicTags2 = [];
      this.fileList1 = [];
      this.fileList2 = [];
      this.fileList3 = [];
      this.fileList4 = [];
      this.fileList5 = [];
      this.fileList6 = [];
      this.fileList7 = [];
      this.fileList8 = [];
      this.fileList9 = [];
      this.fileList10 = [];
      this.form = {
        type:"0",
        id: null,
        sectionName: null,
        projectName: this.projectName+"["+this.proCode+"]",
        projectLegal: this.projectLegalPerson,
        contractName: null,
        contractAcceptTime: null,
        contractResult: null,
        acceptancePerson: null,
        acceptanceDecisionLetter: null,
        completionTechnicalTime: null,
        technicalPreAcceptanceTime: null,
        completionAcceptanceTime: null,
        acceptanceResults: null,
        acceptancePersonnel: null,
        acceptanceAppraisalCertificate: null,
        isEnvironmentalAcceptance: null,
        environmentalAcceptanceDocuments: null,
        isWaterConservation: null,
        waterConservationFile: null,
        isResettlementAcceptance: null,
        resettlementAcceptanceFile: null,
        acceptanceImageData: null,
        isEngineeringArchives: null,
        engineeringArchivesFile: null,
        isCompletionFinal: null,
        completionFinalFile: null,
        proCode: null,
        proNo: this.proNo,
        createUid: null,
        createTime: null,
        updateUid: null,
        updateTime: null,
        owerDept: null,
      };
      this.resetForm("form");
    },
    // 查询表单重置
    resetQueryForm() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        data: {
          type:"0",
          id: null,
          sectionName: null,
          projectName: null,
          completionTechnicalTime: null,
          technicalPreAcceptanceTime: null,
          completionAcceptanceTime: null,
          acceptanceResults: null,
          acceptancePersonnel: null,
          acceptanceAppraisalCertificate: null,
          isEnvironmentalAcceptance: null,
          environmentalAcceptanceDocuments: null,
          isWaterConservation: null,
          waterConservationFile: null,
          isResettlementAcceptance: null,
          resettlementAcceptanceFile: null,
          acceptanceImageData: null,
          isEngineeringArchives: null,
          engineeringArchivesFile: null,
          isCompletionFinal: null,
          completionFinalFile: null,
          proCode: null,
          proNo: null,
          createUid: null,
          createTime: null,
          updateUid: null,
          updateTime: null,
          owerDept: null,
        },
        cv: {
          name: "sectionName",
          type: "like",
          value: null,
        },
        // 排序方式
        params: {
          // 按哪个字段排序
          orderBy: "create_time",
          // desc降序，升序asc
          sortBy: "desc",
        },
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetQueryForm();
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();

      this.open = true;
      this.title = "添加项目完工验收";
    },
    viewInfo(row) {
      this.viewTitle = "查看完工验收";
      this.projectAcceptanceMsg = row;
      console.log("projectAcceptanceMsg", row);
      this.viewOpen = true;
    },
    // 关闭弹窗
    closeView() {
      this.projectAcceptanceMsg = {};
    },
    /** 提交按钮 */
    submitForm() {
      this.form.acceptanceDecisionLetter = this.fileList1.length
        ? JSON.stringify(this.fileList1)
        : null;
      this.form.contractVideo = this.fileList2.length
        ? JSON.stringify(this.fileList2)
        : null;
      this.form.contractDocument = this.fileList3.length
        ? JSON.stringify(this.fileList3)
        : null;
      this.form.environmentalAcceptanceDocuments = this.fileList4.length
        ? JSON.stringify(this.fileList4)
        : null;
      this.form.acceptanceAppraisalCertificate = this.fileList5.length
        ? JSON.stringify(this.fileList5)
        : null;
      this.form.waterConservationFile = this.fileList6.length
        ? JSON.stringify(this.fileList6)
        : null;
      this.form.resettlementAcceptanceFile = this.fileList7.length
        ? JSON.stringify(this.fileList7)
        : null;
      this.form.acceptanceImageData = this.fileList8.length
        ? JSON.stringify(this.fileList8)
        : null;
      this.form.engineeringArchivesFile = this.fileList9.length
        ? JSON.stringify(this.fileList9)
        : null;
      this.form.completionFinalFile = this.fileList10.length
        ? JSON.stringify(this.fileList10)
        : null;

      this.$refs["form"].validate((valid) => {
        if (valid) {
          // this.form.projectName = this.form.projectName.slice(
          //   0,
          //   this.form.projectName.indexOf("[")
          // );
          this.form.proNo = this.proNo;
          this.form.proCode = this.proCode;

          console.log("this.formthis.form", this.form);
          if (this.form.id != null) {
            updateAcc(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addAcc(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      if (ids) {
        this.$confirm("是否删除选中的数据？", "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(function () {
            return delAcc(ids);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(function () {});
      } else {
        this.$message.warning("请选择要删除的数据！！");
      }
    },
    // 上传附件1
    submitUpload1(_, fileList) {
      console.log("fileList1", fileList);
      this.fileList1.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove1(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList1.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList1.splice(index, 1);
    },
    // 上传附件2
    submitUpload2(_, fileList) {
      console.log("fileList2", fileList);
      this.fileList2.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove2(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList2.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList2.splice(index, 1);
    },
    // 上传附件3
    submitUpload3(_, fileList) {
      console.log("fileList3", fileList);
      this.fileList3.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove3(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList3.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList3.splice(index, 1);
    },
    // 上传附件4
    submitUpload4(_, fileList) {
      console.log("fileList4", fileList);
      this.fileList4.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove4(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList4.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList4.splice(index, 1);
    },
    // 上传附件5
    submitUpload5(_, fileList) {
      console.log("fileList5", fileList);
      this.fileList5.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove5(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList5.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList5.splice(index, 1);
    },
    // 上传附件6
    submitUpload6(_, fileList) {
      console.log("fileList6", fileList);
      this.fileList6.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove6(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList6.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList6.splice(index, 1);
    },
    // 上传附件7
    submitUpload7(_, fileList) {
      console.log("fileList7", fileList);
      this.fileList7.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove7(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList7.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList7.splice(index, 1);
    },
    // 上传附件8
    submitUpload8(_, fileList) {
      console.log("fileList8", fileList);
      this.fileList8.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove8(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList8.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList8.splice(index, 1);
    },
    // 上传附件9
    submitUpload9(_, fileList) {
      console.log("fileList9", fileList);
      this.fileList9.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove9(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList9.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList9.splice(index, 1);
    },
    // 上传附件10
    submitUpload10(_, fileList) {
      console.log("fileList10", fileList);
      this.fileList10.push({
        name: fileList.name,
        fileName: fileList.response.fileName,
        url: fileList.response.url,
        uid: fileList.uid,
      });
    },
    handleRemove10(file, fileList) {
      // console.log(file, fileList);
      let index = this.fileList10.findIndex((item) => item.uid === file.uid);
      // 删除文件
      this.fileList10.splice(index, 1);
    },

    // 表格中下载
    downloadFile(scope, index) {
      console.log(scope);
      let file = JSON.parse(scope.row.attachment)[index];
      this.handlePreview(file);
    },
    // 查看信息中, 下载
    downloadFile2(info, index) {
      console.log(info);
      this.handlePreview(info);
    },
    // 点击预览的文件进行下载
    handlePreview(file) {
      // console.log(file);
      getFileStream({ fileName: file.fileName }).then((res) => {
        const blob = new Blob([res], {
          // type类型后端返回来的数据中会有，根据自己实际进行修改
          // 表格下载为 application/xlsx，压缩包为 application/zip等，
          type: "application/xlsx",
        }); //excel,pdf等
        const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象
        const a = document.createElement("a"); //创建a标签
        a.style.display = "none";
        a.href = href; // 指定下载链接
        a.download = file.name; //指定下载文件名
        a.click(); //触发下载
        URL.revokeObjectURL(a.href); //释放URL对象
      });
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>
<style lang="scss">
.myTooltips {
  max-width: 60vw;
}
</style>
<style lang="scss" scoped>
@import "@/assets/css/dialog.scss";
::v-deep {
  .el-dialog {
    margin-top: 2vh !important;
  }
}
.pad12 {
  padding: 0 12.5px;
}
.el-tag + .el-tag {
  margin-left: 10px;
}
.button-new-tag {
  margin-right: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  width: 180px;
  margin-left: 10px;
  vertical-align: bottom;
}

.listTitle {
  font-size: 14px;
  padding-left: 10px;
  padding-right: 30px;
  margin: 20px 0;
  border-left: 2px solid #36b29e;
  display: flex;
  justify-content: space-between;
  span:nth-child(1) {
    font-weight: bold;
  }
  .addBtn {
    color: #36b29e;
    cursor: pointer;
  }
  .addBtn:hover {
    color: #31a08e;
  }
}
.listTitle:nth-child(1) {
  margin-top: 0;
  // border-left: 0;
}
</style>
