<template>
  <div>
    <ns-form :schemas="formConfig.schemas" />
  </div>
</template>

<script lang="ts">
  import { defineComponent } from 'vue';

  export default defineComponent({
    name: 'new',
    setup() {
      const formConfig = {
        schemas: [
          {
            field: 'cpu',
            label: 'CPU',
            component: 'NsSelectApi',
            autoAddLink: true,
            dynamicParams: {
              ram: 'fieldLink.ram.ram',
            },
            componentProps: {
              api: '/api/iaas/iaas/objs/FlavorCPU',
              resultField: 'data',
              labelField: 'cpuCount',
              valueField: 'cpuCount',
              // immediate: true,
              placeholder: '请选择CPU',
              firstOption: {
                label: '全部',
                value: ' ',
              },
            },
          },
          {
            field: 'ram',
            label: '内存',
            component: 'NsSelectApi',
            autoAddLink: true,
            // // 值依赖
            dynamicParams: {
              cpu: 'fieldLink.cpu.cpuCount',
            },
            componentProps: {
              api: '/api/iaas/iaas/objs/FlavorRam',
              resultField: 'data',
              labelField: 'ram',
              valueField: 'ram',
              // immediate: true,
              placeholder: '请选择内存',
              firstOption: {
                label: '全部',
                value: ' ',
              },
              onSelect: () => {
                // unref(nsTableRef).triggerSubmit();
              },
            },
          },
          {
            field: 'ram1',
            label: '内存11',
            component: 'NsSelectApi',
            autoAddLink: true,
            // // 值依赖
            // dynamicParams: {
            //   cpu: 'fieldLink.cpu.cpuCount',
            // },
            componentProps: {
              api: '/api/iaas/iaas/objs/FlavorRam',
              resultField: 'data',
              labelField: 'ram',
              valueField: 'ram',
              // immediate: true,
              placeholder: '请选择内存',
              // firstOption: {
              //   label: '全部',
              //   value: ' ',
              // },
              onSelect: () => {
                // unref(nsTableRef).triggerSubmit();
              },
            },
          },
        ],
        params: {},
      };
      return {
        formConfig,
      };
    },
  });
</script>

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