xm-datetimerange-render.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <a-range-picker v-bind="$attrs" @change="change" v-model="defaultValue" :mode="modes" />
  3. </template>
  4. <script>
  5. import components from './_import-components/xm-datetimerange-render-import'
  6. const XmDatetimerangeRender = {
  7. name: 'XmDatetimerangeRender',
  8. metaInfo: {
  9. title: 'XmDatetimerangeRender',
  10. },
  11. components: {
  12. ...components,
  13. },
  14. computed: {},
  15. props: {
  16. label: {
  17. type: String,
  18. default: '',
  19. },
  20. mode: {
  21. type: String,
  22. default: '',
  23. },
  24. field: {
  25. type: Object,
  26. default: () => {},
  27. },
  28. starttime: {
  29. type: String,
  30. default: '',
  31. },
  32. endtime: {
  33. type: String,
  34. default: '',
  35. },
  36. },
  37. data() {
  38. return {
  39. expanded: true,
  40. defaultValue: this.$attrs?.value?.split(',') || [],
  41. modes:
  42. this.mode === 'month' ? ['month', 'month'] : this.mode === 'year' ? ['year', 'year'] : '',
  43. }
  44. },
  45. inject: {
  46. webflow: { default: () => ({}) },
  47. SdFormContext: { default: () => ({}) },
  48. },
  49. created() {},
  50. methods: {
  51. change(date, dateString) {
  52. const value = new Date(dateString[0]).toString() + ',' + new Date(dateString[1]).toString()
  53. this.$emit('input', value)
  54. if (this.starttime !== '') {
  55. const obj = this.webflow.FlowData.processFormData.processFormPropertyValues.find(
  56. (i) => i.caption === this.starttime
  57. )
  58. this.SdFormContext.setFieldValue(obj.name, new Date(dateString[0]).getTime().toString())
  59. }
  60. if (this.endtime !== '') {
  61. const obj = this.webflow.FlowData.processFormData.processFormPropertyValues.find(
  62. (i) => i.caption === this.endtime
  63. )
  64. this.SdFormContext.setFieldValue(obj.name, new Date(dateString[1]).getTime().toString())
  65. }
  66. },
  67. },
  68. }
  69. // 默认导出:编辑模式的组件
  70. export default XmDatetimerangeRender
  71. // forDisplay导出:只读模式的组件
  72. export { XmDatetimerangeRender as forDisplay }
  73. </script>
  74. <style module lang="scss">
  75. @use '@/common/design' as *;
  76. .expandicon {
  77. // color: #0b75f3;#40a9ff
  78. // color: rgba(0, 0, 0, 0.85);
  79. color: #40a9ff;
  80. line-height: 22px;
  81. cursor: pointer;
  82. }
  83. .maingroupdiv {
  84. position: relative;
  85. .groupstyle {
  86. float: left;
  87. position: relative;
  88. z-index: 11;
  89. }
  90. .expandCount {
  91. // float: right;
  92. position: absolute;
  93. top: 0;
  94. right: 0;
  95. }
  96. }
  97. </style>