config.data.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import { BasicColumn, FormSchema } from '/@/components/Table';
  2. import moment from 'moment';
  3. import { findDictItemByCode } from '/@/api/system/dict';
  4. import { format } from '../util';
  5. import { Tag } from 'ant-design-vue';
  6. import { h } from 'vue';
  7. //格式化资源类型和操作类型
  8. let formatText;
  9. let actionTypeText;
  10. async function formatTextFunc() {
  11. formatText = await findDictItemByCode({ dictCode: 'operate_log' });
  12. actionTypeText = await findDictItemByCode({ dictCode: 'exception_log' });
  13. }
  14. formatTextFunc();
  15. // 表格数据
  16. export const columns: BasicColumn[] = [
  17. {
  18. title: '租户名称',
  19. dataIndex: 'tenantName',
  20. width: 120,
  21. },
  22. {
  23. title: '客户名称',
  24. dataIndex: 'customerName',
  25. width: 120,
  26. },
  27. {
  28. title: '资源类型',
  29. dataIndex: 'entityType',
  30. width: 180,
  31. format: (_, record) => {
  32. const text = formatText.find((f) => {
  33. if (f.itemValue == record.entityType) {
  34. return f.itemText;
  35. }
  36. });
  37. return text?.itemText;
  38. },
  39. },
  40. {
  41. title: '资源名称',
  42. dataIndex: 'entityName',
  43. width: 180,
  44. },
  45. {
  46. title: '操作人员',
  47. dataIndex: 'userName',
  48. width: 180,
  49. },
  50. {
  51. title: '操作类型',
  52. dataIndex: 'actionType',
  53. width: 180,
  54. format: (_, record) => {
  55. const text = actionTypeText.find((f) => {
  56. if (f.itemValue == record.actionType) {
  57. return f.itemText;
  58. }
  59. });
  60. return text?.itemText;
  61. },
  62. },
  63. {
  64. title: '操作状态',
  65. dataIndex: 'actionStatus',
  66. width: 180,
  67. customRender: ({ record }) => {
  68. const status = record.actionStatus;
  69. const enable = status === 'SUCCESS' ? '成功' : '失败';
  70. const color = enable === '成功' ? 'green' : 'red';
  71. const text = enable === '成功' ? '成功' : '失败';
  72. return h(Tag, { color }, () => text);
  73. },
  74. },
  75. {
  76. title: '操作时间',
  77. dataIndex: 'createdTime',
  78. width: 180,
  79. format: (_, record) => {
  80. return format(record.createdTime, 'yyyy-MM-dd HH:mm:ss');
  81. },
  82. },
  83. ];
  84. // 分页查询
  85. export const searchFormSchema: FormSchema[] = [
  86. {
  87. field: 'entityType',
  88. label: '资源类型',
  89. component: 'ApiSelect',
  90. componentProps: {
  91. api: findDictItemByCode,
  92. params: {
  93. dictCode: 'operate_log',
  94. },
  95. labelField: 'itemText',
  96. valueField: 'itemValue',
  97. },
  98. colProps: { span: 6 },
  99. },
  100. {
  101. field: 'actionType',
  102. label: '操作类型',
  103. component: 'ApiSelect',
  104. componentProps: {
  105. api: findDictItemByCode,
  106. params: {
  107. dictCode: 'exception_log',
  108. },
  109. labelField: 'itemText',
  110. valueField: 'itemValue',
  111. },
  112. colProps: { span: 6 },
  113. },
  114. {
  115. field: 'queryTime',
  116. label: '查询时间',
  117. component: 'RangePicker',
  118. componentProps: {
  119. showTime: {
  120. defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  121. },
  122. },
  123. colProps: { span: 6 },
  124. },
  125. ];
  126. // 详情配置
  127. export const formSchema: FormSchema[] = [
  128. {
  129. field: 'createdTime',
  130. label: '操作时间',
  131. component: 'Input',
  132. componentProps: {
  133. disabled: true,
  134. },
  135. },
  136. {
  137. field: 'tenantName',
  138. label: '租户名称',
  139. component: 'Input',
  140. componentProps: {
  141. disabled: true,
  142. },
  143. },
  144. {
  145. field: 'customerName',
  146. label: '客户名称',
  147. component: 'Input',
  148. componentProps: {
  149. disabled: true,
  150. },
  151. },
  152. {
  153. field: 'entityType',
  154. label: '资源类型',
  155. component: 'Input',
  156. componentProps: {
  157. disabled: true,
  158. },
  159. },
  160. {
  161. field: 'entityName',
  162. label: '资源名称',
  163. component: 'Input',
  164. componentProps: {
  165. disabled: true,
  166. },
  167. },
  168. {
  169. field: 'userName',
  170. label: '操作人员',
  171. colProps: { span: 24 },
  172. component: 'Input',
  173. componentProps: {
  174. disabled: true,
  175. },
  176. },
  177. {
  178. field: 'actionType',
  179. label: '操作类型',
  180. component: 'Input',
  181. componentProps: {
  182. disabled: true,
  183. },
  184. },
  185. {
  186. field: 'actionStatus',
  187. label: '操作状态',
  188. component: 'Input',
  189. componentProps: {
  190. disabled: true,
  191. },
  192. },
  193. {
  194. field: 'actionData',
  195. label: '操作数据',
  196. component: 'InputTextArea',
  197. componentProps: {
  198. disabled: true,
  199. autosize: true,
  200. allowClear: false,
  201. },
  202. },
  203. {
  204. field: 'actionFailureDetails',
  205. label: '失败信息',
  206. component: 'InputTextArea',
  207. componentProps: {
  208. disabled: true,
  209. autosize: true,
  210. allowClear: false,
  211. },
  212. },
  213. ];