
<template>
    <el-dialog  title="请确认检测脚本值类型"
                v-model='dialogVisible' 
                @close="close" 
                v-bind="dialogSmall" 
               >
      <div class="dialog-content" >
                <el-form>
                        <el-form-item label='值类型'>
                          <el-select v-model="selectedValue" filterable  clearable placeholder="请选择值类型">
                                          <el-option
                                          v-for="item in dictStore.getDictData('Script_Value_Type')"
                                          :key="item.id"
                                          :label="item.name"
                                          :value="item.id"
                                          />
                          </el-select>
                        </el-form-item> 
                </el-form>
      </div>
      <TestScriptPopup  ref='testScriptPopup' />
      <template #footer>
          <div>
            <el-button @click='close()'>取 消</el-button>
            <el-button type="primary" @click='save()'>新增</el-button>
          </div>
      </template>
    </el-dialog>
  
  
  </template>
  <script setup lang='ts'>
  import { dialogSmall } from '@/utils/elementBind'
  import {  ref } from 'vue'
  import { useDictStore } from '@/stores/modules/dict'
  import { type TestScript } from '@/api/device/interface/testScript';
  
  const mode = ref()
  const testScriptPopup = ref()
  // 定义弹出组件元信息
  const dialogFormRef = ref()
  const dictStore = useDictStore()
  const dialogVisible = ref(false)
  const selectedValue = ref()
  
    // 关闭弹窗
    const close = () => {
      dialogVisible.value = false
      // 重置表单
      dialogFormRef.value?.resetFields()
    }
    
    // 保存数据
    const save = () => {
        testScriptPopup.value?.open('新增检测脚本', {}, mode.value,selectedValue.value)
    }
  
  
  // 打开弹窗，可能是新增，也可能是编辑
  const open = (sign: string,row: any,currentMode: string) => {
      mode.value = currentMode
      // 重置表单
      dialogFormRef.value?.resetFields()
      dialogVisible.value = true
  }
    
  // 对外映射
  defineExpose({ open })

  
  
  </script>
  <style scoped>
  /* .dialog-content {
    padding: 10px;
  } */
  </style>