Browse Source

客户全局搜索功能

jwyu 9 months ago
parent
commit
9ac8d7f339

+ 4 - 0
src/api/customer/modules/user.js

@@ -42,6 +42,10 @@ export default {
   //潜在用户转客户
   potentialUserEdit:params=>{
     return post('/user/potential/edit',params)
+  },
+  // 客户全局搜索
+  userGlobalSearch:params=>{
+    return get('/user/global/list',params)
   }
   
 };

+ 1 - 1
src/layout/components/HeaderWrap.vue

@@ -54,7 +54,7 @@ const hasUnRead=ref(false)//是否有未读
     <el-icon size="26px" v-else @click="menuCloseChange"><i-ep-Fold /></el-icon>
     <!-- 面包屑 -->
     <el-breadcrumb separator="/" style="margin-left: 30px">
-      <el-breadcrumb-item v-for="item in breadcrumbArr" :key="item.title" @click="handleClickBreadcrumb(item)">{{
+      <el-breadcrumb-item v-for="item,index in breadcrumbArr" :key="index" @click="handleClickBreadcrumb(item)">{{
         item.title
       }}</el-breadcrumb-item>
     </el-breadcrumb>

+ 8 - 0
src/router/modules/customer.js

@@ -73,6 +73,14 @@ export default[
           fromPath:'/customer/potentialUserList'
         },
       },
+      {
+        path:'userSearch',
+        component:()=>import('@/views/customer/UserSearch.vue'),
+        name:"CustomerUserSearch",
+        meta:{
+          title:'全局检索'
+        },
+      },
     ]
   }
 ]

+ 290 - 0
src/views/customer/UserSearch.vue

@@ -0,0 +1,290 @@
+<script setup>
+import { Search } from '@element-plus/icons-vue'
+import { apiCustomerUser } from '@/api/customer'
+import UserStatisticDetail from './reportStatistic/components/UserStatisticDetail.vue'
+import EnableUser from './components/EnableUser.vue'
+import { useRouter } from 'vue-router'
+
+const router=useRouter()
+
+const filterState = reactive({
+  keyword: '',
+  sortType: '',
+  sortVal: ''
+})
+
+const tableColOpt = [
+  {
+    label: '姓名',
+    key: 'RealName'
+  },
+  {
+    label: '手机号',
+    key: 'Phone'
+  },
+  {
+    label: '邮箱',
+    key: 'Email'
+  },
+  {
+    label: '注册时间',
+    key: 'RegisterTime',
+    sort: true
+  },
+  {
+    label: '最近一次阅读时间',
+    key: 'LastUpdateTime',
+    sort: true
+  },
+  {
+    label: '累计阅读次数',
+    key: 'ReadCnt',
+    sort: true,
+  },
+]
+const userList = ref([])
+const page = ref(1)
+const pageSize = ref(10)
+const tableLoading = ref(false)
+const totals = ref(0)
+async function getUserList() {
+  if (!filterState.keyword) return
+  tableLoading.value = true
+  const res = await apiCustomerUser.userGlobalSearch({
+    PageSize: pageSize.value,
+    CurrentIndex: page.value,
+    KeyWord: filterState.keyword,
+    SortParam: filterState.sortType,
+    SortType: filterState.sortVal
+  })
+  tableLoading.value = false
+  if (res.Ret === 200) {
+    userList.value = res.Data.List || []
+    totals.value = res.Data.Paging.Totals
+  }
+}
+function handlePageChange(e) {
+  page.value = e
+  getUserList()
+}
+function handleTableSort(e) {
+  // console.log(e);
+  const { order, prop } = e//order:"descending",prop: "RegisterTime"
+  filterState.sortType = prop
+  if (!order) {
+    filterState.sortVal = ''
+  } else {
+    filterState.sortVal = order === 'descending' ? 'desc' : 'asc'
+  }
+
+  handleFilterList()
+}
+function handleFilterList() {
+  page.value = 1
+  totals.value = 0
+  userList.value = []
+  getUserList()
+}
+
+
+const showReadDetail = ref(false)
+const activeUserId = ref(0)
+const activeUserName = ref('')
+function handleShowReadDetail(e) {
+  activeUserId.value = e.UserId
+  activeUserName.value = e.RealName
+  showReadDetail.value = true
+}
+
+// 转客户
+function handleTransFormUser(e) {
+  router.push({
+    path: '/customer/userTransform',
+    query: {
+      id: e.UserId
+    }
+  })
+}
+
+function handleEditUser(e) {
+  const link=router.resolve({
+    path: '/customer/userEdit',
+    query: {
+      id: e.UserId
+    }
+  }).href
+  window.open(link,'__blank')
+}
+
+// 禁用用户
+async function handleDisabledUser(row) {
+  const res = await apiCustomerUser.setUserStatus({
+    UserId: row.UserId,
+    IsEnabled: false
+  })
+  if (res.Ret !== 200) return
+  ElMessage.success('禁用成功')
+  getUserList()
+}
+
+// 启用用户
+const showEnableUserPop = ref(false)
+const enableUserId = ref(0)
+function handleEnableUser(row) {
+  enableUserId.value = row.UserId
+  showEnableUserPop.value = true
+}
+
+// 删除用户
+function handleDelUser(row) {
+  ElMessageBox.confirm(
+    '该操作会删除该用户所有相关信息,不可恢复,确认删除吗?',
+    '提示'
+  ).then(() => {
+    apiCustomerUser.userDelete({
+      UserId: row.UserId
+    }).then(res => {
+      if (res.Ret === 200) {
+        ElMessage.success('删除成功')
+        getUserList()
+      }
+
+    })
+  }).catch(() => { })
+}
+
+// 跳转详情
+function handleGoDetail(e){
+  if(e.Status===1) return
+  const link=router.resolve({
+    path:'/customer/userDetail',
+    query:{
+      id:e.UserId
+    }
+  }).href
+  window.open(link,'__blank')
+}
+
+
+
+</script>
+
+<template>
+  <div class="user-search-page">
+    <el-input
+      placeholder="姓名/手机号/邮箱"
+      v-model="filterState.keyword"
+      :prefix-icon="Search"
+      clearable
+      style="max-width: 359px"
+      @change="handleFilterList"
+    />
+    <div class="userlist-wrap" style="margin-top: 20px">
+      <el-table
+        :data="userList"
+        border
+        highlight-current-row
+        element-loading-text="数据加载中..."
+        v-loading="tableLoading"
+        @sort-change="handleTableSort"
+        @row-click="handleGoDetail"
+      >
+        <el-table-column
+          v-for="column in tableColOpt"
+          :key="column.key"
+          :prop="column.key"
+          :label="column.label"
+          align="center"
+          :sortable="column.sort ? 'custom' : false"
+        >
+          <template v-if="column.headerTips" #header>
+            <span>{{ column.label }}</span>
+            <el-tooltip
+              class="box-item"
+              effect="dark"
+              :content="column.headerTips"
+              placement="top"
+            >
+              <el-icon style="position: relative; top: 2px"
+                ><i-ep-QuestionFilled
+              /></el-icon>
+            </el-tooltip>
+          </template>
+          <template #default="{ row }">
+            <el-button
+              v-if="column.key === 'ReadCnt' && row.ReadCnt > 0"
+              link
+              type="primary"
+              @click.stop="handleShowReadDetail(row)"
+              >{{ row.ReadCnt }}</el-button
+            >
+            <span v-else>{{ row[column.key] || "--" }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" align="center" width="200">
+          <template #default="{ row }">
+            <!-- 潜在 -->
+            <template v-if="row.Status === 1">
+              <el-button
+                type="primary"
+                v-permission="'user:transform'"
+                link
+                @click="handleTransFormUser(row)"
+                >转客户</el-button
+              >
+            </template>
+            <template v-else>
+              <el-button
+                type="primary"
+                link
+                @click.stop="handleEditUser(row)"
+                >编辑</el-button
+              >
+              <el-button
+                type="danger"
+                link
+                v-if="row.Status"
+                @click.stop="handleDisabledUser(row)"
+                >禁用</el-button
+              >
+              <el-button
+                type="primary"
+                link
+                v-else
+                @click.stop="handleEnableUser(row)"
+                >启用</el-button
+              >
+              <el-button
+                type="danger"
+                link
+                @click.stop="handleDelUser(row)"
+                >删除</el-button
+              >
+            </template>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        background
+        layout="total,prev,pager,next,jumper"
+        :current-page="page"
+        :page-size="pageSize"
+        :total="totals"
+        @current-change="handlePageChange"
+        style="margin-top: 30px; justify-content: flex-end"
+      />
+    </div>
+  </div>
+  <!-- 阅读统计 -->
+  <UserStatisticDetail
+    v-model:show="showReadDetail"
+    :userId="activeUserId"
+    :userName="activeUserName"
+  />
+  <!-- 开启用户 -->
+  <EnableUser
+    v-model:show="showEnableUserPop"
+    :userId="enableUserId"
+    @success="getUserList()"
+  />
+</template>

+ 4 - 0
src/views/report/pdf/List.vue

@@ -36,6 +36,10 @@ const tableColOpt = [
     key: 'State',
     width: '100px'
   },
+  {
+    label: '创建人',
+    key: 'SysRealName'
+  },
   {
     label: '发布时间',
     key: 'PublishTime',

+ 4 - 0
src/views/report/pdf/components/EditPdf.vue

@@ -46,6 +46,10 @@ watch(()=>show.value,(n)=>{
 function handleUploadSuccess(e) {
   formData.fileUrl = e.Url
   formData.fileName = e.FileName
+  if(!formData.title){
+    formData.title=e.FileName
+  }
+  
 }
 
 async function onSubmit() {