<template>
  <div style="overflow-y: auto">
    <h1>cascader</h1>
    <div>
      参数：input1，值：{{form.input1}}  (props默认为{
      expandTrigger: 'hover',
      checkStrictly: true,
      emitPath: false
      })
      <CusFormColumn
          link="cascader"
          label="普通"
          placeholder="下拉"
          v-model:param="form.input1"
          :options="opts"
          static
      />
    </div>
    <h2>自定义props</h2>
    <CusFormColumn
        link="cascader"
        label="普通"
        placeholder="下拉"
        v-model:param="form.input1"
        :options="$store.state.dictionary.caseTypeTree"
        :props="{
          expandTrigger: 'click'
        }"
    />
    <h2>下拉面板最大宽度  panelMaxWidth="200px"</h2>
    <CusFormColumn
        link="cascader"
        label="普通"
        placeholder="下拉"
        v-model:param="form.input1"
        :options="$store.state.dictionary.caseTypeTree"
        panelMaxWidth="200px"
    />
    <h2>插槽</h2>
    <CusFormColumn
        link="cascader"
        label="普通"
        placeholder="下拉"
        v-model:param="form.input1"
        :options="$store.state.dictionary.caseTypeTree"
    >
      <template #default="{ node, data }">
        <span>{{ data.label }}</span><span style="color: #2D69ED;">({{ data.children?.length }})</span>
      </template>
    </CusFormColumn>
    <div>自定义label、value</div>
    <CusFormColumn
        link="cascader"
        label="普通"
        placeholder="下拉"
        v-model:param="form.input5"
        :options="opts2"
        static
        :props="{
          expandTrigger: 'hover',
          checkStrictly: true,
          emitPath: false,
          label: 'label3',
          value: 'value2'
        }"
    />
  </div>
</template>

<script lang="ts">
import {
  defineComponent,
  computed,
  onMounted,
  ref,
  reactive,
  watch,
  getCurrentInstance,
  ComponentInternalInstance,
  toRefs,
  nextTick
} from 'vue'
import {useStore} from 'vuex'
import {useRouter, useRoute} from 'vue-router'

export default defineComponent({
  name: '',
  components: {},
  setup() {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
    const state = reactive({
      form: {
        input1: 'axure',
      },
      opts: [
        {
          value: 'guide',
          label: 'Guide',
          children: [
            {
              value: 'disciplines',
              label: 'Disciplines',
              children: [
                {
                  value: 'consistency',
                  label: 'Consistency',
                },
                {
                  value: 'feedback',
                  label: 'Feedback',
                },
                {
                  value: 'efficiency',
                  label: 'Efficiency',
                },
                {
                  value: 'controllability',
                  label: 'Controllability',
                },
              ],
            },
            {
              value: 'navigation',
              label: 'Navigation',
              children: [
                {
                  value: 'side nav',
                  label: 'Side Navigation',
                },
                {
                  value: 'top nav',
                  label: 'Top Navigation',
                },
              ],
            },
          ],
        },
        {
          value: 'component',
          label: 'Component',
          children: [
            {
              value: 'basic',
              label: 'Basic',
              children: [
                {
                  value: 'layout',
                  label: 'Layout',
                },
                {
                  value: 'color',
                  label: 'Color',
                },
                {
                  value: 'typography',
                  label: 'Typography',
                },
                {
                  value: 'icon',
                  label: 'Icon',
                },
                {
                  value: 'button',
                  label: 'Button',
                },
              ],
            },
            {
              value: 'form',
              label: 'Form',
              children: [
                {
                  value: 'radio',
                  label: 'Radio',
                },
                {
                  value: 'checkbox',
                  label: 'Checkbox',
                },
                {
                  value: 'input',
                  label: 'Input',
                },
                {
                  value: 'input-number',
                  label: 'InputNumber',
                },
                {
                  value: 'select',
                  label: 'Select',
                },
                {
                  value: 'cascader',
                  label: 'Cascader',
                },
                {
                  value: 'switch',
                  label: 'Switch',
                },
                {
                  value: 'slider',
                  label: 'Slider',
                },
                {
                  value: 'time-picker',
                  label: 'TimePicker',
                },
                {
                  value: 'date-picker',
                  label: 'DatePicker',
                },
                {
                  value: 'datetime-picker',
                  label: 'DateTimePicker',
                },
                {
                  value: 'upload',
                  label: 'Upload',
                },
                {
                  value: 'rate',
                  label: 'Rate',
                },
                {
                  value: 'form',
                  label: 'Form',
                },
              ],
            },
            {
              value: 'data',
              label: 'Data',
              children: [
                {
                  value: 'table',
                  label: 'Table',
                },
                {
                  value: 'tag',
                  label: 'Tag',
                },
                {
                  value: 'progress',
                  label: 'Progress',
                },
                {
                  value: 'tree',
                  label: 'Tree',
                },
                {
                  value: 'pagination',
                  label: 'Pagination',
                },
                {
                  value: 'badge',
                  label: 'Badge',
                },
              ],
            },
            {
              value: 'notice',
              label: 'Notice',
              children: [
                {
                  value: 'alert',
                  label: 'Alert',
                },
                {
                  value: 'loading',
                  label: 'Loading',
                },
                {
                  value: 'message',
                  label: 'Message',
                },
                {
                  value: 'message-box',
                  label: 'MessageBox',
                },
                {
                  value: 'notification',
                  label: 'Notification',
                },
              ],
            },
            {
              value: 'navigation',
              label: 'Navigation',
              children: [
                {
                  value: 'menu',
                  label: 'Menu',
                },
                {
                  value: 'tabs',
                  label: 'Tabs',
                },
                {
                  value: 'breadcrumb',
                  label: 'Breadcrumb',
                },
                {
                  value: 'dropdown',
                  label: 'Dropdown',
                },
                {
                  value: 'steps',
                  label: 'Steps',
                },
              ],
            },
            {
              value: 'others',
              label: 'Others',
              children: [
                {
                  value: 'dialog',
                  label: 'Dialog',
                },
                {
                  value: 'tooltip',
                  label: 'Tooltip',
                },
                {
                  value: 'popover',
                  label: 'Popover',
                },
                {
                  value: 'card',
                  label: 'Card',
                },
                {
                  value: 'carousel',
                  label: 'Carousel',
                },
                {
                  value: 'collapse',
                  label: 'Collapse',
                },
              ],
            },
          ],
        },
        {
          value: 'resource',
          label: 'Resource',
          children: [
            {
              value: 'axure',
              label: 'Axure Components',
            },
            {
              value: 'sketch',
              label: 'Sketch Templates',
            },
            {
              value: 'docs',
              label: 'Design Documentation',
            },
          ],
        },
      ],
      opts2: [
        {
          value2: 'guide',
          label3: 'Guide',
          children: [
            {
              value2: 'disciplines',
              label3: 'Disciplines',
              children: [
                {
                  value2: 'consistency',
                  label3: 'Consistency',
                },
              ],
            },
            {
              value2: 'navigation',
              label3: 'Navigation',
              children: [
                {
                  value2: 'side nav',
                  label3: 'Side Navigation',
                },
                {
                  value2: 'top nav',
                  label3: 'Top Navigation',
                },
              ],
            },
          ],
        },
      ]
    })
    const initDictionary = () => {
      store.dispatch("dictionary/LOAD_CASE_TYPE");
    }
    onMounted(() => {
      initDictionary()
    })
    return {
      ...toRefs(state),
    }
  },
})
</script>

<style scoped lang="scss">
</style>
