exportHandledInfo.js 1.6 KB
Newer Older
1 2 3 4 5 6
/**
 * 禅道 30031 已处理的页面增加导出按钮
 * */
import { message } from 'antd';
import React from 'react';
import { downloadFile } from '@/webPublic/one_stop_public/Table/globalFunction';
7
import { getToken } from '@/webPublic/one_stop_public/utils/token';
8
import { giveBase16EnCode } from '@/webPublic/one_stop_public/Base16';
9 10 11 12 13 14 15 16

export default function exportHandledInfo({
                                            columns = [],
                                            appId = '1492048888356405248',
                                            type = 'handled',
                                          }) {
  const headers = columns.filter((g) => {
    return g.dataIndex !== 'operationDiy';
17 18 19 20 21 22 23 24
  })
    .map((g) => {
      if (g.title === '流程审核状态') {
        return {
          key: 'formStatusName',
          title: g.title,
        };
      }
25
      return {
26
        key: g.dataIndex,
27 28
        title: g.title,
      };
29
    });
30 31 32
  const data = {
    appId,
    type,
33
    headers: JSON.stringify(headers),
34
    token: getToken(),
35
  };
36
  if (appId) {
37 38
    message.info('正在导出文件,请耐心等待');
    let url = window.CONFIG.OAUTH_ACTION_PATH + '/UnifiedAppFormApi/exportData';
39
    // uaaRequest('/UnifiedAppFormApi/getHandledPage', data);
40
    // downloadFile(url, data);
41
    console.log(data, url);
42 43 44 45 46 47 48 49 50
    giveBase16EnCode(data, url)
      .then((newData) => {
        if (typeof newData === 'object' && newData.url && newData.datas) {
          // newData.datas.rbin = true;
          newData.datas.token = getToken();
          return downloadFile(newData.url, newData.datas);
        }
        // downloadFile(url, data);
      });
51

52
  }
53
}