diff --git a/src/utils/dateUtil.ts b/src/utils/dateUtil.ts index 6b1e8366..98feef10 100644 --- a/src/utils/dateUtil.ts +++ b/src/utils/dateUtil.ts @@ -64,4 +64,31 @@ export function convertDate(date) { return date } +/** + * 将毫秒,转换成时间字符串。例如说,xx 分钟 + * + * @param ms 毫秒 + * @returns {string} 字符串 + */ +export function getDate(ms) { + const day = Math.floor(ms / (24 * 60 * 60 * 1000)) + const hour = Math.floor(ms / (60 * 60 * 1000) - day * 24) + const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60) + const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60) + if (day > 0) { + return day + '天' + hour + '小时' + minute + '分钟' + } + if (hour > 0) { + return hour + '小时' + minute + '分钟' + } + if (minute > 0) { + return minute + '分钟' + } + if (second > 0) { + return second + '秒' + } else { + return 0 + '秒' + } +} + export const dateUtil = dayjs diff --git a/src/views/bpm/task/done.data.ts b/src/views/bpm/task/done.data.ts new file mode 100644 index 00000000..cebb94ae --- /dev/null +++ b/src/views/bpm/task/done.data.ts @@ -0,0 +1,78 @@ +import { BasicColumn, FormSchema, useRender } from '@/components/Table' +import { getDate } from '@/utils/dateUtil' +import { DICT_TYPE } from '@/utils/dict' + +export const columns: BasicColumn[] = [ + { + title: '任务编号', + dataIndex: 'id', + width: 100 + }, + { + title: '任务名称', + dataIndex: 'name', + width: 180 + }, + { + title: '所属流程', + dataIndex: 'processInstance.name', + width: 180 + }, + { + title: '流程发起人', + dataIndex: 'processInstance.startUserNickname', + width: 180 + }, + { + title: '结果', + dataIndex: 'result', + width: 180, + customRender: ({ text }) => { + return useRender.renderDict(text, DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT) + } + }, + { + title: '审批意见', + dataIndex: 'reason', + width: 180 + }, + { + title: '创建时间', + dataIndex: 'createTime', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + } + }, + { + title: '审批时间', + dataIndex: 'endTime', + width: 180, + customRender: ({ text }) => { + return useRender.renderDate(text) + } + }, + { + title: '耗时', + dataIndex: 'durationInMillis', + width: 180, + customRender: ({ text }) => { + return getDate(text) + } + } +] + +export const searchFormSchema: FormSchema[] = [ + { + label: '流程名', + field: 'name', + component: 'Input', + colProps: { span: 8 } + }, + { + label: '创建时间', + field: 'createTime', + component: 'RangePicker', + colProps: { span: 8 } + } +] diff --git a/src/views/bpm/task/done.vue b/src/views/bpm/task/done.vue index 3b64cfc4..ec3c25fe 100644 --- a/src/views/bpm/task/done.vue +++ b/src/views/bpm/task/done.vue @@ -1,3 +1,28 @@ +