data.ts 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. import { FormProps, BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Form/index';
  3. import { adapt } from '/@/utils/adapt';
  4. import moment from 'moment';
  5. import { Tinymce } from '/@/components/Tinymce/index';
  6. import { h } from 'vue';
  7. import UploadFile from '/@/views/general/config/customComponents/UploadFile.vue';
  8. import CustomInput from './customCom/CustomInput.vue';
  9. const adaptWidth = adapt();
  10. export const columns: BasicColumn[] = [
  11. {
  12. title: 'ID',
  13. dataIndex: 'id',
  14. editComponentProps: {
  15. prefix: '$',
  16. },
  17. width: 100,
  18. sorter: true,
  19. },
  20. {
  21. title: '活动名称',
  22. dataIndex: 'name',
  23. width: 130,
  24. sorter: true,
  25. },
  26. {
  27. title: '开始日期',
  28. dataIndex: 'starttime',
  29. width: 200,
  30. customRender({ record }) {
  31. return moment(record.starttime * 1000).format('YYYY-MM-DD HH:mm:ss');
  32. },
  33. sorter: true,
  34. },
  35. {
  36. title: '地点',
  37. dataIndex: 'place',
  38. width: 130,
  39. sorter: true,
  40. },
  41. {
  42. title: '计划人数',
  43. dataIndex: 'plan',
  44. width: 130,
  45. sorter: true,
  46. },
  47. {
  48. title: '报名人数',
  49. dataIndex: 'apply',
  50. width: 130,
  51. sorter: true,
  52. },
  53. {
  54. title: '参加人数',
  55. dataIndex: 'actual',
  56. width: 130,
  57. sorter: true,
  58. },
  59. {
  60. title: '活动状态',
  61. dataIndex: 'status',
  62. width: 130,
  63. customRender({ record }) {
  64. const options = ['筹备', '完成', '取消'];
  65. return options[record.status];
  66. },
  67. sorter: true,
  68. },
  69. {
  70. title: '操作员',
  71. dataIndex: 'manager',
  72. width: 130,
  73. sorter: true,
  74. },
  75. {
  76. title: '备注',
  77. dataIndex: 'remark',
  78. width: 160,
  79. sorter: true,
  80. },
  81. {
  82. title: '创建日期',
  83. dataIndex: 'createtime',
  84. width: 200,
  85. customRender: ({ record }) => {
  86. const createtime = record.createtime * 1000;
  87. return moment(createtime).format('YYYY-MM-DD HH:mm:ss');
  88. },
  89. sorter: true,
  90. },
  91. ];
  92. export function getFormConfig(): Partial<FormProps> {
  93. return {
  94. labelWidth: 100,
  95. schemas: [
  96. {
  97. field: `id`,
  98. label: `ID`,
  99. component: 'Input',
  100. componentProps: {
  101. placeholder: 'ID',
  102. },
  103. colProps: {
  104. xl: 12,
  105. xxl: 8,
  106. },
  107. },
  108. {
  109. field: `name`,
  110. label: `活动名称`,
  111. component: 'Input',
  112. componentProps: {
  113. placeholder: '活动名称',
  114. },
  115. colProps: {
  116. xl: 12,
  117. xxl: 8,
  118. },
  119. },
  120. {
  121. field: `starttime`,
  122. label: `开始日期`,
  123. component: 'DatePicker',
  124. componentProps: {
  125. placeholder: '开始日期',
  126. },
  127. colProps: {
  128. xl: 12,
  129. xxl: 8,
  130. },
  131. },
  132. {
  133. field: `place`,
  134. label: `地点`,
  135. component: 'Input',
  136. componentProps: {
  137. placeholder: '地点',
  138. },
  139. colProps: {
  140. xl: 12,
  141. xxl: 8,
  142. },
  143. },
  144. {
  145. field: `plan`,
  146. label: `计划人数`,
  147. component: 'Input',
  148. componentProps: {
  149. placeholder: '计划人数',
  150. },
  151. colProps: {
  152. xl: 12,
  153. xxl: 8,
  154. },
  155. },
  156. {
  157. field: `apply`,
  158. label: `报名人数`,
  159. component: 'Input',
  160. componentProps: {
  161. placeholder: '报名人数',
  162. },
  163. colProps: {
  164. xl: 12,
  165. xxl: 8,
  166. },
  167. },
  168. {
  169. field: `actual`,
  170. label: `参加人数`,
  171. component: 'Input',
  172. componentProps: {
  173. placeholder: '参加人数',
  174. },
  175. colProps: {
  176. xl: 12,
  177. xxl: 8,
  178. },
  179. },
  180. {
  181. field: `status`,
  182. label: `活动状态`,
  183. component: 'Select',
  184. componentProps: {
  185. options: [
  186. {
  187. label: '筹备',
  188. value: 0,
  189. },
  190. {
  191. label: '完成',
  192. value: 1,
  193. },
  194. {
  195. label: '取消',
  196. value: 2,
  197. },
  198. ],
  199. },
  200. colProps: {
  201. xl: 12,
  202. xxl: 8,
  203. },
  204. },
  205. {
  206. field: `manager`,
  207. label: `操作员`,
  208. component: 'Input',
  209. componentProps: {
  210. placeholder: '操作员',
  211. },
  212. colProps: {
  213. xl: 12,
  214. xxl: 8,
  215. },
  216. },
  217. {
  218. field: `remark`,
  219. label: `备注`,
  220. component: 'Input',
  221. componentProps: {
  222. placeholder: '备注',
  223. },
  224. colProps: {
  225. xl: 12,
  226. xxl: 8,
  227. },
  228. },
  229. {
  230. field: `createtime`,
  231. label: `创建日期`,
  232. component: 'DatePicker',
  233. componentProps: {
  234. placeholder: '创建日期',
  235. },
  236. colProps: {
  237. xl: 12,
  238. xxl: 8,
  239. },
  240. },
  241. ],
  242. };
  243. }
  244. // =================popup================================
  245. export const schemas: FormSchema[] = [
  246. {
  247. field: 'name',
  248. component: 'Input',
  249. label: '活动名称',
  250. labelWidth: adaptWidth.labelWidth,
  251. colProps: {
  252. span: adaptWidth.elContainer,
  253. },
  254. componentProps: {
  255. placeholder: '活动名称',
  256. },
  257. required: true,
  258. },
  259. {
  260. field: 'starttime',
  261. component: 'DatePicker',
  262. label: '开始时间',
  263. labelWidth: adaptWidth.labelWidth,
  264. colProps: {
  265. span: adaptWidth.elContainer,
  266. },
  267. componentProps: {
  268. placeholder: '开始时间',
  269. showTime: true,
  270. },
  271. required: true,
  272. },
  273. {
  274. field: 'endtime',
  275. component: 'DatePicker',
  276. label: '结束时间',
  277. labelWidth: adaptWidth.labelWidth,
  278. colProps: {
  279. span: adaptWidth.elContainer,
  280. },
  281. componentProps: {
  282. placeholder: '结束时间',
  283. showTime: true,
  284. },
  285. required: true,
  286. },
  287. {
  288. field: 'place',
  289. component: 'Input',
  290. label: '地点',
  291. labelWidth: adaptWidth.labelWidth,
  292. colProps: {
  293. span: adaptWidth.elContainer,
  294. },
  295. componentProps: {
  296. placeholder: '地点',
  297. },
  298. required: true,
  299. },
  300. {
  301. field: 'plan',
  302. component: 'Input',
  303. label: '计划参加人员',
  304. labelWidth: adaptWidth.labelWidth,
  305. colProps: {
  306. span: adaptWidth.elContainer,
  307. },
  308. render: ({ model, field }) => {
  309. return h(CustomInput, {
  310. value: model.plan,
  311. placeholder: '计划参加人员',
  312. onChange(value) {
  313. model[field] = value;
  314. },
  315. });
  316. },
  317. },
  318. {
  319. field: 'apply',
  320. component: 'Input',
  321. label: '报名参加人员',
  322. labelWidth: adaptWidth.labelWidth,
  323. colProps: {
  324. span: adaptWidth.elContainer,
  325. },
  326. render: ({ model, field }) => {
  327. return h(CustomInput, {
  328. value: model.apply,
  329. placeholder: '报名参加人员',
  330. onChange(value) {
  331. model[field] = value;
  332. },
  333. });
  334. },
  335. },
  336. {
  337. field: 'actual',
  338. component: 'Input',
  339. label: '实际参加人员',
  340. labelWidth: adaptWidth.labelWidth,
  341. colProps: {
  342. span: adaptWidth.elContainer,
  343. },
  344. render: ({ model, field }) => {
  345. return h(CustomInput, {
  346. value: model.actual,
  347. placeholder: '实际参加人员',
  348. onChange(value) {
  349. model[field] = value;
  350. },
  351. });
  352. },
  353. },
  354. {
  355. field: 'content',
  356. component: 'InputTextArea',
  357. label: '活动内容',
  358. labelWidth: adaptWidth.labelWidth,
  359. colProps: {
  360. span: adaptWidth.elContainer,
  361. },
  362. render: ({ model, field }) => {
  363. return h(Tinymce, {
  364. value: model[field],
  365. onChange: (value: string) => {
  366. model[field] = value;
  367. },
  368. });
  369. },
  370. },
  371. {
  372. field: 'hire',
  373. component: 'InputTextArea',
  374. label: '集体租赁',
  375. labelWidth: adaptWidth.labelWidth,
  376. colProps: {
  377. span: adaptWidth.elContainer,
  378. },
  379. componentProps: {
  380. placeholder: '集体租赁',
  381. },
  382. required: true,
  383. },
  384. {
  385. field: 'car',
  386. component: 'CarArrayCom',
  387. label: '车辆登记',
  388. labelWidth: adaptWidth.labelWidth,
  389. colProps: {
  390. span: adaptWidth.elContainer,
  391. },
  392. defaultValue: [],
  393. componentProps: ({ formModel }) => {
  394. return {
  395. placeholder: '车辆登记',
  396. value: formModel.car,
  397. onChange: () => {},
  398. };
  399. },
  400. },
  401. {
  402. field: 'status',
  403. component: 'Select',
  404. label: '活动状态',
  405. labelWidth: adaptWidth.labelWidth,
  406. colProps: {
  407. span: adaptWidth.elContainer,
  408. },
  409. componentProps: {
  410. placeholder: '活动状态',
  411. options: [
  412. {
  413. label: '筹备',
  414. value: 0,
  415. },
  416. {
  417. label: '完成',
  418. value: 1,
  419. },
  420. {
  421. label: '取消',
  422. value: 2,
  423. },
  424. ],
  425. },
  426. required: true,
  427. },
  428. {
  429. field: 'attachment',
  430. component: 'Select',
  431. label: '附件',
  432. labelWidth: adaptWidth.labelWidth,
  433. colProps: {
  434. span: adaptWidth.elContainer,
  435. },
  436. render: ({ model, field }) => {
  437. return h(UploadFile, {
  438. value: model.attachment,
  439. type: 'files',
  440. style: { width: '100%' },
  441. onChange(value) {
  442. model[field] = value;
  443. },
  444. });
  445. },
  446. },
  447. {
  448. field: 'remark',
  449. component: 'Input',
  450. label: '备注',
  451. labelWidth: adaptWidth.labelWidth,
  452. colProps: {
  453. span: adaptWidth.elContainer,
  454. },
  455. componentProps: {
  456. placeholder: '备注',
  457. },
  458. },
  459. ];