<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">情报语义分析{{ title }}</span>
      <div>
        <el-button type="primary" v-if="title != '详情'" size="small" :loading="loading" @click="submit">保存</el-button>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="cntinfo">
      <el-form :model="listQuery" ref="elform" :label-width="120" label-position="right">
        <div class="form-row">
          <el-form-item label="语义名称">
            <el-input v-model="listQuery.yymc" placeholder="请输入语义名称"/>
          </el-form-item>
          <el-form-item label="要素类型">
            <el-input v-model="listQuery.ddwplb" placeholder="请输入要素类型"/>
          </el-form-item>
          <el-form-item label="要素名称">
            <el-input v-model="listQuery.ysmc" placeholder="请输入要素名称"/>
          </el-form-item>
        </div>
        <div class="form-row">
          <el-form-item label="要素描述">
            <el-input v-model="listQuery.ysms" type="textarea" rows="3" placeholder="要素描述"/>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue';
const elform = ref();
const dialogForm = ref(false);
const listQuery = ref({
  plateImages: [
    {img:require('@/assets/images/person.png')},
    {img:require('@/assets/images/person.png')},
    {img:require('@/assets/images/person.png')},
  ]
});
const title = ref('');

// 初始化数据
const init = (type, row) => {
  dialogForm.value = true;
  title.value = '新增'
  if(row){
    title.value = type == 'edit' ? '编辑' :'详情';
  }
  // 根据type和row初始化表单数据
};


// 提交
const submit = ()=>{
  elform.value.validate((valid) => {
    if (!valid) return false;
    // loading.value = true;
    let params = { ...listQuery.value}
    let url = title.value == '新增' ? '/mosty-lzcj/tbDwYy/insert' :'/mosty-lzcj/tbDwYy/update'
    // qcckPost(params, url).then((res) => {
    //   proxy.$message({ type: "success", message: title.value+'成功'});
    //   close()
    //   emit("updateDate",modelLx.value);
    // }).catch(()=>{
    //   loading.value = false;
    // });
  });
}

const close = () => {
  dialogForm.value = false;
};

defineExpose({init})
</script>

<style lang="scss" scoped>
.dialog {
  padding: 20px;

  .head_box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  .cntinfo{
    height: calc(100% - 70px);
    overflow: hidden;
    overflow-y: auto;
  }

  .form-row {
    display: flex;
    
    .el-form-item {
      flex: 1;
    }
  }
  .image-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  
    
    .image-item {
      width: 150px;
      height: 150px;
      border: 1px solid #dcdfe6;
      
      .el-image {
        width: 100%;
        height: 100%;
      }
    }
  }

}

</style>
