data.tsx 5.5 KB

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