Process-record.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div class="tels-restApply-precess-record">
  3. <el-dialog :title="`审核记录 (${state.title})`" v-model="state.isShowDialog" width="80%" draggable>
  4. <div v-loading="state.loading">
  5. <process-time-line :data="state.traces" defaultExpandAll />
  6. </div>
  7. <template #footer>
  8. <span class="dialog-footer">
  9. <el-button @click="state.isShowDialog = false" class="default-button">关 闭</el-button>
  10. </span>
  11. </template>
  12. </el-dialog>
  13. </div>
  14. </template>
  15. <script setup lang="ts" name="restApplyProcessRecord">
  16. import { reactive, defineAsyncComponent } from 'vue';
  17. import { workflowTraces } from '/@/api/system/workflow';
  18. // 引入组件
  19. const ProcessTimeLine = defineAsyncComponent(() => import('/src/components/ProcessTimeLine/index.vue'));
  20. // 定义变量内容
  21. const state = reactive<any>({
  22. isShowDialog: false,
  23. traces: [],
  24. loading: false,
  25. title: '',
  26. });
  27. // 打开弹窗
  28. const openDialog = async (row: any) => {
  29. try {
  30. state.loading = true;
  31. // 查询审核记录
  32. const res = await workflowTraces(row.workflowId);
  33. state.traces = res.result?.traces ?? [];
  34. state.traces = formatTraces(state.traces);
  35. state.title = row.title ?? '';
  36. state.isShowDialog = true;
  37. state.loading = false;
  38. } catch (error) {
  39. state.loading = false;
  40. }
  41. };
  42. const formatTraces = (val: any) => {
  43. if (!val || !val.length) return [];
  44. val.forEach((item: any) => {
  45. switch (item.expiredStatus) {
  46. case 0:
  47. item.type = 'success';
  48. break;
  49. case 1:
  50. item.type = 'primary';
  51. break;
  52. case 2:
  53. item.type = 'danger';
  54. break;
  55. default:
  56. break;
  57. }
  58. if (item.traces?.length) {
  59. formatTraces(item.traces);
  60. }
  61. });
  62. return val;
  63. };
  64. // 关闭弹窗
  65. const closeDialog = () => {
  66. state.isShowDialog = false;
  67. };
  68. // 暴露变量
  69. defineExpose({
  70. openDialog,
  71. closeDialog,
  72. });
  73. </script>