riku
2025-04-27 f46786f11c5c08ead7501a82e5a71430ad69b782
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
import { getQuestion, deleteQuestion } from '../../../services/clue/fetchClue';
 
export const useQuestion = Behavior({
  data: {
    questionList: [],
  },
  methods: {
    fetchClueQuestion() {
      const { clueTask } = this.data;
      getQuestion(clueTask.clueId, clueTask.internalTask).then(res => {
        this.setData({ questionList: res.data });
      });
    },
 
    deleteQuestion(e) {
      const { index } = e.currentTarget.dataset;
      this.setData({ showDelete: true, currentIndex: index });
    },
 
    onDeleteConfirm() {
      const { currentIndex, questionList } = this.data;
      const q = questionList[currentIndex];
 
      deleteQuestion(q.cqId)
        .then(res => {
          if (res.success) {
            const index = questionList.indexOf(q);
            questionList.splice(index, 1);
            this.setData({ questionList });
          }
        })
        .finally(() => this.closeDialog());
    },
 
    checkQuestion(e) {
      const { index } = e.currentTarget.dataset;
      const question = this.data.questionList[index];
 
      wx.navigateTo({
        url: '/pages/cluetask/question/index',
        events: {
          uploadOver: () => {
            // 问题修改完成后更新状态
            this.fetchClueQuestion();
          },
        },
        success: res => {
          res.eventChannel.emit('acceptClueQuestionData', {
            question,
            clue: this.data.clue,
            isInternal: this.data.clueTask.internalTask,
          });
        },
      });
    },
 
    addQuestion() {
      wx.navigateTo({
        url: '/pages/cluetask/question/index',
        events: {
          uploadOver: () => {
            // 问题提交完成后更新状态
            this.fetchClueQuestion();
          },
        },
        success: res => {
          res.eventChannel.emit('acceptClueQuestionData', {
            clue: this.data.clue,
            isInternal: this.data.clueTask.internalTask,
          });
        },
      });
    },
 
    closeDialog() {
      this.setData({ showDelete: false });
    },
  },
});