columnConfig.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * 列配置 Mock Handlers
  3. * 用于模拟表格列配置 API 响应
  4. */
  5. export const FetchColumnConfig = '@fetchColumnConfig';
  6. export const FetchColumnConfigFail = '@fetchColumnConfigFail';
  7. /**
  8. * Mock 列配置 API 成功响应 - 默认配置
  9. */
  10. export function mockColumnConfigSuccess() {
  11. cy.intercept('GET', '/api/config/table-columns', {
  12. statusCode: 200,
  13. body: {
  14. success: true,
  15. data: [
  16. {
  17. tableName: 'worklist',
  18. columns: [
  19. { key: 'PatientID', visible: true, order: 1, width: 120 },
  20. { key: 'PatientName', visible: true, order: 2, width: 150 },
  21. { key: 'StudyID', visible: true, order: 3, width: 120 },
  22. { key: 'AccessionNumber', visible: true, order: 4, width: 150 },
  23. { key: 'StudyStatus', visible: true, order: 5, width: 100 },
  24. { key: 'Modality', visible: true, order: 6, width: 100 },
  25. { key: 'StudyStartDatetime', visible: true, order: 7, width: 180 },
  26. { key: 'PatientAge', visible: true, order: 8, width: 80 },
  27. { key: 'PatientSex', visible: true, order: 9, width: 80 },
  28. // 其他列默认隐藏
  29. { key: 'StudyInstanceUID', visible: false, order: 100 },
  30. { key: 'SpecificCharacterSet', visible: false, order: 101 },
  31. ],
  32. version: '1.0.0',
  33. updatedAt: '2025-10-07T10:00:00Z',
  34. },
  35. {
  36. tableName: 'history',
  37. columns: [
  38. { key: 'StudyID', visible: true, order: 1, width: 120 },
  39. { key: 'PatientName', visible: true, order: 2, width: 150 },
  40. { key: 'IsExported', visible: true, order: 3, width: 100 },
  41. { key: 'StudyDescription', visible: true, order: 4, width: 200 },
  42. { key: 'StudyStartDatetime', visible: true, order: 5, width: 180 },
  43. ],
  44. version: '1.0.0',
  45. updatedAt: '2025-10-07T10:00:00Z',
  46. },
  47. ],
  48. },
  49. }).as(FetchColumnConfig);
  50. }
  51. /**
  52. * Mock 列配置 API 失败响应
  53. */
  54. export function mockColumnConfigFail() {
  55. cy.intercept('GET', '/api/config/table-columns', {
  56. statusCode: 500,
  57. body: {
  58. success: false,
  59. message: 'Internal Server Error',
  60. },
  61. }).as(FetchColumnConfigFail);
  62. }
  63. /**
  64. * Mock 列配置 API - 自定义列顺序
  65. */
  66. export function mockColumnConfigCustomOrder() {
  67. cy.intercept('GET', '/api/config/table-columns', {
  68. statusCode: 200,
  69. body: {
  70. success: true,
  71. data: [
  72. {
  73. tableName: 'worklist',
  74. columns: [
  75. { key: 'StudyStatus', visible: true, order: 1, width: 100 },
  76. { key: 'PatientID', visible: true, order: 2, width: 120 },
  77. { key: 'Modality', visible: true, order: 3, width: 100 },
  78. { key: 'PatientName', visible: true, order: 4, width: 150 },
  79. ],
  80. version: '1.0.0',
  81. },
  82. ],
  83. },
  84. }).as(FetchColumnConfig);
  85. }
  86. /**
  87. * Mock 列配置 API - 最小列配置(仅4列)
  88. */
  89. export function mockColumnConfigMinimal() {
  90. cy.intercept('GET', '/api/config/table-columns', {
  91. statusCode: 200,
  92. body: {
  93. success: true,
  94. data: [
  95. {
  96. tableName: 'worklist',
  97. columns: [
  98. { key: 'PatientID', visible: true, order: 1, width: 120 },
  99. { key: 'PatientName', visible: true, order: 2, width: 150 },
  100. { key: 'Modality', visible: true, order: 3, width: 100 },
  101. { key: 'StudyStatus', visible: true, order: 4, width: 100 },
  102. ],
  103. version: '1.0.0',
  104. },
  105. ],
  106. },
  107. }).as(FetchColumnConfig);
  108. }
  109. /**
  110. * Mock 多表格配置 - 用于测试配置隔离
  111. */
  112. export function mockMultiTableConfig() {
  113. cy.intercept('GET', '/api/config/table-columns', {
  114. statusCode: 200,
  115. body: {
  116. success: true,
  117. data: [
  118. {
  119. tableName: 'worklist',
  120. columns: [
  121. { key: 'PatientID', visible: true, order: 1, width: 120 },
  122. { key: 'PatientName', visible: true, order: 2, width: 150 },
  123. ],
  124. },
  125. {
  126. tableName: 'history',
  127. columns: [
  128. { key: 'StudyID', visible: true, order: 1, width: 120 },
  129. { key: 'IsExported', visible: true, order: 2, width: 100 },
  130. { key: 'StudyDescription', visible: true, order: 3, width: 200 },
  131. ],
  132. },
  133. ],
  134. },
  135. }).as(FetchColumnConfig);
  136. }