Lijy hai 6 meses
pai
achega
baa44044df

+ 40 - 15
fhKeeper/formulahousekeeper/customerBuler-crm/src/components/translationComponent/personnelSearch/personnelSearch.vue

@@ -1,5 +1,6 @@
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject, watchEffect, computed } from 'vue';
+import { debounce } from 'lodash';
 import { storeToRefs } from 'pinia';
 import { Emits, optionsType } from './type';
 import { useStore } from '@/store/index'
@@ -15,41 +16,65 @@ const props = defineProps({
   options: { type: Array as () => optionsType, required: false, default: () => [] },
 });
 const emit = defineEmits<Emits>();
-const { userInfo } = storeToRefs(useStore());
+const personnelArray = ref<optionsType>([]);
+const { userInfo, personnelList } = storeToRefs(useStore());
+const { setValue, getPersonnelListItems } = useStore()
 
 const timeRef = generateUniqueId()
+const selectLoading = ref(false);
 const controlTranslation = reactive({
   visibleFlag: false
 })
 
 const selectedValue = ref(props.modelValue); // 响应式绑定 v-model 的值
 
-// function getUserList(keyword: string = '', flag: boolean = true) {
-//   post(`/user/getEmployeeList`, {
-//     keyword,
-//     status: 3,
-//     matchingType: 0,
-//   })
-// }
+function getUserList(keyword: string = '') {
+  post(`/user/getSimpleActiveUserListNew`, { keyword }).then(res => {
+    personnelArray.value = res.data
+    if(!keyword) {
+      setValue((res.data || []), 'personnelList')
+    }
+  }).finally(() => {
+    selectLoading.value = false
+  })
+}
 
 function visibleChange(visible: boolean) { // 下拉框出现/隐藏时触发
-  console.log(visible, '<==== visible')
   controlTranslation.visibleFlag = visible
 }
+
+const filterMethod = debounce(filterMethods, 500)
+function filterMethods(val: string) {
+  if(val == '') {
+    personnelArray.value = personnelList.value
+    selectLoading.value = false
+    return
+  }
+  getUserList(val)
+}
+
 function updateValue(val: any) { // 值改变的时候触发
   emit('update:modelValue', selectedValue.value)
   emit('change', val)
 }
 
-console.log(props, userInfo, '<==== 看看数据')
+onMounted(() => {
+  if(personnelList.value.length == 0) {
+    getUserList()
+  } else {
+    personnelArray.value = personnelList.value
+  }
+})
+
+console.log(props, userInfo.value, '<==== 看看数据')
 </script>
 
 <template>
-  <el-select v-model="selectedValue" :ref="`selectRef${timeRef}`" :multiple="multiple" :size="size"
-    :placeholder="placeholder" :disabled="disabled" clearable collapse-tags @change="updateValue"
-    @visible-change="visibleChange">
-    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
-  </el-select>
+  <!-- <el-select v-model="selectedValue" :ref="`selectRef${timeRef}`" :multiple="multiple" :size="size" :loading="selectLoading"
+    :placeholder="placeholder" :disabled="disabled" clearable collapse-tags filterable @change="updateValue"
+    @visible-change="visibleChange" :filter-method="(val: string) => {selectLoading = true, filterMethod(val)}">
+    <el-option v-for="item in personnelArray" :key="item.value" :label="item.label" :value="item.value"></el-option>
+  </el-select> -->
 </template>
 
 <style lang="scss" scoped></style>

+ 1 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/analysis/index.vue

@@ -187,7 +187,7 @@ watchEffect(() => {
           </el-select>
         </div>
         <div class="w-40">
-          <personnel-search v-model="selectVal" disabled multiple placeholder="你好世界" @change="selectChange"></personnel-search>
+          <personnel-search v-model="selectVal" placeholder="你好世界" @change="selectChange"></personnel-search>
           <el-select
             ref="select1"
             size="small"

+ 3 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/home.vue

@@ -82,7 +82,9 @@ const agentConfig = () => {
 onMounted(async () => {
   await nextTick();
   isLoading.value = false;
-  agentConfig()
+  if (userInfo.value.userNameNeedTranslate == 1) {
+    agentConfig()
+  }
 });
 </script>
 

+ 2 - 0
fhKeeper/formulahousekeeper/customerBuler-crm/src/store/Store.d.ts

@@ -2,10 +2,12 @@ type SotreState = {
   userInfo: any;
   routers: RouteRecordRaw[];
   asyncRoutesMark: boolean;
+  personnelList: any[]
 };
 type SoreGetters = {
   getRoutersList: () => RouteRecordRaw[];
   getToken: () => string;
+  getPersonnelListItems: (val: any) => any;
 };
 type SotreActions = {
   setRouters(arr: any): void;

+ 10 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/store/index.ts

@@ -10,6 +10,7 @@ export const useStore = defineStore<
     userInfo: {}, // 当前的用户信息
     routers: [], // 返回的所有路由
     asyncRoutesMark: false, // 是否添加过路由
+    personnelList: [], // 人员列表
   }),
   getters: {
     getRoutersList() {
@@ -17,7 +18,14 @@ export const useStore = defineStore<
     },
     getToken() {
       return this.userInfo?.id || "";
-    }
+    },
+    getPersonnelListItems(val) {
+      let value = val;
+      if(Array.isArray(val)) {
+        value = val[0]
+      }
+      return this.personnelList.find(item => item.value == value)
+    },
   },
   actions: {
     // 方法
@@ -48,6 +56,7 @@ export const useStore = defineStore<
       sessionStorage.clear();
       this.userInfo = {};
       this.routers = [];
+      this.personnelList = [];
       this.asyncRoutesMark = false;
     },
   },