data.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import { Time } from '/@/components/Time';
  2. import { FormProps, BasicColumn } from '/@/components/Table';
  3. import { h, ref, computed } from 'vue';
  4. import { FormSchema } from '/@/components/Form/index';
  5. import { useI18n } from '/@/hooks/web/useI18n';
  6. const { t } = useI18n();
  7. import { dincrementList } from '/@/api/equity';
  8. import type { Dayjs } from 'dayjs';
  9. const selectPriceDate = ref('');
  10. import dayjs from 'dayjs';
  11. import { useLocaleStore } from '/@/store/modules/locale';
  12. const localeStore = useLocaleStore();
  13. const isEn = computed(() => localeStore.getLocale === 'en');
  14. export const columns: BasicColumn[] = [
  15. {
  16. title: t('routes.equity.timeList'),
  17. dataIndex: 'createTime',
  18. width: 150,
  19. customRender: ({ record }) => {
  20. return (
  21. record.createTime &&
  22. h(Time, {
  23. value: record.createTime,
  24. mode: 'datetime',
  25. })
  26. );
  27. },
  28. },
  29. {
  30. title: t('routes.equity.Type'),
  31. dataIndex: 'type',
  32. width: 120,
  33. customRender: ({ record }) => {
  34. return t(`routes.finance.equityType.${record.type}`) || '-';
  35. },
  36. },
  37. {
  38. title: t('routes.equity.nickName'),
  39. dataIndex: 'nickName',
  40. width: 100,
  41. },
  42. {
  43. title: t('routes.equity.userName1'),
  44. dataIndex: 'userName',
  45. width: 180,
  46. },
  47. {
  48. title: t('routes.equity.email'),
  49. dataIndex: 'email',
  50. // slots: { customRender: 'orderType' },
  51. width: 150,
  52. },
  53. {
  54. title: t('routes.equity.userCount'),
  55. dataIndex: 'count',
  56. // slots: { customRender: 'orderStatus' },
  57. width: 120,
  58. },
  59. {
  60. title: t('routes.finance.totalTime'),
  61. dataIndex: 'totalTime',
  62. // slots: { customRender: 'orderStatus' },
  63. width: 120,
  64. customRender: ({ record }) => {
  65. return record.type == 2?'-':record.totalTime;
  66. },
  67. },
  68. {
  69. title: t('routes.equity.giveType'),
  70. dataIndex: 'giveType',
  71. // slots: { customRender: 'orderStatus' },
  72. width: 180,
  73. customRender: ({ record }) => {
  74. return t(`routes.finance.giveType.${record.giveType}`) || '-';
  75. },
  76. },
  77. ];
  78. export const searchForm: Partial<FormProps> = {
  79. labelWidth: isEn.value ? 120 : 100,
  80. schemas: [
  81. {
  82. field: 'type',
  83. label: t('routes.equity.Type'),
  84. component: 'ApiSelect',
  85. componentProps: {
  86. maxLength: 50,
  87. api: async function () {
  88. const list = await dincrementList();
  89. let optionList = [];
  90. list.map((ele) => {
  91. optionList.push({
  92. name: t(`routes.finance.equityType.${ele.validTimeType}`),
  93. value: ele.validTimeType,
  94. key: ele.validTimeType,
  95. });
  96. });
  97. optionList.push({
  98. name: t('routes.finance.equityType.2'),
  99. value: 2,
  100. key: '2',
  101. });
  102. console.log('ele.id', optionList);
  103. return optionList;
  104. },
  105. numberToString: true,
  106. labelField: 'name',
  107. valueField: 'value',
  108. immediate: true,
  109. },
  110. colProps: {
  111. xl: 5,
  112. xxl: 5,
  113. },
  114. },
  115. {
  116. field: 'giveType',
  117. label: t('routes.equity.giveType'),
  118. component: 'Select',
  119. componentProps: {
  120. options: [
  121. {
  122. label: t('routes.finance.giveType.0'),
  123. value: 0,
  124. key: '0',
  125. },
  126. {
  127. label: t('routes.finance.giveType.1'),
  128. value: 1,
  129. key: '1',
  130. },
  131. {
  132. label: t('routes.finance.giveType.2'),
  133. value: 2,
  134. key: '2',
  135. },
  136. {
  137. label: t('routes.finance.giveType.3'),
  138. value: 3,
  139. key: '3',
  140. },
  141. ],
  142. },
  143. colProps: {
  144. xl: 5,
  145. xxl: 5,
  146. },
  147. },
  148. {
  149. field: 'timeList',
  150. label: t('routes.equity.timeList'),
  151. component: 'RangePicker',
  152. componentProps: {
  153. maxLength: 100,
  154. valueFormat: 'YYYY-MM-DD',
  155. format: 'YYYY-MM-DD',
  156. onCalendarChange: (date) => {
  157. console.log('current', date);
  158. selectPriceDate.value = date[0];
  159. },
  160. onOpenChange: (status) => {
  161. if (!status) {
  162. selectPriceDate.value = '';
  163. }
  164. },
  165. disabledDate: (current) => {
  166. if (selectPriceDate.value) {
  167. return (
  168. current > dayjs(selectPriceDate.value).add(3, 'year') ||
  169. current < dayjs(selectPriceDate.value).subtract(3, 'year')
  170. );
  171. } else {
  172. return false;
  173. }
  174. },
  175. },
  176. colProps: {
  177. xl: 7,
  178. xxl: 7,
  179. },
  180. },
  181. ],
  182. };
  183. export const InvoiceSchemas: FormSchema[] = [
  184. {
  185. field: 'type',
  186. component: 'Input',
  187. label: t('routes.product.types'),
  188. slot: 'text',
  189. colProps: {
  190. span: 24,
  191. },
  192. },
  193. {
  194. field: 'version',
  195. component: 'Input',
  196. label: t('routes.product.version'),
  197. required: true,
  198. colProps: {
  199. span: 24,
  200. },
  201. rules: [
  202. {
  203. required: true,
  204. // @ts-ignore
  205. validator: async (rule, value) => {
  206. if (!value) {
  207. return Promise.reject(t('common.inputText') + t('routes.product.version'));
  208. }
  209. if (/.*[\u4e00-\u9fa5]+.*$/.test(value)) {
  210. /* eslint-disable-next-line */
  211. return Promise.reject(t('routes.equity.zhTips'));
  212. }
  213. return Promise.resolve();
  214. },
  215. trigger: 'change',
  216. },
  217. ],
  218. componentProps: {
  219. maxLength: 15,
  220. onChange: (data) => {
  221. console.log('data', data);
  222. },
  223. },
  224. },
  225. {
  226. field: 'description',
  227. component: 'InputTextArea',
  228. required: true,
  229. label: t('routes.product.description'),
  230. componentProps: {
  231. rows: 4,
  232. },
  233. colProps: {
  234. span: 24,
  235. },
  236. },
  237. ];