<template>
  <view class="zhixing-container" style="margin: 20rpx;margin-top: 220rpx; min-height: 300px; ">
    <view class="zhixing_top" style="display: flex; flex-direction: column;">
      <view style="display: flex; flex-direction: column;margin-bottom: 10px; margin-left: 10px;">
        <uni-row style="width: 100%;" :gutter="0">
          <uni-col :xs="24" :sm="5" :md="5">
            <view class="querybox">
              <view class="querybox_title">项目编号：</view>
              <u-input @change="chaxunqy()" v-model="queryParams.projectNo" clearable placeholder="请输入项目编号"></u-input>
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="4" :md="4">
            <view class="querybox">
              <view class="querybox_title">项目状态：</view>
              <csr-uni-data-select style="width: 400px;" :multiple="true" :filterable="false"
                v-model="queryParams.statusList" placeholder="选择项目状态" dataKey="label" dataValue="value"
                :localdata="zhuangtailist" @change="xmztchange" :clear="false"></csr-uni-data-select>
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="6" :md="6">
            <view class="querybox">
              <view class="querybox_title">项目负责人：</view>
              <view style="width: calc(100% - 100px);">
                <u-input @change="chaxunqy()" v-model="queryParams.projectLeaderNameLike" clearable
                  placeholder="请输入项目负责人"></u-input>
              </view>
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="9" :md="9">
            <view class="querybox">
              <view class="querybox_title">单位：</view>
              <view style="width: calc(100% - 100px); display: flex; flex-direction: row;">
                <csr-uni-data-select style="width: 400px; margin-right: 10px;" :filterable="false"
                  v-model="queryParams.customerLevel" placeholder="请选择单位级别" dataKey="label" dataValue="value"
                  :localdata="danweilist" @change="dwjbchange" :clear="true"></csr-uni-data-select>
                <u-input @change="chaxunqy()" style="width:300px;" v-model="queryParams.customerName" clearable
                  placeholder="请输入单位名称"></u-input>
              </view>
            </view>
          </uni-col>
        </uni-row>
        <uni-row style="width: 100%; margin-top: 10px;" :gutter="0">
          <uni-col :xs="24" :sm="5" :md="5">
            <view class="querybox">
              <view class="querybox_title">系统合同号：</view>
              <csr-uni-data-select style="width: 400px;" :filterable="false" v-model="queryParams.contractId"
                placeholder="选择项系统合同号" dataKey="label" dataValue="value" :localdata="xthtlist" @change="chaxunqy()"
                :clear="true"></csr-uni-data-select>
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="7" :md="7">
            <view class="querybox">
              <view class="querybox_title">启动时间：</view>
              <uni-datetime-picker v-model="queryParams.startDatelist" type="daterange" @change="qdcalendarConfirm" />
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="8" :md="8">
            <view class="querybox">
              <view class="querybox_title">创建时间：</view>
              <view style="width: calc(100% - 100px);">
                <uni-datetime-picker v-model="queryParams.createTimelist" type="daterange"
                  @change="cjcalendarConfirm" />
              </view>
            </view>
          </uni-col>
          <uni-col :xs="24" :sm="4" :md="4" style="margin-top:3px;">
            <u-button style="width:70px; float: left;" type="warning" icon="reload" text="重置" @click="resetqy()"
              size="small"></u-button>
            <u-button style="width:70px; float: left;margin-left:20px;" type="primary" icon="search" text="查询"
              @click="chaxunqy()" size="small"></u-button>
          </uni-col>
        </uni-row>
      </view>
      <view style="margin-top: 20px; margin-bottom: 10px;">
        <u-button style="width:100px; float: left; margin-left:10px;" type="success" icon="plus-circle" text="添加项目"
          @click="openright()" size="small" v-if="$checkPermi(['safety_hazard:project:add'])"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="edit-pen" text="编辑项目"
          :disabled="activenum!=1" @click="upxiangmu()" size="small"
          v-if="$checkPermi(['safety_hazard:project:edit'])"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="error" icon="trash" text="删除项目"
          :disabled="activenum==0" @click="shanchujiancha()" size="small"
          v-if="$checkPermi(['safety_hazard:project:remove'])"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="success" icon="play-circle" text="启动"
          :disabled="activenum!=1" @click="qidong()" size="small"
          v-if="$checkPermi(['safety_hazard:project:status'])"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="warning" icon="error-circle" text="完结"
          :disabled="activenum!=1" @click="wanjie()" size="small"
          v-if="$checkPermi(['safety_hazard:project:status'])"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="list-dot" text="查看评价表"
          :disabled="activenum!=1" @click="pingjia()" size="small"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="success" icon="list-dot" text="查看处理建议"
          :disabled="activenum!=1" @click="chulijianyi()" size="small"
          v-if="$checkPermi(['safety_hazard:suggestion:list'])"></u-button>
      </view>
    </view>

    <view class="zhixing_center">

      <u-table row-key="projectId" rowHeight="60" customClass="mewtable2" ref="pageTable" :scrollX="true"
        :cellStyle="{padding:'10px 10px 0px 10px'}" :data="tableData" :ellipsis="false" height="450" :border="true"
        @select="handleSelectionChange" style="width:100%">
        <!-- :span-method="spanMethodWithColspan" -->
        <u-table-column type="selection" fixed width="55" align="center" headerAlign="center"></u-table-column>
        <u-table-column prop="projectNo" width="130" label="编号" headerAlign="center" align="center" />
        <u-table-column prop="name" width="180" label="名称" headerAlign="center" />
        <u-table-column prop="customer1CompanyName" width="180" label="一级单位" headerAlign="center" />
        <u-table-column prop="customer2CompanyName" width="180" label="二级单位" headerAlign="center" />
        <u-table-column prop="customer3CompanyName" width="180" label="三级单位" headerAlign="center" />
        <u-table-column prop="status" width="120" label="项目状态" headerAlign="center" align="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.status" :text="row.status=='2'?'待启动':row.status=='3'?'执行中':row.status=='4'?'完结':''"
              :type="row.status=='2'?'info':row.status=='3'?'primary':row.status=='4'?'success':''" size="mini"></u-tag>
          </template>
        </u-table-column>
        <u-table-column prop="sysCtcNo" width="180" label="系统合同号" headerAlign="center" align="center" />
        <u-table-column prop="projectLeaderName" width="150" label="项目负责人" headerAlign="center" align="center" />
        <u-table-column prop="address" width="180" label="地址" headerAlign="center" />
        <u-table-column prop="startDate" width="180" label="启动时间" headerAlign="center" align="center" />
        <u-table-column prop="createBy" width="80" label="创建人" align="center" headerAlign="center" />
        <u-table-column prop="createTime" width="180" label="创建时间" align="center" headerAlign="center">
          <template #default=" { row, index }">
            {{row.createTime?$dayjs(row.createTime).format("YYYY-MM-DD HH:mm"):''}}
          </template>
        </u-table-column>
      </u-table>
      <!-- 
      <u-pagination v-model="queryParams.pageNum" :total="queryParams.total" :page-size="queryParams.pageSize" simple
        style="float: right; margin-top:20px;"></u-pagination> -->




    </view>

    <customPicker :visible="xmpickerVisible" title="选择项目编号" :options="xmpickerConfig.options"
      :displayKey="xmpickerConfig.displayKey" :valueKey="xmpickerConfig.valueKey" :multiple="xmpickerConfig.multiple"
      :searchable="xmpickerConfig.searchable" :value="xmpickerConfig.value" @confirm="xmhandleConfirm"
      @cancel="xmhandleCancel" />
    <customPicker :visible="addxmpickerVisible" title="选择项目编号" :options="addxmpickerConfig.options"
      :displayKey="addxmpickerConfig.displayKey" :valueKey="addxmpickerConfig.valueKey"
      :multiple="addxmpickerConfig.multiple" :searchable="addxmpickerConfig.searchable" :value="addxmpickerConfig.value"
      @confirm="addxmhandleConfirm" @cancel="addxmhandleCancel" />
    <u-modal content="" :closeOnClickOverlay="true" :title="pjmodaltitle" confirmText="关闭" width="800px"
      :show="pjmodalshow" @confirm="() => pjmodalshow = false">
      <view class="slot-content" style="width: 100%;">
        <scroll-view scroll-y="true" style="height: 300px;">
          <view style="display: flex;
       flex-direction: column;
   width: 100%; align-items: left; border-top:1px solid #eee;">
            <uni-table border ref="page1Table" style="width:98%; margin: 0 auto;">
              <uni-tr style="background-color: #f5f5f5;">
                <uni-th align="center">序号</uni-th>
                <uni-th align="center">评价内容</uni-th>
                <uni-th align="center">得分</uni-th>
              </uni-tr>
              <uni-tr v-for="(item, index) in pjtableInfolist" :key="index">
                <uni-td align="center">{{Number(index+1)}}</uni-td>
                <uni-td align="center">
                  {{item.info}}
                </uni-td>
                <uni-td align="center">
                  {{item.score}}
                </uni-td>
              </uni-tr>
            </uni-table>
          </view>
        </scroll-view>
      </view>
    </u-modal>
    <u-modal content="" :closeOnClickOverlay="true" title="处理建议" confirmText="关闭" width="1030px" :show="yjmodalshow"
      @confirm="() => yjmodalshow = false">
      <view class="slot-content" style="width: 100%;">
        <scroll-view scroll-y="true" style="height:500px;">
          <view style="display: flex;
        flex-direction: column;
    width: 100%; align-items: left; border-top:1px solid #eee;">
            <view style="display: flex; flex-direction: row; justify-content: space-between;margin-top:20px;">
              <view class="querybox" style="margin-bottom: 10px;  margin-left: 15px;">
                <view class="querybox_title">项目：</view>
                <view>{{yjprojectname}}</view>
              </view>
              <view style="margin-right: 15px; margin-bottom: 10px;">
                <u-button type="primary" v-if="jytableInfolist.length>0" icon="arrow-downward" size="small" text="导出"
                  @click="daochu()"></u-button>
              </view>
            </view>
            <u-table row-key="createTime" rowHeight="150" customClass="mewtable2" ref="pageTable" :scrollX="true"
              :cellStyle="{padding:'10px 10px 0px 10px'}" :data="jytableInfolist" :ellipsis="false" height="440"
              :border="true" style="width:98%; margin: 0 auto;">
              <u-table-column type="index" fixed width="50" align="center" headerAlign="center"></u-table-column>
              <u-table-column prop="specialty" width="180" label="专业" headerAlign="center" />
              <u-table-column prop="issue" width="270" label="发现问题" headerAlign="center">
                <template #default="{ row, index }">
                  <view style="display: flex; flex-direction: row;">
                    <u-tag v-if="row.changeType==1" text="更" type="error" size="mini" style="max-width:26px; "></u-tag>
                    <view style="margin-left: 5px;"> {{row.issue}}</view>
                  </view>
                </template>
              </u-table-column>
              <u-table-column prop="" width="50" :headerEllipsis="false" label="问题图片" align="center"
                headerAlign="center">
                <template #default="{ row, index }">
                  <u-tag v-if="row.imgNum" @click="showimg(row)" :text="row.imgNum" type="primary" size="mini"></u-tag>
                </template>
              </u-table-column>
              <u-table-column prop="riskLevel" width="50" :headerEllipsis="false" label="风险等级" align="center"
                headerAlign="center">
                <template #default="{ row, index }">
                  <u-tag v-if="row.riskLevel"
                    :text="row.riskLevel=='1'?'A':row.riskLevel=='2'?'B':row.riskLevel=='3'?'C':''"
                    :type="row.riskLevel=='1'?'error':row.riskLevel=='2'?'warning':row.riskLevel=='3'?'success':''"
                    size="mini"></u-tag>
                </template>
              </u-table-column>
              <u-table-column prop="" width="250" align="center" label="处理建议" headerAlign="center">
                <template #default="{ row, index }">
                  {{row.suggestion}}
                </template>
              </u-table-column>
              <u-table-column prop="" width="100" align="center" label="整改难度" headerAlign="center">
                <template #default="{ row, index }">
                  <u-tag v-if="row.rectificationLevel"
                    :text="row.rectificationLevel=='1'?'难':row.rectificationLevel=='2'?'中等':row.rectificationLevel=='3'?'容易':''"
                    :type="row.rectificationLevel=='1'?'error':row.rectificationLevel=='2'?'warning':row.rectificationLevel=='3'?'success':''"
                    size="mini"></u-tag>
                </template>
              </u-table-column>
            </u-table>
          </view>
        </scroll-view>
      </view>
    </u-modal>
    <u-modal content="" :closeOnClickOverlay="true" title="图片预览" confirmText="关闭" width="600px" :show="imgboxshow"
      @confirm="() => imgboxshow = false">
      <view class="slot-content" style="width: 100%;min-height: 200px; max-height: 200px; overflow-y: auto;">
        <u-album :urls="imgurlslist" style="margin-top: 20px;" autoWrap showMore multipleSize="100"></u-album>
      </view>

    </u-modal>
    <u-toast ref="uToast"></u-toast>
    <uni-drawer ref="showright" mode="right" :width="850" :mask-click="true">

      <AddEditnr style="width: 100%;" :objitem="rowitem" :sjnum="sjnum" @sahnchuevent="sahnchuevent"
        @righteventclose="closeright" @shaunxian="getlistinfo()" />

    </uni-drawer>
    <UniMenu />
  </view>
</template>

<script>
  import {
    getprojectlist,
    getprojectlistdefaultCondtion,
    getprojectinfo,
    setsafety_hazardprojectstatus,
    delsafety_hazardproject
  } from "@/apis/xiangmu"

  import {
    daochuword,
    getsuggestionlist
  } from "@/apis/chulijianyi"


  import {

    getevaluationIdinfo
  } from "@/apis/wenjuan"

  import UniMenu from '@/components/uni-menu/uni-menu.vue'
  import comboxMore from '@/components/wl-combox-more/combox-more.vue'
  import useUserStore from '@/store/user';
  import CustomPicker from '@/components/custom-search-picker/index.vue';
  import AddEditnr from '@/pages/xiangmu/addxiangmu.vue';
  import {
    parseObjectToArray,
    downloadBinaryFile
  } from "@/utils/util"

  export default {
    components: {
      UniMenu,
      comboxMore,
      CustomPicker,
      AddEditnr
    },
    data() {
      return {
        // upurl: import.meta.env.VITE_APP_BASE_PRE + '/safety_hazard/table/img',
        //  httpurl: import.meta.env.VITE_APP_BASE_PRE,
        upurl: 'http://219.146.89.198:19388' + '/safety_hazard/table/img',
        httpurl: 'http://219.146.89.198:19388',
        userStore: useUserStore(),
        xmpickerVisible: false,
        addxmpickerVisible: false,
        xmpickerConfig: {
          title: '选择项目',
          options: [],
          displayKey: 'lablename',
          valueKey: 'projectId',
          multiple: false,
          searchable: true,
          value: ''
        },
        highRiskFlag: false,
        addxmpickerConfig: {
          title: '选择项目',
          options: [],
          displayKey: 'lablename',
          valueKey: 'projectId',
          multiple: false,
          searchable: true,
          value: ''
        },
        isedit: false,
        zhuangtailist: [{
          label: '待启动',
          value: '2'
        }, {
          label: '执行中',
          value: '3'
        }, {
          label: '完结',
          value: '4'
        }, ],
        danweilist: [{
          label: '一级单位',
          value: '1'
        }, {
          label: '二级单位',
          value: '2'
        }, {
          label: '三级单位',
          value: '3'
        }, ],
        formdata: {
          projectId: 0,
          rentRst: 0,
          chemicalsRst: 0,
          fireRst: 0,
          lastYearCheckRst: 0,
          lastYearConsultRst: 0,
          rentArea: "",
          rentPurpose: "",
          rentEndDate: "",
          chemicalsName: "",
          chemicalsQuantity: 0,
          storeAddress: "",
          storeType: "",
          fireDate: "",
          fireAddress: "",
          fireReason: "",
          fireLoss: "",
          fireResult: "",
          checkReportUrl: "",
          correctiveMeasures: "",
          signatureUrl: "",
          projectId: 0,
          remark: ""
        },
        modaltitle: '添加调查问卷',
        pjmodaltitle: '非火灾高危单位',
        pjmodalshow: false,
        pjtableInfolist: [],
        yjmodalshow: false,
        jytableInfolist: [],
        imgboxshow: false,
        imgurlslist: [],
        tableData: [],
        queryParams: {
          pageNum: 1,
          pageSize: 50,
          total: 0,
          projectNo: '', //项目编号
          customerLevel: null, //单位级别
          customerName: '', //单位名称-模糊匹配	
          contractId: null, //系统合同号
          name: '', //项目名称
          status: '', //项目状态
          statusList: [],
          projectLeaderNameLike: '', //项目负责人
          startDatelist: [],
          startDateStart: '', //启动时间
          startDateEnd: '', //启动时间-截止
          createTimelist: [],
          createTimeStart: '', //创建时间-起始	
          createTimeEnd: '', //	创建时间-截止
          reasonable: false,
        },
        yjprojectname: '',
        rowitem: null,
        sjnum: 0,
        addshow: false,
        infolist: [],
        activeitem: null,
        activenum: 0,
        addxmdwlist: [],
        activenumlist: [],
        xthtlist: [],
        xmdwlist: [
          //   {
          //   projectId: 0,
          //   projectNo: "001",
          //   customerCompany3Name: "撒大苏打",
          //   lablename: "001（撒大苏打）",
          // }, {
          //   projectId: 1,
          //   projectNo: "002",
          //   customerCompany3Name: "法国",
          //   lablename: "002（法国）",
          // },

        ],
      }
    },
    computed: {
      nick() {
        // debugger
        // return  userStore.username
        const userStore = useUserStore();
        return userStore.name
      },
      imageSrc() {

        const userStore = useUserStore();
        return userStore.avatar
      },

      username() {
        // debugger
        // return  userStore.username
        const userStore = useUserStore();
        return userStore.username
      },
      avatar() {
        //debugger
        const userStore = useUserStore();
        return userStore.avatar
      },
      windowHeight() {
        return uni.getSystemInfoSync().windowHeight - 50
      }
    },
    // // 监听页面返回
    // onBackPress() {
    //   //debugger
    //   uni.redirectTo({
    //     url: '/pages/index/index'
    //   });
    //   // 阻止界面返回默认操作， 这一步主要是为了防止界面出现异常，uniapp有对onBackPress的详细讲解
    //   return true;
    // },

    onShow() {
      this.getlistinfo(); //获取项目列表
      this.getcxtjlist(); //查询条件

      // this.getxmdwlist(); //获取项目单位列表
      const userStore = useUserStore();
      userStore.setparentmenutitle('项目');
      userStore.setchildrenmenutitle('项目列表');
    },

    onLoad(options) {
      //contractId=${item.contractId}&status=4`
      // debugger
      if (options.contractId && options.status) {
        this.queryParams.contractId = options.contractId;
        this.queryParams.statusList = [options.status];
        this.getlistinfo();
      }
      if (options.contractId && !options.status) {
        this.queryParams.contractId = options.contractId;
        this.queryParams.statusList = ['2', '3'];
        this.getlistinfo();
      }
    },
    methods: {
      parseObjectToArray,
      downloadBinaryFile,
      chaxunqy() {
        //查询
        this.getlistinfo()

      },
      resetqy() {
        //重置
        this.queryParams = {
          // pageNum: 1,
          // pageSize: 10,
          projectNo: '', //项目编号
          customerLevel: null, //单位级别
          customerName: '', //单位名称-模糊匹配	
          contractId: null, //系统合同号
          name: '', //项目名称
          status: '', //项目状态
          projectLeaderNameLike: '', //项目负责人
          startDatelist: [],
          startDateStart: '', //启动时间
          startDateEnd: '', //启动时间-截止
          createTimelist: [],
          createTimeStart: '', //创建时间-起始	
          createTimeEnd: '', //	创建时间-截止
          reasonable: false,
        };
        this.clearSelection();
        this.getlistinfo()

      },
      getcxtjlist() {
        //获取查询条件
        getprojectlistdefaultCondtion().then((res) => {
          // debugger
          this.xthtlist = this.parseObjectToArray(res.data.ctcIdMap);
        })
      },
      xmztchange(e) {
        //项目状态
        //  debugger
        // this.queryParams.status = e.value;
        this.getlistinfo(); //获取项目列表
      },
      xthtchange(e) {
        //系统合同号
        this.queryParams.contractId = e.value;
        this.getlistinfo(); //获取项目列表
      },

      dwjbchange(e) {
        //单位级别
        this.queryParams.customerLevel = e.value;
        this.getlistinfo(); //获取项目列表
      },
      qdcalendarConfirm(e) {
        //启动时间
        //  debugger
        if (e.length > 0) {
          // this.showCalendar = false;
          this.queryParams.startDateStart = e[0];
          this.queryParams.startDateEnd = e[1];
          this.queryParams.workTime = e;
        } else {
          this.queryParams.startDateStart = '';
          this.queryParams.startDateEnd = '';
          this.queryParams.startDatelist = [];
        }
        this.getlistinfo(); //获取项目列表

        // debugger
      },

      cjcalendarConfirm(e) {
        //创建时间
        //  debugger
        if (e.length > 0) {
          // this.showCalendar = false;
          this.queryParams.createTimeStart = e[0];
          this.queryParams.createTimeEnd = e[1];
          this.queryParams.createTimelist = e;
        } else {
          this.queryParams.createTimeStart = '';
          this.queryParams.createTimeEnd = '';
          this.queryParams.createTimelist = [];
        }
        this.getlistinfo(); //获取项目列表

        // debugger
      },
      qidong() {
        //启动   
        setsafety_hazardprojectstatus(this.activeitem.projectId, '1').then((res) => {
          // debugger
          this.$modal.msgSuccess("启动成功！");
          setTimeout(() => {
            this.getlistinfo(); //获取合同列表
          }, 300);
        });

      },
      wanjie() {
        //完结
        setsafety_hazardprojectstatus(this.activeitem.projectId, '2').then((res) => {
          this.$modal.msgSuccess("完结成功！");
          setTimeout(() => {
            this.getlistinfo(); //获取合同列表
          }, 300);
        });

      },

      pingjia() {
        this.pjtableInfolist = []
        getevaluationIdinfo(this.activeitem.projectId).then((res) => {
          //  debugger

          this.highRiskFlag = res.data.highRiskFlag;
          this.pjtableInfolist = res.data.tableInfo || [];


          if (this.highRiskFlag) {
            this.pjmodaltitle = '火灾高危单位';
          } else {
            this.pjmodaltitle = '非火灾高危单位';
          }

          this.pjmodalshow = true;
        });

      },

      daochu() {
        //导出
        let url = this.userStore.allurl + '/safety_hazard/suggestion/export?projectId=' + this.activeitem.projectId;
        this.downloadBinaryFile(url);
        // daochuword({
        //   projectId: this.activeitem.projectId
        // }).then((res) => {
        //   debugger

        // });
      },
      chulijianyi() {
        //处理建议
        this.jytableInfolist = []
        getsuggestionlist(this.activeitem.projectId).then((res) => {
          // debugger
          this.yjmodalshow = true;
          let datalist = res.data.suggestions || [];
          // for (let xx of datalist) {
          //   xx.editshow = false;
          // }
          this.jytableInfolist = datalist;
          this.yjprojectname = res.data.project ? res.data.project.projectNo + `(` + res.data.project
            .customerCompany3Name + ')' : '';

        });

      },


      hideKeyboard() {
        uni.hideKeyboard()
      },
      xmhandleConfirm(result) {
        // 处理确认项目
        //  debugger
        // console.log(result);
        this.xmpickerConfig.value = result.selectedItem;
        this.queryParams.projectname = result.selectedItem.lablename;
        this.queryParams.projectId = result.selectedItem.projectId;
        this.xmpickerVisible = false;
        this.getlistinfo(); //查询列表
      },
      xmhandleclear() {
        this.xmpickerConfig.value = '';
        this.queryParams.projectname = '';
        this.queryParams.projectId = '';
        setTimeout(() => {
          this.xmpickerVisible = false;
        }, 300);
        this.getlistinfo(); //查询列表

      },
      xmhandleCancel() {
        // 处理取消项目
        this.xmpickerVisible = false
      },
      addxmhandleConfirm(result) {
        // 处理确认项目
        //  debugger
        // console.log(result);
        this.addxmpickerConfig.value = result.selectedItem;
        this.formdata.projectname = result.selectedItem.lablename;
        this.formdata.projectId = result.selectedItem.projectId;
        this.addxmpickerVisible = false;

      },
      addxmhandleCancel() {
        // 处理取消项目
        this.addxmpickerVisible = false
      },


      shanchujiancha() {
        //删除
        // debugger
        let checkTableIds = this.activenumlist;
        //this.activeitem.projectId
        this.$modal.confirm('确定要删除此条信息吗？').then(() => {
          // debugger
          delsafety_hazardproject(checkTableIds).then((res) => {
            //  debugger
            if (res.data.failedDetailString) {
              this.$modal.msgError(res.data.failedDetailString);
            } else {
              this.$modal.msgSuccess("删除成功！");

              setTimeout(() => {
                this.getlistinfo(); //获取检查列表
              }, 1000);
            }

          })
        });
      },
      biangenls() {
        //变更日志


      },

      showimg(item) {
        // debugger
        if (!item.imgNum) return;
        this.imgurlslist = [];
        if (item.imgUrl.includes(',')) {
          // debugger
          // this.imgurlslist = item.imgUrl.split(",");
          let imglist = item.imgUrl.split(",");
          for (let s of imglist) {
            //this.imgurlslist.push(this.httpurl + s);
            this.imgurlslist.push(this.userStore.allurl + s);

          }
          // this.imgurlslist = imglist;
        } else {
          //this.imgurlslist = [this.httpurl + item.imgUrl]
          this.imgurlslist = [this.userStore.allurl + item.imgUrl]
        }
        // debugger
        this.imgboxshow = true;

      },
      baocun() {
        //保存


        // if (!this.formdata.standardCheckTableId) {
        //   this.$modal.msgError("请选择要素！")
        //   return;
        // } else if (!this.formdata.buildingId) {
        //   this.$modal.msgError("请选择建筑物！")
        //   return;
        // }
        if (!this.formdata.projectId) {
          this.$modal.msgError("请选择项目编号！")

          // setTimeout(() => {
          //   debugger
          // }, 1000)

          return;
        }
        // this.formdata.projectId = this.queryParams.projectId;

        // debugger
        if (this.formdata.projectId != null) {
          //编辑
          upquestionnaire(this.formdata).then(res => {
            //debugger
            this.$modal.msgSuccess("修改成功！");
            this.addshow = false;

            setTimeout(() => {
              this.getlistinfo(); //获取问卷列表
            }, 300);

          });
        } else {
          addquestionnaire(this.formdata).then(res => {
            // debugger
            this.$modal.msgSuccess("添加成功！");
            this.addshow = false;
            setTimeout(() => {
              this.getlistinfo();
            }, 300);

          });
        }

      },

      clearSelection() {
        //清空选中项
        this.$nextTick(() => {
          this.$refs.pageTable.clearSelection();
        });
        this.activeitem = null;
        this.activenum = 0;

      },
      // handleSelectionChange(selection) {
      //   // debugger
      //   // let del_row = selection.shift();
      //   // this.$refs.pageTable.toggleRowSelection(del_row, false);

      //   // console.log('当前选中的行:', JSON.stringify(selection));
      //   //this.$refs.pageTable.toggleAllSelection(false);
      //   //  this.$refs.pageTable.clearSelection();
      //   // this.$refs.pageTable.toggleRowSelection(selection.index, true);
      //   this.activenum = selection.detail.index.length;
      //   if (selection.detail.index.length > 1) {
      //     // debugger
      //     this.$modal.msgError("只能选一个！");
      //     this.activeitem = null;
      //     // this.$refs.pageTable.toggleRowSelection(selection.detail.index[selection.detail.index.length - 1], false);
      //     // this.$refs.pageTable.toggleAllSelection(true);
      //     // this.$refs.pageTable.clearSelection();
      //     return;
      //   }
      //   // this.$refs.pageTable.clearSelection();
      //   if (selection.detail.index.length == 0) {
      //     this.activeitem = null;
      //   } else {
      //     this.activeitem = this.tableData[selection.detail.index[selection.detail.index.length - 1]];
      //   }
      // },
      handleSelectionChange(selection) {
        // debugger
        // let del_row = selection.shift();
        // this.$refs.pageTable.toggleRowSelection(del_row, false);

        // console.log('当前选中的行:', JSON.stringify(selection));
        //this.$refs.pageTable.toggleAllSelection(false);
        //  this.$refs.pageTable.clearSelection();
        // this.$refs.pageTable.toggleRowSelection(selection.index, true);
        this.activenumlist = [];
        this.activenum = selection.length;
        // this.activenumlist=selection.map
        for (let s of selection) {
          if (s.projectId) {
            this.activenumlist.push(s.projectId)
          } else {
            //   this.$refs.pageTable.toggleRowSelection(s, false);

            // this.$refs.pageTable.clearSelection()
            // this.$modal.msgError("此项没有检查点！");

          }

        }


        if (selection.length > 1) {
          // debugger
          // this.$modal.msgError("只能选一个！");
          this.activeitem = null;
          // this.$refs.pageTable.toggleRowSelection(selection.detail.index[selection.detail.index.length - 1], false);
          // this.$refs.pageTable.toggleAllSelection(true);
          // this.$refs.pageTable.clearSelection();
          return;
        }
        if (selection.length == 0) {
          this.activeitem = null;
          //   this.isbutclick = false;
        } else {
          // this.activeitem = this.tableData[selection.detail.index[selection.detail.index.length - 1]];

          this.activeitem = selection[0];
        }
        if (this.activeitem) {
          //debugger
          if (this.activeitem.projectId == null) {
            //   this.isbutclick = false;
          } else {
            //  this.isbutclick = true;
          }
        }





        // this.$refs.pageTable.clearSelection();

      },


      getlistinfo() {
        //获取项目列表
        this.tableData = [];
        this.clearSelection(); //清空
        getprojectlist(this.queryParams).then((res) => {
          // debugger
          this.tableData = res.rows || [];
          this.queryParams.total = res.total;

        })
      },


      getaddxmdwlist() {
        //获取新增时的未添加项目
        getadddefaultcondition().then((res) => {
          //debugger
          res.rows = res.rows || [];
          for (let s of res.rows) {
            s.lablename = s.projectNo + `（${s.customerCompany3Name}）`;
          }
          this.addxmdwlist = res.rows || [];

          this.addxmpickerConfig.options = res.rows || [];
          // if (this.addxmdwlist.length > 0) {
          //   //debugger
          //   // this.queryParams.projectId = this.xmdwlist[0].projectId;
          //   // this.queryParams.projectname = this.xmdwlist[0].lablename;
          //   // this.xmpickerConfig.value = this.xmdwlist[0].projectId;
          // }


        })

      },

      getxmdwlist() {
        //获取项目单位列表
        getxmdwdefaultconditionlist().then((res) => {
          //debugger
          res.data.projects = res.data.projects || [];
          for (let s of res.data.projects) {
            s.lablename = s.projectNo + `（${s.customerCompany3Name}）`;
          }
          this.xmdwlist = res.data.projects || [];

          this.xmpickerConfig.options = res.data.projects || [];
          if (this.xmdwlist.length > 0) {
            //debugger
            // this.queryParams.projectId = this.xmdwlist[0].projectId;
            // this.queryParams.projectname = this.xmdwlist[0].lablename;
            // this.xmpickerConfig.value = this.xmdwlist[0].projectId;
          }

          this.getlistinfo(); //获取问卷列表
        })
      },
      clickcell(row, column, cell, event) {
        debugger
      },
      halechange() {
        //查询  
        this.getlistinfo(); //获取问卷列表
      },
      banhaoselectionEvent(selection, selectObj) {
        console.log('selectionEvent:', selection, selectObj)
      },
      closeright() {
        // debugger
        this.rowitem = null;
        this.$refs.showright.close();
        this.getlistinfo(); //获取检查列表
      },
      sahnchuevent(e) {
        //删除
        this.activenumlist = [];
        this.activenumlist.push(e)
        this.$refs.showright.close();
        this.shanchujiancha();

      },
      openright() {
        // /debugger
        // uni.navigateTo({
        //   url: `/pages/zhixing/addjianchabiao?isedit=1&projectid=${this.activeitem.projectId}&checkTableId=${this.activeitem.checkTableId}&id1=${this.activeitem.standardCheckTable1Id}&id2=${this.activeitem.standardCheckTable2Id}&id3=${this.activeitem.standardCheckTable3Id}&id4=${this.activeitem.standardCheckTable4Id}&projectName=${this.queryParams.projectname}`,
        // })
        // item.isedit = 1;
        // item.projectid = item.projectId;
        // item.projectName = this.queryParams.projectname;
        // item.id1 = item.standardCheckTable1Id;
        // item.id2 = item.standardCheckTable2Id;
        // item.id3 = item.standardCheckTable3Id;
        // item.id4 = item.standardCheckTable4Id;
        // this.rowitem = item;
        let item2 = {
          isedit: 0,
        }
        this.rowitem = item2;
        this.sjnum = Math.random();
        this.$refs.showright.open();
      },

      upxiangmu() {
        //编辑
        let item = {
          projectid: this.activeitem.projectId,
          isedit: 1,
          projectName: this.activeitem.name,

        }
        this.rowitem = item;
        this.sjnum = Math.random();
        this.$refs.showright.open();

      },



    }
  }
</script>

<style lang="scss" scoped>
  .zhixing_top {
    width: 100%;
    display: flex;
    flex-direction: column;


  }

  .querybox {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-right: 10px;

    .querybox_title {
      font-size: 13px;
      text-align: right;
      justify-content: end;
    }
  }

  ::v-deep .infotable {
    .xincellclass {}

    .u-table-header {
      z-index: 0;
    }

    .u-table-cell {
      .u-table-cell_content {
        padding: 0rpx 16rpx 0rpx 16rpx;
        white-space: normal;
        text-align: left;

      }
    }
  }


  ::v-deep .uni-table {
    // tr:first-child th:nth-of-type(1) {

    //   /* 你的样式 */
    //   .uni-table-checkbox {
    //     display: none !important;
    //   }

    //   //
    // }
    .frisytr {
      .uni-table-checkbox {
        display: none !important;
      }
    }

    .checkbox__inner {
      z-index: 0 !important;
    }
  }

  .wenjuanadbox {
    display: flex;
    flex-direction: column;

    .querybox1 {
      display: flex;
      flex-direction: row;
      // align-items: center;
      justify-content: space-between;

      .querybox_title {
        // text-align: right;
        text-align: right;
        justify-content: end;
      }
    }

  }

  ::v-deep .mewtable2 {
    .u-table__header {
      .u-checkbox {
        // display: none !important;
        // visibility: hidden !important;
      }

      .u-table__cell {
        //justify-content: center !important;
        min-height: 50px !important;

      }

      .u-table__rows {
        //border-bottom: 1px solid #dadbde !important;

        ::v-deep .u-table__cell {
          //justify-content: center !important;
          // min-height: 50px !important;
          height: auto !important;
        }

      }


    }

    .u-table__body {
      .u-table__rows {
        border-bottom: 1px solid #dadbde !important;

        .u-table__cell {
          z-index: 0 !important;
        }
      }
    }

  }
</style>