riku
2024-04-25 743044407e35a10ff824ef18cb883ac2b66e2d12
src/api/fysp/evaluateApi.js
@@ -1,3 +1,4 @@
import { Base64 } from 'js-base64';
import { $fysp } from '../index';
export default {
@@ -9,11 +10,57 @@
  },
  /**
   * 根据巡查任务获取评分细则
   */
  fetchItemEvaluation(subTaskId) {
    const params = `?subTaskId=${subTaskId}`;
    return $fysp.get(`evaluationsubrule/score${params}`).then((res) => res.data);
  },
  /**
   * 批量更新评分细则得分
   */
  updateItemEvaluation(param) {
    return $fysp.post(`itemevaluation/uplist`, param).then((res) => res.data);
  },
  /**
   * 查询评估总规则
   * @param {Object} param
   * @returns
   * @param {Object} param
   * @returns
   */
  fetchEvaluationRule(param) {
    return $fysp.post(`evaluationrule/find`, param).then((res) => res.data);
  },
  autoEvaluate(param) {
    return $fysp.post(`evaluation/auto`, param).then((res) => res.data);
  },
  /**
   * 下载规范性评估与分析报告
   */
  downloadAutoEvaluation(param, forceUpdate) {
    return $fysp
      .post(`evaluation/auto/record/download?forceUpdate=${forceUpdate}`, param, { responseType: 'blob' })
      .then((res) => {
        // 文档未生成,已启动文档生成后台任务
        if (res.data.type == 'application/json') {
          return false
        }
        // 文档已存在,直接下载
        else {
          const name = Base64.decode(res.headers.get('filename'));
          const url = window.URL.createObjectURL(res.data);
          const link = document.createElement('a');
          link.href = url;
          link.setAttribute('download', name);
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          window.URL.revokeObjectURL(url);
        }
      });
  }
};