WXL (wul)
6 天以前 a99e82da2b087d7019cdce015c25befc620b9d61
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
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
import { getTaskservelist } from "@/api/AiCentre/SingleTask";
import { getSfStatisticsJoyInfo } from "@/api/system/user";
 
// 随访统计页复用的满意度分析数据(与满意度统计页默认口径一致:离院、病区、服务类型 6)
export default {
  data() {
    return {
      satisfactionRows: [],
      satisfactionRowsLoading: false,
      satisfactionTopics: [],
      satisfactionTopicsLoading: false,
      satisfactionMeta: {
        dimension: "ward",
        scope: "leave",
        dateRange: [],
        total: 0,
      },
      satisfactionLoaded: false,
    };
  },
  computed: {
    satisfactionDetailMeta() {
      return {
        ...this.satisfactionMeta,
        groupLabel: "全部",
      };
    },
  },
  created() {
    this.loadSatisfactionAnalysis();
  },
  methods: {
    loadSatisfactionAnalysis(force = false) {
      if (this.satisfactionLoaded && !force) return;
      this.satisfactionLoaded = true;
      this.fetchSatisfactionRows();
      this.fetchSatisfactionTopics();
    },
 
    analysisScope() {
      const depts = (this.$store.getters.belongDepts || [])
        .map((dept) => dept.deptCode)
        .filter(Boolean);
      const wards = (this.$store.getters.belongWards || [])
        .map((ward) => ward.districtCode)
        .filter(Boolean);
      return { depts, wards };
    },
 
    fetchSatisfactionRows() {
      const { depts, wards } = this.analysisScope();
      if (!depts.length && !wards.length) {
        this.satisfactionRows = [];
        this.satisfactionMeta = {
          ...this.satisfactionMeta,
          total: 0,
        };
        return;
      }
 
      this.satisfactionRowsLoading = true;
      const payload = {
        pageNum: null,
        pageSize: null,
        sendstate: null,
        sendstateView: 2,
        sort: 2,
        serviceType: 6,
        searchscope: 3,
        visitCount: 1,
        scopetype: [],
        deptOrDistrict: depts.length && wards.length ? 2 : 1,
        leaveldeptcodes: depts,
        leavehospitaldistrictcodes: wards,
      };
 
      getTaskservelist(payload)
        .then((response) => {
          const rows = this.pickSatisfactionRows(response);
          this.satisfactionRows = rows;
          this.satisfactionMeta = {
            dimension: "ward",
            scope: "leave",
            dateRange: [],
            total: rows.length,
          };
        })
        .catch((error) => {
          console.error("随访统计页获取满意度患者明细失败:", error);
          this.satisfactionRows = [];
        })
        .finally(() => {
          this.satisfactionRowsLoading = false;
        });
    },
 
    fetchSatisfactionTopics() {
      const { wards } = this.analysisScope();
      if (!wards.length) {
        this.satisfactionTopics = [];
        return;
      }
 
      this.satisfactionTopicsLoading = true;
      const payload = {
        configKey: "joyCount",
        statisticaltype: 1,
        serviceType: [6],
        pageNum: 1,
        pageSize: 999,
        leavehospitaldistrictcodes: wards,
      };
 
      getSfStatisticsJoyInfo(payload)
        .then((response) => {
          this.satisfactionTopics = response.data || [];
        })
        .catch((error) => {
          console.error("随访统计页获取满意度问题详情失败:", error);
          this.satisfactionTopics = [];
        })
        .finally(() => {
          this.satisfactionTopicsLoading = false;
        });
    },
 
    pickSatisfactionRows(response) {
      if (!response) return [];
 
      const rowsWrap = response.rows || (response.data && response.data.rows);
      let list = [];
 
      if (Array.isArray(rowsWrap) && rowsWrap[0]) {
        list =
          rowsWrap[0].serviceSubtaskList ||
          (rowsWrap[0].sendname ? rowsWrap : []);
      } else if (Array.isArray(response.data)) {
        list = response.data;
      }
 
      return (list || [])
        .filter(Boolean)
        .map((row) => this.normalizeSatisfactionRow(row));
    },
 
    normalizeSatisfactionRow(row) {
      const item = { ...row };
      if (item.endtime) {
        item.endDay = this.daysBetween(item.endtime);
      }
      return item;
    },
  },
};