大数据模型练习3

html 复制代码
<template>
  <div class="search-panel-container">
    <div class="panel-header">
      <el-popover placement="bottom-start" width="200" trigger="click">
        <template #reference>
          <el-button link>
            当前模板: {{ searchStore.currentTemplateName || '自定义' }}
            <el-icon class="el-icon--right"><ArrowDown /></el-icon>
          </el-button>
        </template>
        <ul class="template-dropdown-list">
          <li v-for="t in searchStore.templates" :key="t.id" @click="searchStore.applyTemplate(t)">
            {{ t.name }}
          </li>
          <li class="manage-btn" @click="showManager = true">
            <el-icon><Setting /></el-icon> 搜索模板管理
          </li>
        </ul>
      </el-popover>
    </div>

    <div class="search-form-wrapper">
      <el-form :inline="true" :model="searchStore.searchForm" class="demo-form-inline">
        <template v-for="field in searchStore.activeFieldsConfig" :key="field.key">
          <el-form-item :label="field.label">
            <el-input
              v-if="field.type === 'input'"
              v-model="searchStore.searchForm[field.key]"
              :placeholder="'Enter ' + field.label"
              clearable
            />

            <el-select
              v-else-if="field.type === 'select'"
              v-model="searchStore.searchForm[field.key]"
              :placeholder="'Select ' + field.label"
              clearable
              style="width: 180px"
            >
              <el-option
                v-for="opt in field.options"
                :key="opt.value"
                :label="opt.label"
                :value="opt.value"
              />
            </el-select>

            <el-date-picker
              v-else-if="field.type === 'date-picker'"
              v-model="searchStore.searchForm[field.key]"
              type="datetimerange"
              start-placeholder="Start"
              end-placeholder="End"
            />
          </el-form-item>
        </template>

        <el-form-item>
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button @click="handleReset">重置</el-button>
          <el-button
            v-if="canUpdateCurrentTemplate"
            type="warning"
            plain
            @click="handleUpdateTemplate"
          >
            更新模板
          </el-button>
          <el-button @click="showSaveDialog">存为模板</el-button>
          <el-button link type="primary" @click="showConfig = true"> 搜索项配置 </el-button>
        </el-form-item>
      </el-form>
    </div>

    <SearchConfigDialog v-model="showConfig" />
    <TemplateManagerDialog v-model="showManager" />
  </div>
</template>

<script setup>
import { ref, onMounted, computed } from 'vue'
import { ArrowDown, Setting } from '@element-plus/icons-vue'
import { useSearchStore } from '../../stores/searchStore'
import { ElMessageBox, ElMessage } from 'element-plus'
// import SearchConfigDialog from './SearchConfigDialog.vue'
import SearchConfigDialog from './DiySearchConfigDialog.vue'
import TemplateManagerDialog from './TemplateManagerDialog.vue'

const searchStore = useSearchStore()
const showConfig = ref(false)
const showManager = ref(false)

onMounted(() => {
  searchStore.initData()
})

const handleSearch = () => {
  console.log('发起查询,参数:', JSON.parse(JSON.stringify(searchStore.searchForm)))
  ElMessage.info('查询请求已发出,请查看控制台')
}

const handleReset = () => {
  searchStore.searchForm = {}
}

const showSaveDialog = () => {
  ElMessageBox.prompt('请输入模板名称', '存为模板', {
    confirmButtonText: '保存',
    cancelButtonText: '取消',
  })
    .then(({ value }) => {
      if (value) {
        searchStore.saveAsTemplate(value)
      }
    })
    .catch(() => {})
}
const canUpdateCurrentTemplate = computed(() => {
  const tplId = searchStore.currentTemplateId
  if (!tplId) return false

  const tpl = searchStore.templates.find((t) => t.id === tplId)
  // 核心判断:存在且允许更新
  return tpl && tpl.permission && tpl.permission.canUpdate
})

const handleUpdateTemplate = async () => {
  try {
    await searchStore.updateCurrentTemplate()
    ElMessage.success('当前模板已更新')
  } catch (e) {
    ElMessage.error('更新失败')
  }
}
</script>

<style scoped>
.search-panel-container {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.panel-header {
  margin-bottom: 12px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}
.template-dropdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.template-dropdown-list li {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
}
.template-dropdown-list li:hover {
  background-color: #f0f9eb;
  color: #409eff;
}
.template-dropdown-list li.manage-btn {
  color: #409eff;
  border-top: 1px solid #eee;
  margin-top: 4px;
}
</style>
相关推荐
AC赳赳老秦14 小时前
智能协同新纪元:DeepSeek驱动的跨岗位、跨工具多智能体实操体系展望(2026)
大数据·运维·人工智能·深度学习·机器学习·ai-native·deepseek
blackorbird14 小时前
Palantir的战争AI:藏在美军Maven系统里的Claude大模型
java·大数据·人工智能·maven
wanhengidc15 小时前
服务器硬盘都有哪些功能
大数据·运维·服务器·数据库·科技
zy119315 小时前
AI排名优化公司 - 电商大促季如何通过AI可见率实现弯道超车
大数据·人工智能
xier_ran15 小时前
【第二周】 RAG与Agent实战05:提示词优化案例_金融文本分析
大数据·人工智能·语言模型·金融
尋有緣15 小时前
Spark SQL 调优
大数据·sql·spark
zhang2008l15 小时前
Python大数据可视化:基于大数据技术的共享单车数据分析与辅助管理系统_flask+hadoop+spider
大数据·python·信息可视化
qq_4371006615 小时前
ElasticSearch相关记录
大数据·前端·javascript·elasticsearch·全文检索
逸Y 仙X15 小时前
文章六:ElasticSearch 映射配置与字段类型详解
大数据·elasticsearch·搜索引擎
花间相见15 小时前
【知识库笔记管理】—— 使用PARA方法高效建立自己个人知识库
大数据·笔记