<template>
  <el-table :data="addressData" border style="width: 100%">
    <el-table-column label="指标类型" width="180">
      <template #default="scope">
        {{metrics_category.find(item=>item.value==scope.row.metricsType).label}}
      </template>
    </el-table-column>
    <el-table-column label="普罗米修斯job">
      <template #default="scope">
        <el-input v-model="scope.row.apiAddr" />
      </template>
    </el-table-column>
    <el-table-column label="操作" width="100" align="center">
      <template #default="scope">
        <el-button link type="primary" icon="CircleCheck" @click="handleSave(scope.row)">保存</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script setup lang="ts">
import {getDataList,updateData,delData} from "@/api/obj/data"
import {onMounted, ref} from "vue";
const {proxy,emit} = getCurrentInstance()
const {metrics_category} = proxy.useDict('metrics_category');
const props = defineProps(['rowId'])
const addressData = ref([])

onMounted(()=>{
  dataList()
})

const handleDelete=(row)=>{
  delData(row.dataId).then(res=>{
    proxy.$modal.msgSuccess(res.msg)
    dataList()
  })
}

const handleSave=(row)=>{
  updateData(row).then(res=>{
    proxy.$modal.msgSuccess(res.msg)
  })
}

const dataList = () => {
  getDataList(props.rowId).then(res => {
    addressData.value =  res.rows
  })
}

const submitForm=()=>{
  emit("nextStep", "done")
}

defineExpose({submitForm})

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