刘光辉
10 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
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
<script lang="ts" setup>
import type { ActionItem, BasicColumn } from '@jnpf/ui/vxeTable';
 
import { computed } from 'vue';
 
import { createImgPreview } from '@jnpf/ui';
import { useModal } from '@jnpf/ui/modal';
import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { Image } from 'ant-design-vue';
 
import { useFlowState } from '#/hooks/flow/useFlowStatus';
 
import LogErrorModal from './modal/LogErrorModal.vue';
 
const props = defineProps({
  list: { type: Array, default: () => [] },
  endTime: { type: Number, default: 0 },
  opType: { default: '' },
  type: { type: Number, default: 0 },
  status: { type: Number, default: 0 },
});
const emit = defineEmits(['viewDetail']);
const { getFlowStateContent, getFlowStateColor } = useFlowState();
const columns: BasicColumn[] = [
  { title: '节点名称', dataIndex: 'nodeName', minWidth: 200, slots: { default: 'nodeName' } },
  { title: '操作人员', dataIndex: 'userName', width: 120 },
  { title: '接收时间', dataIndex: 'creatorTime', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '操作时间', dataIndex: 'handleTime', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '执行动作', dataIndex: 'handleType', width: 200, slots: { default: 'handleType' } },
  { title: '签名', dataIndex: 'signImg', width: 100, align: 'center', ellipsis: false, slots: { default: 'signImg' } },
  { title: '附件', dataIndex: 'fileList', width: 200, slots: { default: 'fileList' } },
  { title: '备注', dataIndex: 'handleOpinion', width: 200 },
];
const taskColumns: BasicColumn[] = [
  { title: '节点名称', dataIndex: 'nodeName', minWidth: 200, slots: { default: 'nodeName' } },
  { title: '进入时间', dataIndex: 'startTime', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '离开时间', dataIndex: 'endTime', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
  { title: '状态', dataIndex: 'status', width: 200, slots: { default: 'status' } },
  { title: '操作', dataIndex: 'action', width: 85, slots: { default: 'action' } },
];
const [registerTable] = useVxeTable({
  showTableSetting: false,
  pagination: false,
});
const [registerLogErrorModal, { openModal: openLogErrorModal }] = useModal();
 
const statusMap = ['已完成', '异常', '进行中'];
const statusIconMap = ['icon-ym-success', 'icon-ym-fail', 'icon-ym-recovery'];
 
const getList = computed<any[]>(() => {
  const list = (props.list as any[]).map((o) => {
    const operator = [5, 7, 11, 13].includes(o.handleStatus) ? `:${o.handleUserName}` : '';
    o.statusText = getFlowStateContent(o.handleType || 0) + operator;
    o.fileJson = o.fileList ? JSON.parse(o.fileList) : [];
    return o;
  });
  return list;
});
 
function handlePreview(img) {
  createImgPreview({ imageList: [img] });
}
function handleNodeDetail(record) {
  const data = {
    id: record.taskId,
    taskId: record.id,
    opType: 4,
    status: record.status,
    title: record.nodeName,
    disabled: true,
  };
  emit('viewDetail', data);
}
function getTaskTableActions(record): ActionItem[] {
  return [
    {
      ifShow: record.status == 1,
      label: '查看异常',
      onClick: handleShowErrorModal.bind(null, record),
    },
  ];
}
function handleShowErrorModal(item) {
  openLogErrorModal(true, { errorTip: item.errorTip, errorData: item.errorData });
}
</script>
 
<template>
  <BasicVxeTable @register="registerTable" :columns="type === 2 ? taskColumns : columns" :data-source="getList">
    <template #nodeName="{ record }">
      <span class="recordList-nodeName" @click="handleNodeDetail(record)" v-if="opType == '6' && type !== 2 && !record.isOutSideNode">
        {{ record.nodeName }}
      </span>
      <span v-else>{{ record.nodeName }}</span>
    </template>
 
    <template #handleType="{ record }">
      <div class="handle-action" :title="record.statusText">
        <span class="spot" :style="{ background: getFlowStateColor(record.handleType || 0) }"></span>{{ record.statusText }}
      </div>
    </template>
    <template #signImg="{ record }">
      <Image :width="80" :src="record.signImg" :preview="false" v-if="record.signImg" class="cursor-pointer" @click="handlePreview(record.signImg)" />
    </template>
    <template #fileList="{ record }">
      <jnpf-upload-file v-model:value="record.fileJson" type="workFlow" detailed simple />
    </template>
    <template #status="{ record }">
      <div class="task-flow-status">
        <i class="icon icon-ym" :class="statusIconMap[record.status]" v-if="statusIconMap[record.status]"></i>
        {{ statusMap[record.status] }}
      </div>
    </template>
    <template #action="{ record }">
      <TableAction :actions="getTaskTableActions(record)" />
    </template>
  </BasicVxeTable>
  <LogErrorModal @register="registerLogErrorModal" />
</template>
<style lang="scss">
.recordList-nodeName {
  color: var(--primary-color);
  cursor: pointer;
}
 
.handle-action {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
 
  .spot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    margin-bottom: 2px;
    border-radius: 50%;
  }
}
</style>