<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: row;margin-bottom: 10px; margin-left: 10px;">
        <view class="querybox">
          <view class="querybox_title" style="display: flex; flex-direction: row;">
            <view style="color: #ca4341; margin-right:5px;">*</view>
            <view>项目编号：</view>
          </view>
          <!-- <combox-more style="width:150px;" @onSelect="banhaoselectionEvent" label=""></combox-more> -->
          <!-- <piaoyi-select style="300px" :inputValue.sync="queryParams.projectId" ref="piaoyiSelect" :clearable="true"
            :filterable="true" placeholder="请选择项目编号" valueKey="projectId" label="lablename" :options="xmdwlist"
            @changeval="halechange">
          </piaoyi-select> -->
          <!-- 项目自定义选择器组件 -->
          <view @click="xmpickerVisible = true; hideKeyboard()">
            <u-input style="width: 400px;" v-model="queryParams.projectname" disabled disabledColor="#ffffff"
              placeholder="请选择项目编号"></u-input>
          </view>

        </view>
        <view class="querybox">
          <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="search" text="查询"
            @click="getlistinfo()"></u-button>
        </view>

      </view>
      <view style="margin-top: 20px; margin-bottom: 10px; margin-left:200px;">
        <!--  :disabled="activenum>=2||(activenum>0&!isbutclick)" -->
        <!--  <u-button style="width:100px; float: left; margin-left:10px;" type="success" icon="plus-circle" text="添加检查点"
          :disabled="activenum>=2" @click="addjiancha()" size="small"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="edit-pen" text="编辑检查点"
          :disabled="activenum!=1||!isbutclick" @click="upjiancha()" size="small"></u-button> -->
        <u-button style="width:100px; float: left;margin-left: 20px;" type="error" icon="trash" text="删除检查点"
          :disabled="activenum==0||!isbutclick" @click="shanchujiancha()" size="small"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="warning" icon="info-circle" text="变更日志"
          @click="biangenls()" :disabled="activenum!=1||!isbutclick" size="small"></u-button>
        <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="list-dot" text="评价表"
          :disabled="!queryParams.projectId" @click="pingjia()" size="small"></u-button>
      </view>
    </view>

    <view class="zhixing_center" style="display: flex; flex-direction: row; width: 100%;">
      <view
        style=" width:19%;margin-right: 1%; padding: 10px; height: 460px; max-height: 460; overflow-y: auto; border:1px solid #e4e7ed ">
        <!-- <u-tree @checked="treechange" expand-icon="arrow-right-fill" collapse-icon="arrow-down-fill" :data="treelist"
          key-field="standardCheckTableId" label-field="name" children-field="children" :check-on-click="true"
          expand-on-click /> -->

        <view style=" float: right; " @click="qingchu()">
          <u-icon label="清除" size="20" labelColor="#3c9cff" color="#3c9cff" name="reload"></u-icon>
        </view>
        <!-- <u-tree :data="treelist" :props="{ children: 'children',
        label: 'name',
        nodeKey: 'standardCheckTableId'}" @node-click="treechange" /> -->

        <!--   <vrapile-tree ref="vrapileTreeRef" style="margin-top:20px;"
          :defaultProps="{id: 'standardCheckTableId',label:'name',children:'children' }" :data="treelist"
          @node-click="treechange"> </vrapile-tree> -->
        <!-- <LoadTree :list="treelist" :isFirst="true" @change="treechange"></LoadTree> -->
        <!--        <Op-Cascader v-model="acyivetree" :option="treelist" :defProps="{ children: 'children',
  label: 'name',
  nodeKey: 'standardCheckTableId'}" :sjnum="sjnum" :iconShow="true" maxHeight="600rpx"
          @change="treechange"></Op-Cascader> -->
        <u-tree style="float: left;" :data="treelist" v-if="treelist.length>0" key-field="standardCheckTableId"
          label-field="name" children-field="children" selectable selected-bg-color=" #e5e5e5">
          <template #content="{ node }">
            <view class="custom-content" @click="treechange(node)" style=" padding: 6px 0 6px 0 !important;">
              <text class="custom-label" style="font-size: 12px;">{{ node.name }}</text>
            </view>
          </template>
        </u-tree>
      </view>
      <view style="width:80%;display: flex; flex-direction: column;">
        <u-table row-key="createTime" rowHeight="150" customClass="mewtable2" ref="pageTable" :scrollX="true"
          :cellStyle="{padding:'10px 10px 0px 10px'}" :data="tableData" :ellipsis="false" height="460" :border="true"
          @select="handleSelectionChange">
          <!-- :span-method="spanMethodWithColspan" -->
          <u-table-column type="selection" fixed width="55" align="center" headerAlign="center"></u-table-column>

          <u-table-column prop="name3" width="100" label="子项" headerAlign="center" />
          <u-table-column prop="name4" width="200" label="要素" headerAlign="center">
            <template #default="{ row, index }">
              <view style="height: auto !important;">
                <!-- <u-link :text="row.name4" :under-line="true" @click.navite="openright(row)"></u-link> -->
                <u-text :text="row.name4" type="primary" decoration="underline" @click="openright(row)"></u-text>
              </view>
            </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="checkPoint" width="100" label="检查点位" headerAlign="center" />
          <u-table-column prop="" width="70" :headerEllipsis="false" align="center" label="是否存在问题" headerAlign="center">
            <template #default="{ row, index }">
              <!--   {{row.result=='1'?'是':row.result=='2'?'否':row.result=='3'?'不涉及':''}}-->
              <u-tag v-if="row.result" :text="row.result=='1'?'是':row.result=='2'?'否':row.result=='3'?'不涉及':''"
                :type="row.result=='1'?'error':row.result=='2'?'success':row.result=='3'?'primary':''"
                size="mini"></u-tag>
            </template>
          </u-table-column>
          <u-table-column prop="" width="70" :headerEllipsis="false" align="center" label="问题是否因规范更替引起"
            headerAlign="center">
            <template #default="{ row, index }">
              <!--   {{row.result=='1'?'是':row.result=='2'?'否':row.result=='3'?'不涉及':''}}-->
              <u-tag v-if="row.issueStandardChanged"
                :text="row.issueStandardChanged=='1'?'是':row.issueStandardChanged=='2'?'否':row.result=='3'?'不涉及':''"
                :type="row.issueStandardChanged=='1'?'error':row.issueStandardChanged=='2'?'success':row.issueStandardChanged=='3'?'primary':''"
                size="mini"></u-tag>
            </template>
          </u-table-column>


          <u-table-column prop="issue" width="150" label="问题描述" headerAlign="center" />
          <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>
              <!-- <view @click="showimg(row)" @longpress="handleLongPress()"
                style="width: 100%; height: 100%; text-align: center; justify-content: center;">
                <u-text align="center" type="primary" :text="row.imgNum" v-if="row.imgNum"
                  style=" margin: 0 auto;width: 100%; height: 100%;"></u-text>
              </view> -->
            </template>
          </u-table-column>
          <u-table-column prop="score" width="100" label="得分" align="center" headerAlign="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:ss"):''}}
            </template>
          </u-table-column>
        </u-table>
        <view style="width:98%; margin: 0 auto; text-align: center; line-height:30px;">小计：{{statistic}} </view>

      </view>




    </view>
    <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-modal content="" :closeOnClickOverlay="true" title="变更日志" confirmText="关闭" width="600px" :show="biangenshow"
      @confirm="() => biangenshow = false">
      <view class="slot-content biangengcontent" 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;">
            <!--   <u-steps direction="column">
            <u-steps-item v-for="(item,index) in bglslist" :key="index" :title="item.info" :desc="item.createTime">
            </u-steps-item>
          </u-steps> -->
            <uni-steps :options="bglslist" style="color: #999;" :active="bglslist.length" active-color="#007AFF"
              direction="column" />
          </view>
        </scroll-view>
      </view>
    </u-modal>

    <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>
    <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" />
    <uni-drawer ref="showright" mode="right" :width="550" :mask-click="true">
      <scroll-view scroll-y="true" style="height: 100%;">
        <AddEditnr style="width: 100%;" :objitem="rowitem" :sjnum="sjnum" @sahnchuevent="sahnchuevent"
          @righteventclose="closeright" @shaunxian="getlistinfo()" />
      </scroll-view>
    </uni-drawer>
    <UniMenu />
  </view>
</template>

<script>
  import {
    getsafety_hazardInfo,
    getxmdwdefaultconditionlist,
    getloginfo,
    delsafety_hazard,
    getcheckTableIdtree
  } from "@/apis/zhixing"
  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/zhixing/addjianchabiao.vue';


  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:19380/prod-api',
        userStore: useUserStore(),
        xmpickerVisible: false,
        isbutclick: false,
        xmpickerConfig: {
          title: '选择项目',
          options: [],
          displayKey: 'lablename',
          valueKey: 'projectId',
          multiple: false,
          searchable: true,
          value: ''
        },
        statistic: '',
        columns: [{
            type: 'selection',
            width: '50px',
            align: 'center'
          }, {
            title: '项目编号',
            key: 'projectName',
            align: 'center',
            width: '100px',
          },
          {
            title: '专业',
            key: 'name1',
            align: 'center'
          },
          {
            title: '单项',
            key: 'name2',
            align: 'center'
          },
          {
            title: '子项',
            key: 'name3',

            align: 'center'
          },
          {
            title: '要素',
            key: 'name4',
            align: 'center'
          },
          {
            title: '检查点位',
            key: 'checkPoint',
            align: 'center'
          },
          {
            title: '是否存在问题',
            key: 'result',
            align: 'center',
            width: '100px',
          },
          {
            title: '问题描述',
            key: 'issue',
            align: 'center'
          },
          {
            title: '问题图片',
            key: 'imgNum',
            align: 'center',
            width: '100px',
          },
          {
            title: '得分',
            key: 'score',
            align: 'center',
            width: '100px',
          },
          {
            title: '制单',
            key: 'createTime',
            align: 'center',
            width: '100px',

          },
          {
            title: '创建时间',
            key: 'createBy',
            align: 'center',

            width: '100px',
          },
        ],
        checkedkeys: [0],
        expandedkeys: [0],
        acyivetree: [],
        biangenshow: false,
        imgboxshow: false,
        imgurlslist: [],
        tableData: [],
        bglslist: [],
        queryParams: {
          // pageNum: 1,
          // pageSize: 10,
          projectId: null,
          projectname: '',
          standardCheckTable1Id: null,
          standardCheckTable2Id: null,
          standardCheckTable3Id: null,
          standardCheckTable4Id: null,
          reasonable: false,
        },
        infolist: [],
        activeitem: null,
        rowitem: null,
        activenum: 0,
        activenumlist: 0,
        sjnum: 0,
        pjmodaltitle: '非火灾高危单位',
        pjmodalshow: false,
        pjtableInfolist: [],
        treelist: [],
        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(); //获取检查列表

      if (this.queryParams.projectId) {
        this.getlistinfo(); //获取检查列表
      }

      const userStore = useUserStore();
      userStore.setparentmenutitle('执行');
      userStore.setchildrenmenutitle('检查表');
    },
    onLoad() {
      // this.getUser()
      this.getxmdwlist(); //获取项目单位列表
      this.getjctree();
    },
    methods: {

      getjctree() {
        //请求树

        getcheckTableIdtree().then((res) => {
          // debugger
          this.treelist = res.data;
          this.sjnum = Math.random();
        });
      },
      // 合并单元格方法三：自动合并相同值的单元格
      spanMethodWithColspan({
        row,
        column,
        rowIndex,
        columnIndex
      }) {
        if (column.prop === 'name1') {
          // 计算相同地区的连续行数
          const currentValue = row[column.prop]
          let startIndex = rowIndex
          let endIndex = rowIndex
          //console.log('currentValue', this.tableData)
          // 向前找到开始位置
          while (startIndex > 0 && this.tableData[startIndex - 1][column.prop] === currentValue) {
            startIndex--
          }

          // 向后找到结束位置
          while (endIndex < this.tableData.length - 1 && this.tableData[endIndex + 1][column.prop] === currentValue) {
            endIndex++
          }

          const spanCount = endIndex - startIndex + 1

          if (spanCount > 1) {
            if (rowIndex === startIndex) {
              // 第一行显示合并的单元格
              return {
                rowspan: spanCount,
                colspan: 1
              }
            } else {
              // 其他行隐藏
              return {
                rowspan: 0,
                colspan: 0
              }
            }
          }
        }
        if (column.prop === 'name2') {
          // 计算相同地区的连续行数
          const currentValue = row[column.prop]
          let startIndex = rowIndex
          let endIndex = rowIndex
          //console.log('currentValue', this.tableData)
          // 向前找到开始位置
          while (startIndex > 0 && this.tableData[startIndex - 1][column.prop] === currentValue) {
            startIndex--
          }

          // 向后找到结束位置
          while (endIndex < this.tableData.length - 1 && this.tableData[endIndex + 1][column.prop] === currentValue) {
            endIndex++
          }

          const spanCount = endIndex - startIndex + 1

          if (spanCount > 1) {
            if (rowIndex === startIndex) {
              // 第一行显示合并的单元格
              return {
                rowspan: spanCount,
                colspan: 1
              }
            } else {
              // 其他行隐藏
              return {
                rowspan: 0,
                colspan: 0
              }
            }
          }
        }
        if (column.prop === 'name3') {
          // 计算相同地区的连续行数
          const currentValue = row[column.prop]
          let startIndex = rowIndex
          let endIndex = rowIndex
          //console.log('currentValue', this.tableData)
          // 向前找到开始位置
          while (startIndex > 0 && this.tableData[startIndex - 1][column.prop] === currentValue) {
            startIndex--
          }

          // 向后找到结束位置
          while (endIndex < this.tableData.length - 1 && this.tableData[endIndex + 1][column.prop] === currentValue) {
            endIndex++
          }

          const spanCount = endIndex - startIndex + 1

          if (spanCount > 1) {
            if (rowIndex === startIndex) {
              // 第一行显示合并的单元格
              return {
                rowspan: spanCount,
                colspan: 1
              }
            } else {
              // 其他行隐藏
              return {
                rowspan: 0,
                colspan: 0
              }
            }
          }
        }
        if (column.prop === 'name4') {
          // 计算相同地区的连续行数
          const currentValue = row[column.prop]
          let startIndex = rowIndex
          let endIndex = rowIndex
          //console.log('currentValue', this.tableData)
          // 向前找到开始位置
          while (startIndex > 0 && this.tableData[startIndex - 1][column.prop] === currentValue) {
            startIndex--
          }

          // 向后找到结束位置
          while (endIndex < this.tableData.length - 1 && this.tableData[endIndex + 1][column.prop] === currentValue) {
            endIndex++
          }

          const spanCount = endIndex - startIndex + 1

          if (spanCount > 1) {
            if (rowIndex === startIndex) {
              // 第一行显示合并的单元格
              return {
                rowspan: spanCount,
                colspan: 1
              }
            } else {
              // 其他行隐藏
              return {
                rowspan: 0,
                colspan: 0
              }
            }
          }
        }
        return {
          rowspan: 1,
          colspan: 1
        }
      },
      locationreload() {
        uni.reload();
      },
      pingjia() {
        getevaluationIdinfo(this.queryParams.projectId).then((res) => {
          //  debugger
          this.pjtableInfolist = []
          this.highRiskFlag = res.data.highRiskFlag;
          this.pjtableInfolist = res.data.tableInfo || [];


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

          this.pjmodalshow = true;
        });

      },
      getbglslist() {
        //获取变更日志
        getloginfo(this.activeitem.checkTableId).then((res) => {
          //debugger
          this.biangenshow = true;
          // this.bglslist = res.rows;
          res.rows = res.rows || [];
          for (let s of res.rows) {
            s.title = s.info + ` -（${s.createBy}）`;
            s.desc = s.createTime ? this.$dayjs(s.createTime).format("YYYY-MM-DD HH:mm:ss") : '';

          }
          this.bglslist = res.rows;
        })
      },

      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(); //查询列表
      },
      xmhandleCancel() {
        // 处理取消项目
        this.xmpickerVisible = false
      },
      biangenls() {
        //变更日志
        this.getbglslist();
        //获取变更日志

      },
      showimg(item) {
        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;

      },

      addjiancha() {
        //新增
        if (this.activeitem) {
          uni.navigateTo({
            url: `/pages/zhixing/addjianchabiao?isedit=0&projectid=${this.queryParams.projectId}&projectName=${this.queryParams.projectname}&checkTableId=${this.activeitem.checkTableId}&id1=${this.activeitem.standardCheckTable1Id}&id2=${this.activeitem.standardCheckTable2Id}&id3=${this.activeitem.standardCheckTable3Id}&id4=${this.activeitem.standardCheckTable4Id}`,
          })
        } else {
          uni.navigateTo({
            url: `/pages/zhixing/addjianchabiao?isedit=0&projectid=${this.queryParams.projectId}&projectName=${this.queryParams.projectname}`,
          })
        }

      },
      upjiancha() {
        //编辑
        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}`,
        })
      },
      shanchujiancha() {
        //删除
        this.$modal.confirm('确定要删除信息吗？').then(() => {
          // debugger
          //this.activenumlist
          // this.activeitem.checkTableId
          let checkTableIds = this.activenumlist

          delsafety_hazard(checkTableIds).then((res) => {
            //  debugger
            this.$modal.msgSuccess("删除成功！");
            setTimeout(() => {
              this.getlistinfo(); //获取检查列表
            }, 300);

          })
        });
      },
      clearSelection() {
        //清空选中项
        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.activenumlist = [];
        this.activenum = selection.length;
        // this.activenumlist=selection.map
        for (let s of selection) {
          if (s.checkTableId) {
            this.activenumlist.push(s.checkTableId)
          } 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.checkTableId == null) {
            this.isbutclick = false;
          } else {
            this.isbutclick = true;
          }
        }





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

      },
      getlistinfo() {
        //获取检查列表
        this.tableData = [];
        this.statistic = '';
        this.clearSelection(); //清空
        //  this.queryParams.projectname = null;
        getsafety_hazardInfo(this.queryParams).then((res) => {
          //debugger
          this.tableData = res.rows || [];
          this.statistic = res.statistic;
        })
      },
      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];
            // this.xmpickerConfig.value = this.xmdwlist.filter(item => res.data.areaIds.includes(item.value));
          }

          this.getlistinfo(); //获取检查列表
        })
      },

      halechange() {
        //查询  
        this.getlistinfo(); //获取检查列表
      },
      banhaoselectionEvent(selection, selectObj) {
        console.log('selectionEvent:', selection, selectObj)
      },
      handleLongPress() {
        this.$modal.msgError("只能选一个！");
      },
      openright(item) {
        // /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;
        this.sjnum = Math.random();
        this.$refs.showright.open();
      },
      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();




      },
      treechange(em, d) {
        // debugger

        if (em.level == 1) {
          this.queryParams.standardCheckTable1Id = em.standardCheckTableId;
          this.queryParams.standardCheckTable2Id = null;
          this.queryParams.standardCheckTable3Id = null;
          this.queryParams.standardCheckTable4Id = null;
        } else if (em.level == 2) {
          this.queryParams.standardCheckTable2Id = em.standardCheckTableId;
          this.queryParams.standardCheckTable1Id = null;
          this.queryParams.standardCheckTable3Id = null;
          this.queryParams.standardCheckTable4Id = null;
        } else if (em.level == 3) {
          this.queryParams.standardCheckTable3Id = em.standardCheckTableId;
          this.queryParams.standardCheckTable1Id = null;
          this.queryParams.standardCheckTable2Id = null;
          this.queryParams.standardCheckTable4Id = null;
        } else if (em.level == 4) {
          this.queryParams.standardCheckTable4Id = em.standardCheckTableId;
          this.queryParams.standardCheckTable2Id = null;
          this.queryParams.standardCheckTable3Id = null;
          this.queryParams.standardCheckTable1Id = null;
        }
        this.getlistinfo(); //获取检查列表

      },
      qingchu() {
        this.queryParams.standardCheckTable1Id = null;
        this.queryParams.standardCheckTable2Id = null;
        this.queryParams.standardCheckTable3Id = null;
        this.queryParams.standardCheckTable4Id = null;
        //let mewlist = JSON.parse(JSON.stringify(this.treelist));
        this.treelist = [];
        //this.treelist = mewlist;
        //  this.checkedkeys = [];
        //  this.expandedkeys = []

        this.getjctree();

        this.getlistinfo(); //获取检查列表
      }
    }
  }
</script>

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

    .querybox {
      display: flex;
      flex-direction: row;
      align-items: center;

      .querybox_title {}
    }
  }

  ::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;
    }
  }

  ::v-deep .biangengcontent {
    .uni-steps__column-title {
      color: #666 !important;
    }

    .uni-steps__column-desc {
      color: #666 !important;
    }
  }


  ::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 {
        ::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;
      }
    }
  }
</style>