xuzhancheng 1 dzień temu
rodzic
commit
53cbb1b632

+ 23 - 28
yudao-ui-admin-vue3/src/views/pressure2/inspectionNature/index.vue

@@ -178,7 +178,7 @@
       <el-table-column label="检验项目名称" prop="name">
         <template #default="{ row }">
           <div style="display: flex; align-items: center; gap: 4px;">
-            <span v-if="row.isMainProject === '1'" style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #6cbcf5; color: #fff; font-size: 12px; border-radius: 2px; font-weight: bold;">主</span>
+            <span v-if="row.projectType === 'MAIN'" style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #6cbcf5; color: #fff; font-size: 12px; border-radius: 2px; font-weight: bold;">主</span>
             <span>{{ row.name }}</span>
           </div>
         </template>
@@ -224,32 +224,15 @@
     v-model="reportTemplateDialog_Boiler"
     title="选择检验项目"
     width="1200px"
+    append-to-body 
     @confirm="handleReportTemplateConfirm"
   >
     <!-- 搜索表单 -->
-    <!--
-        <el-form :inline="true" :model="reportSearchForm" class="search-form">
-          <el-form-item label="报告名称">
-            <el-input v-model="reportSearchForm.name" placeholder="请输入报告名称" clearable
-                      style="width: 200px"/>
-          </el-form-item>
-          <el-form-item label="报告分类">
-            <el-select v-model="reportSearchForm.classId" placeholder="请选择" clearable
-                       style="width: 180px">
-              <el-option
-                v-for="item in reportClassOptions"
-                :key="item.value"
-                :label="item.label"
-                :value="item.value"
-              />
-            </el-select>
-          </el-form-item>
-          <el-form-item>
-            <el-button type="primary" @click="fetchReportTemplateList_Boiler">查询</el-button>
-            <el-button @click="handleReportReset">重置</el-button>
-          </el-form-item>
-        </el-form>
-    -->
+    <el-form :inline="true" :model="reportSearchForm" class="search-form" @submit.prevent>
+      <el-form-item label="检验项目">
+        <el-input v-model="reportSearchKeyword" placeholder="输入关键词高亮匹配项" clearable style="width: 240px"/>
+      </el-form-item>
+    </el-form>
 
     <!-- 检验项目列表 - 复选框网格布局 -->
     <div class="checkItemContentWrapper" v-loading="reportLoading">
@@ -274,8 +257,8 @@
                 @change="(val) => handleReportItemSelect(item, val)"
               />
               <div style="display: flex; align-items: center; gap: 4px;">
-                <span v-if="item.isMainProject === '1'" style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #6cbcf5; color: #fff; font-size: 12px; border-radius: 2px; font-weight: bold;">主</span>
-                <span>{{ item.projectName }}</span>
+                <span v-if="item.projectType === 'MAIN'" style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #6cbcf5; color: #fff; font-size: 12px; border-radius: 2px; font-weight: bold;">主</span>
+                <span v-html="highlightText(item.projectName)"></span>
               </div>
             </div>
           </div>
@@ -477,6 +460,7 @@ const handleInspectionNatureDialogClose = () => {
   inspectionNatureFormRef.value.resetFields()
   inspectionNatureForm.value.templateSaveReqVOList = []
   reportTemplateList.value = []
+  reportSearchKeyword.value = ''
 }
 
 // 提交检验性质
@@ -520,12 +504,23 @@ const reportTotal = ref(0)
 const reportSearchForm = ref<any>({})
 const reportTemplateList = ref<any[]>([])
 const reportLoading = ref(false)
-
+const reportSearchKeyword = ref('') // 搜索关键词
+
+// 高亮匹配文本
+const highlightText = (text: string) => {
+  if (!text) return ''
+  const keyword = reportSearchKeyword.value
+  if (!keyword) return text
+  // 转义正则特殊字符
+  const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+  const regex = new RegExp(`(${escaped})`, 'gi')
+  return text.replace(regex, '<mark style="background-color: #fff3cd; padding: 0 2px;">$1</mark>')
+}
 
 // 判断报告是否已选中
 const isReportSelected = (item: any) => {
   // 判断是否已经有主项目
-  if (inspectionNatureForm.value.templateSaveReqVOList.some((x: any) => x.isMainProject === '1') && item.isMainProject === '1'){
+  if (inspectionNatureForm.value.templateSaveReqVOList.some((x: any) => x.projectType === 'MAIN') && item.projectType === 'MAIN'){
     console.log(item)
     return true
   }