<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" style=" margin-right:20px;">
          <view class="querybox_title" style="display: flex; flex-direction: row;">
            <view style="color: #ca4341; margin-right:5px;">*</view>
            <view>系统合同号(执行中)：</view>
          </view>
          <csr-uni-data-select :filterable="true" v-model="contractId" placeholder="请选择系统合同号" dataKey="label"
            dataValue="value" :localdata="xththlist" @change="changexthth" :clear="false"
            style="width: 400px;"></csr-uni-data-select>
        </view>
        <view class="querybox">
          <view class="querybox_title" style="display: flex; flex-direction: row;">
            <view style="color: #ca4341; margin-right:5px;">*</view>
            <view>项目编号：</view>
          </view>
          <csr-uni-data-select :filterable="true" v-model="queryParams.projectId" placeholder="请选择项目编号"
            dataKey="lablename" dataValue="projectId" :localdata="xmpickerConfig.options" :clear="false"
            style="width: 400px;"></csr-uni-data-select>
        </view>


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

      </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="addwenjuan()" size="small" v-if="$checkPermi(['safety_hazard:questionnaire:add'])"></u-button>
        <!--   <u-button style="width:100px; float: left;margin-left: 20px;" type="primary" icon="edit-pen" text="编辑问卷"
          :disabled="activenum!=1" @click="upwenjuan()" size="small"></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:questionnaire:remove'])"></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>
      </view>
    </view>

    <view class="zhixing_center">
      <!-- <uni-table border ref="pageTable" style="width:98%; margin: 0 auto; max-height:450px; " type="selection"
        @selection-change="handleSelectionChange">
        <uni-tr class="frisytr" style="background-color: #f5f5f5;">
          <uni-th align="center" width="220">项目编号</uni-th>
          <uni-th align="center">是否租赁</uni-th>
          <uni-th align="center">是否存放易燃易爆危险化学品</uni-th>
          <uni-th align="center">近1年内是否发生过火灾</uni-th>
          <uni-th align="center">上一年度是否进行消防设施年度检测</uni-th>
          <uni-th align="center">上一年度是否进行消防安全咨询评估</uni-th>
          <uni-th align="center" width="120">制单</uni-th>
          <uni-th align="center" width="200">创建时间</uni-th>
        </uni-tr>
        <uni-tr v-for="(item, index) in tableData" :key="index">
          <uni-td align="center">{{item.projectName}}</uni-td>
          <uni-td align="center">
            {{item.rentRst=='1'?'是':item.rentRst=='2'?'否':item.rentRst=='3'?'不涉及':''}}
          </uni-td>
          <uni-td align="center">
            {{item.chemicalsRst=='1'?'是':item.chemicalsRst=='2'?'否':item.chemicalsRst=='3'?'不涉及':''}}
          </uni-td>
          <uni-td align="center">
            {{item.fireRst=='1'?'是':item.fireRst=='2'?'否':item.fireRst=='3'?'不涉及':''}}
          </uni-td>
          <uni-td align="center">
            {{item.lastYearCheckRst=='1'?'是':item.lastYearCheckRst=='2'?'否':item.lastYearCheckRst=='3'?'不涉及':''}}
          </uni-td>
          <uni-td align="center">
            {{item.lastYearConsultRst=='1'?'是':item.lastYearConsultRst=='2'?'否':item.lastYearConsultRst=='3'?'不涉及':''}}
          </uni-td>
          <uni-td align="center">{{item.createBy}}</uni-td>
          <uni-td align="center">{{item.createTime?$dayjs(item.createTime).format("YYYY-MM-DD HH:mm:ss"):''}}</uni-td>
        </uni-tr>
      </uni-table> -->


      <u-table row-key="createTime" rowHeight="60" customClass="mewtable2" ref="pageTable" :scrollX="true"
        :cellStyle="{padding:'10px 10px 0px 10px'}" :data="tableData" :ellipsis="false" height="480" :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="180" label="项目编号" headerAlign="center">
          <template #default="{ row, index }">
            <!-- <u-text :text="row.projectNo" v-if="$checkPermi(['safety_hazard:questionnaire:edit'])" type="primary"
              decoration="underline" @click="upedit(row)"></u-text>
            <view v-else>{{row.projectNo}}</view> -->
            <u-text :text="row.projectNo" type="primary" decoration="underline" @click="upedit(row)"></u-text>
          </template>
        </u-table-column>
        <u-table-column prop="" width="180" align="center" label="是否租赁" headerAlign="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.rentRst" :text="row.rentRst=='1'?'是':row.rentRst=='2'?'否':row.result=='3'?'不涉及':''"
              :type="row.rentRst=='1'?'error':row.rentRst=='2'?'success':row.rentRst=='3'?'primary':''"
              size="mini"></u-tag>
          </template>
        </u-table-column>
        <u-table-column prop="" width="180" align="center" label="是否存放易燃易爆危险化学品" headerAlign="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.chemicalsRst"
              :text="row.chemicalsRst=='1'?'是':row.chemicalsRst=='2'?'否':row.chemicalsRst=='3'?'不涉及':''"
              :type="row.chemicalsRst=='1'?'error':row.chemicalsRst=='2'?'success':row.chemicalsRst=='3'?'primary':''"
              size="mini"></u-tag>
          </template>
        </u-table-column>
        <u-table-column prop="" width="180" align="center" label="近1年内是否发生过火灾" headerAlign="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.fireRst" :text="row.fireRst=='1'?'是':row.fireRst=='2'?'否':row.fireRst=='3'?'不涉及':''"
              :type="row.fireRst=='1'?'error':row.fireRst=='2'?'success':row.fireRst=='3'?'primary':''"
              size="mini"></u-tag>
          </template>
        </u-table-column>
        <u-table-column prop="" align="center" width="180" label="上一年度是否进行消防设施年度检测" headerAlign="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.lastYearCheckRst"
              :text="row.lastYearCheckRst=='1'?'是':row.lastYearCheckRst=='2'?'否':row.lastYearCheckRst=='3'?'不涉及':''"
              :type="row.lastYearCheckRst=='1'?'error':row.lastYearCheckRst=='2'?'success':row.lastYearCheckRst=='3'?'primary':''"
              size="mini"></u-tag>
          </template>
        </u-table-column>
        <u-table-column prop="" align="center" width="180" label="上一年度是否进行消防安全咨询评估" headerAlign="center">
          <template #default="{ row, index }">
            <u-tag v-if="row.lastYearConsultRst"
              :text="row.lastYearConsultRst=='1'?'是':row.lastYearConsultRst=='2'?'否':row.lastYearConsultRst=='3'?'不涉及':''"
              :type="row.lastYearConsultRst=='1'?'error':row.lastYearConsultRst=='2'?'success':row.lastYearConsultRst=='3'?'primary':''"
              size="mini"></u-tag>
          </template>
        </u-table-column>

        <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>



    </view>
    <u-modal content="" :closeOnClickOverlay="true" :title="modaltitle" :showCancelButton="true" confirmText="保存"
      width="600px" :show="addshow" @confirm="baocun()" @cancel="() => addshow = false">
      <view class="slot-content" style="width: 100%;">
        <view class="wenjuanadbox" style="width: 100%; height: 300px; align-items: left; border-top:1px solid #eee;">
          <view class="querybox" style=" margin-top: 10px;">
            <view class="querybox_title">项目编号：</view>
            <view v-if="!isedit" class="querybox_title" @click="addxmpickerVisible = true; hideKeyboard()">
              <u-input style="width: 400px;" disabled v-model="formdata.projectname" :clearable="true"
                disabledColor="#ffffff" placeholder="请选择项目编号"></u-input>
            </view>
            <view v-else class="querybox_title"> {{activeitem.projectName}}</view>
          </view>
          <view class="querybox1" style=" margin-top:20px;">
            <view class="querybox_title">是否存在租赁情况：</view>
            <view class="querybox_title">
              <u-radio-group v-model="formdata.rentRst" placement="row" activeColor="#007aff">
                <u-radio :name="1" label="是"></u-radio>
                <u-radio :name="2" label="否"></u-radio>
              </u-radio-group>
            </view>
          </view>
          <view class="querybox1" style=" margin-top:20px;">
            <view class="querybox_title">是否存放易燃易爆危险化学品：</view>
            <view class="querybox_title">
              <u-radio-group v-model="formdata.chemicalsRst" placement="row" activeColor="#007aff">
                <u-radio :name="1" label="是"></u-radio>
                <u-radio :name="2" label="否"></u-radio>
              </u-radio-group>
            </view>
          </view>
          <view class="querybox1" style=" margin-top:20px;">
            <view class="querybox_title">近1年内是否发生过火灾：</view>
            <view class="querybox_title">
              <u-radio-group v-model="formdata.fireRst" placement="row" activeColor="#007aff">
                <u-radio :name="1" label="是"></u-radio>
                <u-radio :name="2" label="否"></u-radio>
              </u-radio-group>
            </view>
          </view>
          <view class="querybox1" style=" margin-top:20px;">
            <view class="querybox_title">上一年度是否进行消防设施年度检测：</view>
            <view class="querybox_title">
              <u-radio-group v-model="formdata.lastYearCheckRst" placement="row" activeColor="#007aff">
                <u-radio :name="1" label="是"></u-radio>
                <u-radio :name="2" label="否"></u-radio>
              </u-radio-group>
            </view>
          </view>
          <view class="querybox1" style=" margin-top:20px;">
            <view class="querybox_title"> 上一年度是否进行消防安全咨询评估：</view>
            <view class="querybox_title">
              <u-radio-group v-model="formdata.lastYearConsultRst" placement="row" activeColor="#007aff">
                <u-radio :name="1" label="是"></u-radio>
                <u-radio :name="2" label="否"></u-radio>
                <u-radio :name="3" label="不涉及"></u-radio>
              </u-radio-group>
            </view>
          </view>

        </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" />
    <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-toast ref="uToast"></u-toast>
    <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" @righteventclose="closeright"
          @shaunxian="getlistinfo()" @qianziclick="qianzishow=true" :qiaziimg="qianziimg" :qiaziimgnum="qiaziimgnum" />
      </scroll-view>
    </uni-drawer>
    <next-modal :show="qianzishow" confirmText="关闭" :showCancel="false" @confirm="qianzishow=false" width="900px">
      <!--注意插槽的使用的优先级大于next-modal组件的props的值-->
      <view slot="title">
        <view style="text-align: center;padding:20rpx"><text>手写签名</text></view>
      </view>
      <!-- <template #content><view style="text-align: center;"><text>hello你好，这是next-modal组件的内容！next-modal是一个轻量级的组件，没有其他依赖，请放心使用！</text></view></template> -->
      <!--自定义content内容-->
      <view slot="content">
        <LandScape style="width:98%; height:500px; margin: 0 auto;" @onConfirm="qianziConfirm" />
      </view>

    </next-modal>
    <UniMenu />
  </view>
</template>

<script>
  import {
    getsafety_hazardInfo,
    getexecutionprojectlist,

    setprojectcurrent,
    setcontractcurrent,
    getprojectcurrent,
    getcontractcurrent
  } from "@/apis/zhixing"
  import {
    getthstatus
  } from "@/apis/hetong"
  import {
    getquestionnaireInfo,
    getxmdwdefaultconditionlist,
    addquestionnaire,
    upquestionnaire,
    getquestionnaireIdinfo,
    delquestionnaire,
    getadddefaultcondition,
    getevaluationIdinfo,

  } from "@/apis/wenjuan"
  import {
    getToken,
    setToken,
    removeToken
  } from '@/utils/auth'
  import {
    parseObjectToArray
  } from "@/utils/util"
  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/addwenjuan.vue';
  import LandScape from '@/components/signature/landscape.vue';
  export default {
    components: {
      UniMenu,
      comboxMore,
      CustomPicker,
      AddEditnr,
      LandScape
    },
    data() {
      return {
        // upurl: import.meta.env.VITE_APP_BASE_PRE + '/safety_hazard/table/img',
        //  httpurl: import.meta.env.VITE_APP_BASE_PRE,
        userStore: useUserStore(),
        upurl: 'http://219.146.89.198:19388' + '/safety_hazard/table/img',
        httpurl: 'http://219.146.89.198:19388',
        xmpickerVisible: false,
        addxmpickerVisible: false,
        xththlist: [],
        contractId: '',
        qianziimg: '',
        qiaziimgnum: 0,
        rowitem: null,
        sjnum: 0,
        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,
        formdata: {
          questionnaireId: 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: [],
        imgboxshow: false,
        imgurlslist: [],
        tableData: [],
        queryParams: {
          // pageNum: 1,
          // pageSize: 10,
          projectId: null,
          projectname: '',
          reasonable: false,
        },
        addshow: false,
        infolist: [],
        activeitem: null,
        activenum: 0,
        qianzishow: false,
        addxmdwlist: [],
        activenumlist: [],
        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.getxthtxlist(); //获取系统合同号列表
      //  this.getxmdwlist(); //获取项目单位列表
      const userStore = useUserStore();
      this.upurl = userStore.allurl + '/safety_hazard/questionnaire/img';
      userStore.setparentmenutitle('执行');
      userStore.setchildrenmenutitle('调查问卷');
    },
    onLoad() {
      // this.getUser()
    },
    methods: {
      parseObjectToArray,
      closeright() {
        // debugger
        this.rowitem = null;
        this.$refs.showright.close();
        this.getlistinfo(); //获取问卷列表
      },
      qianziConfirm(res) {
        //签字
        uni.uploadFile({
          url: this.upurl,
          filePath: res,
          name: "img",
          formData: {},
          header: {
            Bearerauth: 'Bearer ' + getToken()
          },
          // #ifdef MP-ALIPAY
          //fileType: filetype,
          // #endif
          success: (uploadFileRes) => {
            //debugger
            // console.log("sdsa", uploadFileRes)
            const data = JSON.parse(uploadFileRes.data)
            console.log("签字上传", data)
            uni.hideLoading();
            if (data.code == 200) {
              this.qianzishow = false;
              this.qiaziimgnum = Math.random();
              this.qianziimg = data.data;
            } else {

            }

          },
          fail: (error) => {
            uni.hideLoading();
            console.error('error', error);

          }
        });
      },
      changexthth(e) {
        //系统合同号
        //debugger
        this.queryParams.projectname = '';
        this.queryParams.projectId = '';
        this.getxmdwlist();
        //获取项目单位列表
        if (e) {
          setcontractcurrent(this.contractId).then((res) => {
            //保存选择的系统合同号
            this.userStore.setxtht(e.value, e.label);
          });
        }

      },
      getxthtxlist() {
        //获取系统合同号列表
        getthstatus('3').then((res) => {
          // debugger
          this.xththlist = res.data ? this.parseObjectToArray(res.data) : [];
          if (this.xththlist.length > 0) {
            // debugger
            // this.contractId = this.xththlist[0].value;
            // this.getxmdwlist(); //获取项目单位列表
            // debugger
            getcontractcurrent().then((res2) => {
              //获取当前保存过的合同号 没有就默认
              // debugger
              if (res2.data) {
                this.contractId = res2.data.contractId;
                this.getxmdwlist(); //获取项目单位列表
                //保存选择的系统合同号
                this.userStore.setxtht(res2.data.contractId, res2.data.sysCtcNo);
              } else {
                this.contractId = this.xththlist[0].value;
                this.getxmdwlist(); //获取项目单位列表
                setcontractcurrent(this.contractId).then((res) => {
                  //保存选择的系统合同号
                  this.userStore.setxtht(this.xththlist[0].value, this.xththlist[0].label);
                });
              }
            });
          }
        })
      },

      pingjia() {
        getevaluationIdinfo(this.activeitem.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;
        });

      },

      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.questionnaireId
        this.$modal.confirm('确定要删除此条信息吗？').then(() => {
          // debugger
          delquestionnaire(checkTableIds).then((res) => {
            //  debugger
            this.$modal.msgSuccess("删除成功！");
            setTimeout(() => {
              this.getlistinfo(); //获取检查列表
            }, 300);
          })
        });
      },
      biangenls() {
        //变更日志


      },
      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 = imglist;
        } else {
          this.imgurlslist = [this.httpurl + item.imgUrl]
        }
        // debugger
        this.imgboxshow = true;

      },

      addwenjuan() {
        //新增
        // this.isedit = false;
        // this.getaddxmdwlist();
        // this.modaltitle = '添加调查问卷';
        // this.formdata = {
        //   rentRst: '',
        //   chemicalsRst: '',
        //   fireRst: '',
        //   lastYearCheckRst: '',
        //   lastYearConsultRst: ''
        // }
        // this.addshow = true;
        let item = {
          contractId: this.contractId,
          isedit: 0,
        }
        this.rowitem = item;
        this.sjnum = Math.random();
        this.$refs.showright.open();
      },
      upedit(item) {
        //编辑
        //debugger
        let item1 = {
          contractId: this.contractId,
          isedit: 1,
        }
        this.rowitem = {
          ...item,
          ...item1
        };
        this.sjnum = Math.random();
        this.$refs.showright.open();



      },
      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.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.questionnaireId) {
            this.activenumlist.push(s.questionnaireId)
          } 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.questionnaireId == null) {
            //   this.isbutclick = false;
          } else {
            //  this.isbutclick = true;
          }
        }





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

      },
      getlistinfo() {
        //获取问卷列表
        this.tableData = [];
        this.clearSelection(); //清空
        getquestionnaireInfo(this.queryParams).then((res) => {
          //debugger
          this.tableData = res.rows || [];

        })
      },




      getxmdwlist() {
        //获取项目单位列表
        getexecutionprojectlist(this.contractId).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;
            getprojectcurrent().then((res2) => {
              //获取当前保存过的项目 没有就默认
              // debugger
              if (res2.data) {
                if (this.contractId == res2.data.contractId) {
                  //当前选的和保存的一样
                  this.queryParams.projectId = res2.data.projectId;
                  this.queryParams.projectname = res2.data.projectNo + `（${res2.data.name}）`;

                  this.userStore.setproject(this.xmdwlist[0].projectId, res2.data.projectNo +
                    `（${res2.data.name}）`);
                } else {
                  this.queryParams.projectId = this.xmdwlist[0].projectId;
                  this.queryParams.projectname = this.xmdwlist[0].lablename;

                  setprojectcurrent(this.queryParams.projectId).then((res) => {
                    //保存选择的项目编号
                    this.userStore.setproject(this.xmdwlist[0].projectId, this.xmdwlist[0].lablename);
                  });
                }

              } else {
                this.queryParams.projectId = this.xmdwlist[0].projectId;
                this.queryParams.projectname = this.xmdwlist[0].lablename;

                setprojectcurrent(this.queryParams.projectId).then((res) => {
                  //保存选择的项目编号
                  this.userStore.setproject(this.xmdwlist[0].projectId, this.xmdwlist[0].lablename);
                });
              }
              this.getlistinfo(); //获取检查列表
            });

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

          // this.getlistinfo(); //获取问卷列表
        })
      },
      clickcell(row, column, cell, event) {
        debugger
      },
      halechange() {
        //查询  
        this.getlistinfo(); //获取问卷列表
      },
      banhaoselectionEvent(selection, selectObj) {
        console.log('selectionEvent:', selection, selectObj)
      }
    }
  }
</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 {
      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 {
        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;
        }
      }
    }

  }

  .qztkbox {
    width: 90%;
    position: fixed;
    z-index: 10000;
    left: 5%;
    top: 10%;
    display: flex;
    flex-direction: column;
    background: #fff;
  }
</style>