DefaultForm.vue 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. <script setup lang="ts">
  2. import { Form } from '@/components/Form'
  3. import { reactive, ref, onMounted, computed } from 'vue'
  4. import { useI18n } from '@/hooks/web/useI18n'
  5. import { useIcon } from '@/hooks/web/useIcon'
  6. import { ContentWrap } from '@/components/ContentWrap'
  7. import { useAppStore } from '@/store/modules/app'
  8. import { FormSchema } from '@/types/form'
  9. import { ComponentOptions } from '@/types/components'
  10. const appStore = useAppStore()
  11. const { t } = useI18n()
  12. const isMobile = computed(() => appStore.getMobile)
  13. const restaurants = ref<Recordable[]>([])
  14. const querySearch = (queryString: string, cb: Fn) => {
  15. const results = queryString
  16. ? restaurants.value.filter(createFilter(queryString))
  17. : restaurants.value
  18. // call callback function to return suggestions
  19. cb(results)
  20. }
  21. const createFilter = (queryString: string) => {
  22. return (restaurant: Recordable) => {
  23. return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
  24. }
  25. }
  26. const loadAll = () => {
  27. return [
  28. { value: 'vue', link: 'https://github.com/vuejs/vue' },
  29. { value: 'element', link: 'https://github.com/ElemeFE/element' },
  30. { value: 'cooking', link: 'https://github.com/ElemeFE/cooking' },
  31. { value: 'mint-ui', link: 'https://github.com/ElemeFE/mint-ui' },
  32. { value: 'vuex', link: 'https://github.com/vuejs/vuex' },
  33. { value: 'vue-router', link: 'https://github.com/vuejs/vue-router' },
  34. { value: 'babel', link: 'https://github.com/babel/babel' }
  35. ]
  36. }
  37. const handleSelect = (item: Recordable) => {
  38. console.log(item)
  39. }
  40. onMounted(() => {
  41. restaurants.value = loadAll()
  42. })
  43. const initials = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
  44. const options = ref<ComponentOptions[]>(
  45. Array.from({ length: 1000 }).map((_, idx) => ({
  46. value: `Option ${idx + 1}`,
  47. label: `${initials[idx % 10]}${idx}`
  48. }))
  49. )
  50. const options2 = ref<ComponentOptions[]>(
  51. Array.from({ length: 10 }).map((_, idx) => {
  52. const label = idx + 1
  53. return {
  54. value: `Group ${label}`,
  55. label: `Group ${label}`,
  56. options: Array.from({ length: 10 }).map((_, idx) => ({
  57. value: `Option ${idx + 1 + 10 * label}`,
  58. label: `${initials[idx % 10]}${idx + 1 + 10 * label}`
  59. }))
  60. }
  61. })
  62. )
  63. const options3: ComponentOptions[] = [
  64. {
  65. value: 'guide',
  66. label: 'Guide',
  67. children: [
  68. {
  69. value: 'disciplines',
  70. label: 'Disciplines',
  71. children: [
  72. {
  73. value: 'consistency',
  74. label: 'Consistency'
  75. },
  76. {
  77. value: 'feedback',
  78. label: 'Feedback'
  79. },
  80. {
  81. value: 'efficiency',
  82. label: 'Efficiency'
  83. },
  84. {
  85. value: 'controllability',
  86. label: 'Controllability'
  87. }
  88. ]
  89. },
  90. {
  91. value: 'navigation',
  92. label: 'Navigation',
  93. children: [
  94. {
  95. value: 'side nav',
  96. label: 'Side Navigation'
  97. },
  98. {
  99. value: 'top nav',
  100. label: 'Top Navigation'
  101. }
  102. ]
  103. }
  104. ]
  105. },
  106. {
  107. value: 'component',
  108. label: 'Component',
  109. children: [
  110. {
  111. value: 'basic',
  112. label: 'Basic',
  113. children: [
  114. {
  115. value: 'layout',
  116. label: 'Layout'
  117. },
  118. {
  119. value: 'color',
  120. label: 'Color'
  121. },
  122. {
  123. value: 'typography',
  124. label: 'Typography'
  125. },
  126. {
  127. value: 'icon',
  128. label: 'Icon'
  129. },
  130. {
  131. value: 'button',
  132. label: 'Button'
  133. }
  134. ]
  135. },
  136. {
  137. value: 'form',
  138. label: 'Form',
  139. children: [
  140. {
  141. value: 'radio',
  142. label: 'Radio'
  143. },
  144. {
  145. value: 'checkbox',
  146. label: 'Checkbox'
  147. },
  148. {
  149. value: 'input',
  150. label: 'Input'
  151. },
  152. {
  153. value: 'input-number',
  154. label: 'InputNumber'
  155. },
  156. {
  157. value: 'select',
  158. label: 'Select'
  159. },
  160. {
  161. value: 'cascader',
  162. label: 'Cascader'
  163. },
  164. {
  165. value: 'switch',
  166. label: 'Switch'
  167. },
  168. {
  169. value: 'slider',
  170. label: 'Slider'
  171. },
  172. {
  173. value: 'time-picker',
  174. label: 'TimePicker'
  175. },
  176. {
  177. value: 'date-picker',
  178. label: 'DatePicker'
  179. },
  180. {
  181. value: 'datetime-picker',
  182. label: 'DateTimePicker'
  183. },
  184. {
  185. value: 'upload',
  186. label: 'Upload'
  187. },
  188. {
  189. value: 'rate',
  190. label: 'Rate'
  191. },
  192. {
  193. value: 'form',
  194. label: 'Form'
  195. }
  196. ]
  197. },
  198. {
  199. value: 'data',
  200. label: 'Data',
  201. children: [
  202. {
  203. value: 'table',
  204. label: 'Table'
  205. },
  206. {
  207. value: 'tag',
  208. label: 'Tag'
  209. },
  210. {
  211. value: 'progress',
  212. label: 'Progress'
  213. },
  214. {
  215. value: 'tree',
  216. label: 'Tree'
  217. },
  218. {
  219. value: 'pagination',
  220. label: 'Pagination'
  221. },
  222. {
  223. value: 'badge',
  224. label: 'Badge'
  225. }
  226. ]
  227. },
  228. {
  229. value: 'notice',
  230. label: 'Notice',
  231. children: [
  232. {
  233. value: 'alert',
  234. label: 'Alert'
  235. },
  236. {
  237. value: 'loading',
  238. label: 'Loading'
  239. },
  240. {
  241. value: 'message',
  242. label: 'Message'
  243. },
  244. {
  245. value: 'message-box',
  246. label: 'MessageBox'
  247. },
  248. {
  249. value: 'notification',
  250. label: 'Notification'
  251. }
  252. ]
  253. },
  254. {
  255. value: 'navigation',
  256. label: 'Navigation',
  257. children: [
  258. {
  259. value: 'menu',
  260. label: 'Menu'
  261. },
  262. {
  263. value: 'tabs',
  264. label: 'Tabs'
  265. },
  266. {
  267. value: 'breadcrumb',
  268. label: 'Breadcrumb'
  269. },
  270. {
  271. value: 'dropdown',
  272. label: 'Dropdown'
  273. },
  274. {
  275. value: 'steps',
  276. label: 'Steps'
  277. }
  278. ]
  279. },
  280. {
  281. value: 'others',
  282. label: 'Others',
  283. children: [
  284. {
  285. value: 'dialog',
  286. label: 'Dialog'
  287. },
  288. {
  289. value: 'tooltip',
  290. label: 'Tooltip'
  291. },
  292. {
  293. value: 'popover',
  294. label: 'Popover'
  295. },
  296. {
  297. value: 'card',
  298. label: 'Card'
  299. },
  300. {
  301. value: 'carousel',
  302. label: 'Carousel'
  303. },
  304. {
  305. value: 'collapse',
  306. label: 'Collapse'
  307. }
  308. ]
  309. }
  310. ]
  311. }
  312. ]
  313. const generateData = () => {
  314. const data: {
  315. value: number
  316. desc: string
  317. disabled: boolean
  318. }[] = []
  319. for (let i = 1; i <= 15; i++) {
  320. data.push({
  321. value: i,
  322. desc: `Option ${i}`,
  323. disabled: i % 4 === 0
  324. })
  325. }
  326. return data
  327. }
  328. const holidays = [
  329. '2021-10-01',
  330. '2021-10-02',
  331. '2021-10-03',
  332. '2021-10-04',
  333. '2021-10-05',
  334. '2021-10-06',
  335. '2021-10-07'
  336. ]
  337. const isHoliday = ({ dayjs }) => {
  338. return holidays.includes(dayjs.format('YYYY-MM-DD'))
  339. }
  340. const schema = reactive<FormSchema[]>([
  341. {
  342. field: 'field1',
  343. label: t('formDemo.input'),
  344. component: 'Divider'
  345. },
  346. {
  347. field: 'field2',
  348. label: t('formDemo.default'),
  349. component: 'Input'
  350. },
  351. {
  352. field: 'field3',
  353. label: `${t('formDemo.icon')}1`,
  354. component: 'Input',
  355. componentProps: {
  356. suffixIcon: useIcon({ icon: 'ep:calendar' }),
  357. prefixIcon: useIcon({ icon: 'ep:calendar' })
  358. }
  359. },
  360. {
  361. field: 'field4',
  362. label: `${t('formDemo.icon')}2`,
  363. component: 'Input',
  364. componentProps: {
  365. slots: {
  366. suffix: true,
  367. prefix: true
  368. }
  369. }
  370. },
  371. {
  372. field: 'field5',
  373. label: t('formDemo.mixed'),
  374. component: 'Input',
  375. componentProps: {
  376. slots: {
  377. prepend: true,
  378. append: true
  379. }
  380. }
  381. },
  382. {
  383. field: 'field6',
  384. label: t('formDemo.textarea'),
  385. component: 'Input',
  386. componentProps: {
  387. type: 'textarea',
  388. rows: 1
  389. }
  390. },
  391. {
  392. field: 'field7',
  393. label: t('formDemo.autocomplete'),
  394. component: 'Divider'
  395. },
  396. {
  397. field: 'field8',
  398. label: t('formDemo.default'),
  399. component: 'Autocomplete',
  400. componentProps: {
  401. fetchSuggestions: querySearch,
  402. onSelect: handleSelect
  403. }
  404. },
  405. {
  406. field: 'field9',
  407. label: t('formDemo.slot'),
  408. component: 'Autocomplete',
  409. componentProps: {
  410. fetchSuggestions: querySearch,
  411. onSelect: handleSelect,
  412. slots: {
  413. default: true
  414. }
  415. }
  416. },
  417. {
  418. field: 'field10',
  419. component: 'Divider',
  420. label: t('formDemo.inputNumber')
  421. },
  422. {
  423. field: 'field11',
  424. label: t('formDemo.default'),
  425. component: 'InputNumber',
  426. value: 0
  427. },
  428. {
  429. field: 'field12',
  430. label: t('formDemo.position'),
  431. component: 'InputNumber',
  432. componentProps: {
  433. controlsPosition: 'right'
  434. },
  435. value: 0
  436. },
  437. {
  438. field: 'field13',
  439. label: t('formDemo.select'),
  440. component: 'Divider'
  441. },
  442. {
  443. field: 'field14',
  444. label: t('formDemo.default'),
  445. component: 'Select',
  446. componentProps: {
  447. options: [
  448. {
  449. label: 'option1',
  450. value: '1'
  451. },
  452. {
  453. label: 'option2',
  454. value: '2'
  455. }
  456. ]
  457. }
  458. },
  459. {
  460. field: 'field15',
  461. label: t('formDemo.slot'),
  462. component: 'Select',
  463. componentProps: {
  464. options: [
  465. {
  466. label: 'option1',
  467. value: '1'
  468. },
  469. {
  470. label: 'option2',
  471. value: '2'
  472. }
  473. ],
  474. optionsSlot: true
  475. }
  476. },
  477. {
  478. field: 'field16',
  479. label: t('formDemo.selectGroup'),
  480. component: 'Select',
  481. componentProps: {
  482. options: [
  483. {
  484. label: 'option1',
  485. options: [
  486. {
  487. label: 'option1-1',
  488. value: '1-1'
  489. },
  490. {
  491. label: 'option1-2',
  492. value: '1-2'
  493. }
  494. ]
  495. },
  496. {
  497. label: 'option2',
  498. options: [
  499. {
  500. label: 'option2-1',
  501. value: '2-1'
  502. },
  503. {
  504. label: 'option2-2',
  505. value: '2-2'
  506. }
  507. ]
  508. }
  509. ]
  510. }
  511. },
  512. {
  513. field: 'field17',
  514. label: `${t('formDemo.selectGroup')}${t('formDemo.slot')}`,
  515. component: 'Select',
  516. componentProps: {
  517. options: [
  518. {
  519. label: 'option1',
  520. options: [
  521. {
  522. label: 'option1-1',
  523. value: '1-1',
  524. disabled: true
  525. },
  526. {
  527. label: 'option1-2',
  528. value: '1-2'
  529. }
  530. ]
  531. },
  532. {
  533. label: 'option2',
  534. options: [
  535. {
  536. label: 'option2-1',
  537. value: '2-1'
  538. },
  539. {
  540. label: 'option2-2',
  541. value: '2-2'
  542. }
  543. ]
  544. }
  545. ],
  546. optionsSlot: true
  547. }
  548. },
  549. {
  550. field: 'field18',
  551. label: `${t('formDemo.selectV2')}`,
  552. component: 'Divider'
  553. },
  554. {
  555. field: 'field19',
  556. label: t('formDemo.default'),
  557. component: 'SelectV2',
  558. componentProps: {
  559. options: options.value
  560. }
  561. },
  562. {
  563. field: 'field20',
  564. label: t('formDemo.slot'),
  565. component: 'SelectV2',
  566. componentProps: {
  567. options: options.value,
  568. slots: {
  569. default: true
  570. }
  571. }
  572. },
  573. {
  574. field: 'field21',
  575. label: t('formDemo.selectGroup'),
  576. component: 'SelectV2',
  577. componentProps: {
  578. options: options2.value
  579. }
  580. },
  581. {
  582. field: 'field22',
  583. label: `${t('formDemo.selectGroup')}${t('formDemo.slot')}`,
  584. component: 'SelectV2',
  585. componentProps: {
  586. options: options2.value,
  587. slots: {
  588. default: true
  589. }
  590. }
  591. },
  592. {
  593. field: 'field23',
  594. label: t('formDemo.cascader'),
  595. component: 'Divider'
  596. },
  597. {
  598. field: 'field24',
  599. label: t('formDemo.default'),
  600. component: 'Cascader',
  601. componentProps: {
  602. options: options3
  603. }
  604. },
  605. {
  606. field: 'field25',
  607. label: t('formDemo.slot'),
  608. component: 'Cascader',
  609. componentProps: {
  610. options: options3,
  611. slots: {
  612. default: true
  613. }
  614. }
  615. },
  616. {
  617. field: 'field26',
  618. label: t('formDemo.switch'),
  619. component: 'Divider'
  620. },
  621. {
  622. field: 'field27',
  623. label: t('formDemo.default'),
  624. component: 'Switch',
  625. value: false
  626. },
  627. {
  628. field: 'field28',
  629. label: t('formDemo.icon'),
  630. component: 'Switch',
  631. value: false,
  632. componentProps: {
  633. activeIcon: useIcon({ icon: 'ep:check' }),
  634. inactiveIcon: useIcon({ icon: 'ep:close' })
  635. }
  636. },
  637. {
  638. field: 'field29',
  639. label: t('formDemo.rate'),
  640. component: 'Divider'
  641. },
  642. {
  643. field: 'field30',
  644. label: t('formDemo.default'),
  645. component: 'Rate',
  646. value: null
  647. },
  648. {
  649. field: 'field31',
  650. label: t('formDemo.icon'),
  651. component: 'Rate',
  652. value: null,
  653. componentProps: {
  654. voidIcon: useIcon({ icon: 'ep:chat-round' }),
  655. icons: [
  656. useIcon({ icon: 'ep:chat-round' }),
  657. useIcon({ icon: 'ep:chat-line-round' }),
  658. useIcon({ icon: 'ep:chat-dot-round' })
  659. ]
  660. }
  661. },
  662. {
  663. field: 'field32',
  664. label: t('formDemo.colorPicker'),
  665. component: 'Divider'
  666. },
  667. {
  668. field: 'field33',
  669. label: t('formDemo.default'),
  670. component: 'ColorPicker'
  671. },
  672. {
  673. field: 'field34',
  674. label: t('formDemo.transfer'),
  675. component: 'Divider'
  676. },
  677. {
  678. field: 'field35',
  679. label: t('formDemo.default'),
  680. component: 'Transfer',
  681. componentProps: {
  682. props: {
  683. key: 'value',
  684. label: 'desc',
  685. disabled: 'disabled'
  686. },
  687. data: generateData()
  688. },
  689. value: [],
  690. colProps: {
  691. span: 24
  692. }
  693. },
  694. {
  695. field: 'field36',
  696. label: t('formDemo.slot'),
  697. component: 'Transfer',
  698. componentProps: {
  699. props: {
  700. key: 'value',
  701. label: 'desc',
  702. disabled: 'disabled'
  703. },
  704. leftDefaultChecked: [2, 3],
  705. rightDefaultChecked: [1],
  706. data: generateData(),
  707. slots: {
  708. default: true
  709. }
  710. },
  711. value: [1],
  712. colProps: {
  713. span: 24
  714. }
  715. },
  716. {
  717. field: 'field37',
  718. label: `${t('formDemo.render')}`,
  719. component: 'Transfer',
  720. componentProps: {
  721. props: {
  722. key: 'value',
  723. label: 'desc',
  724. disabled: 'disabled'
  725. },
  726. leftDefaultChecked: [2, 3],
  727. rightDefaultChecked: [1],
  728. data: generateData(),
  729. renderContent: (h: Fn, option: Recordable) => {
  730. return h('span', null, `${option.value} - ${option.desc}`)
  731. }
  732. },
  733. value: [1],
  734. colProps: {
  735. span: 24
  736. }
  737. },
  738. {
  739. field: 'field38',
  740. label: t('formDemo.radio'),
  741. component: 'Divider'
  742. },
  743. {
  744. field: 'field39',
  745. label: t('formDemo.default'),
  746. component: 'Radio',
  747. componentProps: {
  748. options: [
  749. {
  750. label: 'option-1',
  751. value: '1'
  752. },
  753. {
  754. label: 'option-2',
  755. value: '2'
  756. }
  757. ]
  758. }
  759. },
  760. {
  761. field: 'field40',
  762. label: t('formDemo.button'),
  763. component: 'RadioButton',
  764. componentProps: {
  765. options: [
  766. {
  767. label: 'option-1',
  768. value: '1'
  769. },
  770. {
  771. label: 'option-2',
  772. value: '2'
  773. }
  774. ]
  775. }
  776. },
  777. {
  778. field: 'field41',
  779. label: t('formDemo.checkbox'),
  780. component: 'Divider'
  781. },
  782. {
  783. field: 'field42',
  784. label: t('formDemo.default'),
  785. component: 'Checkbox',
  786. value: [],
  787. componentProps: {
  788. options: [
  789. {
  790. label: 'option-1',
  791. value: '1'
  792. },
  793. {
  794. label: 'option-2',
  795. value: '2'
  796. },
  797. {
  798. label: 'option-3',
  799. value: '23'
  800. }
  801. ]
  802. }
  803. },
  804. {
  805. field: 'field43',
  806. label: t('formDemo.button'),
  807. component: 'CheckboxButton',
  808. value: [],
  809. componentProps: {
  810. options: [
  811. {
  812. label: 'option-1',
  813. value: '1'
  814. },
  815. {
  816. label: 'option-2',
  817. value: '2'
  818. },
  819. {
  820. label: 'option-3',
  821. value: '23'
  822. }
  823. ]
  824. }
  825. },
  826. {
  827. field: 'field44',
  828. component: 'Divider',
  829. label: t('formDemo.slider')
  830. },
  831. {
  832. field: 'field45',
  833. component: 'Slider',
  834. label: t('formDemo.default'),
  835. value: 0
  836. },
  837. {
  838. field: 'field46',
  839. component: 'Divider',
  840. label: t('formDemo.datePicker')
  841. },
  842. {
  843. field: 'field47',
  844. component: 'DatePicker',
  845. label: t('formDemo.default'),
  846. componentProps: {
  847. type: 'date'
  848. }
  849. },
  850. {
  851. field: 'field48',
  852. component: 'DatePicker',
  853. label: t('formDemo.shortcuts'),
  854. componentProps: {
  855. type: 'date',
  856. disabledDate: (time: Date) => {
  857. return time.getTime() > Date.now()
  858. },
  859. shortcuts: [
  860. {
  861. text: t('formDemo.today'),
  862. value: new Date()
  863. },
  864. {
  865. text: t('formDemo.yesterday'),
  866. value: () => {
  867. const date = new Date()
  868. date.setTime(date.getTime() - 3600 * 1000 * 24)
  869. return date
  870. }
  871. },
  872. {
  873. text: t('formDemo.aWeekAgo'),
  874. value: () => {
  875. const date = new Date()
  876. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  877. return date
  878. }
  879. }
  880. ]
  881. }
  882. },
  883. {
  884. field: 'field49',
  885. component: 'DatePicker',
  886. label: t('formDemo.week'),
  887. componentProps: {
  888. type: 'week',
  889. format: `[${t('formDemo.week')}] ww`
  890. }
  891. },
  892. {
  893. field: 'field50',
  894. component: 'DatePicker',
  895. label: t('formDemo.year'),
  896. componentProps: {
  897. type: 'year'
  898. }
  899. },
  900. {
  901. field: 'field51',
  902. component: 'DatePicker',
  903. label: t('formDemo.month'),
  904. componentProps: {
  905. type: 'month'
  906. }
  907. },
  908. {
  909. field: 'field52',
  910. component: 'DatePicker',
  911. label: t('formDemo.dates'),
  912. componentProps: {
  913. type: 'dates'
  914. }
  915. },
  916. {
  917. field: 'field53',
  918. component: 'DatePicker',
  919. label: t('formDemo.daterange'),
  920. componentProps: {
  921. type: 'daterange'
  922. }
  923. },
  924. {
  925. field: 'field54',
  926. component: 'DatePicker',
  927. label: t('formDemo.monthrange'),
  928. componentProps: {
  929. type: 'monthrange'
  930. }
  931. },
  932. {
  933. field: 'field55',
  934. component: 'DatePicker',
  935. label: t('formDemo.slot'),
  936. componentProps: {
  937. type: 'date',
  938. format: 'YYYY/MM/DD',
  939. valueFormat: 'YYYY-MM-DD',
  940. slots: {
  941. default: true
  942. }
  943. }
  944. },
  945. {
  946. field: 'field56',
  947. component: 'Divider',
  948. label: t('formDemo.dateTimePicker')
  949. },
  950. {
  951. field: 'field57',
  952. component: 'DatePicker',
  953. label: t('formDemo.default'),
  954. componentProps: {
  955. type: 'datetime'
  956. }
  957. },
  958. {
  959. field: 'field58',
  960. component: 'DatePicker',
  961. label: t('formDemo.shortcuts'),
  962. componentProps: {
  963. type: 'datetime',
  964. shortcuts: [
  965. {
  966. text: t('formDemo.today'),
  967. value: new Date()
  968. },
  969. {
  970. text: t('formDemo.yesterday'),
  971. value: () => {
  972. const date = new Date()
  973. date.setTime(date.getTime() - 3600 * 1000 * 24)
  974. return date
  975. }
  976. },
  977. {
  978. text: t('formDemo.aWeekAgo'),
  979. value: () => {
  980. const date = new Date()
  981. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  982. return date
  983. }
  984. }
  985. ]
  986. }
  987. },
  988. {
  989. field: 'field59',
  990. component: 'DatePicker',
  991. label: t('formDemo.dateTimerange'),
  992. componentProps: {
  993. type: 'datetimerange'
  994. }
  995. },
  996. {
  997. field: 'field60',
  998. component: 'Divider',
  999. label: t('formDemo.timePicker')
  1000. },
  1001. {
  1002. field: 'field61',
  1003. component: 'TimePicker',
  1004. label: t('formDemo.default')
  1005. },
  1006. {
  1007. field: 'field62',
  1008. component: 'Divider',
  1009. label: t('formDemo.timeSelect')
  1010. },
  1011. {
  1012. field: 'field63',
  1013. component: 'TimeSelect',
  1014. label: t('formDemo.default')
  1015. }
  1016. ])
  1017. </script>
  1018. <template>
  1019. <ContentWrap :title="t('formDemo.defaultForm')" :message="t('formDemo.formDes')">
  1020. <Form :schema="schema" label-width="auto" :label-position="isMobile ? 'top' : 'right'">
  1021. <template #field4-prefix>
  1022. <Icon icon="ep:calendar" class="el-input__icon" />
  1023. </template>
  1024. <template #field4-suffix>
  1025. <Icon icon="ep:calendar" class="el-input__icon" />
  1026. </template>
  1027. <template #field5-prepend> Http:// </template>
  1028. <template #field5-append> .com </template>
  1029. <template #field9-default="{ item }">
  1030. <div class="value">{{ item.value }}</div>
  1031. <span class="link">{{ item.link }}</span>
  1032. </template>
  1033. <template #field15-option="{ item }">
  1034. <span style="float: left">{{ item.label }}</span>
  1035. <span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
  1036. {{ item.value }}
  1037. </span>
  1038. </template>
  1039. <template #field17-option="{ item }">
  1040. <span style="float: left">{{ item.label }}</span>
  1041. <span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
  1042. {{ item.value }}
  1043. </span>
  1044. </template>
  1045. <template #field20-default="{ item }">
  1046. <span style="float: left">{{ item.label }}</span>
  1047. <span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
  1048. {{ item.value }}
  1049. </span>
  1050. </template>
  1051. <template #field22-default="{ item }">
  1052. <span style="float: left">{{ item.label }}</span>
  1053. <span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
  1054. {{ item.value }}
  1055. </span>
  1056. </template>
  1057. <template #field25-default="{ node, data }">
  1058. <span>{{ data.label }}</span>
  1059. <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
  1060. </template>
  1061. <template #field36-default="{ option }">
  1062. <span>{{ option.value }} - {{ option.desc }}</span>
  1063. </template>
  1064. <template #field55-default="cell">
  1065. <div class="cell" :class="{ current: cell.isCurrent }">
  1066. <span class="text">{{ cell.text }}</span>
  1067. <span v-if="isHoliday(cell)" class="holiday"></span>
  1068. </div>
  1069. </template>
  1070. </Form>
  1071. </ContentWrap>
  1072. </template>
  1073. <style lang="less" scoped>
  1074. .cell {
  1075. height: 30px;
  1076. padding: 3px 0;
  1077. box-sizing: border-box;
  1078. .text {
  1079. position: absolute;
  1080. left: 50%;
  1081. display: block;
  1082. width: 24px;
  1083. height: 24px;
  1084. margin: 0 auto;
  1085. line-height: 24px;
  1086. border-radius: 50%;
  1087. transform: translateX(-50%);
  1088. }
  1089. &.current {
  1090. .text {
  1091. color: #fff;
  1092. background: purple;
  1093. }
  1094. }
  1095. .holiday {
  1096. position: absolute;
  1097. bottom: 0px;
  1098. left: 50%;
  1099. width: 6px;
  1100. height: 6px;
  1101. background: red;
  1102. border-radius: 50%;
  1103. transform: translateX(-50%);
  1104. }
  1105. }
  1106. </style>