nbb-component-ui 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nbb-component-ui",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "main": "./dist/index.umd.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "./dist/index.d.ts",
@@ -0,0 +1,187 @@
1
+ <template>
2
+ <div class="scroll-area">
3
+ <div class="flow-header flex justify-between">
4
+ <div class="text-18px font-bold">
5
+ <span>{{ t('processFlow.flow') }}</span>
6
+ <span>{{ processInstance.id }}</span>
7
+ </div>
8
+ <div class="text-14px font-bold" style="color: #005aae">
9
+ <span>{{ processInstance.name }}</span>
10
+ </div>
11
+ </div>
12
+ <div class="flex items-center">
13
+ <div class="flow-start">
14
+ <p>{{ t('processFlow.startTime') }}{{ formatDate(processInstance.startTime) }}</p>
15
+ <p>{{ t('processFlow.endTime') }}{{ formatDate(processInstance.endTime) }}</p>
16
+ <p v-if="processInstance.durationInMillis">
17
+ {{ t('processFlow.duration') }}{{ formatPast2(processInstance?.durationInMillis) }}
18
+ </p>
19
+ </div>
20
+ <Icon
21
+ :size="100"
22
+ :icon="statusIconMapping[processInstance.status] || 'svg-icon:approvalPending'"
23
+ />
24
+ </div>
25
+
26
+ <div class="mt-30px block">
27
+ <el-timeline>
28
+ <el-timeline-item
29
+ v-for="(item, index) in tasks"
30
+ :key="index"
31
+ :type="getTaskTimelineItemType(item) || 'info'"
32
+ >
33
+ <template #dot>
34
+ <img
35
+ :src="
36
+ item?.assigneeUser?.avatar ||
37
+ 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
38
+ "
39
+ class="avatar-wrap"
40
+ />
41
+ </template>
42
+ <p style="font-weight: 700">
43
+ {{ item.name }}
44
+ <dict-tag
45
+ v-if="item.status"
46
+ :type="DICT_TYPE.BPM_TASK_STATUS"
47
+ :value="item.status || ''"
48
+ />
49
+ </p>
50
+
51
+ <el-card :body-style="{ padding: '10px' }">
52
+ <label v-if="index === 0" style="margin-right: 30px; font-weight: normal">
53
+ {{ item.assigneeUser?.nickname || item.ownerUser?.nickname }}
54
+ <el-tag size="small" type="info" style="vertical-align: 1px">{{
55
+ processInstance?.startUser?.deptName
56
+ }}</el-tag>
57
+ </label>
58
+ <label v-if="item.assigneeUser" style="margin-right: 30px; font-weight: normal">
59
+ {{ t('processFlow.approver') }}{{ item.assigneeUser?.nickname || item.ownerUser?.nickname }}
60
+ <el-tag size="small" type="info" style="vertical-align: 1px">{{
61
+ item.assigneeUser.deptName
62
+ }}</el-tag>
63
+ </label>
64
+ <div>
65
+ <label v-if="item.createTime && !item.endTime" style="font-weight: normal"
66
+ >{{ t('processFlow.createTime') }}</label
67
+ >
68
+ <label
69
+ v-if="item.createTime && !item.endTime"
70
+ style="font-weight: normal; color: #8a909c"
71
+ >
72
+ {{ formatDate(item?.createTime, 'MM-DD HH:mm') }}
73
+ </label>
74
+ <label v-if="item.endTime" style="font-weight: normal"> {{ t('processFlow.approvalTime') }} </label>
75
+ <label v-if="item.endTime" style="font-weight: normal; color: #8a909c">
76
+ {{ formatDate(item?.endTime, 'MM-DD HH:mm') }}
77
+ </label>
78
+ <label v-if="item.durationInMillis" style="margin-left: 30px; font-weight: normal">
79
+ {{ t('processFlow.duration') }}
80
+ </label>
81
+ <label v-if="item.durationInMillis" style="font-weight: normal; color: #8a909c">
82
+ {{ formatPast2(item?.durationInMillis) }}
83
+ </label>
84
+ </div>
85
+ <div v-if="item.reason"> {{ t('processFlow.approvalSuggestion') }}{{ item.reason }} </div>
86
+ </el-card>
87
+ </el-timeline-item>
88
+ </el-timeline>
89
+ </div>
90
+ </div>
91
+ </template>
92
+
93
+
94
+ <script lang="ts" setup>
95
+ import { formatDate, formatPast2 } from '@/utils/formatTime'
96
+ import { propTypes } from '@/utils/propTypes'
97
+ import { DICT_TYPE } from '@/utils/dict'
98
+ import { isEmpty } from '@/utils/is'
99
+ import TaskSignList from './dialog/TaskSignList.vue'
100
+ import type { ApiAttrs } from '@form-create/element-ui/types/config'
101
+ import { setConfAndFields2 } from '@/utils/formCreate'
102
+ import * as TaskApi from '@/api/bpm/task'
103
+ import download from '@/utils/download'
104
+ import {ref} from "vue";
105
+
106
+ defineOptions({ name: 'BpmProcessInstanceTaskList' })
107
+
108
+ const { t } = useI18n()
109
+ const statusIconMapping = {
110
+ 1: 'svg-icon:approvalPending', // 审批中
111
+ 2: 'svg-icon:approvalPass', // 通过
112
+ 3: 'svg-icon:approvalRejected', // 拒绝
113
+ 4: 'svg-icon:approvalCanceled' // 取消
114
+ }
115
+ const props = defineProps({
116
+ loading: propTypes.bool, // 是否加载中
117
+ processInstance: propTypes.object, // 流程实例
118
+ tasks: propTypes.arrayOf(propTypes.object) // 流程任务的数组
119
+ })
120
+
121
+ /** 获得任务对应的颜色 */
122
+ const getTaskTimelineItemType = (item: any) => {
123
+ if ([0, 1, 6, 7].includes(item.status)) {
124
+ return 'primary'
125
+ }
126
+ if (item.status === 2) {
127
+ return 'success'
128
+ }
129
+ if (item.status === 3) {
130
+ return 'danger'
131
+ }
132
+ if (item.status === 4) {
133
+ return 'info'
134
+ }
135
+ if (item.status === 5) {
136
+ return 'warning'
137
+ }
138
+ return ''
139
+ }
140
+
141
+ /** 查看表单 */
142
+ const fApi = ref<ApiAttrs>() // form-create 的 API 操作类
143
+ const taskForm = ref({
144
+ rule: [],
145
+ option: {},
146
+ value: {}
147
+ }) // 流程任务的表单详情
148
+ const taskFormVisible = ref(false)
149
+
150
+
151
+ /** 刷新数据 */
152
+ const emit = defineEmits(['refresh']) // 定义 success 事件,用于操作成功后的回调
153
+ const refresh = () => {
154
+ emit('refresh')
155
+ }
156
+ </script>
157
+
158
+
159
+
160
+ <style scoped lang="scss">
161
+ .avatar-wrap {
162
+ width: 40px;
163
+ height: 40px;
164
+ }
165
+ .flow-start {
166
+ width: 70%;
167
+ margin: 10px auto;
168
+ padding: 10px;
169
+ padding-top: 0;
170
+ background: rgba(245, 247, 253, 1);
171
+
172
+ p {
173
+ margin: 0px;
174
+ padding-top: 10px;
175
+ font-size: 14px;
176
+ }
177
+ }
178
+ :deep(.el-timeline-item__dot) {
179
+ left: -15px;
180
+ top: -15px;
181
+ }
182
+ .scroll-area {
183
+ flex: 1;
184
+ min-height: 0;
185
+ overflow-y: auto;
186
+ }
187
+ </style>
@@ -1,41 +1,75 @@
1
1
  <template>
2
- <el-button @click="open">aaaa</el-button>
2
+ <el-button @click="open">测试按钮</el-button>
3
+ <!-- 审批记录列表 -->
4
+ <ProcessInstanceTaskList
5
+ :process-instance="processInstance"
6
+ :tasks="tasks"
7
+ @refresh="getTaskList"
8
+ />
3
9
  </template>
4
10
 
5
11
  <script setup lang="ts">
6
12
  import { ElMessage } from 'element-plus'
7
13
  import {ref, watch} from "vue";
8
14
  import {createProcessInstanceApi} from "@/api/processInstance";
15
+ import {createTaskApi} from "@/api/task";
16
+
17
+ import ProcessInstanceTaskList from './CmcFlowList.vue'
18
+
19
+
20
+ const message = useMessage() // 消息弹窗
9
21
 
10
22
  const props = defineProps<{
11
23
  processInstanceId: string
12
24
  request: any
13
25
  }>()
14
26
 
27
+
28
+ const processInstanceLoading = ref(false)
29
+ const processInstance = ref<any>({})
30
+ const todoTask = ref<any>({})
31
+ const applicationPrefix = ref('')
32
+ const tasks = ref<any[]>([])
33
+
15
34
  const id = ref<string>('')
16
35
  const processInstanceApi = createProcessInstanceApi(props.request)
17
- console.log('props.request', props.request)
18
- console.log('processInstanceApi', processInstanceApi)
36
+ const taskApi = createTaskApi(props.request)
19
37
 
20
38
 
21
39
  const open = () => {
22
40
  ElMessage.success('aaa!')
23
- console.log(props.request)
24
- props.request.get({
25
- url: `/system/bpm/process-instance/get-approval-detail`,
26
- params: {
27
- processInstanceId: id.value
28
- }
29
- })
30
41
  }
31
42
 
32
43
  const init = (processInstanceId: string) => {
33
44
  id.value = processInstanceId
34
- processInstanceApi.getApprovalDetail(processInstanceId)
35
- .then((res: any) => {
36
- console.log(res)
37
- })
45
+ getApprovalDetail()
46
+ getTaskList()
47
+ }
48
+
49
+ // 获取审批详情数据
50
+ const getApprovalDetail = async () => {
51
+ try {
52
+ processInstanceLoading.value = true
53
+ const data = await processInstanceApi.getApprovalDetail(id.value)
54
+ if (!data) {
55
+ message.error('查询不到审批详情信息!')
56
+ return
57
+ }
58
+ if (!data.processDefinition || !data.processInstance) {
59
+ message.error('查询不到流程信息!')
60
+ return
61
+ }
62
+ processInstance.value = data?.processInstance
63
+ applicationPrefix.value = data?.processInstance?.formVariables?.applicationPrefix
64
+ todoTask.value = data?.todoTask
65
+ } finally {
66
+ processInstanceLoading.value = false
67
+ }
68
+ }
38
69
 
70
+ // 获取任务列表
71
+ const getTaskList = async () => {
72
+ tasks.value = await taskApi.getTaskListByProcessInstanceId(id.value)
39
73
  }
40
74
 
41
75
  watch(
@@ -0,0 +1,12 @@
1
+ export const createTaskApi = (request: any) => ({
2
+ getTaskListByProcessInstanceId: async (processInstanceId: string) => {
3
+ return await request.get({
4
+ url: `/system/bpm/task/list-by-process-instance-id`,
5
+ params: {
6
+ processInstanceId
7
+ }
8
+ })
9
+ }
10
+ })
11
+
12
+