<template>
  <el-dialog v-model="info.show" :title="info.title" :close-on-press-escape="false" :close-on-click-modal="false"
    align-center append-to-body :width="info.width" modal-class="choice-model-dlg">
    <el-table v-loading="info.loading" :data="info.data" stripe>
      <el-table-column label="模型名称" align="left" prop="model_name" width="300" />
      <el-table-column label="网络名称" align="left" prop="model_network" v-if="1 == 2" />
      <el-table-column label="模型类型" align="left" prop="modl_main_type_name" />
      <el-table-column label="版本" align="left" prop="model_version" />
      <el-table-column label="说明" align="left" prop="model_desc" />
      <el-table-column label="上传时间" width="120" align="left" prop="create_time" />
      <el-table-column label="上传用户" width="100" align="left" prop="user_name" />
      <el-table-column label="操作" fixed="right" width="120">
        <template #default="scope">
          <el-button text type="primary" size="small" @click="doCreateConn(scope.row)"><i-ep-edit />新建互联</el-button>
        </template>
      </el-table-column>
    </el-table>

  </el-dialog>
</template>
<script setup>
import ModelApi from '@/api/models'
const emit = defineEmits(['success'])
const info = reactive({
  title: '模型选择',
  show: false,
  width: '960px',
  data: null,
  loading: false
})

const showDialog = opt => {
  info.show = true;
  loadData();
}

const doCreateConn = row => {
  emit("success", row)
}

const loadData = () => {
  info.loading = true
  ModelApi.list({
    page_num: 1,
    page_size: 100
  }).then(d => {
    info.loading = false
    info.data = d.data.data.model_list || [];
  })
}
defineExpose({
  showDialog
})
</script>