<template>
  <div style="height:100%;width:100%;">
    <a-layout style="height:100%;width:100%;">
      <a-layout-sider width="320px" theme="light" style="border-right:2px solid #d5d5ff;float:left" :style="{ 'max-height': testHeight + 'px', 'height': testHeight + 'px' }">
        <div class="tree" style="height: calc(100% - 50px); width: 100%; overflow: auto; display: inline-flex;">
          <a-tree
            :tree-data="treeData"
            @select="treeNodeClickHandler"
            :fieldNames="{ children: 'children', title: 'pnm', key: 'id' }"
            :expandedKeys="expandedKeys"
            @update:expandedKeys="expandedKeys = $event"
            ref="jigou_tree"
            style="height:100%;">
            <template #custom="item">
              <span style="float:left;" :title="item.pnm">
                <span v-if="item.id && item.id.length >=12">
                  <img src="../../assets/images/choucha.png" v-if="item.chkType=='0'" style="width: 25px;height:20px;float: left;" />
                  <img src="../../assets/images/zicha.png" v-if="item.chkType=='1'" style="width: 25px;height:20px;float: left;" />
                  &nbsp;
                </span>
                {{ item.pnm?(item.pnm.length>12?(item.pnm.substring(0,10))+"...":item.pnm):"" }}
              </span>
            </template>
          </a-tree>
        </div>
      </a-layout-sider>
      <a-layout-content id="dxdcListMainsk" style="padding:5px 20px;">
        <a-row>
          <a-col :span="24">
            <a-form
              layout="inline"
              class="demo-form-inline"
              style="padding-left: 10px;">
              <a-form-item label="督查事项" style="min-width: 23%;">
                <a-select v-model:value="prjType" placeholder="督查事项" allow-clear>
                  <a-select-option v-for="(item, index) in prjTypeList" :key="index" :value="item.code">{{ item.val }}</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item label="督查状态" style="min-width: 23%;">
                <a-select v-model:value="dcType" placeholder="督查状态" allow-clear>
                  <a-select-option value="0">未督查</a-select-option>
                  <a-select-option value="1">督查中</a-select-option>
                  <a-select-option value="2">已督查</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item label="对象名称" style="min-width: 23%;">
                <a-input v-model:value="depName" placeholder="对象名称" />
              </a-form-item>
              <a-form-item label="是否申请信息调整" style="min-width: 23%;">
                <a-select v-model:value="adjustState" placeholder="是否申请信息调整" allow-clear>
                  <a-select-option value="1">是</a-select-option>
                  <a-select-option value="2">否</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-button type="primary" @click="onSubmit" size="small">查询</a-button>
              </a-form-item>
            </a-form>
          </a-col>
        </a-row>
        <a-table
          ref="table"
          :columns="columns"
          :data-source="skDataList"
          :loading="expLoading"
          :pagination="false"
          row-key="rgstrId"
          style="width: 100%;"
          :style="{ height: tableHeight + 'px'}"
          :scroll="{x: 'max-content', y: tableHeight - 60}"
          bordered>
          <template #bodyCell="{ column, record }">
            <template v-if="column.dataIndex === 'nm'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.nm }}</span></template>
                <span class="ellipsis100">{{ record.nm }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'adName'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.adName }}</span></template>
                <span class="ellipsis100">{{ record.adName }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'chkType'">
              <img src="../../assets/images/choucha.png" v-if="record.chkType=='0'" style="width: 25px;height:20px;" />
              <img src="../../assets/images/zicha.png" v-if="record.chkType=='1'" style="width: 25px;height:20px;" />
            </template>
            <template v-else-if="column.dataIndex === 'typeName'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.typeName }}</span></template>
                <span class="ellipsis100">{{ record.typeName }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'state'">
              <span style="padding:3px 10px;background:#F56C6C;border-radius:15px;color:#fff" v-if="record.state == 0">未督查</span>
              <span style="padding:3px 10px;background:#FBB56D;border-radius:15px;color:#fff" v-if="record.state == 1">督查中</span>
              <span style="padding:3px 10px;background:#63C25E;border-radius:15px;color:#fff" v-if="record.state == 2">已督查</span>
            </template>
            <template v-else-if="column.dataIndex === 'intm1'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.intm1 }}</span></template>
                <span class="ellipsis150">{{ record.intm1 }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'gdX'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.gdX }}</span></template>
                <span class="ellipsis100">{{ record.gdX }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'gdY'">
              <a-tooltip placement="top">
                <template #title><span>{{ record.gdY }}</span></template>
                <span class="ellipsis100">{{ record.gdY }}</span>
              </a-tooltip>
            </template>
            <template v-else-if="column.dataIndex === 'action'">
              <div style="display:flex;justify-content:center;" v-if="parseInt(record.type)>=615 && parseInt(record.type)<630">
                <div>
                  <a-button size="small" type="primary" v-if="!record.rgstrId" ghost @click="toAddMember('填报',record)">填报</a-button>
                  <a-button size="small" type="primary" v-if="record.rgstrId" ghost @click="toAddMember('编辑',record)" :disabled="record.state=='2'&&record.chkType!='1'">督查</a-button>
                  <a-button size="small" type="primary  v-if="record.rgstrId&&record.chkType!='1'" ghost @click="submitHandler(record)" :disabled="record.state=='2'" >提交</a-button>
                  <a-button size="small" type="primary" v-if="record.rgstrId&&record.state=='2'" ghost @click="toCheck(record)">查看</a-button>
                  <a-button type="primary" size="small" v-if="record.rgstrId&&(record.adjustState=='1'||record.adjustState=='0'||!record.adjustState)" @click="showEditDialog(record)">信息调整</a-button>
                  <a-button size="small" type="primary" @click="showRecord(record)">记录</a-button>
                </div>
              </div>
              <div style="display:flex;justify-content:center;" v-else>
                <a-button size="small" type="primary" v-if="record.rgstrId" ghost @click="toAddMember('编辑',record)" :disabled="record.state=='2'">督查</a-button>
                <a-button size="small" type="primary" v-if="record.rgstrId" ghost @click="submitHandler(record)" :disabled="record.state=='2'">提交</a-button>
                <a-button size="small" type="primary" v-if="record.rgstrId&&record.state=='2'" ghost @click="toCheck(record)">查看</a-button>
                <a-button size="small" type="primary" v-if="record.rgstrId&&record.state=='2'" ghost @click="revoke(record)">撤回</a-button>
              </div>
            </template>
          </template>
        </a-table>
        <a-pagination
          show-size-changer
          :pageSize="pageSize"
          @update:pageSize="pageSize = $event"
          :total="total"
          :page-size-options="['10','20', '30', '40', '50','100']"
          :show-total="total => `共${total}条`"
          @showSizeChange="handleSizeChange"
          @change="pageIndexChange"
          style="margin-top: 10px;" />
      </a-layout-content>

      <commonTab
        v-if="showShuiKuTianBao"
        :rowData="rowData"
        :currentObjectRgstrId="currentObjectRgstrId"
        :currentResCode="currentResCode"
        :currentObjectId="currentObjectId"
        :currentObjectName="currentResName"
        :pType="pType"
        :openType="openType"
        :chkType="chkType"
        @cancelHandler="cancelHandler"
        @addShuiKuSuccess="addShuiKuSuccess"
        :flag="1"
        :isTongYong="1">
      </commonTab>

      <a-modal :title="editTitle+'信息调整申请'" :open="isEditShow" width="30%" @cancel="isEditShow = false">
        <a-form :model="editForm" :label-col="{span: 8}" :wrapper-col="{span: 16}" class="demo-ruleForm" ref="editForm">
          <a-form-item label="调整方式" required>
            <a-select v-model:value="editForm.adjustWay">
              <a-select-option value="1">数据调整</a-select-option>
              <a-select-option value="2">逻辑删除</a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item label="对象名称" required>
            <a-input v-model:value="editForm.nm" :disabled="true" />
          </a-form-item>
          <a-form-item label="所属地市" v-show="editForm.adjustWay=='1'" required>
            <addvSingle key="city" ref="city" @addvSelect="citySelect" :level="0"></addvSingle>
          </a-form-item>
          <a-form-item label="所属区县" v-show="editForm.adjustWay=='1'" required>
            <addvSingle key="country" ref="country" @addvSelect="countrySelect" :level="1"></addvSingle>
          </a-form-item>
          <a-form-item :label="editForm.adjustWay=='1'?'调整说明':'删除原因'" required>
            <a-textarea v-model:value="editForm.adjustRecord" />
          </a-form-item>
          <a-form-item label="相关文件">
            <a-upload
              :action="`/modular-source/6ace62b8e2bb467d98286d260aebcef2/pdcApi/file/insert?bizId=${this.bizId}&bizType=adjustment`"
              :file-list="fileList"
              :headers="header"
              @change="changeFileList"
              multiple
              class="upload-demo">
              <a-button type="primary" size="small">点击上传</a-button>
            </a-upload>
          </a-form-item>
        </a-form>
        <span slot="footer" class="dialog-footer" style="display: flex;justify-content: center;">
          <a-button @click="isEditShow = false">取 消</a-button>
          <a-button type="primary" @click="editSubmit" :disabled="isLoadingBtn">确 定</a-button>
        </span>
      </a-modal>

      <a-modal
        :title="editTitle + '数据调整记录'"
        :open="isEditRecordShow"
        width="40%"
        @cancel="isEditRecordShow = false"
        :footer="null">
        <span style="display: block;max-height:500px;overflow:auto;padding: 20px">
          <a-timeline v-if="activities && activities.length>0">
            <a-timeline-item v-for="(activity, index) in activities" :key="index" color="#3fa4ff">
              <p style="font-size: 18px;font-weight: bold;">{{ activity.timestamp }}</p>
              <p style="font-size: 18px;">{{ activity.title }}</p>
              <p style="font-size: 15px;">{{ activity.detail }}</p>
            </a-timeline-item>
          </a-timeline>
          <div
            style="width:100%;height:100%;display: flex;align-items: center;justify-content: center;font-size: 20px;font-weight: bold"
            v-else>无记录</div>
        </span>
      </a-modal>
    </a-layout>
    <!-- 上传模板弹窗 -->
    <shuiku-tian-bao-pl
      v-if="showShuiKuTianBaoPl"
      :showShuiKuTianBaoPl="showShuiKuTianBaoPl"
      :id="currentNodeId"
      @closePlDialog="closePlDialog"></shuiku-tian-bao-pl>
    <!-- 水库信息查看 -->
    <rsvr-info
      :currentObjectRgstrId="currentObjectRgstrId"
      :currentResCode="currentResCode"
      :currentObjectId="currentObjectId"
      :currentObjectName="currentResName"
      :isJiangXi="isJiangXi"
      v-if="showDuchaDetails"
      @cancelHandler="closeInfoDialog"></rsvr-info>
    <!-- 水库督查信息 -->
    <popupSk
      ref="xskTianBaoRef"
      v-if="xskInfoDialog"
      :currentDuchaTpe="currentDuchaTpe"
      :currentObjectRgstrId="xskRgstrId"
      :currentResCode="currentRsCode"
      :currentObjectId="currentObjId"
      :currentObjectName="currentRsName"
      @cancelHandler="skCancelHandler">
    </popupSk>

  </div>
</template>

<script>
import request from '../../utils/gw_ajax_request.js';
import { dateFormat } from '../../utils/gw_date.js';
import { exportModel } from '../../utils/gw_exportModel';
import addvSearch from '../../widgets/addvSearch.vue';
import addvSingle from '../../widgets/addvSingle.vue';
import provTreeList from '../../widgets/provTreeList.vue';
import commonTab from '../duChaTianBao/commonTab.vue';
export default {
  components: {
    provTreeList: provTreeList,
    commonTab: commonTab,
    addvSearch,
    addvSingle,
  },
  data() {
    return {
      testHeight: window.innerHeight - 140,
      treeData: [],
      expandedKeys: [],
      treeList: [],
      groups: [],
      lyjg: [],
      currentNodeId: '',
      prjTypeList: [],
      prjType: undefined,
      dcType: undefined,
      depName: '',
      adjustState: undefined,
      header: {
        persId: localStorage.getItem('persId'),
        accessToken: localStorage.getItem('accessToken'),
      },
      skDataList: [],
      pageIndex: 1,
      pageSize: 10,
      total: 0,
      tableHeight: 0,
      expLoading: false,
      columns: [
        {
          title: '对象名称',
          dataIndex: 'nm',
          width: 100,
          align: 'center',
        },
        {
          title: '行政区划',
          dataIndex: 'adName',
          width: 100,
          align: 'center',
        },
        {
          title: '督查分类',
          dataIndex: 'chkType',
          width: 100,
          align: 'center',
        },
        {
          title: '督查事项',
          dataIndex: 'typeName',
          width: 100,
          align: 'center',
        },
        {
          title: '督查状态',
          dataIndex: 'state',
          width: 100,
          align: 'center',
        },
        {
          title: '上一次督查完成时间',
          dataIndex: 'intm1',
          width: 150,
          align: 'center',
        },
        {
          title: '经度',
          dataIndex: 'gdX',
          width: 100,
          align: 'center',
        },
        {
          title: '纬度',
          dataIndex: 'gdY',
          width: 100,
          align: 'center',
        },
      ],
      rowData: '',
      currentResCode: '',
      currentObjectId: '',
      currentObjectRgstrId: '',
      currentResName: '',
      showShuiKuTianBao: false,
      openType: false,
      chkType: '',
      pType: 111,
      xskInfoDialog: false,
      currentDuchaTpe: false,
      currentRsCode: '',
      xskRgstrId: '',
      currentObjId: '',
      currentRsName: '',
      isLoadingBtn: false,
      editTitle: '',
      activities: [],
      editForm: {
        objId: '',
        nm: '',
        adjustWay: '',
        adCode: '',
        newAdCode: '',
        adjustRecord: '',
        type: '',
      },
      isEditShow: false,
      bizId: '',
      fileList: [],
      isEditRecordShow: false,
      showShuiKuTianBaoPl: false,
      disabled: true,
      showDuchaDetails: false,
      batchGroupName: '',
      batchName: '',
    };
  },
  computed: {
    persId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '1098101939614724096';
    },
    currentRlcode() {
      return localStorage.getItem('currentRlcode')
        ? localStorage.getItem('currentRlcode')
        : '';
    },
    isJiangXi() {
      return this.currentRlcode.indexOf('36') == '0';
    },
  },
  created() {
    this.getLeftTreeData();
    this.getPrjType();
    // if (this.ownPriv('manage')) {/
    this.columns.push({
      title: '操作',
      dataIndex: 'action',
      width: 450,
      fixed: 'right',
      align: 'center',
    });
    // }
  },
  mounted() {
    this.testHeight = window.innerHeight - 100;
    this.tableHeight = window.innerHeight - 240;
    window.addEventListener('resize', () => {
      return (() => {
        this.testHeight = window.innerHeight - 100;
        this.tableHeight = window.innerHeight - 240;
      })();
    });
    this.getAllGroup();
    this.getSkDataList();
  },
  watch: {
    currentNodeId(n, o) {
      this.getPrjType();
      this.getSkDataList();
    },
  },
  methods: {
    getLeftTreeData() {
      this.expandedKeys = [];
      request
        .get('/dc/organization/base/getNewAllNode', {
          params: {
            userId: this.persId,
            orgType: '111',
          },
        })
        .then((res) => {
          this.treeData = [res.data];
          this.expandedKeys.push(res.data.id);
          if (res.data && res.data.children && res.data.children !== 0) {
            this.expandedKeys.push(
              res.data.children[res.data.children.length - 1].id,
            );
          }
          // if (res.data && res.data.children) {
          //   res.data.children.forEach(item => {
          //     _self.expandedKeys.push(item.id)
          //     if (item.children) {
          //       item.children.forEach(item1 => {
          //         _self.expandedKeys.push(item1.id)
          //       })
          //     }
          //   })
          // }
        });
    },
    // 格式化树形数据
    getTrees(list) {
      // @wxcwater重写方法 适应多个树
      let highLevelLength = 99; // 预设最大节点id长度，目前最大应该为12，所以设置为99保证正常
      list.forEach((item, index) => {
        item['pidLength'] = item.pid && item.pid != '' ? item.pid.length : 0;
        if (highLevelLength > item.pidLength) {
          highLevelLength = item.pidLength;
        }
      });
      const heightLevelNode = [];
      list.forEach((item, index) => {
        if (highLevelLength >= item.pidLength) {
          heightLevelNode.push(item);
        }
      });

      list.forEach((item, index) => {
        heightLevelNode.forEach((pItem) => {
          this.addTreeNode(pItem, item);
        });
      });
      return heightLevelNode;
    },
    addTreeNode: function (treeNode, leafNode) {
      if (!Object.hasOwn(treeNode, 'children')) {
        treeNode['children'] = [];
      }
      if (leafNode.pid == treeNode.id) {
        treeNode.children.push(leafNode);
        return;
      }
      treeNode.children.forEach((item) => {
        this.addTreeNode(item, leafNode);
      });
    },
    treeNodeClickHandler: function (data, checked) {
      this.treeNodeArray = data;
      if (checked.node.dataRef.levels == '0') {
        this.batchGroupName = '';
        this.batchName = '';
      } else if (checked.node.dataRef.levels == '1') {
        this.batchGroupName = '';
        this.batchName = checked.node.dataRef.pnm;
      } else {
        this.batchGroupName = checked.node.dataRef.pnm;
        this.batchName = checked.node.dataRef.batchName;
      }
      this.getPrjType();
      this.getSkDataList();
    },
    // 获取所有的组
    getAllGroup() {
      request
        .get('/dc/user/getGroupByPersid', {
          params: { persid: this.persId, ptype: '111', tabType: '0' },
        })
        .then((res) => {
          if (res.success) {
            this.groups = res.data;
          }
        });
    },
    // 获取督查事项下拉框数据
    getPrjType() {
      const params = {
        batchName: this.batchName,
        groupName: this.batchGroupName,
      };
      request
        .get('/att/gnrl/base/getOrderMatterDropdownBox', { params })
        .then((res) => {
          if (res.success) {
            this.prjTypeList = res.data.filter((item) => item.code != null);
          } else {
            this.$message.error(res.message);
          }
        })
        .catch(() => {
          this.$message.error('请求失败,请联系管理员!');
        });
    },
    onSubmit() {
      this.getSkDataList();
    },
    getSkDataList() {
      let paramStartDate = '';
      let paramEndDate = '';
      if (
        this.dateRange &&
        this.dateRange.length > 1 &&
        this.dateRange[0] != '' &&
        this.dateRange[1] != ''
      ) {
        paramStartDate = this.dateRange[0];
        paramEndDate = this.dateRange[1];
      }
      const params = {
        prjType: this.prjType,
        presId: this.persId,
        pType: '111',
        pageSize: this.pageSize,
        pageNum: this.pageIndex,
        plnaId: this.currentNodeId,
        groupId: this.groupId, // 分组
        state: this.dcType,
        nm: this.depName,
        adName: this.adName,
        sttm: paramStartDate,
        entm: paramEndDate,
        adjustState: this.adjustState,
        groupName: this.batchGroupName,
        batchName: this.batchName,
      };
      request.post(`/dc/insp/rsvrRgstr/list/type`, params).then((res) => {
        if (res.success) {
          res.data.list.forEach((item) => {
            if (item.intm) {
              item.intm1 = dateFormat(item.intm, 'yyyy-MM-dd');
            }
          });
          this.skDataList = res.data.list;
          this.total = res.data.total;
        }
      });
    },
    pageIndexChange(val) {
      this.pageIndex = val;
      this.getSkDataList();
    },
    handleSizeChange(size, val) {
      this.pageSize = val;
      this.getSkDataList();
    },
    toAddMember(type, rowData) {
      this.rowData = rowData;
      this.currentResCode = this.rowData.code;
      this.currentObjectId = this.rowData.objId;
      this.currentObjectRgstrId = this.rowData.rgstrId;
      this.currentResName = this.rowData.nm;
      this.showShuiKuTianBao = true;
      this.openType = true;
      this.chkType = this.rowData.chkType;
    },
    cancelHandler() {
      this.showShuiKuTianBao = false;
      this.getSkDataList();
    },
    addShuiKuSuccess() {
      this.getSkDataList();
    },
    submitHandler(rowData) {
      this.$confirm({
        title: '提示',
        content: '请确认所有信息填报完毕？',
        okType: 'warning',
        onOk: () => {
          const formObj = {
            rgstrId: rowData.rgstrId,
            state: '2',
          };
          request.post('/bis/insp/gnrl', formObj).then((res) => {
            if (res.success) {
              request
                .get('/dc/insp/pblm/submit/updateState/' + rowData.objId)
                .then((res) => {
                  if (res.success) {
                    this.addShuiKuSuccess();
                    this.$message.success('提交成功');
                  } else {
                    this.cancelHandler();
                  }
                });
            } else {
              this.cancelHandler();
            }
          });
        },
      });
    },
    toCheck(rowData) {
      this.rowData = rowData;
      this.currentResCode = this.rowData.code;
      this.currentObjectId = this.rowData.objId;
      this.currentObjectRgstrId = this.rowData.rgstrId;
      this.currentResName = this.rowData.nm;
      this.showShuiKuTianBao = true;
      this.openType = false;
      this.chkType = this.rowData.chkType;
      this.$nextTick(() => {
        if (this.$refs['xskTianBaoRef']) {
          this.$refs['xskTianBaoRef'].showDialog();
        }
      });
    },
    skCancelHandler() {
      this.xskInfoDialog = false;
    },
    showEditDialog(row) {
      this.isLoadingBtn = false;
      this.editTitle = row.nm;
      this.editForm.nm = row.nm;
      this.editForm.objId = row.objId;
      this.editForm.adCode = row.adCode;
      this.editForm.newAdCode = row.adCode;
      // this.editForm.type = this.$route.params.type
      this.editForm.type = this.$route.path.substring(
        this.$route.path.length - 3,
      );
      this.editForm.adjustWay = '1';
      this.editForm.adjustRecord = '';
      this.isEditShow = true;
      var cityCode = '';
      var countryCode = '';
      if (row.adCode.indexOf('00000000') > -1) {
        cityCode = row.adCode;
        this.editForm.adCode = cityCode;
      } else {
        cityCode = row.adCode.substring(0, 4) + '00000000';
        countryCode = row.adCode;
        this.editForm.adCode = countryCode;
      }
      this.$nextTick(() => {
        this.$refs.city.getAdDataList();
        this.$refs.city.setCheck(cityCode, row.city);
        this.$refs.country.getAdDataList(cityCode);
        this.$refs.country.setCheck(countryCode, row.country);
      });
    },
    deleteMember(obj) {
      this.$confirm({
        title: '提示',
        content: '此操作将督查对象从列表中删除，确认删除该对象吗？',
        okType: 'warning',
        onOk: () => {
          request
            .get(
              `/supervision/plan/cleanObjDataByObjId?objType=111&objId=${obj.objId}&deleteMethod=1`,
            )
            .then((res) => {
              if (res.success) {
                this.pageIndexChange();
                this.$message.success('删除成功');
              } else {
                this.$message.error(res.message);
              }
            });
        },
      });
    },
    revoke(rowData) {
      this.$confirm({
        title: '提示',
        content: '确定要撤销当前信息吗？',
        okType: 'warning',
        onOk: () => {
          const formObj = {
            rgstrId: rowData.rgstrId,
            state: '1',
          };
          request.post('/bis/insp/gnrl', formObj).then((res) => {
            if (res.success) {
              this.addShuiKuSuccess();
              this.$message.success('提交成功');
            } else {
              this.cancelHandler();
            }
          });
        },
      });
    },
    citySelect(obj) {
      this.$refs.country.getAdDataList(obj);
      this.$refs.country.setCheck('', '');
      this.editForm.newAdCode = obj;
    },
    countrySelect(obj) {
      this.editForm.newAdCode = obj;
    },
    editSubmit() {
      if (!this.editForm.adjustWay) {
        this.$message.warning('请选择调整方式');
        return;
      }
      if (this.editForm.adjustWay == '1') {
        if (!this.editForm.adCode) {
          this.$message.warning('所属地市、区县不能为空');
          return;
        }
        if (this.editForm.newAdCode == this.editForm.adCode) {
          this.$message.warning('修改的行政区划不能跟当前区划一致');
          return;
        }
        if (!this.editForm.adjustRecord) {
          this.$message.warning('请输入调整说明');
          return;
        }
      }
      if (this.editForm.adjustWay == '2') {
        this.editForm.newAdCode = '';
        if (!this.editForm.adjustRecord) {
          this.$message.warning('请输入删除原因');
          return;
        }
      }
      this.isLoadingBtn = true;
      request
        .post('/bis/insp/gnrlRgstrAdjust', this.editForm)
        .then((res) => {
          if (res.success) {
            this.bizId = res.data.id;
            if (this.fileList.length > 0) {
              this.$nextTick(() => {
                this.$refs.adjustment.submit();
              });
            }
            this.isEditShow = false;
            this.isLoadingBtn = false;
            this.$message.success('申请已提交');
            this.getSkDataList();
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((res) => {
          this.$message.error('请求错误' + res.message);
        });
    },
    changeFileList({ fileList }) {
      this.fileList = fileList;
    },
    showRecord(row) {
      this.editTitle = row.nm;
      this.isEditRecordShow = true;
      this.activities = [];
      var params = {
        objId: row.objId,
      };
      request
        .post('/bis/insp/gnrlRgstrAdjust/findDtoList', params)
        .then((res) => {
          if (res.success) {
            if (res.data && res.data.length > 0) {
              var data = res.data;
              var dataList = [];
              data.forEach((item) => {
                var updateContent = item.detail;
                item.auditList.forEach((item1) => {
                  var date = new Date(item1.intm);
                  var timestamp =
                    date.getFullYear() +
                    '年' +
                    (date.getMonth() + 1) +
                    '月' +
                    date.getDate() +
                    '日';
                  dataList.push({
                    title: item1.roleName + '-' + item1.auditPersName,
                    timestamp: timestamp,
                    detail: item1.opStatus + ',' + updateContent,
                  });
                });
                // var date = new Date(item.time);
                // item.timestamp = date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
                // if(item.auditWay){
                //     item.title = "业务处室审核";
                //     item.detail = item.auditWay=="1"?("同意,"+item.detail):("驳回,"+item.detail)
                // }else{
                //     item.title = item.adjustWay=="1"?"督查单位提交申请-信息调整":"督查单位提交申请-删除";
                // }
              });
              this.activities = dataList;
            }
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((res) => {
          this.$message.error('请求错误' + res.message);
        });
    },
    showPlDialog() {
      this.showShuiKuTianBaoPl = true;
    },
    closePlDialog(val) {
      this.showShuiKuTianBaoPl = false;
    },
    // 下载填报模板
    async downloadTemplate() {
      const url =
        '/pdcApi/dc/impExcel/downloadTemplate/sk?userId=' +
        this.persId +
        '&id=' +
        this.currentNodeId;
      const downloadName = '小水库填报模板.xls';
      const type = 'get';
      await exportModel(type, url, downloadName);
      this.disabled = false;
    },
    // 新需求  点击复查显示以前的督查信息
    toShowDuchaDetail(row) {
      this.currentResCode = row.code;
      this.currentObjectId = row.objId;
      this.currentObjectRgstrId = row.rgstrId;
      this.currentResName = row.nm;
      this.showDuchaDetails = true;
    },
    closeInfoDialog() {
      this.showDuchaDetails = false;
    },
  },
};
</script>
<style scoped>
.ant-btn-dangerous.ant-btn-background-ghost[disabled] {
  opacity: 0.5;
}
</style>
<style lang='less' scoped>

/deep/ .ant-layout-sider,
/deep/ .ant-layout-content {
  background: #fff;
}
.skactive {
  background: #3f8eff !important;
  color: white !important;
  margin-top: 5px;
  margin-bottom: 5px;
}

.sknormal {
  background: white;
  margin-top: 5px;
  margin-bottom: 5px;
}

.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

#dxdcListMainsk {
  overflow-y: hidden;
}
/deep/ .ant-table-pagination {
  float: left;
}

/deep/ .ant-layout-sider,
/deep/ .ant-layout-content {
  background: #fff;
}

/deep/ .ant-table-thead>tr>th,
/deep/ .ant-table-tbody>tr>td {
  padding: 0;
  height: 60px;
}

.ellipsis200 {
  display: block;
  width: 198px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.ellipsis150 {
  display: block;
  width: 148px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.ellipsis120 {
  display: block;
  width: 118px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.ellipsis100 {
  display: block;
  width: 98px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/deep/ .ant-table-scroll {
  position: relative;
  z-index: 1;
}

/deep/.ant-table-fixed-left,
/deep/ .ant-table-fixed-right {
  z-index: 2;
}
</style>
