<template>
  <div :class="$style.wrapHeight">
    <a-card :bordered="false">
      <a-tabs v-model="activeKey" type="line" @change="toggleTabs">
        <a-tab-pane key="1" tab="资料上报">
          <!-- 高级搜索组件 -->
          <audit-advanced-query
            :class="$style.advancedQuery"
            :expand="isShowAdvSearch"
            :search-data="SJXMAdvSearchForm"
            :ref-name="searchform"
            :search-style="{ height: '210px', left: '10px', top: '60px' }"
            :search-fun="advSJXMSearch"
            @searchedClick="searchedClick"
          >
            <template>
              <a-row>
                <a-col :span="12">
                  <a-form-model-item :label="'年\u2002\u2002度'" prop="reportYear">
                    <a-input v-model="SJXMAdvSearchForm.reportYear" allow-clear />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item :label="'标\u2002\u2002题'" prop="title">
                    <a-input v-model="SJXMAdvSearchForm.title" allow-clear />
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="12">
                  <a-form-model-item :label="'当前状态'" prop="flowState">
                    <sd-select
                      v-model="SJXMAdvSearchForm.flowState"
                      :allow-clear="true"
                      :options="flowStateOptions"
                    />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item :label="'上报单位'" prop="reportUnitName">
                    <a-input v-model="SJXMAdvSearchForm.reportUnitName" allow-clear />
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="12">
                  <a-form-model-item :label="'是否逾期未报'" prop="isLate">
                    <sd-select
                      v-model="SJXMAdvSearchForm.isLate"
                      :allow-clear="true"
                      :options="isLateOptions"
                    />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </template>
          </audit-advanced-query>
          <sd-data-table-ex
            ref="SJXMDataTable"
            style="margin-top: 25px"
            :filter-expressions="SJXMTableExpressions"
            :columns="columns1"
            show-selection
            form-id="spicCompositeDatabase"
            :data-url="dataurl1"
            :actions="actions1"
            :page-id="pageId1"
            @selectedRowsChanged="selectedRowsChanged"
          >
            <div slot="islink" slot-scope="text, record">
              <a :title="text" @click="rowClick1(record)">{{ text }}</a>
            </div>
          </sd-data-table-ex>
        </a-tab-pane>

        <a-tab-pane key="2" tab="综合资料下发">
          <!-- 高级搜索区域 -->
          <audit-advanced-query
            :class="$style.advancedQuery"
            :expand="isShowAdvSearch"
            :search-data="SJJHAdvSearchForm"
            :ref-name="searchform"
            :search-style="{ height: '170px', left: '10px', top: '60px' }"
            :search-fun="advJHBGSearch"
            @searchedClick="searchedClick"
          >
            <template>
              <a-row>
                <a-col :span="12">
                  <a-form-model-item :label="'年度'" prop="reportYear">
                    <a-input v-model="SJJHAdvSearchForm.reportYear" allow-clear />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item :label="'标题'" prop="title">
                    <a-input v-model="SJJHAdvSearchForm.title" allow-clear />
                  </a-form-model-item>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="12">
                  <a-form-model-item :label="'当前状态'" prop="docStatus">
                    <sd-select
                      v-model="SJJHAdvSearchForm.docStatus"
                      :allow-clear="true"
                      :options="flowStateOptions1"
                    />
                  </a-form-model-item>
                </a-col>
                <a-col :span="12">
                  <a-form-model-item :label="'编制人员'" prop="creatorName">
                    <a-input v-model="SJJHAdvSearchForm.creatorName" />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </template>
          </audit-advanced-query>
          <sd-data-table-ex
            ref="JHBGDataTable"
            style="margin-top: 25px"
            :filter-expressions="JHBGTableExpressions"
            :columns="columns2"
            show-selection
            form-id="spicCompositeDatabasePublish"
            :data-url="dataurl2"
            :actions="actions2"
            :page-id="pageId2"
            @selectedRowsChanged="selectedRowsChanged"
          >
            <div slot="islink" slot-scope="text, record">
              <a :title="text" @click="rowClick2(record)">{{ text }}</a>
            </div>
          </sd-data-table-ex>
        </a-tab-pane>
      </a-tabs>

      <div :class="[$style.btns]">
        <a-input-search
          v-model="searchValue"
          style="width: 155px; vertical-align: bottom"
          placeholder="请输入搜索条件"
          allow-clear
          @search="onSearch"
        />
        <a-button title="高级搜索" :class="$style.advSearchBtn" @click="AdvSearchClick">
          <a-icon type="sd-audit-advancesearch" theme="filled" :class="$style.searchIcon" />
        </a-button>
        <a-button
          v-if="activeKey === '2' && isApplicationAdmin"
          type="primary"
          :class="[$style.buttonSpacing]"
          @click="createProject"
          >新建
        </a-button>
        <a-button
          v-if="activeKey === '1' && true"
          :class="[$style.buttonSpacing]"
          :loading="exportLoading"
          @click="fnexport"
          >批量导出附件
        </a-button>
        <a-button
          v-if="activeKey === '2' && isApplicationAdmin"
          :class="[$style.buttonSpacing]"
          :disabled="deleteButtonDisable"
          @click="linkToDelete"
          >删除
        </a-button>
      </div>
    </a-card>
  </div>
</template>

<script>
import moment from 'moment'

import auditAdvancedQueryMixins from '@product/iam/components/audit-advanced-query-mixins'
import auditAdvancedQuery from '@product/iam/components/audit-advanced-query.vue'
import CompositeDatabaseService from './composite-database-service'
import crossWindowWatcher from '@/common/services/cross-window-watcher'
import { message, Modal } from 'ant-design-vue'
import axios from '@/common/services/axios-instance'
import TableColumnTypes from '@/common/services/table-column-types'
import storeMixin, { getUserInfo } from '@/common/store-mixin'
import errorUtil from '@/common/services/error-util'
import components from './_import-components/xm-composite-database-list-import'

export default {
  name: 'XmCompositeDatabaseList',
  metaInfo: {
    title: '资料上报',
  },
  components: { ...components, auditAdvancedQuery },

  mixins: [storeMixin, auditAdvancedQueryMixins],
  data() {
    return {
      // radioValue: 1,
      exportLoading: false,
      activeKey: '1',
      searchValue: '',
      deleteButtonDisable: true,
      searchform: 'searchform',
      isShowAdvSearch: false,
      showYearPicker: false,
      year: null,
      endOpen: false,
      SJXMAdvSearchForm: {
        reportYear: '',
        title: '',
        flowState: '',
        reportUnitName: '',
        isLate: '',
      },
      SJJHAdvSearchForm: {
        reportYear: '',
        docStatus: '',
        creatorName: '',
      },
      SJXMTableExpressions: [],
      JHBGTableExpressions: [],
      pageId1: 'audit/spiccompositedatabase/spicCompositeDatabase',
      pageId2: 'audit/spiccompositedatabase/spicCompositeDatabasePublish',
      dataurl2: 'api/xcoa-mobile/v1/spiccompositedatabasepublish/al-list',
      dataurl1: 'api/xcoa-mobile/v1/spiccompositedatabase/al-list',
      columns1: [
        {
          title: '序号',
          dataIndex: 'sortNumber',
          width: '40px',
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          title: '年度',
          dataIndex: 'reportYear',
          width: '80px',
        },
        {
          title: '标题',
          width: '15%',
          dataIndex: 'title',
          scopedSlots: { customRender: 'islink' },
        },
        {
          title: '上报单位',
          dataIndex: 'reportUnitName',
          width: '200px',
        },
        {
          title: '编制人员',
          dataIndex: 'creatorName',
          width: '100px',
        },
        {
          title: '编制日期',
          dataIndex: 'creationTime',
          sorter: true,
          sdRender: TableColumnTypes.date,
          width: '100px',
        },
        {
          title: '当前状态',
          dataIndex: 'flowState',
          width: '100px',
          sorter: true,
        },
        {
          title: '当前处理人',
          dataIndex: 'currentUser',
          width: '100px',
        },
        { title: '文档状态', dataIndex: 'endType', width: '120px', sdHidden: true },
        {
          title: '操作',
          dataIndex: 'opt',
          aligen: 'center',
          customRender: (text, record, index) => {
            const adminRole = getUserInfo().roles.find((item) => {
              return item.code === 'G-1_COMPOSITE_DATABASE'
            })
            if (
              record.endType === 5 &&
              (record.publishAccount === getUserInfo().account || adminRole)
            ) {
              return (
                <span>
                  <a vOn:click={(evt) => this.overruleReport(record)}>驳回上报</a>
                </span>
              )
            }
          },
          width: '100px',
        },
      ],
      actions1: [],
      columns2: [
        {
          title: '序号',
          dataIndex: 'sortNumber',
          width: '40px',
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          title: '年度',
          dataIndex: 'reportYear',
          width: '80px',
        },
        {
          title: '标题',
          width: '30%',
          dataIndex: 'title',
          scopedSlots: { customRender: 'islink' },
        },
        {
          title: '在线反馈截止时间',
          dataIndex: 'endTime',
          width: '120px',
          sorter: true,
          sdRender: TableColumnTypes.date,
        },
        {
          title: '编制人员',
          dataIndex: 'creatorName',
          width: '120px',
        },
        {
          title: '编制日期',
          dataIndex: 'creationTime',
          sorter: true,
          sdRender: TableColumnTypes.date,
          width: '120px',
        },
        {
          title: '当前状态',
          dataIndex: 'docStatus',
          width: '120px',
          sorter: true,
        },
      ],
      actions2: [],
      formId: 'spicCompositeDatabase',
      tableId: 'SJXMDataTable',
      itemStatusOptions: [],
      flowStateOptions: [
        {
          id: '开始',
          name: '开始',
        },
        {
          id: '结束',
          name: '结束',
        },
      ],
      isLateOptions: [
        {
          id: '是',
          name: '是',
        },
        {
          id: '否',
          name: '否',
        },
      ],
      flowStateOptions1: [
        {
          id: '起草',
          name: '起草中',
        },
        {
          id: '已发布',
          name: '已发布',
        },
      ],
      isApplicationAdmin: false, // 是否为综合资料管理员
    }
  },
  mounted() {
    // 初始化权限
    this.initJurisdiction()
  },
  methods: {
    // 初始化权限
    initJurisdiction() {
      // 校验权限（检查为综合资料管理员）
      CompositeDatabaseService.checkPermission().then((res) => {
        this.isApplicationAdmin = res.data.isHasPermission // 删除按钮权限（拥有综合资料管理员）
      })
    },

    // 驳回上报
    overruleReport(record) {
      axios({
        url: 'api/xcoa-mobile/v1/spic-common/overruleReport?id=' + record.id,
        method: 'get',
      }).then((res) => {
        if (res.data) {
          Modal.info({
            title: '提示',
            content: '驳回成功!',
          })
          // this.refresh()
          this.$refs.SJXMDataTable.refresh()
        } else {
          Modal.warning({
            title: '提示',
            content: '驳回失败，请联系管理员!',
          })
        }
      })
    },

    refreshDataTable() {
      if (this.activeKey === '1') {
        this.tableId = 'SJXMDataTable'
      }
      if (this.activeKey === '2') {
        this.tableId = 'JHBGDataTable'
      }
      if (this.$refs[`${this.tableId}`]) {
        this.$refs[`${this.tableId}`].clearSelection()
        this.$refs[`${this.tableId}`].refresh()
      }
    },

    onChange(value) {
      if (value) {
        this.SJXMAdvSearchForm.reportYear = value.format('YYYY')
      } else {
        this.SJXMAdvSearchForm.reportYear = ''
      }
    },

    toggleTabs(key) {
      this.activeKey = key
      if (this.activeKey === '1') {
        this.tableId = 'SJXMDataTable'
        this.SJXMTableExpressions = []
      }
      if (this.activeKey === '2') {
        this.tableId = 'JHBGDataTable'
        this.JHBGTableExpressions = []
      }
      this.deleteButtonDisable = true
      if (this.$refs[`${this.tableId}`]) {
        this.$refs[`${this.tableId}`].clearSelection()
      }
    },
    // 新建
    createProject() {
      let url
      if (this.activeKey === '1') {
        url = '/sd-flow-guide?code=SPIC_AUDIT_ZHZLK'
      } else {
        url = '/xm-composite-database-publish-form'
      }
      crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
        if (refreshFlag) {
          // 这里写或者调刷新的方法
          this.refreshDataTable()
        }
      })
    },
    linkToDelete() {
      if (this.activeKey === '1') {
        this.tableId = 'SJXMDataTable'
        this.formId = 'spicCompositeDatabase'
      }
      const selectedRowKeys = this.$refs[`${this.tableId}`].getSelectedRowKeys()
      if (selectedRowKeys.length === 0) {
        Modal.info({
          content: '请选择需要删除的数据！',
        })
      }
      if (this.activeKey === '1') {
        // if (this.checkStateDelete('开始', '只能删除开始环节的数据！', '1')) {
        this.deleteMethod1(selectedRowKeys)
        // }
      }

      if (this.activeKey === '2') {
        if (this.checkStateDelete('起草中', '只能删除起草中状态的数据！', '2')) {
          this.deleteMethod(selectedRowKeys)
        }
      }
    },
    clearSelection() {
      this.$refs.SJXMDataTable.clearSelection()
    },
    // 刷新列表
    refresh() {
      this.$emit('refreshTable')
    },
    // 删除记录
    deleteMethod1(selectedRowKeys) {
      debugger
      if (selectedRowKeys.length === 0) {
        Modal.info({
          content: '请选择需要删除的文件',
        })
        return
      }
      const selectedRows = this.$refs.SJXMDataTable.getSelectedRows()
      const currentAccount = getUserInfo().account
      const instIds = []
      let flag = false
      selectedRows.forEach((item) => {
        if (item.endType !== 0) {
          flag = true
        }
      })
      if (flag) {
        Modal.error({
          title: '删除失败：存在不是草稿状态的数据',
        })
        return
      }
      var flages = true
      selectedRows.forEach((item) => {
        var instId = item.instId - 0
        if (item.creatorAccount !== currentAccount) {
          Modal.info({
            content: '请选择自己创建的文件',
          })
          flages = false
        } else {
          instIds.push(instId)
        }
      })
      if (!flages) {
        return
      }
      return new Promise((resolve) => {
        Modal.confirm({
          title: '您确定删除这项内容吗？',
          content: '删除这条数据后，就无法恢复初始的状态。',
          okText: '删除',
          okType: 'danger',
          onOk: () => {
            axios({
              url: 'api/flow-mobile/v1/process-manager/process-instance/remove',
              method: 'POST',
              data: {
                flowCallbackBeanName: 'formBeanCleanerCallBack',
                processInstanceIds: instIds.join(','),
              },
            })
              .then(() => {
                this.clearSelection()
                // this.refresh()
                this.$refs.SJXMDataTable.refresh()
                message.success('删除成功')
                /**
                 * 数据删除成功后触发
                 * @property {Array} rowKeys 已删除的记录ids
                 */
                this.$emit('recordsDeleted', selectedRowKeys)
              })
              .catch((err) => {
                const msg = errorUtil.getMessage(err) || '删除失败'
                message.error(msg)
              })
              .finally(resolve)
          },
          onCancel: () => {
            resolve()
          },
        })
      })
    },
    deleteMethod(selectedRowKeys) {
      debugger
      const selectedRows = this.$refs.JHBGDataTable.getSelectedRows()
      const currentAccount = getUserInfo().account
      const instIds = []
      var flages = true
      selectedRows.forEach((item) => {
        console.log(item)
        var instId = item.instId - 0
        if (item.creatorAccount !== currentAccount) {
          Modal.info({
            content: '请选择自己创建的文件',
          })
          flages = false
        } else {
          instIds.push(instId)
        }
      })
      if (!flages) {
        return
      }
      return new Promise((resolve) => {
        Modal.confirm({
          title: '您确定删除这项内容吗？',
          content: '删除这条数据后，就无法恢复初始的状态。',
          cancelText: '取消',
          okText: '删除',
          okType: 'danger',
          onOk: () => {
            axios({
              url: 'api/framework/v1/page/' + this.$refs.JHBGDataTable.formId,
              method: 'delete',
              params: { ids: selectedRowKeys.join(',') },
            })
              .then(() => {
                this.$refs.JHBGDataTable.clearSelection()
                this.$refs.JHBGDataTable.refresh()
                message.success('删除成功')
                this.$emit('recordsDeleted', selectedRowKeys)
              })
              .catch((err) => {
                const msg = errorUtil.getMessage(err) || '删除失败'
                message.error(msg)
              })
              .finally(resolve)
          },
          onCancel: () => {
            resolve()
          },
        })
      })
    },
    // 删除是否为起草状态校验
    checkStateDelete(flowState, message, type) {
      let temp = false
      const selectedRows = this.$refs[`${this.tableId}`].getSelectedRows()
      if (type === '2') {
        selectedRows.some((item) => {
          if (item.docStatus !== '起草中') {
            // if (!flowState.includes(item.flowState)) {
            temp = true
            return true
          }
        })
      }
      if (type === '1') {
        selectedRows.some((item) => {
          if (item.flowState !== '开始') {
            // if (!flowState.includes(item.flowState)) {
            temp = true
            return true
          }
        })
      }
      if (temp) {
        Modal.warning({
          title: '提示',
          content: message,
        })
        return false
      }
      return true
    },
    AdvSearchClick() {
      this.isShowAdvSearch = !this.isShowAdvSearch
    },
    searchedClick() {
      this.isShowAdvSearch = !this.isShowAdvSearch
    },

    onSearch(value) {
      if (this.activeKey === '1') {
        this.SJXMTableExpressions = []
        if (value) {
          const expressions = []
          // 标题
          expressions.push({
            dataType: 'str',
            name: 'title',
            op: 'like',
            stringValue: `%${value}%`,
          })
          this.SJXMTableExpressions.push({
            dataType: 'exps',
            op: 'or',
            expressionsValue: expressions,
          })
        }
      }
      if (this.activeKey === '2') {
        this.JHBGTableExpressions = []
        if (value) {
          const expressions = []
          // 标题
          expressions.push({
            dataType: 'str',
            name: 'title',
            op: 'like',
            stringValue: `%${value}%`,
          })
          this.JHBGTableExpressions.push({
            dataType: 'exps',
            op: 'or',
            expressionsValue: expressions,
          })
        }
      }
      this.$refs[`${this.tableId}`].clearSelection()
    },
    // 上报
    advSJXMSearch() {
      debugger
      this.SJXMTableExpressions = []
      // 年度
      if (this.SJXMAdvSearchForm.reportYear) {
        // const reportyear = this.SJXMAdvSearchForm.reportYear.year() + ''
        // console.log('上报年度高级查询----', reportyear)
        this.SJXMTableExpressions.push({
          dataType: 'str',
          name: 'reportYear',
          op: 'like',
          stringValue: `%${this.SJXMAdvSearchForm.reportYear}%`,
          // stringValue: `%${reportyear}%`,
        })
      }
      if (this.SJXMAdvSearchForm.flowState[0]) {
        this.SJXMTableExpressions.push({
          dataType: 'str',
          name: 'flowState',
          op: 'like',
          stringValue: `%${this.SJXMAdvSearchForm.flowState[0].id}%`,
        })
      }
      // 报送机构
      if (this.SJXMAdvSearchForm.reportUnitName) {
        this.SJXMTableExpressions.push({
          dataType: 'str',
          name: 'reportUnitName',
          op: 'like',
          stringValue: `%${this.SJXMAdvSearchForm.reportUnitName}%`,
        })
      }
      if (this.SJXMAdvSearchForm.title) {
        this.SJXMTableExpressions.push({
          dataType: 'str',
          name: 'title',
          op: 'like',
          stringValue: `%${this.SJXMAdvSearchForm.title}%`,
        })
      }
      if (this.SJXMAdvSearchForm.isLate[0]) {
        this.SJXMTableExpressions.push({
          dataType: 'str',
          name: 'isLate',
          op: 'like',
          stringValue: `${this.SJXMAdvSearchForm.isLate[0].id}`,
        })
      }

      this.$refs[`${this.tableId}`].clearSelection()
    },
    // 下发
    advJHBGSearch() {
      // debugger
      this.JHBGTableExpressions = []
      // 年度
      if (this.SJJHAdvSearchForm.reportYear) {
        // const reportyear = this.SJJHAdvSearchForm.reportYear.year() + ''
        // console.log('下发年度高级查询----', reportyear)
        this.JHBGTableExpressions.push({
          dataType: 'str',
          name: 'reportYear',
          op: 'like',
          stringValue: `%${this.SJJHAdvSearchForm.reportYear}%`,
          // stringValue: `%${reportyear}%`,
        })
      }
      if (this.SJJHAdvSearchForm.docStatus[0]) {
        this.JHBGTableExpressions.push({
          dataType: 'str',
          name: 'docStatus',
          op: 'like',
          stringValue: `%${this.SJJHAdvSearchForm.docStatus[0].name}%`,
        })
      }
      if (this.SJJHAdvSearchForm.creatorName) {
        this.JHBGTableExpressions.push({
          dataType: 'str',
          name: 'creatorName',
          op: 'like',
          stringValue: `%${this.SJJHAdvSearchForm.creatorName}%`,
        })
      }
      if (this.SJJHAdvSearchForm.title) {
        this.JHBGTableExpressions.push({
          dataType: 'str',
          name: 'title',
          op: 'like',
          stringValue: `%${this.SJJHAdvSearchForm.title}%`,
        })
      }
      this.$refs[`${this.tableId}`].clearSelection()
    },
    rowClick1(record) {
      // debugger
      let openurl = ''
      if (this.activeKey === '1') {
        if (
          (record.flowState === '起草') |
          (record.flowState === '开始') |
          (record.flowState === null)
        ) {
          if (
            (record.flowState === '起草' || record.flowState === '开始') &&
            record.creatorAccount === getUserInfo().account
          ) {
            openurl = '/sd-webflow/pages/draft/' + record.instId
          } else {
            openurl = '/sd-webflow/done-pages/' + record.instId
          }
        } else {
          openurl = '/sd-webflow/done-pages/' + record.instId
        }
      }
      crossWindowWatcher.waitForChanged(openurl).then((refreshFlag) => {
        if (refreshFlag) {
          // 这里写或者调刷新的方法
          this.refresh()
        }
      })
    },
    rowClick2(record) {
      if (this.activeKey === '2') {
        var url = '/xm-composite-database-publish-form?record=' + record.id
        crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
          if (refreshFlag) {
            // 这里写或者调刷新的方法
            this.refreshDataTable()
          }
        })
      }
    },

    selectedRowsChanged(row) {
      if (row.length > 0) {
        this.deleteButtonDisable = false
      } else {
        this.deleteButtonDisable = true
      }
    },
    // 导出
    fnexport() {
      console.log('导出点击-----')
      const selectedRowKeys = this.$refs.SJXMDataTable.getSelectedRowKeys()
      if (selectedRowKeys.length === 0) {
        Modal.warning({
          title: '提示',
          content: '请选择要一键导出附件的报告（最多可选择10条）',
        })
      } else {
        const timestamp = new Date().getTime()
        console.log(timestamp)
        axios({
          method: 'get',
          url: 'api/xcoa-mobile/v1/spic-common/exportCompositeDatabaseFiles/' + selectedRowKeys,
          responseType: 'blob',
        }).then((res) => {
          if (res.data) {
            let blob = null
            let fileName = res.headers['content-disposition']?.split('fileName=')[1]
            if (fileName === null || fileName === undefined) {
              fileName = '.zip'
            }
            blob = new Blob([res.data], { type: 'application/zip' })
            const time = moment(moment()).format('yyyyMMDD')
            fileName = '综合资料-' + time + '.zip'
            if ('msSaveOrOpenBlob' in navigator) {
              // 适配ie
              window.navigator.msSaveOrOpenBlob(blob, fileName)
            } else {
              // 其他浏览器
              const blobUrl = window.URL.createObjectURL(blob)
              const a = document.createElement('a')
              a.style.display = 'none'
              a.href = blobUrl
              a.setAttribute('download', fileName)
              a.click()
            }
            message.success('导出成功')
          } else {
            message.error('导出失败，请联系系统管理员')
          }
        })
      }
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.wrap-height {
  :global(.ant-col-offset-10) {
    margin-left: 0;
  }
}

.btns {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 100;
}

.buttonSpacing {
  margin-left: 5px;
}

.advancedQuery {
  :global(.ant-col .ant-form-item-label) {
    width: 30% !important;
  }

  :global(.ant-col .ant-form-item-control-wrapper) {
    width: 60% !important;
  }
}

.advSearchBtn {
  width: 35px;
  padding: 0;
  margin-left: -5px;
  border-radius: 0 5px 5px 0;
}

.search-icon {
  margin-left: 1px !important;
  font-size: 12px;
}

.wrap-height {
  .success {
    color: $alert-success-icon-color;
  }

  .error {
    color: $alert-error-icon-color;
  }

  :global(.part-time) {
    padding-right: 5px !important;
  }
}
</style>
