<template>
  <div>
    <el-form ref="interfaceForm" :model="interfaceForm" >
      <el-row>
        <el-col :span="8">
          <el-form-item label="接口名称:" >
            <el-input v-model="interfaceForm.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="所属模块:">
            <el-select v-model="interfaceForm.moduleName" placeholder="请选择模块">
              <el-option v-for="item in modelList" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="请求方式:">
            <el-select v-model="interfaceForm.method" placeholder="请选择模块">
              <el-option v-for="item in optionMethod" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- <el-row>
        <el-col :span="8">
          <el-form-item label="请求路径:" style="float:left">
            <el-input v-model="interfaceForm.url"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="参数类型:" class="col-style">
            <el-select v-model="interfaceForm.reqType" placeholder="请选择参数类型">
              <el-option v-for="item in optionReqType" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row> -->
    </el-form>
  </div>
</template>

<script>
import { getModulList } from '@/api/getAotoInterface'
export default {
  data() {
    return {
      queryModuleInfo: {
        pageNum: 1,
        pageSize: 10
      },
      interfaceForm: {
        name: '',
        moduleName: '',
        method: '',
        url: '',
        reqType: ''
      },
      modelList: [],
      rules: {
        name: [
          {
            required: true,
            message: '接口名称不能为空！',
            trigger: 'blur'
          }
        ],
        modelName: [
          {
            required: true,
            message: '接口名称不能为空！',
            trigger: 'blur'
          }
        ],
        method: [
          {
            required: true,
            message: '接口名称不能为空！',
            trigger: 'blur'
          }
        ],
        url: [
          {
            required: true,
            message: '接口名称不能为空！',
            trigger: 'blur'
          }
        ],
        reqType: [
          {
            required: true,
            message: '接口名称不能为空！',
            trigger: 'blur'
          }
        ]
      },
      optionMethod: [
        {
          id: 'get',
          name: 'get'
        },
        {
          id: 'post',
          name: 'post'
        }
      ],
      optionReqType: [
        {
          id: 'params',
          name: 'params'
        },
        {
          id: 'json',
          name: 'json'
        },
        {
          id: 'form',
          name: 'form'
        }
      ]
    }
  },
  created() {
    this.getModelList()
  },
  methods: {
    // 模块列表
    getModelList() {
      getModulList(this.queryModuleInfo).then((resp) => {
        this.modelList = resp.data.data.list
      })
    }
  }
}
</script>
<style lang="less" scoped>
// .col-style {
//   margin-left: 50px;
//   float: left;
// }
// .col-new-style {
//   margin-left: 20px;
// }
</style>
