From addf0fc0002931d5db98b6e9eccbebd679dbb6cb Mon Sep 17 00:00:00 2001
From: xiezhijun <15270898033@163.com>
Date: Tue, 9 Mar 2021 18:25:13 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A1=88=E4=BE=8B=E7=AE=A1=E7=90=86=E4=BC=98?=
 =?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../custom/SysCustomerCaseController.java     |  1 +
 .../stdiet/custom/domain/SysCustomerCase.java |  2 +
 .../mapper/custom/SysCustomerCaseMapper.xml   | 20 ++++++++--
 .../components/FileDownload/MuchFileDown.vue  |  2 +-
 .../components/FileUpload/DragUploadEdit.vue  |  2 +-
 .../src/views/custom/customerCase/index.vue   | 40 +++++++++++++++++--
 6 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java
index 02164aad6..aa4f90018 100644
--- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java
+++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java
@@ -57,6 +57,7 @@ public class SysCustomerCaseController extends BaseController
     public TableDataInfo list(SysCustomerCase sysCustomerCase)
     {
         startPage();
+        sysCustomerCase.setKeywordArray(StringUtils.isNotEmpty(sysCustomerCase.getKeyword()) ? sysCustomerCase.getKeyword().split(",") : null);
         List<SysCustomerCase> list = sysCustomerCaseService.selectSysCustomerCaseList(sysCustomerCase);
         return getDataTable(list);
     }
diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java
index 4a4cfc4f8..1bc94bf0a 100644
--- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java
+++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java
@@ -28,6 +28,8 @@ public class SysCustomerCase extends BaseEntity
     @Excel(name = "关键词")
     private String keyword;
 
+    private String[] keywordArray;
+
     /** 案例所属客户ID */
     private Long customerId;
 
diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml
index 8f1ce69c0..73827a0f3 100644
--- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml
+++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml
@@ -23,16 +23,30 @@
         select id, name, keyword, remark, customer_id, create_time from sys_customer_case
     </sql>
 
+    <sql id="searchKey">
+        <if test="keywordArray != null">
+            <trim prefix="AND (" suffix=")" suffixOverrides="or">
+                <foreach collection="keywordArray"  separator="or" item="typeArray" index="i">
+                    ( scc.keyword like concat('%', #{typeArray}, '%') or scc.name like concat('%', #{typeArray}, '%') or scc.remark like concat('%', #{typeArray}, '%') )
+                </foreach>
+            </trim>
+        </if>
+    </sql>
+
     <select id="selectSysCustomerCaseList" parameterType="SysCustomerCase" resultMap="SysCustomerCaseResult">
         select scc.id, scc.name, scc.keyword, scc.remark, scc.customer_id, scc.create_time,sc.name as customer_name from sys_customer_case scc
         left join sys_customer sc on sc.id = scc.customer_id and sc.del_flag = 0
         where scc.del_flag = 0
-        <if test="name != null  and name != ''">
-            and (scc.name like concat('%', #{name}, '%') OR scc.keyword like concat('%', #{name}, '%') OR scc.remark like concat('%', #{name}, '%'))
-        </if>
+        <!--<if test="name != null  and name != ''">
+            and (scc.name like concat('%', #{name}, '%') OR scc.remark like concat('%', #{name}, '%'))
+        </if>-->
+        <include refid="searchKey">
+            <property name="keywordArray" value="#{keywordArray}"/>
+        </include>
         <if test="customerName != null and customerName != ''">
             and sc.name like concat('%', #{customerName}, '%')
         </if>
+        OR scc.keyword like concat('%', #{name}, '%')
         order by id desc
     </select>
 
diff --git a/stdiet-ui/src/components/FileDownload/MuchFileDown.vue b/stdiet-ui/src/components/FileDownload/MuchFileDown.vue
index 7e54ff43d..1d42e27ea 100644
--- a/stdiet-ui/src/components/FileDownload/MuchFileDown.vue
+++ b/stdiet-ui/src/components/FileDownload/MuchFileDown.vue
@@ -132,7 +132,7 @@ export default {
       downSigleFile(file.downUrl, file.fileName);
     },
     isImage(name){
-      var idx = name.indexOf('.');
+      var idx = name.lastIndexOf(".");
       if (idx === -1) {
         return false;
       }
diff --git a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue
index eb69c4693..14da04c39 100644
--- a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue
+++ b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue
@@ -2,7 +2,7 @@
   <div>
     <div v-for="(item, index) in oldCaseFileList">
       <span style="margin-right: 10px;">
-        {{item.fileName ? (item.fileName.substring(0,15)+"..."): ""}}
+        {{item.fileName.length > 15 ? (item.fileName.substring(0,15)+"...") : item.fileName}}
       </span>
       <el-button style="margin-left: 10px;" type="danger" size="small" @click="removeOldFile(index)">移除该文件</el-button>
     </div>
diff --git a/stdiet-ui/src/views/custom/customerCase/index.vue b/stdiet-ui/src/views/custom/customerCase/index.vue
index a17314f58..9afe6f0ae 100644
--- a/stdiet-ui/src/views/custom/customerCase/index.vue
+++ b/stdiet-ui/src/views/custom/customerCase/index.vue
@@ -1,14 +1,32 @@
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="案例信息" prop="name">
+      <!--<el-form-item label="案例信息" prop="name">
         <el-input
           v-model.trim="queryParams.name"
-          placeholder="请输入案例名称或关键字"
+          placeholder="请输入案例名称或备注"
           clearable
           size="small"
         />
+      </el-form-item>-->
+      <el-form-item label="案例信息" prop="name">
+        <el-select
+          v-model="keywordArray"
+          multiple
+          filterable
+          allow-create
+          clearable
+          default-first-option
+          placeholder="关键词搜索" style="width: 100%;">
+          <el-option
+            v-for="dict in caseKeyOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue">
+          </el-option>
+        </el-select>
       </el-form-item>
+
       <el-form-item label="客户姓名" prop="customerName">
         <el-input
           v-model.trim="queryParams.customerName"
@@ -149,9 +167,16 @@
             v-model="form.keywordArray"
             multiple
             filterable
+            clearable
             allow-create
             default-first-option
             placeholder="请创建案例关键词,按回车创建,最多20个" style="width: 100%;">
+            <el-option
+              v-for="dict in caseKeyOptions"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="dict.dictValue">
+            </el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="案例备注" prop="remark">
@@ -222,6 +247,7 @@
           pageNum: 1,
           pageSize: 10,
           name: null,
+          keyword: null,
           customerName: null
         },
         // 表单参数
@@ -237,7 +263,9 @@
             { required: true, message: "案例关键词不能为空", trigger: "blur" },
           ],
         },
-        submitFlag: false
+        keywordArray:[],
+        submitFlag: false,
+        caseKeyOptions: [],
       };
     },
     components: {
@@ -250,16 +278,20 @@
     },
     created() {
       this.getList();
+      this.getDicts("case_key").then((response) => {
+        this.caseKeyOptions = response.data;
+      });
     },
     methods: {
       /** 查询客户案例管理列表 */
       getList() {
         this.loading = true;
+        this.queryParams.keyword = this.keywordArray.join(",");
         listCustomerCase(this.queryParams).then(response => {
           this.customerCaseList = response.rows;
           this.total = response.total;
           this.loading = false;
-      });
+        });
       },
       // 取消按钮
       cancel() {