From b515fae43490ab20977d559e19d4e5f63a4fd96d Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 25 四月 2025 16:42:39 +0800
Subject: [PATCH] 应急线索模块

---
 services/clue/fetchClue.js |  266 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 178 insertions(+), 88 deletions(-)

diff --git a/services/clue/fetchClue.js b/services/clue/fetchClue.js
index 4a50ed4..be15df5 100644
--- a/services/clue/fetchClue.js
+++ b/services/clue/fetchClue.js
@@ -5,110 +5,200 @@
 import { get, post, _delete } from '../baseRequset';
 import { clueUrl, cluePicUrl } from '../../config/index';
 import { getClueQuestionList } from '../../model/clue/clueQuestion';
+import { getClueList } from '../../model/clue/clue';
 
-export default {
-  /******************************************************************************* */
-  /**
-   * 鏌ヨ绾跨储浠诲姟
-   * @param {*} clueTask
-   * @returns
-   */
-  fetchClueTask(clueTask) {
-    return post(
-      {
-        url: `clue/task/fetch`,
-        data: clueTask,
-      },
-      clueUrl,
-    ).then(res => {
-      return res.data;
-    });
-  },
+/******************************************************************************* */
+/**
+ * 鏌ヨ绾跨储
+ * @param {*} clue
+ * @returns
+ */
+function fetchClue(clue) {
+  return post(
+    {
+      url: `clue/search`,
+      data: clue,
+    },
+    clueUrl,
+  ).then(res => {
+    res.data.data = getClueList(res.data.data);
+    return res.data;
+  });
+}
 
-  /******************************************************************************* */
-  /**
-   * 鑾峰彇绾跨储缁撹
-   * @param {string} clueId 绾跨储id
-   */
-  getConclusion(clueId) {
-    return get({
+/**
+ * 鏌ヨ绾跨储
+ * @param {*} clue
+ * @returns
+ */
+function fetchClueInternal(clue) {
+  return post(
+    {
+      url: `clue/internal/search`,
+      data: clue,
+    },
+    clueUrl,
+  ).then(res => {
+    res.data.data = getClueList(res.data.data);
+    return res.data;
+  });
+}
+/******************************************************************************* */
+/**
+ * 鏌ヨ绾跨储浠诲姟
+ * @param {*} clueTask
+ * @returns
+ */
+function fetchClueTask(clueTask) {
+  return post(
+    {
+      url: `clue/task/fetch`,
+      data: clueTask,
+    },
+    clueUrl,
+  ).then(res => {
+    return res.data;
+  });
+}
+
+/******************************************************************************* */
+/**
+ * 鑾峰彇绾跨储缁撹
+ * @param {string} clueId 绾跨储id
+ */
+function getConclusion(clueId, internal) {
+  return get(
+    {
       url: `clue/conclusion/fetch`,
       params: {
-        clueId: clueId,
+        clueId,
+        internal,
       },
-      clueUrl,
-    }).then(res => res.data);
-  },
+    },
+    clueUrl,
+  ).then(res => res.data);
+}
 
-  /**
-   * 鎻愪氦绾跨储缁撹
-   * @param {object} conclusion 绾跨储
-   * @returns
-   */
-  uploadConclusion(conclusion) {
-    return post(
-      {
-        url: `clue/conclusion/upload`,
-        data: conclusion,
-      },
-      clueUrl,
-    ).then(res => res.data);
-  },
+/**
+ * 鎻愪氦绾跨储缁撹
+ * @param {object} conclusion 绾跨储
+ * @returns
+ */
+function uploadConclusion(conclusion) {
+  return post(
+    {
+      url: `clue/conclusion/upload`,
+      data: conclusion,
+    },
+    clueUrl,
+  ).then(res => res.data);
+}
 
-  /******************************************************************************* */
-  /**
-   * 鑾峰彇宸叉彁浜ょ殑绾跨储闂
-   * @param {string} clueId 绾跨储id
-   */
-  getQuestion(clueId) {
-    return get({
+/******************************************************************************* */
+/**
+ * 鑾峰彇宸叉彁浜ょ殑绾跨储闂
+ * @param {string} clueId 绾跨储id
+ */
+function getQuestion(clueId, internal) {
+  return get(
+    {
       url: `clue/question/fetch`,
       params: {
-        clueId: clueId,
+        clueId,
+        internal,
       },
-      clueUrl,
-    }).then(res => {
-      return getClueQuestionList(res.data);
+    },
+    clueUrl,
+  ).then(res => {
+    res.data.data = getClueQuestionList(res.data.data);
+    return res.data;
+  });
+}
+
+/**
+ * 涓婁紶绾跨储闂
+ * @param {object} question 闂鎻忚堪
+ * @param {*} files 闂鍥剧墖
+ * @returns
+ */
+function uploadQuestion(question, files) {
+  const fields = [
+    {
+      name: 'question',
+      value: JSON.stringify(question),
+    },
+  ];
+  const images = files.map(f => {
+    return {
+      name: 'images',
+      filePath: f,
+    };
+  });
+
+  return new Multipart({
+    fields,
+    files: images,
+  })
+    .submit(clueUrl + `/clue/question/upload`)
+    .then(res => {
+      return res.data;
     });
-  },
+}
 
-  /**
-   * 涓婁紶绾跨储闂
-   * @param {object} question 闂鎻忚堪
-   * @param {*} files 闂鍥剧墖
-   * @returns
-   */
-  uploadQuestion(question, files) {
-    const fields = [
-      {
-        name: 'question',
-        value: JSON.stringify(question),
-      },
-    ];
-    const images = files.map(f => {
-      return {
-        name: 'images',
-        filePath: f,
-      };
+/**
+ * 鏇存柊绾跨储闂
+ * @param {object} question 闂鎻忚堪
+ * @param {Sting} deleteImgUrl 鍒犻櫎鐨勫浘鐗囩浉瀵硅矾寰勶紝鐢�;鍒嗗壊
+ * @param {*} files 闂鍥剧墖
+ * @returns
+ */
+function updateQuestion(question, deleteImgUrl, files) {
+  const fields = [
+    {
+      name: 'question',
+      value: JSON.stringify(question),
+    },
+    {
+      name: 'deleteImg',
+      value: deleteImgUrl,
+    },
+  ];
+  const images = files.map(f => {
+    return {
+      name: 'images',
+      filePath: f,
+    };
+  });
+
+  return new Multipart({
+    fields,
+    files: images,
+  })
+    .submit(clueUrl + `/clue/question/update`)
+    .then(res => {
+      return res.data;
     });
+}
 
-    return new Multipart({
-      fields,
-      images,
-    })
-      .submit(clueUrl + `/clue/question/upload`)
-      .then(res => {
-        return res.data;
-      });
-  },
-
-  deleteQuestion(questionId) {
-    return _delete({
+function deleteQuestion(questionId) {
+  return _delete(
+    {
       url: `clue/question`,
       params: {
         questionId: questionId,
       },
-      clueUrl,
-    }).then(res => res.data);
-  },
+    },
+    clueUrl,
+  ).then(res => res.data);
+}
+export {
+  fetchClue,
+  fetchClueInternal,
+  fetchClueTask,
+  getConclusion,
+  uploadConclusion,
+  updateQuestion,
+  getQuestion,
+  uploadQuestion,
+  deleteQuestion,
 };

--
Gitblit v1.9.3