overviewColumns.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { h } from 'vue';
  2. import type { BasicColumn } from '@/components/Table';
  3. import { ElSwitch } from 'element-plus';
  4. import { pushChannelName, recipientTypeName, statusName } from './constant'
  5. import { statisticTypeName } from '@/views/message/constant'
  6. import { storeToRefs } from 'pinia';
  7. import useFormList from './store/useFormList';
  8. const formStore = useFormList();
  9. const { type } = storeToRefs(formStore);
  10. const { getForm } = formStore;
  11. import { updateStatus, updateStatusParams } from './api/index'
  12. export const reportDataCol: BasicColumn[] = [
  13. {
  14. label: '报表周期',
  15. prop: 'statisticType',
  16. render(record) {
  17. const typeName = statisticTypeName.find(item => item.value === record.row.statisticType);
  18. return h(
  19. 'span',
  20. {},
  21. typeName ? typeName.label : ''
  22. )
  23. }
  24. },
  25. {
  26. label: '推送渠道',
  27. prop: 'pushChannel',
  28. render(record) {
  29. const labels = record.row.pushChannel
  30. .map(channel => {
  31. const typeName = pushChannelName.find(item => item.value === channel);
  32. return typeName ? typeName.label : '';
  33. })
  34. .filter(label => label !== '')
  35. .join(', ');
  36. return h('span', {}, labels);
  37. }
  38. },
  39. {
  40. label: '推送对象',
  41. prop: 'recipientType',
  42. render(record) {
  43. const length = record.row.recipientType.length;
  44. if (length > 1) {
  45. return h('span', {}, '多类对象');
  46. }
  47. const label = recipientTypeName.find(item => item.value === record.row.recipientType[0])
  48. return h('span', {}, label ? label.label : '');
  49. }
  50. },
  51. {
  52. label: '是否启用',
  53. prop: 'status',
  54. render(record) {
  55. return h(
  56. ElSwitch,
  57. {
  58. modelValue: record.row.status,
  59. onChange: () => {
  60. const params: updateStatusParams = {
  61. type: type.value,
  62. statisticType: record.row.statisticType,
  63. status: record.row.status === 1 ? 0 : 1
  64. }
  65. updateStatus(params).then(() => {
  66. getForm(type.value);
  67. });
  68. },
  69. activeValue: 0,
  70. inactiveValue: 1,
  71. },
  72. {},
  73. );
  74. },
  75. },
  76. {
  77. label: '操作时间',
  78. prop: 'updatedAt',
  79. }
  80. ];
  81. export const logColumns: BasicColumn[] = [
  82. {
  83. label: '序号',
  84. type: 'index',
  85. minWidth: 56,
  86. },
  87. {
  88. label: '推送时间',
  89. prop: 'createdAt',
  90. },
  91. {
  92. label: '推送状态',
  93. prop: 'status',
  94. render(record) {
  95. const name = statusName.find(item => item.value === record.row.status);
  96. const style = record.row.status === 1 ? { color: '#FAAD14' } : {};
  97. return h(
  98. 'span',
  99. { style },
  100. name ? name.label : ''
  101. )
  102. }
  103. },
  104. ];