publicApiService.js 4.3 KB
Newer Older
王绍森's avatar
王绍森 committed
1 2 3 4 5 6 7 8 9 10
/**
 * 事务页面。 根据一站式服务大厅的事务接口。达到增删发起事务流程
 * 2019年10月23日 09:48:13
 * 钟是志
 *
 * */

import { apiRequest } from '../request';
import { getFormArrayConfig }  from '../config/index';
import { setHuanGeToken } from '@/utils/authority';
11
import { getOneStopConfig, isJSON } from '@/baseComponent/utils';
12
import config from '@/config/config';
王绍森's avatar
王绍森 committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

const giveValue = (x) => {
  if(x && x.rows){
    let res = [];
    for(let item of x.rows){
      res.push({
        ...item.hisTaskListData,
        ...item,
      });
    }
    x.rows = res;
    return x;
  }else{
    return {
      rows: [],
      total: 1,
    };
  }
};


34 35
const getId = async (pathname) => { // 获取流程引擎 事务workId 和表dataBaseId
  let idObj = await getOneStopConfig(pathname);
钟是志's avatar
钟是志 committed
36
  console.log(idObj);
37
  if (typeof idObj === 'undefined' || !idObj) {
王绍森's avatar
王绍森 committed
38 39 40 41
    console.error('没有找到对应的流程引擎id');
    return false;
  } else {
    return {
42 43
      dataBaseId: idObj,
      workId: idObj,
王绍森's avatar
王绍森 committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    };
  }
};


const getPages = (info) => { // 获取代办事项 分页数据 workId
  // workId, pageSize, pageNo,
  if (typeof info.pageNo === 'undefined') {
    info.pageNo = 1;
    info.pageSize = 10;
  }
  return apiRequest('/UnifiedAppFormApi/getWaitPage', info);
};







const getColumns = (workId) => { // 获取表头 workId
  return apiRequest('/UnifiedAppFormApi/getFormTitle', { id: workId });
};


/**
 * 获取下拉枚举值
 * */
const getOptions  = async (id, filterSql = undefined, key, name) => {
  return await apiRequest('/DataColumnApi/getOptions', {id, filterSql}).then((x)=>{
    if(x){
      return x.map((y)=>{
        return {
          key: y[key],
          name: y[name],
        }
      })
    }else{
      return [];
    }
  });
};

/**
 * 获取下拉枚举值 通过sql语句
 * */
const getSqlOptions  = async (id, sqlKey = undefined, key, name ) => {
  return await apiRequest('/DataColumnApi/getSqlOptions', {id, sqlKey}).then((x)=>{
    if(x){
      return x.map((y)=>{
        return {
          key: y[key],
          name: y[name],
        }
      })
    }else{
      return [];
    }
  });
};

/**
 * 获取发起流程填写的字段表单详情
 * */
const getFormDetail = (id) => {
  return apiRequest('/UnifiedAppApi/getDetail', {id}).then((x)=>{
    if(x){
      return x;
    }else{
      return {};
    }
  });
};


/**
 *  发起流程
 * */
const startProcess = (info) => {
  return apiRequest('/UnifiedAppFormApi/startProcess', info).then((x)=>{
    if(x){
      return x;
    }else{
      return null;
    }
  });
};

/**
 *  查询已发起的流程的分页接口
 *
 * */

const getApplyPage = (info) => {
  return apiRequest('/UnifiedAppFormApi/getApplyPage', info).then((x)=>{
    return giveValue(x);

  });
};
/**
 *  查询一个流程的详情数据
 *
 * */

const getDetailInfo = (id) => {
  return apiRequest('/UnifiedAppFormApi/getFormDetail', {id}).then((x)=>{
      if(x){
        return x;
      }else{
        return null;
      }
  });
  };
/**
 * 待办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getWaitPage = (info) => {
    return apiRequest('/UnifiedAppFormApi/getWaitPage', info).then((x) => {
       return giveValue(x);
    })
};
/**
 * 已办业务
 * pageSize: 10
 * appId: 1185524814832467968
 * pageNo: 1
 * */
const getHandledPage = (info) => {
  return apiRequest('/UnifiedAppFormApi/getHandledPage', info).then((x) => {

    return giveValue(x);
  })
};

/**
 * 审核接口,支持批量
 *  taskIds: 08d8d359-f7a6-11e9-9a27-0242b1fd760b
 *  examineMap: {"examine":"0","reason":"通过"}
 *  taskForm: {}
 * */
const handleAudit = (info) => {
  return apiRequest('/UnifiedAppFormApi/examineProcess', info).then((x) => {
    if(x){
      return x;
    }
  })
};

const handleSqlData = (info) => {
  return apiRequest('/DataColumnApi/getSqlData', info).then((x) => {
    if(x){
      return x;
    }else{
      return [];
    }
  })
};

const handleSqlfind = async(sqlKey = '') => {
  return await apiRequest('/SqlManageEntityApi/find', {sqlKey}).then((x) => {
    if(x){
      return x;
    }else{
      return null;
    }
  })
};



export {
218 219 220
  getId, getColumns, getPages,
  getFormDetail,
  getOptions, startProcess, getApplyPage,
王绍森's avatar
王绍森 committed
221
  getDetailInfo, getWaitPage, getHandledPage, handleAudit,
222
  handleSqlData,handleSqlfind, getSqlOptions,
王绍森's avatar
王绍森 committed
223 224 225
};