<template>
  <div class="purchase">
    <div class="search-wrapper">
      <el-form :inline="true" :model="searchForm" class="search_form" style="text-align: left">
        <el-form-item label="姓名">
          <el-input v-model="searchForm.name" placeholder="请输入姓名" @keyup.enter.native="onSubmit"></el-input>
        </el-form-item>
        <el-form-item label="手机号码">
          <el-input v-model="searchForm.phone" placeholder="请输入手机号码" @keyup.enter.native="onSubmit"></el-input>
        </el-form-item>
        <el-form-item label="事项名称">
          <el-select v-model="searchForm.guideId" placeholder="请选择事项名称">
            <el-option v-for="item in guideIdList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
        <br />
        <el-form-item label="状态" style="margin-top: 10px">
          <el-radio-group v-model="searchForm.state" @change="onSubmit">
            <el-radio :label="item.state" v-for="item in stateList" :key="item.state">{{ item.stateName }}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-wrapper">
      <table-template :tableData="tableData" :tableColumns="tableColumns" :loading="loading" :pagination="pagination"
        @Jump="jumpPage">
        <el-table-column width="120" label="状态" align="center">
          <template slot-scope="scope">
            <el-tag type="warning" v-if="scope.row.houseState === 0 && scope.row.reviewerState !== 8">待审核</el-tag>
            <el-tag type="warning" v-if="scope.row.houseState === 0 && scope.row.reviewerState === 8">待复审</el-tag>
            <el-tag type="success" v-if="scope.row.houseState === 1">初审通过</el-tag>
            <el-tag type="warning" v-if="scope.row.houseState === 2">待终审</el-tag>
            <el-tag type="success" v-if="scope.row.houseState === 3">已完结</el-tag>
            <el-tag type="danger" v-if="scope.row.houseState === 4">已驳回</el-tag>
            <el-tag type="info" v-if="scope.row.houseState === 5">已撤销</el-tag>
            <el-tag type="warning" v-if="scope.row.houseState === 6">资料审核</el-tag>
            <el-tag type="success" v-if="scope.row.houseState === 7">发放补贴</el-tag>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="380" align="left">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" round @click="view(scope.row)">查看</el-button>
            <el-button type="primary" size="mini" round @click="record(scope.row)">记录</el-button>
            <!-- 申请的单子有通过拒绝-->
            <el-button v-if="scope.row.houseState === 0 && scope.row.reviewerState === 0" type="success" size="mini" round
              @click="pass(scope.row)">通过</el-button>
            <el-button v-if="scope.row.houseState === 0 && scope.row.reviewerState === 0" type="danger" size="mini" round
              @click="deny(scope.row)">拒绝</el-button>
            <el-button v-if="
              scope.row.houseState === 3 &&
              searchForm.departmentCode === '10000031'
            " type="success" size="mini" round @click="dispatch(scope.row)">发放补贴</el-button>
            <el-button v-if="scope.row.attachedFileMark === true" type="info" size="mini" round
              @click="viewUrl(scope.row)">查看附件</el-button>
          </template>
        </el-table-column>
      </table-template>
    </div>
    <el-dialog title="申报详情" :visible.sync="viewShow" width="800px" :close-on-press-escape="false">
      <div class="content">
        <el-table :data="totalList" style="width: 100%">
          <el-table-column prop="reasonName" label="审核单位" width="180">
          </el-table-column>
          <el-table-column prop="state" label="审核状态" width="180">
          </el-table-column>
          <el-table-column prop="reason" label="审核意见"> </el-table-column>
        </el-table>
        <div class="enterprise">
          <div class="title">企业信息</div>
          <div class="cell">
            <p class="label">企业名称</p>
            <p class="value">{{ viewDetail.enterprise.enterpriseName }}</p>
          </div>
          <div class="cell">
            <p class="label">企业纳税地</p>
            <p class="value">{{ viewDetail.enterprise.payTaxesArea }}</p>
          </div>
          <div class="cell">
            <p class="label">组织机构代码</p>
            <p class="value">{{ viewDetail.enterprise.organizationCode }}</p>
          </div>
          <div class="cell">
            <p class="label">联系人</p>
            <p class="value">{{ viewDetail.enterprise.contactUser }}</p>
          </div>
          <div class="cell">
            <p class="label">联系方式</p>
            <p class="value">{{ viewDetail.enterprise.contactMobile }}</p>
          </div>
          <div class="cell">
            <p class="label">企业营业执照或事业单位法人登记证</p>
            <p class="value">
              <el-image v-for="(item, index) in viewDetail.enterprise
                .businessLicenseList" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                :src="item.picture" :z-index="7777777" :preview-src-list="[item.picture]">
              </el-image>
            </p>
          </div>
          <div class="cell">
            <p class="label">单位申报人才购房补贴汇总表</p>
            <p class="value">
              <el-image v-for="(item, index) in viewDetail.enterprise.summarySheetList" :key="index"
                style="width: 100px; height: 100px; margin-right: 10px" :src="item.picture" :z-index="7777777"
                :preview-src-list="[item.picture]">
              </el-image>
            </p>
          </div>
        </div>
        <div class="applilist">
          <div class="card" v-for="(item, index) in viewDetail.appliList" :key="index">
            <div class="title">申报人信息{{ index + 1 }}</div>
            <div class="cell">
              <p class="label">申报人姓名</p>
              <p class="value">{{ item.name }}</p>
            </div>
            <div class="cell">
              <p class="label">身份证号码</p>
              <p class="value">{{ item.idCard }}</p>
            </div>
            <div class="cell">
              <p class="label">手机号码</p>
              <p class="value">{{ item.mobile }}</p>
            </div>
            <div class="cell">
              <p class="label">人才类型</p>
              <p class="value">{{ item.staffType }}</p>
            </div>
            <div class="cell">
              <p class="label">毕业院校</p>
              <p class="value">{{ item.graduateSchool }}</p>
            </div>
            <div class="cell">
              <p class="label">毕业时间</p>
              <p class="value">{{ item.graduationTime }}</p>
            </div>
            <div class="cell">
              <p class="label">学历</p>
              <p class="value">{{ item.highestEducation }}</p>
            </div>
            <div class="cell">
              <p class="label">学位</p>
              <p class="value">{{ item.highestDegree }}</p>
            </div>
            <div class="cell">
              <p class="label">市区缴纳养老保险开始时间</p>
              <p class="value">{{ item.payEndowmentInsuranceBeginTime }}</p>
            </div>
            <div class="cell">
              <p class="label">劳动合同开始时间</p>
              <p class="value">{{ item.laborContractBeginTime }}</p>
            </div>
            <div class="cell">
              <p class="label">劳动合同结束时间</p>
              <p class="value">{{ item.laborContractEndTime }}</p>
            </div>
            <div class="cell">
              <p class="label">不动产权证坐落</p>
              <p class="value">{{ item.realEstateAddress }}</p>
            </div>
            <div class="cell">
              <p class="label">不动产权证号</p>
              <p class="value">{{ item.realEstateCard }}</p>
            </div>
            <div class="cell">
              <p class="label">建筑面积（m2）</p>
              <p class="value">{{ item.square }}</p>
            </div>
            <div class="cell">
              <p class="label">个人银行卡开户行</p>
              <p class="value">{{ item.bank }}</p>
            </div>
            <div class="cell">
              <p class="label">个人银行卡号</p>
              <p class="value">{{ item.bankCard }}</p>
            </div>
            <div class="cell">
              <p class="label">购房时间（网签时间）</p>
              <p class="value">{{ item.buyHouseTime }}</p>
            </div>
            <div class="cell">
              <p class="label">缴纳金额（元）</p>
              <p class="value">{{ item.taxesValue }}</p>
            </div>
            <div class="cell">
              <p class="label">计税房价（元）</p>
              <p class="value">{{ item.taxableHouseValue }}</p>
            </div>
            <div class="cell">
              <p class="label">个人申请表</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 3" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">身份证照片</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 4" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">个人银行卡照</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 5" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">商品买卖合同</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 6" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">不动产权证书</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 7" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">契税完税凭证</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 8" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell">
              <p class="label">劳动或聘用合同</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 9" :key="index" style="width: 100px; height: 100px; margin-right: 10px"
                    :src="i.picture" :z-index="7777777" :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
            <div class="cell" v-if="viewDetail.guideName == '镇江市市区“归雁”人才购房补贴'">
              <p class="label">镇江籍证明材料</p>
              <p class="value">
                <template v-for="(i, index) in item.pictureVoS">
                  <el-image v-if="i.pictureType == 10" :key="index"
                    style="width: 100px; height: 100px; margin-right: 10px" :src="i.picture" :z-index="7777777"
                    :preview-src-list="[i.picture]">
                  </el-image>
                </template>
              </p>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <el-dialog title="操作记录" :visible.sync="recordShow" width="800px" :close-on-press-escape="false">
      <div class="content">
        <div class="cell" v-for="(item, index) in recordList" :key="index">
          <p class="label" style="margin-right: 20px">
            {{ item.stateName }}
            <span v-if="item.reason">{{ item.reason }}</span>
          </p>
          <div class="info">
            <p class="item">操作人：{{ item.reasonName }}</p>
            <p class="item">操作时间：{{ item.createTime }}</p>
          </div>
        </div>
        <p v-if="record.length === 0">暂无记录~</p>
      </div>
    </el-dialog>
    <el-dialog title="拒绝原因" :visible.sync="refuseShow" width="800px" :close-on-press-escape="false">
      <div class="reject" v-for="(item, index) in arrList" :key="index">
        <el-cascader v-model="item.test" :options="options" :props="{ checkStrictly: true }" :show-all-levels="false"
          clearable></el-cascader>
        <el-input v-model="item.remark" style="padding: 0 10px" placeholder="请输入原因" clearable></el-input>
        <el-button type="primary" icon="el-icon-plus" @click="arrList.push({ test: '', remark: '' })"></el-button>
      </div>
      <div class="button">
        <el-button @click="cancel">取消</el-button>
        <el-button @click="affirm" type="primary">确认</el-button>
      </div>
    </el-dialog>
    <el-dialog title="查看附件" :visible.sync="showUrl" width="500px" :close-on-press-escape="false">
      <div style="margin: 0 0 0 10px;font-weight: 700;">图片附件：</div>
      <div class="content" style="display: flex; flex-wrap: wrap" v-if="pictureUrlList.length > 0">
        <div v-for="(item, index) in pictureUrlList" :key="index">
          <el-image style="width: 95px; height: 95px; margin: 10px" :src="item.file"
            :preview-src-list="[item.file]"></el-image>
        </div>
      </div>
      <div class="content" style="display: flex; justify-content: center" v-if="pictureUrlList.length == 0">
        <el-empty :image-size="50"></el-empty>
      </div>
      <div style="margin: 0 0 0 10px;font-weight: 700;">文件附件：</div>
      <div class="content" style="display: flex; flex-direction: column; flex-wrap: wrap" v-if="fileUrlList.length > 0">
        <div v-for="(item, index) in fileUrlList" :key="index" style="
              margin: 10px 10px 0 10px;
              display: flex;
              align-items: center;
              justify-content: space-between;
            ">
          <p class="label" style="margin: 0; text-align: center">
            {{ item.fileExplain }}
          </p>
          <el-button size="mini" type="primary" @click="download(item.file)" class="down-text">下载附件</el-button>
        </div>
      </div>
      <div class="content" style="display: flex; justify-content: center" v-if="fileUrlList.length == 0">
        <el-empty :image-size="50"></el-empty>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import TableTemplate from "@/components/Table";
import { changeList, setName, setTel } from "@/utils";
import {
  mattersHouseReviewerList,
  mattersHouseRevieweReason,
  mattersHouseReason,
  mattersHouseGetInfo,
  mattersHouseReviewerPass,
  mattersHouseReviewerReject,
  mattersHousePass,
  mattersHouseStaffList,
  queryAttacheFile,
} from "@/api/purchase";
export default {
  components: { TableTemplate },

  data() {
    return {
      showUrl: false,
      pictureUrlList: [],
      fileUrlList: [],
      options: [
        {
          value: "",
          label: "企业原因",
        },
        {
          value: "1111",
          disabled: true,
          label: "个人原因",
          children: [],
        },
      ],
      arrList: [
        {
          test: "",
          remark: "",
        },
      ],
      select: "",
      input: "",
      userName: "",
      searchForm: {
        name: "",
        phone: "",
        state: "",
        departmentCode: "",
        guideId: null,
        payTaxesArea: null,
      },
      guideIdList: [
        {
          label: "全部",
          value: null,
        },
        {
          label: "购房补贴申领服务指南",
          value: "1000126",
        },
        {
          label: "镇江市市区“归雁”人才购房补贴",
          value: "1000159",
        },
      ],
      stateList: [
        {
          state: "",
          stateName: "全部",
          type: "",
        },
        {
          state: 0,
          stateName: "待审核",
          type: "warning",
        },
        {
          state: 8,
          stateName: "初审通过",
          type: "success",
        },
        {
          state: 9,
          stateName: "已驳回",
          type: "danger",
        },
      ],
      stateList1: [
        {
          state: 0,
          stateName: "待审核",
          type: "warning",
        },
        {
          state: 1,
          stateName: "待复审",
          type: "warning",
        },
        {
          state: 6,
          stateName: "资料审核",
          type: "warning",
        },
        {
          state: 2,
          stateName: "待终审",
          type: "warning",
        },
        {
          state: 3,
          stateName: "已完结",
          type: "success",
        },
        {
          state: 4,
          stateName: "已驳回",
          type: "danger",
        },
        {
          state: 5,
          stateName: "已撤销",
          type: "info",
        },
        {
          state: 7,
          stateName: "发放补贴",
          type: "success",
        },
        {
          state: 8,
          stateName: "初审通过",
          type: "success",
        },
        {
          state: 9,
          stateName: "已驳回",
          type: "danger",
        },
      ],
      loading: false,
      tableData: [],
      tableColumns: [
        {
          key: "houseCode",
          label: "申请编号",
          width: 200,
        },
        {
          key: "contactUser",
          label: "姓名",
          width: 150,
        },
        {
          key: "contactMobile",
          label: "手机号",
          width: 150,
        },
        {
          key: "payTaxesArea",
          label: "企业纳税地",
          width: 200,
        },
        {
          key: "guideName",
          label: "事项名称",
          width: 200,
        },
        {
          key: "departmentName",
          label: "实施主体",
          width: 150,
        },
        {
          key: "createTime",
          label: "更新时间",
          width: 180,
        },
      ],
      pagination: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      viewShow: false,
      viewDetail: {
        guideName: "",
        enterprise: {
          businessLicenseList: [],
          summarySheetList: [],
        },
        appliList: [],
      },
      examineList: [], // 审核单位数据
      housingList: [], // 住建局列表数据
      totalList: [], // 合并数组
      recordShow: false,
      recordList: [],
      refuseShow: false,
      row: {},
    };
  },
  watch: {
    $route() {
      if (this.$route) {
        this.userName = localStorage.getItem("userName");
        this.searchForm.departmentCode = this.$route.query.departmentCode;
        this.searchForm.name = "";
        this.searchForm.phone = "";
        this.searchForm.state = "";
        this.init();
      }
    },
  },
  methods: {
    download(url) {
      console.log(url);
      let fileType = url.split(".")[url.split(".").length - 1];
      if (fileType == "pdf" || fileType == "PDF") {
        window.open(url);
      } else {
        window.location.href = url;
      }
    },
    viewUrl(row) {
      console.log(row);
      queryAttacheFile({ code: row.houseCode }).then((res) => {
        console.log(res);
        if (res.success) {
          this.pictureUrlList = res.data.filter((item) => {
            let fileType =
              item.fileExplain.split(".")[
              item.fileExplain.split(".").length - 1
              ];
            return fileType == "jpg" || fileType == "jpeg" || fileType == "png";
          });
          this.fileUrlList = res.data.filter((item) => {
            let fileType =
              item.fileExplain.split(".")[
              item.fileExplain.split(".").length - 1
              ];
            return fileType != "jpg" && fileType != "jpeg" && fileType != "png";
          });
          console.log(this.pictureUrlList);
          console.log(this.fileUrlList);
          this.showUrl = true;
        } else {
          this.$message.error(res.msg || "查询失败");
        }
      });
    },
    init() {
      this.tableData = [];
      this.loading = true;
      let parmas = {
        name: this.searchForm.name,
        phone: this.searchForm.phone,
        state: this.searchForm.state,
        departmentCode: this.searchForm.departmentCode,
        guideId: this.searchForm.guideId,
        payTaxesArea: this.searchForm.payTaxesArea,
        pageNum: this.pagination.currentPage,
        pageSize: this.pagination.pageSize,
      };
      mattersHouseReviewerList(parmas).then((res) => {
        console.log("数据res---", res);
        this.loading = false;
        if (res.success) {
          this.pagination.total = res.data.total;
          if (res.data.total) {
            this.tableData = res.data.list.map((item) => {
              console.log("item------", item);
              if (item.stateName && item.type) {
                item.stateName = this.getSatusArr(item.state).stateName;
                item.type = this.getSatusArr(item.state).type;
              }
              return item;
            });
            if (localStorage.getItem("userName") == "admin") {
              this.tableData = changeList(this.tableData);
            }
          } else {
            this.tableData = [];
          }
        }
      });
    },
    jumpPage() {
      this.init();
    },
    onSubmit() {
      this.pagination.currentPage = 1;
      this.init();
    },
    //查看
    view(row) {
      // console.log(row);
      let params = {
        appId: "1234",
        code: row.houseCode,
      };
      let params2 = {
        appId: "1234",
        houseCode: row.houseCode,
      };
      // 查询四个部门的记录  mattersHouseRevieweReason
      mattersHouseRevieweReason(params).then((res) => {
        // console.log(res.data);
        this.examineList = res.data;
        this.examineList.forEach((item) => {
          item.state == 8 ? (item.state = "通过") : (item.state = "拒绝");
        });
        this.totalList = this.examineList.concat(this.housingList);
      });
      // 查询最后审批的记录  mattersHouseReason
      mattersHouseReason(params).then((res) => {
        this.housingList = res.data;
        // console.log("this.housingList----", this.housingList);
        this.housingList.forEach((item) => {
          item.state == 1 ||
            item.state == 2 ||
            item.state == 3 ||
            item.state == 6 ||
            item.state == 7
            ? (item.state = "通过")
            : (item.state = "拒绝");
        });
        this.totalList = this.examineList.concat(this.housingList);
      });
      mattersHouseGetInfo(params2).then((res) => {
        // console.log(res.data);
        this.viewDetail.guideName = res.data.guideName;
        this.viewDetail.enterprise = res.data.enterpriseVO;
        this.viewDetail.enterprise.businessLicenseList =
          res.data.enterpriseVO.pictureVoS.filter((item) => {
            return item.pictureType != 2;
          });
        this.viewDetail.enterprise.summarySheetList =
          res.data.enterpriseVO.pictureVoS.filter((item) => {
            return item.pictureType != 1;
          });
        this.viewDetail.appliList = res.data.staffVOList;
        if (localStorage.getItem("userName") == "admin") {
          this.viewDetail.enterprise.contactUser = setName(
            this.viewDetail.enterprise.contactUser
          );
          this.viewDetail.enterprise.contactMobile = setTel(
            this.viewDetail.enterprise.contactMobile
          );
          this.viewDetail.appliList = changeList(res.data.staffVOList);
        }
        this.viewShow = true;
      });
    },
    //记录
    record(row) {
      let params = {
        appId: "1234",
        code: row.houseCode,
      };
      // 查询四个部门的记录  mattersHouseRevieweReason
      mattersHouseRevieweReason(params).then((res) => {
        let housingReason = res.data;
        // 查询住建局的记录  mattersHouseReason
        mattersHouseReason(params).then((res) => {
          // console.log(res.data);
          let getReason = res.data;
          let reason = housingReason.concat(getReason);
          this.recordList = reason.map((item) => {
            item.stateName = this.getSatusArr1(item.state)
              ? this.getSatusArr1(item.state).stateName
              : "未知状态";
            return item;
          });
        });
        this.recordShow = true;
      });
    },
    //初审通过
    pass(row) {
      this.$prompt(`确定通过该申请的初审吗?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPlaceholder: "请输入原因",
        inputType: "textarea",
        type: "warning",
      })
        .then(({ value }) => {
          if (!value) {
            this.$message.error("未输入原因");
            return;
          }
          let params = {
            appId: "1234",
            code: row.houseCode,
            name: this.userName,
            state: 8,
            reviewerId: row.reviewerId,
            reason: value,
          };

          mattersHouseReviewerPass(params).then((res) => {
            if (res.success) {
              this.$message.success(`初审通过`);
              this.init();
            } else {
              this.$message.warning("该申请已被其他部门驳回，无法审核通过");
            }
          });
        })
        .catch(() => {
          // console.log("取消审核");
        });
    },
    //初审拒绝
    deny(row) {
      this.refuseShow = true;
      this.row = row;
      let params = {
        appId: "1234",
        houseCode: row.houseCode,
      };
      let params1 = {
        houseCode: row.houseCode,
        staffCodeList: [],
      };
      mattersHouseGetInfo(params).then((res) => {
        this.options[0].value = res.data.enterpriseVO.code;
      });
      mattersHouseStaffList(params1).then((res) => {
        this.options[1].children = res.data.map((item) => {
          return { label: item.name, value: item.staffCode };
        });
      });
    },
    cancel() {
      this.arrList = [
        {
          test: "",
          remark: "",
        },
      ];
      this.refuseShow = false;
    },
    affirm() {
      let params = {
        appId: "1234",
        code: this.row.houseCode,
        name: this.userName,
        rejectList: this.arrList.map((item) => {
          if (item.test.length == 1) {
            return {
              code: item.test[0],
              houseCode: this.row.houseCode,
              reason: item.remark,
              rejectType: 2,
            };
          } else if (item.test.length == 2) {
            return {
              code: item.test[1],
              houseCode: this.row.houseCode,
              reason: item.remark,
              rejectType: 1,
            };
          } else if (item.test.length == 0 || item.remark == "") {
            this.$alert("请将拒绝原因填写完整！");
          }
        }),
        reviewerId: this.row.reviewerId,
        state: 9,
      };
      mattersHouseReviewerReject(params).then((res) => {
        console.log(res);
        this.arrList = [
          {
            test: "",
            remark: "",
          },
        ];
        this.refuseShow = false;
        this.$message.success(`初审驳回成功`);
        this.init();
      });
    },
    //发放补贴
    dispatch(row) {
      this.$prompt(`确定发放补贴吗?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPlaceholder: "请输入原因",
        inputType: "textarea",
        type: "warning",
      })
        .then(({ value }) => {
          if (!value) {
            this.$message.error("未输入原因");
            return;
          }
          let params = {
            appId: "1234",
            code: row.houseCode,
            name: this.userName,
            state: 7,
            reason: value,
          };
          mattersHousePass(params).then((res) => {
            if (res.success) {
              this.$message.success(`发放补贴`);
              this.init();
            }
          });
        })
        .catch(() => {
          // console.log("取消审核");
        });
    },
    getSatusArr(state) {
      return this.stateList.filter((item) => {
        return item.state === state;
      })[0];
    },
    getSatusArr1(state) {
      return this.stateList1.filter((item) => {
        return item.state === state;
      })[0];
    },
  },
  created() {
    this.userName = localStorage.getItem("userName");
    // 10000031  财政局code   10000032 税务局code    10000033  不动产登记中心code    10000023 人社局code  10000027 住建局
    this.searchForm.departmentCode = this.$route.query.departmentCode;
    this.init();
  },
};
</script>

<style lang="stylus" scoped>
@import '~@/stylus/common';

.reject {
  display: flex;
  padding: 10px 0;
}

.button {
  padding: 20px 0;
  display: flex;
  justify-content: flex-end;
}

.content {
  max-height: 60vh;
  overflow-y: auto;

  .title {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    font-size: 20px;
    font-weight: 500;
    color: #fff;
    background: #409EFF;
  }

  .cell {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;

    .label {
      width: 350px;
      color: #999;
      text-align: left;

      span {
        color: red;
        font-size: 12px;
      }
    }

    .value {
      color: #000;
      text-align: left;
    }

    .info {
      .item {
        width: 100%;
        text-align: left;
        color: #000;
        margin-bottom: 10px;
      }

      .item:last-child {
        margin-bottom: 0;
      }
    }
  }
}
</style>
