schemas.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { FormSchema } from '/@/components/Form';
  2. // import { uploadApi } from '/@/api/sys/upload';
  3. import { Tinymce } from '/@/components/Tinymce/index';
  4. import { h } from 'vue';
  5. import { uploadApi } from '/@/api/advertisement/list';
  6. import { BrandListApi } from '/@/api/order/list';
  7. export const padsSchemas: FormSchema[] = [
  8. {
  9. field: 'image',
  10. component: 'Upload',
  11. label: '封面',
  12. rules: [{ required: true, message: '请选择上传文件' }],
  13. itemProps: {
  14. validateTrigger: 'blur',
  15. },
  16. componentProps: {
  17. api: uploadApi,
  18. maxNumber: 1,
  19. accept: ['jpg', 'jpeg', 'gif', 'png'],
  20. afterFetch: function (data) {
  21. console.log('data', data);
  22. Reflect.set(data, 'url', data.message);
  23. return data;
  24. },
  25. },
  26. required: true,
  27. },
  28. {
  29. field: 'title',
  30. component: 'Input',
  31. label: '标题',
  32. componentProps: {
  33. placeholder: '标题',
  34. },
  35. required: true,
  36. },
  37. {
  38. field: 'connectId',
  39. label: '直播间名称',
  40. component: 'ApiSelect',
  41. required: true,
  42. itemProps: {
  43. validateTrigger: 'blur',
  44. },
  45. componentProps: {
  46. api: BrandListApi,
  47. // resultField: 'list',
  48. // numberToString: true,
  49. labelField: 'name',
  50. valueField: 'id',
  51. immediate: true,
  52. params: {
  53. page: 1,
  54. limit: 1000,
  55. },
  56. },
  57. },
  58. {
  59. field: 'orderNum',
  60. component: 'Input',
  61. label: '排序',
  62. defaultValue: 0,
  63. componentProps: {
  64. placeholder: '推荐排序',
  65. type: 'number',
  66. min: 0,
  67. },
  68. required: true,
  69. },
  70. // {
  71. // field: 'connectId',
  72. // component: 'Input',
  73. // label: '链接ID',
  74. // componentProps: {
  75. // placeholder: '链接',
  76. // },
  77. // // required: true,
  78. // },
  79. ];
  80. export const schemas: FormSchema[] = [
  81. {
  82. field: 'title',
  83. component: 'Input',
  84. label: '正文标题',
  85. componentProps: {
  86. placeholder: '轮播图正文标题',
  87. },
  88. required: true,
  89. },
  90. {
  91. field: 'orderNum',
  92. component: 'Input',
  93. label: '轮播排序',
  94. defaultValue: 0,
  95. componentProps: {
  96. placeholder: '轮播排序',
  97. type: 'number',
  98. min: 0,
  99. },
  100. required: true,
  101. },
  102. {
  103. field: 'url',
  104. component: 'Input',
  105. label: '链接',
  106. componentProps: {
  107. placeholder: '链接',
  108. },
  109. // required: true,
  110. },
  111. {
  112. field: 'image',
  113. component: 'Upload',
  114. label: '封面图',
  115. rules: [{ required: true, message: '请选择上传文件' }],
  116. itemProps: {
  117. validateTrigger: 'blur',
  118. },
  119. componentProps: {
  120. api: uploadApi,
  121. maxNumber: 1,
  122. afterFetch(data) {
  123. // console.log('afterFetch1', data);
  124. // const covertData = [data.message];
  125. Reflect.set(data, 'url', data.message);
  126. // console.log('afterFetch2', data);
  127. return data;
  128. },
  129. },
  130. required: true,
  131. },
  132. {
  133. field: 'content',
  134. component: 'Input',
  135. label: '正文内容',
  136. defaultValue: '',
  137. rules: [{ required: true }],
  138. render: ({ model, field }) => {
  139. return h(Tinymce, {
  140. value: model[field],
  141. onChange: (value: string) => {
  142. model[field] = value;
  143. },
  144. });
  145. },
  146. },
  147. ];