ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<script lang="ts" setup>
import { ref } from 'vue';
 
import { useGlobSetting } from '@jnpf/hooks';
import { useModal } from '@jnpf/ui/modal';
import { formatToDateTime } from '@jnpf/utils';
 
import { Timeline, TimelineItem } from 'ant-design-vue';
 
import { flowNodeList } from '#/components/FlowProcess/src/helper/componentMap';
import { useFlowState } from '#/hooks/flow/useFlowStatus';
 
import LogErrorModal from './../components/modal/LogErrorModal.vue';
import CirculateUserModal from './modal/CirculateUserModal.vue';
import RecordModal from './modal/RecordModal.vue';
import TaskLogModal from './modal/TaskLogModal.vue';
 
const props: any = defineProps({
  list: { type: Array, default: () => [] },
  endTime: { type: Number, default: 0 },
  opType: { default: '' },
  taskId: { type: [String, Number], default: '' },
});
const emit = defineEmits(['onRetry']);
const globSetting = useGlobSetting();
const apiUrl = ref(globSetting.apiURL);
const { getFlowStateContent, getFlowStateColor, getHexColor } = useFlowState();
const [registerRecord, { openModal: openRecordModal }] = useModal();
const [registerTaskLog, { openModal: openTaskLogModal }] = useModal();
const [registerCirculateUserModal, { openModal: openCirculateUserModal }] = useModal();
const [registerLogErrorModal, { openModal: openLogErrorModal }] = useModal();
function getNodeStatusColor(status) {
  return status == 1 || status == 2 ? 'success' : status == 3 ? 'error' : 'blue';
}
function getTimeLineTagColor(status) {
  return status == 1 || status == 2 ? '#08AF28' : status == 3 ? '#ed6f6f' : '#0177FF';
}
function getNodeStatusContent(status) {
  const list = ['', '已提交', '已通过', '已拒绝', '审批中', '已退回', '已撤回', '等待中', '办理中'];
  return list[status] || '';
}
function getCounterSignContent(counterSign, assigneeType) {
  if (assigneeType == 10) return '逐级审批';
  return counterSign == 0 ? '或签' : counterSign == 1 ? '会签' : '依次审批';
}
function getOutsideState(state: boolean) {
  return state ? '成功' : '失败';
}
function getNodeIcon(nodeType) {
  const list = flowNodeList.find((o) => o.option.wnType == nodeType);
  return list?.icon || 'icon-ym icon-ym-flow-node-start';
}
function handleShowRecordModal(item) {
  const title = `${item.nodeName}(${getCounterSignContent(item.counterSign, item.assigneeType)})`;
  openRecordModal(true, { taskId: props.taskId, nodeId: item.nodeId, title });
}
function handleShowTaskLogModal(item) {
  openTaskLogModal(true, { taskId: props.taskId, nodeId: item.nodeId });
}
function handleShowErrorModal(item) {
  openLogErrorModal(true, { errorTip: item.errorTip, errorData: item.errorData });
}
function handleRetry(item) {
  emit('onRetry', item.nodeId);
}
function handleShowCirculateUserModal(item) {
  openCirculateUserModal(true, { taskId: props.taskId, nodeId: item.nodeId });
}
</script>
<template>
  <Timeline class="record-time-list-container">
    <TimelineItem v-for="item in props.list" :key="item">
      <template #dot>
        <span class="tag" :style="{ background: getTimeLineTagColor(item.nodeStatus) }"></span>
      </template>
      <span>{{ formatToDateTime(item.startTime, 'YYYY-MM-DD HH:mm') }}</span>
      <div class="time-item-container">
        <div class="time-node-name">
          <i :class="getNodeIcon(item.nodeType)"></i>
          <span class="node-name">{{ item.nodeName }}</span>
          <a-tag :color="getNodeStatusColor(item.nodeStatus)" :bordered="false" class="node-status">{{ getNodeStatusContent(item.nodeStatus) }}</a-tag>
        </div>
        <div class="time-node-approver" v-if="item.approver?.length">
          <div class="approver-container">
            <div class="approver-item" v-for="child in item.approver.slice(0, 4)" :key="child">
              <a-avatar :size="24" :src="apiUrl + child.headIcon" />
              <a-tag class="node-handle-type" :color="getHexColor(getFlowStateColor(child.handleType))">{{ getFlowStateContent(child.handleType) }}</a-tag>
              <span class="user-name">{{ child.userName }}</span>
            </div>
          </div>
          <div class="approver-count" v-if="item.approverCount">{{ item.approverCount }}</div>
        </div>
        <div class="counter-sign" @click="handleShowRecordModal(item)" v-if="['approver', 'processing'].includes(item.nodeType)">
          <span>{{ getCounterSignContent(item.counterSign, item.assigneeType) }}</span>
          <i class="icon-ym icon-ym-right"></i>
        </div>
        <div class="counter-sign" @click="handleShowCirculateUserModal(item)" v-if="item.isCirculate">
          <span>抄送人员</span>
          <i class="icon-ym icon-ym-right"></i>
        </div>
        <div class="outside-sign" v-if="item.nodeType == 'outside'">
          <div>数据传递{{ getOutsideState(item.outSideStatus) }}</div>
          <div v-if="!item.outSideStatus">
            <a-button type="link" size="small" @click="handleShowErrorModal(item)">查看异常</a-button>
            <a-button type="link" size="small" @click="handleRetry(item)" danger v-if="item.isRetry">重试</a-button>
          </div>
        </div>
        <div class="counter-sign" @click="handleShowTaskLogModal(item)" v-if="item.showTaskFlow">
          <span>任务流程</span>
          <i class="icon-ym icon-ym-right"></i>
        </div>
      </div>
    </TimelineItem>
  </Timeline>
  <RecordModal @register="registerRecord" />
  <TaskLogModal @register="registerTaskLog" />
  <LogErrorModal @register="registerLogErrorModal" />
  <CirculateUserModal @register="registerCirculateUserModal" />
</template>
<style lang="scss">
.record-time-list-container {
  height: 100%;
  padding: 24px 12px;
  overflow: auto;
 
  .tag {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }
 
  .time-item-container {
    margin-top: 8px;
    background-color: var(--app-content-background);
    border-radius: 4px;
 
    .time-node-name {
      display: flex;
      align-items: center;
      height: 40px;
      margin-left: 10px;
 
      i {
        margin-right: 4px;
        font-size: 12px;
      }
 
      .node-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
 
      .node-status {
        padding-inline: 10px;
        border-radius: 10px;
      }
    }
 
    .time-node-approver {
      display: flex;
 
      .approver-container {
        display: flex;
        flex: 1;
        justify-content: flex-start;
        min-width: 0;
        margin: 0 10px 10px;
 
        .approver-item {
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          width: 25%;
 
          .node-handle-type {
            z-index: 999;
            margin: -8px auto 0;
          }
 
          .user-name {
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            text-align: center;
            white-space: nowrap;
          }
        }
      }
 
      .approver-count {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        margin-right: 10px;
        background-color: var(--component-background);
        border-radius: 12px;
      }
    }
 
    .counter-sign {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 40px;
      margin: 0 16px;
      cursor: pointer;
      border-top: 1px solid var(--border-color-base);
 
      span {
        height: 20px;
        padding: 0 12px;
        line-height: 20px;
        text-align: center;
        background: #e2e2e2;
        border-radius: 4px;
      }
    }
 
    .outside-sign {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 40px;
      margin: 0 16px;
      cursor: pointer;
      border-top: 1px solid var(--border-color-base);
 
      span {
        height: 20px;
        line-height: 20px;
        text-align: center;
        border-radius: 4px;
      }
    }
  }
}
</style>