Sfoglia il codice sorgente

im绑定好友兼容优化

yjwang 6 ore fa
parent
commit
4167815fe3
2 ha cambiato i file con 53 aggiunte e 3 eliminazioni
  1. 8 0
      src/api/his/friendship.js
  2. 45 3
      src/views/app/imAddFriend/index.vue

+ 8 - 0
src/api/his/friendship.js

@@ -9,6 +9,14 @@ export function listImFriendshipBind(query) {
   })
 }
 
+// 查询 IM 绑定可选销售列表(管理员看全部,销售仅看自己)
+export function listBindCompanyUser() {
+  return request({
+    url: '/his/friendship/bindCompanyUserList',
+    method: 'get'
+  })
+}
+
 // 查询可绑定用户列表
 export function listBindUser(query) {
   return request({

+ 45 - 3
src/views/app/imAddFriend/index.vue

@@ -103,6 +103,22 @@
               <el-radio :label="2">自动发课添加好友</el-radio>
             </el-radio-group>
           </el-form-item>
+          <el-form-item v-if="bindForm.addType === 1" label="所属销售">
+            <el-select
+              v-model="bindForm.companyUserId"
+              placeholder="请选择销售(不选则绑定当前登录销售)"
+              clearable
+              filterable
+              style="width: 320px"
+            >
+              <el-option
+                v-for="item in companyUserList"
+                :key="item.userId"
+                :label="formatCompanyUserLabel(item)"
+                :value="item.userId"
+              />
+            </el-select>
+          </el-form-item>
         </el-form>
 
         <el-divider content-position="left">选择用户</el-divider>
@@ -233,6 +249,7 @@
 <script>
 import {
   listImFriendshipBind,
+  listBindCompanyUser,
   listBindUser,
   listBindExternalContact,
   addUserAndSaleFriend
@@ -258,8 +275,10 @@ export default {
         companyUserNickName: null
       },
       bindForm: {
-        addType: 1
+        addType: 1,
+        companyUserId: null
       },
+      companyUserList: [],
       userLoading: false,
       userList: [],
       userTotal: 0,
@@ -289,8 +308,26 @@ export default {
   },
   created() {
     this.getList()
+    this.loadCompanyUserList()
   },
   methods: {
+    loadCompanyUserList() {
+      listBindCompanyUser().then(res => {
+        if (res.code === 200) {
+          this.companyUserList = res.data || []
+          if (this.companyUserList.length === 1) {
+            this.bindForm.companyUserId = this.companyUserList[0].userId
+          }
+        }
+      })
+    },
+    formatCompanyUserLabel(item) {
+      if (!item) {
+        return ''
+      }
+      const name = item.nickName || item.userName || ''
+      return name ? `${name}(${item.userId})` : String(item.userId)
+    },
     getList() {
       this.loading = true
       listImFriendshipBind(this.queryParams).then(response => {
@@ -310,6 +347,7 @@ export default {
       this.handleQuery()
     },
     handleAddTypeChange() {
+      this.bindForm.companyUserId = null
       this.selectedUsers = []
       this.selectedUser = null
       this.selectedExternal = null
@@ -403,10 +441,14 @@ export default {
           return
         }
         this.submitLoading = true
-        addUserAndSaleFriend({
+        const payload = {
           addType: 1,
           userIds: this.selectedUsers.map(item => this.resolveRowUserId(item))
-        }).then(res => {
+        }
+        if (this.bindForm.companyUserId != null && this.bindForm.companyUserId !== '') {
+          payload.companyUserId = this.bindForm.companyUserId
+        }
+        addUserAndSaleFriend(payload).then(res => {
           this.$message.success(res.msg || '操作成功')
           this.handleAddTypeChange()
           this.activeTab = 'list'