<template>
  <a-form-item label="默认值">
    <a-week-picker
      :value="component.attr.defaultValue ? moment(component.attr.defaultValue, 'YYYY-ww周') : null"
      @change="onChange"
    />
  </a-form-item>
</template>

<script>
import moment from 'moment'
import { DatePicker } from 'ant-design-vue'
import components from './_import-components/xm-week-picker-import'
export const metaInfo = {
  caption: '周选择器',
  component: {
    props: ['designerData'],
    render() {
      const value = this.designerData.attr.defaultValue
        ? moment(this.designerData.attr.defaultValue, 'YYYY-ww周')
        : null
      return <DatePicker.WeekPicker vModel={value} />
    },
  },
  icon: 'schedule',
  order: 700,
}
export const fieldProps = {
  dataType: 'string',
  attr: {
    defaultValue: null,
  },
}
export default {
  name: 'XmWeekPicker',
  components,
  data() {
    return {}
  },
  methods: {
    moment,
    onChange(value, str) {
      this.component.attr.defaultValue = str
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
