refactor(frontend): 统一当前登录用户 ID 获取入口
- 新增 getCurrentUserId 到 utils/auth - 替换 IM、CRM、BPM、MES、Mall 等模块中直接读取 userStore.getUser.id 的写法 - 移除 IM 内部 currentUser 工具依赖,统一从全局 auth 工具获取当前用户编号 - 保留 userStore 对昵称、头像、部门等非 ID 字段的读取im
parent
763e11eb78
commit
89a49cf19c
|
|
@ -2,7 +2,7 @@ import request from '@/config/axios'
|
||||||
import { isEmpty } from '@/utils/is'
|
import { isEmpty } from '@/utils/is'
|
||||||
import { ApiSelectProps } from '@/components/FormCreate/src/type'
|
import { ApiSelectProps } from '@/components/FormCreate/src/type'
|
||||||
import { jsonParse } from '@/utils'
|
import { jsonParse } from '@/utils'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
export const useApiSelect = (option: ApiSelectProps) => {
|
export const useApiSelect = (option: ApiSelectProps) => {
|
||||||
return defineComponent({
|
return defineComponent({
|
||||||
|
|
@ -99,9 +99,7 @@ export const useApiSelect = (option: ApiSelectProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前用户 ID
|
// 获取当前用户 ID
|
||||||
const userStore = useUserStoreWithOut()
|
const currentUserId = getCurrentUserId()
|
||||||
const user = userStore.getUser
|
|
||||||
const currentUserId = user?.id
|
|
||||||
if (currentUserId) {
|
if (currentUserId) {
|
||||||
// 根据多选/单选模式设置默认值
|
// 根据多选/单选模式设置默认值
|
||||||
const defaultValue = props.multiple ? [currentUserId] : currentUserId
|
const defaultValue = props.multiple ? [currentUserId] : currentUserId
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,12 @@ export const formatToken = (token: string): string => {
|
||||||
}
|
}
|
||||||
// ========== 账号相关 ==========
|
// ========== 账号相关 ==========
|
||||||
|
|
||||||
|
/** 获取当前登录用户编号 */
|
||||||
|
export const getCurrentUserId = (): number => {
|
||||||
|
const user = wsCache.get(CACHE_KEY.USER)?.user
|
||||||
|
return Number(user?.id) || 0
|
||||||
|
}
|
||||||
|
|
||||||
export type LoginFormType = {
|
export type LoginFormType = {
|
||||||
tenantName: string
|
tenantName: string
|
||||||
username: string
|
username: string
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ import * as FormApi from '@/api/bpm/form'
|
||||||
import { setConfAndFields2 } from '@/utils/formCreate'
|
import { setConfAndFields2 } from '@/utils/formCreate'
|
||||||
import { BpmModelFormType } from '@/utils/constants'
|
import { BpmModelFormType } from '@/utils/constants'
|
||||||
import { checkPermi } from '@/utils/permission'
|
import { checkPermi } from '@/utils/permission'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useAppStore } from '@/store/modules/app'
|
import { useAppStore } from '@/store/modules/app'
|
||||||
import { cloneDeep, isEqual } from 'lodash-es'
|
import { cloneDeep, isEqual } from 'lodash-es'
|
||||||
import { useDebounceFn } from '@vueuse/core'
|
import { useDebounceFn } from '@vueuse/core'
|
||||||
|
|
@ -333,7 +333,6 @@ const emit = defineEmits(['success'])
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const { push } = useRouter() // 路由
|
const { push } = useRouter() // 路由
|
||||||
const userStore = useUserStoreWithOut() // 用户信息缓存
|
|
||||||
const isDark = computed(() => useAppStore().getIsDark) // 是否黑暗模式
|
const isDark = computed(() => useAppStore().getIsDark) // 是否黑暗模式
|
||||||
const router = useRouter() // 路由
|
const router = useRouter() // 路由
|
||||||
|
|
||||||
|
|
@ -501,7 +500,7 @@ const handleFormDetail = async (row: any) => {
|
||||||
|
|
||||||
/** 判断是否可以操作 */
|
/** 判断是否可以操作 */
|
||||||
const isManagerUser = (row: any) => {
|
const isManagerUser = (row: any) => {
|
||||||
const userId = userStore.getUser.id
|
const userId = getCurrentUserId()
|
||||||
return row.managerUserIds && row.managerUserIds.includes(userId)
|
return row.managerUserIds && row.managerUserIds.includes(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { useTagsViewStore } from '@/store/modules/tagsView'
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import * as ModelApi from '@/api/bpm/model'
|
import * as ModelApi from '@/api/bpm/model'
|
||||||
import * as FormApi from '@/api/bpm/form'
|
import * as FormApi from '@/api/bpm/form'
|
||||||
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
|
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
|
||||||
|
|
@ -107,7 +107,6 @@ const { delView } = useTagsViewStore() // 视图操作
|
||||||
const tagsView = useTagsView()
|
const tagsView = useTagsView()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const userStore = useUserStoreWithOut()
|
|
||||||
|
|
||||||
// 组件引用
|
// 组件引用
|
||||||
const basicInfoRef = ref()
|
const basicInfoRef = ref()
|
||||||
|
|
@ -237,7 +236,7 @@ const initData = async () => {
|
||||||
} else {
|
} else {
|
||||||
// 情况三:新增场景
|
// 情况三:新增场景
|
||||||
formData.value.startUserType = 0 // 全体
|
formData.value.startUserType = 0 // 全体
|
||||||
formData.value.managerUserIds.push(userStore.getUser.id)
|
formData.value.managerUserIds.push(getCurrentUserId())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取表单列表
|
// 获取表单列表
|
||||||
|
|
|
||||||
|
|
@ -513,7 +513,7 @@
|
||||||
<SignDialog ref="signRef" @success="handleSignFinish" />
|
<SignDialog ref="signRef" @success="handleSignFinish" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { setConfAndFields2 } from '@/utils/formCreate'
|
import { setConfAndFields2 } from '@/utils/formCreate'
|
||||||
import * as TaskApi from '@/api/bpm/task'
|
import * as TaskApi from '@/api/bpm/task'
|
||||||
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
||||||
|
|
@ -535,7 +535,7 @@ defineOptions({ name: 'ProcessInstanceBtnContainer' })
|
||||||
const router = useRouter() // 路由
|
const router = useRouter() // 路由
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const userId = useUserStoreWithOut().getUser.id // 当前登录的编号
|
const userId = getCurrentUserId() // 当前登录的编号
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ import * as BusinessApi from '@/api/crm/business'
|
||||||
import * as BusinessStatusApi from '@/api/crm/business/status'
|
import * as BusinessStatusApi from '@/api/crm/business/status'
|
||||||
import * as CustomerApi from '@/api/crm/customer'
|
import * as CustomerApi from '@/api/crm/customer'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import BusinessProductForm from './components/BusinessProductForm.vue'
|
import BusinessProductForm from './components/BusinessProductForm.vue'
|
||||||
import { erpPriceMultiply, erpPriceInputFormatter } from '@/utils'
|
import { erpPriceMultiply, erpPriceInputFormatter } from '@/utils'
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ const open = async (type: string, id?: number, customerId?: number, contactId?:
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ import * as ClueApi from '@/api/crm/clue'
|
||||||
import * as AreaApi from '@/api/system/area'
|
import * as AreaApi from '@/api/system/area'
|
||||||
import { defaultProps } from '@/utils/tree'
|
import { defaultProps } from '@/utils/tree'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
@ -205,7 +205,7 @@ const open = async (type: string, id?: number) => {
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ import * as UserApi from '@/api/system/user'
|
||||||
import * as CustomerApi from '@/api/crm/customer'
|
import * as CustomerApi from '@/api/crm/customer'
|
||||||
import * as AreaApi from '@/api/system/area'
|
import * as AreaApi from '@/api/system/area'
|
||||||
import { defaultProps } from '@/utils/tree'
|
import { defaultProps } from '@/utils/tree'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
@ -252,7 +252,7 @@ const open = async (type: string, id?: number, customerId?: number, businessId?:
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ import * as UserApi from '@/api/system/user'
|
||||||
import * as ContactApi from '@/api/crm/contact'
|
import * as ContactApi from '@/api/crm/contact'
|
||||||
import * as BusinessApi from '@/api/crm/business'
|
import * as BusinessApi from '@/api/crm/business'
|
||||||
import { erpPriceMultiply, erpPriceInputFormatter } from '@/utils'
|
import { erpPriceMultiply, erpPriceInputFormatter } from '@/utils'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import ContractProductForm from '@/views/crm/contract/components/ContractProductForm.vue'
|
import ContractProductForm from '@/views/crm/contract/components/ContractProductForm.vue'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
@ -284,7 +284,7 @@ const open = async (type: string, id?: number) => {
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
// 获取联系人
|
// 获取联系人
|
||||||
contactList.value = await ContactApi.getSimpleContactList()
|
contactList.value = await ContactApi.getSimpleContactList()
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ import * as CustomerApi from '@/api/crm/customer'
|
||||||
import * as AreaApi from '@/api/system/area'
|
import * as AreaApi from '@/api/system/area'
|
||||||
import { defaultProps } from '@/utils/tree'
|
import { defaultProps } from '@/utils/tree'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
@ -205,7 +205,7 @@ const open = async (type: string, id?: number) => {
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ import * as CustomerApi from '@/api/crm/customer'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import type { UploadUserFile } from 'element-plus'
|
import type { UploadUserFile } from 'element-plus'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
defineOptions({ name: 'CrmCustomerImportForm' })
|
defineOptions({ name: 'CrmCustomerImportForm' })
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ const open = async () => {
|
||||||
await resetForm()
|
await resetForm()
|
||||||
// 获得用户列表
|
// 获得用户列表
|
||||||
userOptions.value = await UserApi.getSimpleUserList()
|
userOptions.value = await UserApi.getSimpleUserList()
|
||||||
ownerUserId.value = useUserStore().getUser.id
|
ownerUserId.value = getCurrentUserId()
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import { ElTable } from 'element-plus'
|
import { ElTable } from 'element-plus'
|
||||||
import * as PermissionApi from '@/api/crm/permission'
|
import * as PermissionApi from '@/api/crm/permission'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import CrmPermissionForm from './PermissionForm.vue'
|
import CrmPermissionForm from './PermissionForm.vue'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
|
||||||
|
|
@ -64,7 +64,6 @@ const list = ref<PermissionApi.PermissionVO[]>([]) // 列表的数据
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
ownerUserId: 0
|
ownerUserId: 0
|
||||||
})
|
})
|
||||||
const userStore = useUserStoreWithOut() // 用户信息缓存
|
|
||||||
|
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
|
@ -75,13 +74,14 @@ const getList = async () => {
|
||||||
bizId: props.bizId
|
bizId: props.bizId
|
||||||
})
|
})
|
||||||
list.value = data
|
list.value = data
|
||||||
|
const currentUserId = getCurrentUserId()
|
||||||
const permission = list.value.find(
|
const permission = list.value.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.userId === userStore.getUser.id &&
|
item.userId === currentUserId &&
|
||||||
item.level === PermissionApi.PermissionLevelEnum.OWNER
|
item.level === PermissionApi.PermissionLevelEnum.OWNER
|
||||||
)
|
)
|
||||||
if (permission) {
|
if (permission) {
|
||||||
formData.value.ownerUserId = userStore.getUser.id
|
formData.value.ownerUserId = currentUserId
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|
@ -150,7 +150,7 @@ watch(
|
||||||
)
|
)
|
||||||
validateOwnerUser.value = false
|
validateOwnerUser.value = false
|
||||||
validateWrite.value = false
|
validateWrite.value = false
|
||||||
const userId = userStore.getUser?.id
|
const userId = getCurrentUserId()
|
||||||
list.value
|
list.value
|
||||||
.filter((item) => item.userId === userId)
|
.filter((item) => item.userId === userId)
|
||||||
.forEach((item) => {
|
.forEach((item) => {
|
||||||
|
|
@ -176,15 +176,16 @@ const emits = defineEmits<{
|
||||||
}>()
|
}>()
|
||||||
/** 退出团队 */
|
/** 退出团队 */
|
||||||
const handleQuit = async () => {
|
const handleQuit = async () => {
|
||||||
|
const currentUserId = getCurrentUserId()
|
||||||
const permission = list.value.find(
|
const permission = list.value.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.userId === userStore.getUser.id && item.level === PermissionApi.PermissionLevelEnum.OWNER
|
item.userId === currentUserId && item.level === PermissionApi.PermissionLevelEnum.OWNER
|
||||||
)
|
)
|
||||||
if (permission) {
|
if (permission) {
|
||||||
message.warning('负责人不能退出团队!')
|
message.warning('负责人不能退出团队!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const userPermission = list.value.find((item) => item.userId === userStore.getUser.id)
|
const userPermission = list.value.find((item) => item.userId === currentUserId)
|
||||||
if (!userPermission) {
|
if (!userPermission) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ import * as ProductApi from '@/api/crm/product'
|
||||||
import * as ProductCategoryApi from '@/api/crm/product/category'
|
import * as ProductCategoryApi from '@/api/crm/product/category'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
defineOptions({ name: 'CrmProductForm' })
|
defineOptions({ name: 'CrmProductForm' })
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const dialogTitle = ref('') // 弹窗的标题
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
const userId = useUserStore().getUser.id // 当前登录的编号
|
const userId = getCurrentUserId() // 当前登录的编号
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ import { ReceivableVO } from '@/api/crm/receivable'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import * as CustomerApi from '@/api/crm/customer'
|
import * as CustomerApi from '@/api/crm/customer'
|
||||||
import * as ContractApi from '@/api/crm/contract'
|
import * as ContractApi from '@/api/crm/contract'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
@ -200,7 +200,7 @@ const open = async (
|
||||||
customerList.value = await CustomerApi.getCustomerSimpleList()
|
customerList.value = await CustomerApi.getCustomerSimpleList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
// 从回款计划创建回款
|
// 从回款计划创建回款
|
||||||
if (receivablePlan) {
|
if (receivablePlan) {
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
|
||||||
import * as UserApi from '@/api/system/user'
|
import * as UserApi from '@/api/system/user'
|
||||||
import * as CustomerApi from '@/api/crm/customer'
|
import * as CustomerApi from '@/api/crm/customer'
|
||||||
import * as ContractApi from '@/api/crm/contract'
|
import * as ContractApi from '@/api/crm/contract'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { cloneDeep } from 'lodash-es'
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ const open = async (type: string, id?: number, customerId?: number, contractId?:
|
||||||
customerList.value = await CustomerApi.getCustomerSimpleList()
|
customerList.value = await CustomerApi.getCustomerSimpleList()
|
||||||
// 默认新建时选中自己
|
// 默认新建时选中自己
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
formData.value.ownerUserId = useUserStore().getUser.id
|
formData.value.ownerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
// 设置 customerId 和 contractId 默认值
|
// 设置 customerId 和 contractId 默认值
|
||||||
if (customerId) {
|
if (customerId) {
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ import { useUserStore } from '@/store/modules/user'
|
||||||
|
|
||||||
import UserAvatar from '../user/UserAvatar.vue'
|
import UserAvatar from '../user/UserAvatar.vue'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
import { getCurrentUserId } from '../../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { ImFriendAddSource } from '../../../utils/constants'
|
import { ImFriendAddSource } from '../../../utils/constants'
|
||||||
import { getGenderColor, getGenderIcon } from '../../../utils/user'
|
import { getGenderColor, getGenderIcon } from '../../../utils/user'
|
||||||
import { getSimpleUserListByNickname, type UserVO } from '@/api/system/user'
|
import { getSimpleUserListByNickname, type UserVO } from '@/api/system/user'
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
import GroupAvatar from './GroupAvatar.vue'
|
import GroupAvatar from './GroupAvatar.vue'
|
||||||
import GroupMemberGrid from './GroupMemberGrid.vue'
|
import GroupMemberGrid from './GroupMemberGrid.vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
import { useGroupStore } from '../../store/groupStore'
|
import { useGroupStore } from '../../store/groupStore'
|
||||||
|
|
@ -70,7 +70,6 @@ const emit = defineEmits<{
|
||||||
apply: [group: GroupLite]
|
apply: [group: GroupLite]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const friendStore = useFriendStore()
|
const friendStore = useFriendStore()
|
||||||
|
|
||||||
|
|
@ -91,7 +90,7 @@ const isMember = computed(() => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (cached.membersLoaded && cached.members) {
|
if (cached.membersLoaded && cached.members) {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
return cached.members.some(
|
return cached.members.some(
|
||||||
(m) => m.userId === myId && m.status === CommonStatusEnum.ENABLE
|
(m) => m.userId === myId && m.status === CommonStatusEnum.ENABLE
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { inviteGroupMember } from '@/api/im/group/member'
|
import { inviteGroupMember } from '@/api/im/group/member'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
import { useGroupStore } from '../../store/groupStore'
|
import { useGroupStore } from '../../store/groupStore'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { ImGroupMemberRole } from '@/views/im/utils/constants'
|
import { ImGroupMemberRole } from '@/views/im/utils/constants'
|
||||||
import { GROUP_MAX_MEMBER } from '@/views/im/utils/config'
|
import { GROUP_MAX_MEMBER } from '@/views/im/utils/config'
|
||||||
import FriendPickerPanel from '../picker/FriendPickerPanel.vue'
|
import FriendPickerPanel from '../picker/FriendPickerPanel.vue'
|
||||||
|
|
@ -53,7 +53,6 @@ const emit = defineEmits<{
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const friendStore = useFriendStore()
|
const friendStore = useFriendStore()
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
|
@ -99,7 +98,7 @@ const willGoApproval = computed(() => {
|
||||||
if (!group?.joinApproval) {
|
if (!group?.joinApproval) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
if (!myId) {
|
if (!myId) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ import {
|
||||||
ImConversationType
|
ImConversationType
|
||||||
} from '@/views/im/utils/constants'
|
} from '@/views/im/utils/constants'
|
||||||
import { RTC_NO_ANSWER_CALL_CHECK_INTERVAL_MS } from '@/views/im/utils/config'
|
import { RTC_NO_ANSWER_CALL_CHECK_INTERVAL_MS } from '@/views/im/utils/config'
|
||||||
import { getCurrentUserId } from '@/views/im/utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { getSenderAvatar, getSenderDisplayName } from '@/views/im/utils/user'
|
import { getSenderAvatar, getSenderDisplayName } from '@/views/im/utils/user'
|
||||||
import { Track } from 'livekit-client'
|
import { Track } from 'livekit-client'
|
||||||
import RtcCallInviting from './RtcCallInviting.vue'
|
import RtcCallInviting from './RtcCallInviting.vue'
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useGroupStore } from '../../store/groupStore'
|
import { useGroupStore } from '../../store/groupStore'
|
||||||
import { getCurrentUserId } from '@/views/im/utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import GroupMemberPickerPanel from '../picker/GroupMemberPickerPanel.vue'
|
import GroupMemberPickerPanel from '../picker/GroupMemberPickerPanel.vue'
|
||||||
import type { GroupMemberLite } from '../group/GroupMember.vue'
|
import type { GroupMemberLite } from '../group/GroupMember.vue'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ import { useRtcStore } from '../../store/rtcStore'
|
||||||
import { useGroupCallMembers } from '../../composables/useGroupCallMembers'
|
import { useGroupCallMembers } from '../../composables/useGroupCallMembers'
|
||||||
import { joinCall, getActiveCall } from '@/api/im/rtc'
|
import { joinCall, getActiveCall } from '@/api/im/rtc'
|
||||||
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
import { getCurrentUserId } from '@/views/im/utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
groupId: number
|
groupId: number
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
import { computed, onMounted, onUnmounted } from 'vue'
|
import { computed, onMounted, onUnmounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useImUiStore } from '../../store/uiStore'
|
import { useImUiStore } from '../../store/uiStore'
|
||||||
import { useConversationStore } from '../../store/conversationStore'
|
import { useConversationStore } from '../../store/conversationStore'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
|
|
@ -44,14 +44,13 @@ defineOptions({ name: 'ImUserInfoCard' })
|
||||||
const uiStore = useImUiStore()
|
const uiStore = useImUiStore()
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const friendStore = useFriendStore()
|
const friendStore = useFriendStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const card = computed(() => uiStore.userInfoCard)
|
const card = computed(() => uiStore.userInfoCard)
|
||||||
const user = computed(() => card.value.user)
|
const user = computed(() => card.value.user)
|
||||||
|
|
||||||
const isSelf = computed(() => {
|
const isSelf = computed(() => {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
return !!user.value?.id && user.value.id === myId
|
return !!user.value?.id && user.value.id === myId
|
||||||
})
|
})
|
||||||
const isActiveFriend = computed(() => {
|
const isActiveFriend = computed(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { updateFile } from '@/api/infra/file'
|
import { updateFile } from '@/api/infra/file'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { isOpenableUrl } from '@/utils/url'
|
import { isOpenableUrl } from '@/utils/url'
|
||||||
|
|
||||||
|
|
@ -157,7 +157,6 @@ export function ensureMediaSizeWithinLimit(
|
||||||
export const useMediaUploader = () => {
|
export const useMediaUploader = () => {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const messageStore = useMessageStore()
|
const messageStore = useMessageStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
const muteOverlay = useMuteOverlay()
|
const muteOverlay = useMuteOverlay()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const { sendRaw } = useMessageSender()
|
const { sendRaw } = useMessageSender()
|
||||||
|
|
@ -193,7 +192,7 @@ export const useMediaUploader = () => {
|
||||||
content: opts.buildContent(blobUrl),
|
content: opts.buildContent(blobUrl),
|
||||||
status: ImMessageStatus.SENDING,
|
status: ImMessageStatus.SENDING,
|
||||||
sendTime: Date.now(),
|
sendTime: Date.now(),
|
||||||
senderId: Number(userStore.getUser?.id) || 0,
|
senderId: getCurrentUserId(),
|
||||||
targetId: conversation.targetId,
|
targetId: conversation.targetId,
|
||||||
selfSend: true,
|
selfSend: true,
|
||||||
uploadProgress: 0,
|
uploadProgress: 0,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import {
|
||||||
} from '../../utils/config'
|
} from '../../utils/config'
|
||||||
import { buildChannelConversationStub } from '../../utils/channel'
|
import { buildChannelConversationStub } from '../../utils/channel'
|
||||||
import { generateClientMessageId, getPrivateMessagePeerId } from '../../utils/message'
|
import { generateClientMessageId, getPrivateMessagePeerId } from '../../utils/message'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import type { Message } from '../types'
|
import type { Message } from '../types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { ImMessageType, ImMessageStatus, ImConversationType } from '../../utils/
|
||||||
import { MESSAGE_PRIVATE_READ_ENABLED, MESSAGE_GROUP_READ_ENABLED } from '../../utils/config'
|
import { MESSAGE_PRIVATE_READ_ENABLED, MESSAGE_GROUP_READ_ENABLED } from '../../utils/config'
|
||||||
import { getClientConversationId } from '../../utils/db'
|
import { getClientConversationId } from '../../utils/db'
|
||||||
import type { Conversation, Message } from '../types'
|
import type { Conversation, Message } from '../types'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
/** 非文本消息的扩展选项(通用) */
|
/** 非文本消息的扩展选项(通用) */
|
||||||
interface SendExtOptions {
|
interface SendExtOptions {
|
||||||
|
|
@ -60,7 +60,6 @@ interface SendExtOptions {
|
||||||
export const useMessageSender = () => {
|
export const useMessageSender = () => {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const messageStore = useMessageStore()
|
const messageStore = useMessageStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
/** 构造本地乐观消息对象 */
|
/** 构造本地乐观消息对象 */
|
||||||
const buildLocalMessage = (opts: {
|
const buildLocalMessage = (opts: {
|
||||||
|
|
@ -76,7 +75,7 @@ export const useMessageSender = () => {
|
||||||
content: opts.content,
|
content: opts.content,
|
||||||
status: ImMessageStatus.SENDING,
|
status: ImMessageStatus.SENDING,
|
||||||
sendTime: Date.now(),
|
sendTime: Date.now(),
|
||||||
senderId: Number(userStore.getUser?.id) || 0,
|
senderId: getCurrentUserId(),
|
||||||
targetId: opts.targetId,
|
targetId: opts.targetId,
|
||||||
selfSend: true,
|
selfSend: true,
|
||||||
atUserIds: opts.atUserIds
|
atUserIds: opts.atUserIds
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { computed, onScopeDispose, ref, type ComputedRef } from 'vue'
|
import { computed, onScopeDispose, ref, type ComputedRef } from 'vue'
|
||||||
|
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useConversationStore } from '../store/conversationStore'
|
import { useConversationStore } from '../store/conversationStore'
|
||||||
import { useGroupStore } from '../store/groupStore'
|
import { useGroupStore } from '../store/groupStore'
|
||||||
import { ImConversationType, ImGroupMemberRole } from '../../utils/constants'
|
import { ImConversationType, ImGroupMemberRole } from '../../utils/constants'
|
||||||
|
|
@ -47,7 +47,6 @@ function unsubscribeNowTick(): void {
|
||||||
export function useMuteOverlay(): ComputedRef<MuteOverlayInfo | null> {
|
export function useMuteOverlay(): ComputedRef<MuteOverlayInfo | null> {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
// 订阅模块级 tick;scope 销毁时反订阅,最后一个订阅者退场后 timer 也跟着清
|
// 订阅模块级 tick;scope 销毁时反订阅,最后一个订阅者退场后 timer 也跟着清
|
||||||
subscribeNowTick()
|
subscribeNowTick()
|
||||||
|
|
@ -62,7 +61,7 @@ export function useMuteOverlay(): ComputedRef<MuteOverlayInfo | null> {
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
// 群封禁:管理后台操作,所有人不可发送
|
// 群封禁:管理后台操作,所有人不可发送
|
||||||
if (group.banned) {
|
if (group.banned) {
|
||||||
return { text: '该群已被管理员封禁,无法发送消息', icon: 'ant-design:stop-outlined' }
|
return { text: '该群已被管理员封禁,无法发送消息', icon: 'ant-design:stop-outlined' }
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ import { ElMessageBox } from 'element-plus'
|
||||||
import UserAvatar from '../../components/user/UserAvatar.vue'
|
import UserAvatar from '../../components/user/UserAvatar.vue'
|
||||||
import UserInfo from '../../components/user/UserInfo.vue'
|
import UserInfo from '../../components/user/UserInfo.vue'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
import { getCurrentUserId } from '../../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { ImFriendRequestHandleResult } from '../../../utils/constants'
|
import { ImFriendRequestHandleResult } from '../../../utils/constants'
|
||||||
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
import type { FriendRequest, User } from '../../types'
|
import type { FriendRequest, User } from '../../types'
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ import { computed, ref } from 'vue'
|
||||||
import Icon from '@/components/Icon/src/Icon.vue'
|
import Icon from '@/components/Icon/src/Icon.vue'
|
||||||
import UserAvatar from '../../components/user/UserAvatar.vue'
|
import UserAvatar from '../../components/user/UserAvatar.vue'
|
||||||
import { useFriendStore } from '../../store/friendStore'
|
import { useFriendStore } from '../../store/friendStore'
|
||||||
import { getCurrentUserId } from '../../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
|
||||||
import type { FriendRequest } from '../../types'
|
import type { FriendRequest } from '../../types'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ import { computed, ref, watch } from 'vue'
|
||||||
import Icon from '@/components/Icon/src/Icon.vue'
|
import Icon from '@/components/Icon/src/Icon.vue'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import {
|
import {
|
||||||
updateGroup,
|
updateGroup,
|
||||||
|
|
@ -436,7 +436,6 @@ const emit = defineEmits<{
|
||||||
'open-history': [] // 点击 "查找聊天内容" 行 → 父组件打开 MessageHistory 弹窗
|
'open-history': [] // 点击 "查找聊天内容" 行 → 父组件打开 MessageHistory 弹窗
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
@ -461,7 +460,7 @@ function handleOpenInvite() {
|
||||||
inviteDialogRef.value?.open({ groupId: props.group.id })
|
inviteDialogRef.value?.open({ groupId: props.group.id })
|
||||||
}
|
}
|
||||||
|
|
||||||
const myId = computed(() => Number(userStore.getUser?.id) || 0)
|
const myId = computed(() => getCurrentUserId())
|
||||||
const isOwner = computed(() => props.group != null && props.group.ownerId === myId.value)
|
const isOwner = computed(() => props.group != null && props.group.ownerId === myId.value)
|
||||||
/** 当前用户在群里的角色(来自 props.members 的 me 行);用于判定是否可移出他人 */
|
/** 当前用户在群里的角色(来自 props.members 的 me 行);用于判定是否可移出他人 */
|
||||||
const myRole = computed(() => props.members.find((m) => m.userId === myId.value)?.role)
|
const myRole = computed(() => props.members.find((m) => m.userId === myId.value)?.role)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ import { computed, ref, useTemplateRef, watch } from 'vue'
|
||||||
import { ElScrollbar } from 'element-plus'
|
import { ElScrollbar } from 'element-plus'
|
||||||
|
|
||||||
import Icon from '@/components/Icon/src/Icon.vue'
|
import Icon from '@/components/Icon/src/Icon.vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { IM_AT_ALL_NICKNAME, IM_AT_ALL_USER_ID } from '@/views/im/utils/constants'
|
import { IM_AT_ALL_NICKNAME, IM_AT_ALL_USER_ID } from '@/views/im/utils/constants'
|
||||||
import GroupMember, { type GroupMemberLite } from '../../../../components/group/GroupMember.vue'
|
import GroupMember, { type GroupMemberLite } from '../../../../components/group/GroupMember.vue'
|
||||||
|
|
@ -92,12 +92,11 @@ const emit = defineEmits<{
|
||||||
select: [member: GroupMemberLite]
|
select: [member: GroupMemberLite]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const scrollRef = useTemplateRef<InstanceType<typeof ElScrollbar>>('scrollRef')
|
const scrollRef = useTemplateRef<InstanceType<typeof ElScrollbar>>('scrollRef')
|
||||||
const activeIdx = ref(0)
|
const activeIdx = ref(0)
|
||||||
|
|
||||||
/** 当前登录用户 id(成员列表过滤掉自己) */
|
/** 当前登录用户 id(成员列表过滤掉自己) */
|
||||||
const selfUserId = computed(() => Number(userStore.getUser?.id) || 0)
|
const selfUserId = computed(() => getCurrentUserId())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 虚拟"所有人"项:群主 / 管理员(canAtAll=true)+ 关键字命中"所有人"前缀时存在
|
* 虚拟"所有人"项:群主 / 管理员(canAtAll=true)+ 关键字命中"所有人"前缀时存在
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ import { useGroupStore } from '@/views/im/home/store/groupStore'
|
||||||
import { useFriendStore } from '@/views/im/home/store/friendStore'
|
import { useFriendStore } from '@/views/im/home/store/friendStore'
|
||||||
import { getMemberDisplayName } from '@/views/im/utils/user'
|
import { getMemberDisplayName } from '@/views/im/utils/user'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useMessageSender } from '@/views/im/home/composables/useMessageSender'
|
import { useMessageSender } from '@/views/im/home/composables/useMessageSender'
|
||||||
import {
|
import {
|
||||||
ensureMediaSizeWithinLimit,
|
ensureMediaSizeWithinLimit,
|
||||||
|
|
@ -199,7 +199,6 @@ defineOptions({ name: 'ImMessageInput' })
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const friendStore = useFriendStore()
|
const friendStore = useFriendStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const { send, sendRaw } = useMessageSender()
|
const { send, sendRaw } = useMessageSender()
|
||||||
const {
|
const {
|
||||||
|
|
@ -654,7 +653,7 @@ const canAtAll = computed<boolean>(() => {
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
if (!myId) {
|
if (!myId) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ import { ImConversationType, ImGroupMemberRole } from '@/views/im/utils/constant
|
||||||
import { unpinGroupMessage as apiUnpinGroupMessage } from '@/api/im/group'
|
import { unpinGroupMessage as apiUnpinGroupMessage } from '@/api/im/group'
|
||||||
import { getSenderDisplayName } from '@/views/im/utils/user'
|
import { getSenderDisplayName } from '@/views/im/utils/user'
|
||||||
import { resolveConversationLastContent } from '@/views/im/utils/conversation'
|
import { resolveConversationLastContent } from '@/views/im/utils/conversation'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useGroupStore } from '../../../../store/groupStore'
|
import { useGroupStore } from '../../../../store/groupStore'
|
||||||
import type { Message } from '../../../../types'
|
import type { Message } from '../../../../types'
|
||||||
|
|
||||||
|
|
@ -97,7 +97,6 @@ const emit = defineEmits<{
|
||||||
locate: [messageId: number]
|
locate: [messageId: number]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
|
|
@ -124,7 +123,7 @@ const latest = computed(() => pinnedMessages.value[pinnedMessages.value.length -
|
||||||
|
|
||||||
/** 当前用户是否群主 / 管理员(决定是否显示「移除」入口) */
|
/** 当前用户是否群主 / 管理员(决定是否显示「移除」入口) */
|
||||||
const canManage = computed(() => {
|
const canManage = computed(() => {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
const role = group.value?.members?.find((m) => m.userId === myId)?.role
|
const role = group.value?.members?.find((m) => m.userId === myId)?.role
|
||||||
return role === ImGroupMemberRole.OWNER || role === ImGroupMemberRole.ADMIN
|
return role === ImGroupMemberRole.OWNER || role === ImGroupMemberRole.ADMIN
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import Icon from '@/components/Icon/src/Icon.vue'
|
import Icon from '@/components/Icon/src/Icon.vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
import { ImGroupMemberRole } from '@/views/im/utils/constants'
|
import { ImGroupMemberRole } from '@/views/im/utils/constants'
|
||||||
import { useGroupStore } from '../../../../store/groupStore'
|
import { useGroupStore } from '../../../../store/groupStore'
|
||||||
|
|
@ -47,7 +47,6 @@ const props = defineProps<{
|
||||||
groupId: number
|
groupId: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const groupRequestStore = useGroupRequestStore()
|
const groupRequestStore = useGroupRequestStore()
|
||||||
|
|
||||||
|
|
@ -64,7 +63,7 @@ const group = computed(() => groupStore.getGroup(props.groupId))
|
||||||
|
|
||||||
/** 当前用户在群里的角色;优先用 group.members,懒加载未到时回退到 ownerUserId 直判 */
|
/** 当前用户在群里的角色;优先用 group.members,懒加载未到时回退到 ownerUserId 直判 */
|
||||||
const myRole = computed(() => {
|
const myRole = computed(() => {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
if (group.value?.ownerUserId === myId) {
|
if (group.value?.ownerUserId === myId) {
|
||||||
return ImGroupMemberRole.OWNER
|
return ImGroupMemberRole.OWNER
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
:class="{ 'flex-row-reverse': message.selfSend }"
|
:class="{ 'flex-row-reverse': message.selfSend }"
|
||||||
>
|
>
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
:id="message.selfSend ? userStore.getUser?.id : message.senderId"
|
:id="message.selfSend ? getCurrentUserId() : message.senderId"
|
||||||
:name="senderRealNickname"
|
:name="senderRealNickname"
|
||||||
:url="message.selfSend ? userStore.getUser?.avatar : senderAvatar"
|
:url="message.selfSend ? userStore.getUser?.avatar : senderAvatar"
|
||||||
:size="36"
|
:size="36"
|
||||||
|
|
@ -95,7 +95,7 @@
|
||||||
<!-- 头像:点击弹 UserInfoCard 由 UserAvatar 内部承接;频道素材消息不显示头像 -->
|
<!-- 头像:点击弹 UserInfoCard 由 UserAvatar 内部承接;频道素材消息不显示头像 -->
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
v-if="!isMaterial"
|
v-if="!isMaterial"
|
||||||
:id="message.selfSend ? userStore.getUser?.id : message.senderId"
|
:id="message.selfSend ? getCurrentUserId() : message.senderId"
|
||||||
:name="senderRealNickname"
|
:name="senderRealNickname"
|
||||||
:url="message.selfSend ? userStore.getUser?.avatar : senderAvatar"
|
:url="message.selfSend ? userStore.getUser?.avatar : senderAvatar"
|
||||||
:size="36"
|
:size="36"
|
||||||
|
|
@ -232,6 +232,7 @@ import {
|
||||||
import { buildRecallTipSegments } from '@/views/im/utils/conversation'
|
import { buildRecallTipSegments } from '@/views/im/utils/conversation'
|
||||||
import { formatTimeTip } from '@/views/im/utils/time'
|
import { formatTimeTip } from '@/views/im/utils/time'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { useUserStore } from '@/store/modules/user'
|
||||||
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useConversationStore } from '../../../../store/conversationStore'
|
import { useConversationStore } from '../../../../store/conversationStore'
|
||||||
import { useGroupStore } from '../../../../store/groupStore'
|
import { useGroupStore } from '../../../../store/groupStore'
|
||||||
import { useFriendStore } from '../../../../store/friendStore'
|
import { useFriendStore } from '../../../../store/friendStore'
|
||||||
|
|
@ -573,7 +574,7 @@ const groupMembersForReadStatus = computed<GroupMemberLite[]>(() => {
|
||||||
|
|
||||||
/** 是否 @我(群消息展示小徽标) */
|
/** 是否 @我(群消息展示小徽标) */
|
||||||
const isAtMe = computed(() => {
|
const isAtMe = computed(() => {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
if (!myId) {
|
if (!myId) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -804,7 +805,7 @@ const currentGroup = computed(() => {
|
||||||
|
|
||||||
/** 当前用户在该群里的角色;私聊或非群成员 → undefined */
|
/** 当前用户在该群里的角色;私聊或非群成员 → undefined */
|
||||||
const myGroupRole = computed(() => {
|
const myGroupRole = computed(() => {
|
||||||
const myId = Number(userStore.getUser?.id) || 0
|
const myId = getCurrentUserId()
|
||||||
return currentGroup.value?.members?.find((m) => m.userId === myId)?.role
|
return currentGroup.value?.members?.find((m) => m.userId === myId)?.role
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ export const useChannelStore = defineStore('imChannelStore', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 用最新的频道信息覆盖已有 CHANNEL 会话的 name / avatar;conversationStore 持久化的旧占位被刷掉 */
|
/** 用最新的频道信息覆盖已有 CHANNEL 会话的 name / avatar */
|
||||||
syncChannelConversationMetadata() {
|
syncChannelConversationMetadata() {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const indexed = new Map(this.channels.map((c) => [c.id, c]))
|
const indexed = new Map(this.channels.map((c) => [c.id, c]))
|
||||||
|
|
@ -84,12 +84,10 @@ export const useChannelStore = defineStore('imChannelStore', {
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (channel.name) {
|
conversationStore.updateConversation(ImConversationType.CHANNEL, conversation.targetId, {
|
||||||
conversation.name = channel.name
|
name: channel.name,
|
||||||
}
|
avatar: channel.avatar
|
||||||
if (channel.avatar) {
|
})
|
||||||
conversation.avatar = channel.avatar
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { store } from '@/store'
|
||||||
import { CONVERSATION_RECENT_FORWARD_MAX } from '../../utils/config'
|
import { CONVERSATION_RECENT_FORWARD_MAX } from '../../utils/config'
|
||||||
import { ImConversationType } from '../../utils/constants'
|
import { ImConversationType } from '../../utils/constants'
|
||||||
import { getClientConversationId, getDb, StorageKeys, type DbTransaction } from '../../utils/db'
|
import { getClientConversationId, getDb, StorageKeys, type DbTransaction } from '../../utils/db'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useMessageStore } from './messageStore'
|
import { useMessageStore } from './messageStore'
|
||||||
import type { Conversation, ConversationDO } from '../types'
|
import type { Conversation, ConversationDO } from '../types'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { useConversationStore } from './conversationStore'
|
||||||
import { ImConversationType, ImFriendRequestHandleResult } from '../../utils/constants'
|
import { ImConversationType, ImFriendRequestHandleResult } from '../../utils/constants'
|
||||||
import { FRIEND_REQUEST_PAGE_SIZE } from '../../utils/config'
|
import { FRIEND_REQUEST_PAGE_SIZE } from '../../utils/config'
|
||||||
import { getDb } from '../../utils/db'
|
import { getDb } from '../../utils/db'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { getFriendDisplayName } from '../../utils/user'
|
import { getFriendDisplayName } from '../../utils/user'
|
||||||
import type { Friend, FriendDO, FriendLite, FriendRequest, FriendRequestDO } from '../types'
|
import type { Friend, FriendDO, FriendLite, FriendRequest, FriendRequestDO } from '../types'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import {
|
||||||
} from '../../utils/constants'
|
} from '../../utils/constants'
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import { getDb } from '../../utils/db'
|
import { getDb } from '../../utils/db'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { getGroupDisplayName } from '../../utils/user'
|
import { getGroupDisplayName } from '../../utils/user'
|
||||||
import { type GroupNotificationPayload } from '../../utils/message'
|
import { type GroupNotificationPayload } from '../../utils/message'
|
||||||
import type { Group, GroupDO, GroupMember, GroupMemberDO, Message } from '../types'
|
import type { Group, GroupDO, GroupMember, GroupMemberDO, Message } from '../types'
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import {
|
||||||
revokeBlobUrlsInContent
|
revokeBlobUrlsInContent
|
||||||
} from '../../utils/message'
|
} from '../../utils/message'
|
||||||
import { resolveConversationLastContent } from '../../utils/conversation'
|
import { resolveConversationLastContent } from '../../utils/conversation'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { tryGetSenderDisplayName } from '../../utils/user'
|
import { tryGetSenderDisplayName } from '../../utils/user'
|
||||||
import { useGroupStore } from './groupStore'
|
import { useGroupStore } from './groupStore'
|
||||||
import { useConversationStore } from './conversationStore'
|
import { useConversationStore } from './conversationStore'
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
type ImRtcParticipantStatusValue,
|
type ImRtcParticipantStatusValue,
|
||||||
type ImRtcCallStageValue
|
type ImRtcCallStageValue
|
||||||
} from '../../utils/constants'
|
} from '../../utils/constants'
|
||||||
import { getCurrentUserId } from '../../utils/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { useFriendStore } from './friendStore'
|
import { useFriendStore } from './friendStore'
|
||||||
import { useGroupStore } from './groupStore'
|
import { useGroupStore } from './groupStore'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { defineStore, acceptHMRUpdate } from 'pinia'
|
import { defineStore, acceptHMRUpdate } from 'pinia'
|
||||||
import { store } from '@/store'
|
import { store } from '@/store'
|
||||||
import { getRefreshToken } from '@/utils/auth'
|
import { getCurrentUserId, getRefreshToken } from '@/utils/auth'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ImWebSocketMessageType,
|
ImWebSocketMessageType,
|
||||||
|
|
@ -476,9 +475,8 @@ export const useImWebSocketStore = defineStore('imWebSocketStore', {
|
||||||
*/
|
*/
|
||||||
handlePrivateMessage(websocketMessage: ImPrivateMessageDTO) {
|
handlePrivateMessage(websocketMessage: ImPrivateMessageDTO) {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
const friendStore = useFriendStore()
|
const friendStore = useFriendStore()
|
||||||
const currentUserId = Number(userStore.getUser?.id) || 0
|
const currentUserId = getCurrentUserId()
|
||||||
|
|
||||||
// 0. 防御层:senderId / receiverId 均不含当前用户的私聊帧直接丢弃,避免后端路由 / 多端串号污染会话
|
// 0. 防御层:senderId / receiverId 均不含当前用户的私聊帧直接丢弃,避免后端路由 / 多端串号污染会话
|
||||||
// (FRIEND_* 等系统通知也走这条通道,但 fromUserId=senderId、toUserId=receiverId 仍是当前用户视角)
|
// (FRIEND_* 等系统通知也走这条通道,但 fromUserId=senderId、toUserId=receiverId 仍是当前用户视角)
|
||||||
|
|
@ -603,9 +601,8 @@ export const useImWebSocketStore = defineStore('imWebSocketStore', {
|
||||||
*/
|
*/
|
||||||
handleGroupMessage(websocketMessage: ImGroupMessageDTO) {
|
handleGroupMessage(websocketMessage: ImGroupMessageDTO) {
|
||||||
const conversationStore = useConversationStore()
|
const conversationStore = useConversationStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
const groupStore = useGroupStore()
|
const groupStore = useGroupStore()
|
||||||
const currentUserId = Number(userStore.getUser?.id) || 0
|
const currentUserId = getCurrentUserId()
|
||||||
const selfSend = websocketMessage.senderId === currentUserId
|
const selfSend = websocketMessage.senderId === currentUserId
|
||||||
|
|
||||||
// 0. 防御层:定向群消息 receiverUserIds 非空且未包含当前用户时丢弃
|
// 0. 防御层:定向群消息 receiverUserIds 非空且未包含当前用户时丢弃
|
||||||
|
|
@ -723,8 +720,7 @@ export const useImWebSocketStore = defineStore('imWebSocketStore', {
|
||||||
* becomeFriends 单条入库后双方收到同一份 payload,payload.friendUserId 固定是 toUserId,本端真正的对端要从帧 sender / receiver 反推
|
* becomeFriends 单条入库后双方收到同一份 payload,payload.friendUserId 固定是 toUserId,本端真正的对端要从帧 sender / receiver 反推
|
||||||
*/
|
*/
|
||||||
computeFriendPeerId(frame: ImPrivateMessageDTO): number {
|
computeFriendPeerId(frame: ImPrivateMessageDTO): number {
|
||||||
const userStore = useUserStore()
|
const currentUserId = getCurrentUserId()
|
||||||
const currentUserId = Number(userStore.getUser?.id) || 0
|
|
||||||
return getPrivateMessagePeerId(frame, currentUserId)
|
return getPrivateMessagePeerId(frame, currentUserId)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { toRaw } from 'vue'
|
import { toRaw } from 'vue'
|
||||||
|
|
||||||
import { getCurrentUserId } from './user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { ImConversationType } from './constants'
|
import { ImConversationType } from './constants'
|
||||||
import type { MessageDO, SettingDO } from '../home/types'
|
import type { MessageDO, SettingDO } from '../home/types'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
ImMessageType,
|
ImMessageType,
|
||||||
type ImConversationTypeValue
|
type ImConversationTypeValue
|
||||||
} from './constants'
|
} from './constants'
|
||||||
import { getCurrentUserId } from './user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { formatCallDuration } from './time'
|
import { formatCallDuration } from './time'
|
||||||
import { useFriendStore } from '../home/store/friendStore'
|
import { useFriendStore } from '../home/store/friendStore'
|
||||||
import { useGroupStore } from '../home/store/groupStore'
|
import { useGroupStore } from '../home/store/groupStore'
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
import { countBy } from 'lodash-es'
|
import { countBy } from 'lodash-es'
|
||||||
|
|
||||||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { useUserStore } from '@/store/modules/user'
|
||||||
import { SystemUserSexEnum } from '@/utils/constants'
|
import { SystemUserSexEnum } from '@/utils/constants'
|
||||||
import {
|
import {
|
||||||
|
|
@ -20,6 +19,7 @@ import {
|
||||||
IM_AT_ALL_NICKNAME,
|
IM_AT_ALL_NICKNAME,
|
||||||
IM_AT_ALL_USER_ID
|
IM_AT_ALL_USER_ID
|
||||||
} from './constants'
|
} from './constants'
|
||||||
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { type MentionCandidate } from './message'
|
import { type MentionCandidate } from './message'
|
||||||
import { useConversationStore } from '../home/store/conversationStore'
|
import { useConversationStore } from '../home/store/conversationStore'
|
||||||
import { useFriendStore } from '../home/store/friendStore'
|
import { useFriendStore } from '../home/store/friendStore'
|
||||||
|
|
@ -31,13 +31,6 @@ import type { Conversation, Friend, Group, User } from '../home/types'
|
||||||
// MessageBubble 的 textSegments 才不会跟着无谓重算
|
// MessageBubble 的 textSegments 才不会跟着无谓重算
|
||||||
const EMPTY_MENTIONS: MentionCandidate[] = []
|
const EMPTY_MENTIONS: MentionCandidate[] = []
|
||||||
|
|
||||||
/** 取当前登录用户编号 */
|
|
||||||
export function getCurrentUserId(): number {
|
|
||||||
const { wsCache } = useCache()
|
|
||||||
const user = wsCache.get(CACHE_KEY.USER)?.user
|
|
||||||
return Number(user?.id) || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 私聊好友显示名:备注 > 真实昵称
|
* 私聊好友显示名:备注 > 真实昵称
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ import { TradeOrderSummaryRespVO } from '@/api/mall/trade/order'
|
||||||
import { DeliveryPickUpStoreVO } from '@/api/mall/trade/delivery/pickUpStore'
|
import { DeliveryPickUpStoreVO } from '@/api/mall/trade/delivery/pickUpStore'
|
||||||
import OrderPickUpForm from '@/views/mall/trade/order/form/OrderPickUpForm.vue'
|
import OrderPickUpForm from '@/views/mall/trade/order/form/OrderPickUpForm.vue'
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
const port = ref('')
|
const port = ref('')
|
||||||
|
|
@ -319,7 +319,7 @@ const pickUpStoreList = ref<DeliveryPickUpStoreVO[]>([])
|
||||||
const getPickUpStoreList = async () => {
|
const getPickUpStoreList = async () => {
|
||||||
pickUpStoreList.value = await PickUpStoreApi.getSimpleDeliveryPickUpStoreList()
|
pickUpStoreList.value = await PickUpStoreApi.getSimpleDeliveryPickUpStoreList()
|
||||||
// 移除自己无法核销的门店
|
// 移除自己无法核销的门店
|
||||||
const userId = useUserStore().getUser.id
|
const userId = getCurrentUserId()
|
||||||
pickUpStoreList.value = pickUpStoreList.value.filter((item) =>
|
pickUpStoreList.value = pickUpStoreList.value.filter((item) =>
|
||||||
item.verifyUserIds?.includes(userId)
|
item.verifyUserIds?.includes(userId)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ import DvMachinerySelect from '@/views/mes/dv/machinery/components/DvMachinerySe
|
||||||
import DvCheckPlanSelect from '@/views/mes/dv/checkplan/components/DvCheckPlanSelect.vue'
|
import DvCheckPlanSelect from '@/views/mes/dv/checkplan/components/DvCheckPlanSelect.vue'
|
||||||
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
||||||
import MaintenRecordLineList from './MaintenRecordLineList.vue'
|
import MaintenRecordLineList from './MaintenRecordLineList.vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import {
|
import {
|
||||||
MesDvMaintenRecordStatusEnum,
|
MesDvMaintenRecordStatusEnum,
|
||||||
MesDvSubjectTypeEnum,
|
MesDvSubjectTypeEnum,
|
||||||
|
|
@ -88,7 +88,6 @@ const emit = defineEmits(['success'])
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const formLoading = ref(false) // 表单的加载中
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
|
@ -135,7 +134,7 @@ const open = async (type: string, id?: number) => {
|
||||||
}
|
}
|
||||||
// 新增时,自动填充当前登录用户
|
// 新增时,自动填充当前登录用户
|
||||||
if (type === 'create') {
|
if (type === 'create') {
|
||||||
formData.value.userId = userStore.getUser.id
|
formData.value.userId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
// 保存原始数据快照
|
// 保存原始数据快照
|
||||||
originalFormData.value = JSON.stringify(formData.value)
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
import { ProAndonRecordApi } from '@/api/mes/pro/andon/record'
|
import { ProAndonRecordApi } from '@/api/mes/pro/andon/record'
|
||||||
import { ProAndonConfigVO } from '@/api/mes/pro/andon/config'
|
import { ProAndonConfigVO } from '@/api/mes/pro/andon/config'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import { formatDate } from '@/utils/formatTime'
|
import { formatDate } from '@/utils/formatTime'
|
||||||
import { MesProAndonStatusEnum, MesProWorkOrderStatusEnum } from '@/views/mes/utils/constants'
|
import { MesProAndonStatusEnum, MesProWorkOrderStatusEnum } from '@/views/mes/utils/constants'
|
||||||
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
||||||
|
|
@ -148,7 +148,6 @@ const createRules = reactive({
|
||||||
workstationId: [{ required: true, message: '工作站不能为空', trigger: 'change' }],
|
workstationId: [{ required: true, message: '工作站不能为空', trigger: 'change' }],
|
||||||
configId: [{ required: true, message: '呼叫原因不能为空', trigger: 'change' }]
|
configId: [{ required: true, message: '呼叫原因不能为空', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
const userStore = useUserStoreWithOut()
|
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
|
|
@ -157,7 +156,7 @@ const open = async (type: string, id?: number) => {
|
||||||
resetForm()
|
resetForm()
|
||||||
if (type === 'create') {
|
if (type === 'create') {
|
||||||
// 新增时,自动填充当前用户
|
// 新增时,自动填充当前用户
|
||||||
formData.value.userId = userStore.getUser?.id
|
formData.value.userId = getCurrentUserId()
|
||||||
} else {
|
} else {
|
||||||
// 修改 / 详情时,设置数据
|
// 修改 / 详情时,设置数据
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
|
|
@ -169,7 +168,7 @@ const open = async (type: string, id?: number) => {
|
||||||
formData.value.handleTime = formatDate(new Date())
|
formData.value.handleTime = formatDate(new Date())
|
||||||
}
|
}
|
||||||
if (!formData.value.handlerUserId) {
|
if (!formData.value.handlerUserId) {
|
||||||
formData.value.handlerUserId = userStore.getUser?.id
|
formData.value.handlerUserId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorksta
|
||||||
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
||||||
import ItemConsumeList from './ItemConsumeList.vue'
|
import ItemConsumeList from './ItemConsumeList.vue'
|
||||||
import ProductProduceList from './ProductProduceList.vue'
|
import ProductProduceList from './ProductProduceList.vue'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
import {
|
import {
|
||||||
MesAutoCodeRuleCode,
|
MesAutoCodeRuleCode,
|
||||||
MesProFeedbackStatusEnum,
|
MesProFeedbackStatusEnum,
|
||||||
|
|
@ -484,7 +484,7 @@ const open = async (type: string, id?: number) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 创建模式:默认报工人为当前用户,报工时间为当前时间
|
// 创建模式:默认报工人为当前用户,报工时间为当前时间
|
||||||
formData.value.feedbackUserId = useUserStore().getUser.id
|
formData.value.feedbackUserId = getCurrentUserId()
|
||||||
formData.value.feedbackTime = new Date()
|
formData.value.feedbackTime = new Date()
|
||||||
// 自动生成报工单号
|
// 自动生成报工单号
|
||||||
await generateCode()
|
await generateCode()
|
||||||
|
|
|
||||||
|
|
@ -212,13 +212,13 @@ import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
import UserSelectV2 from '@/views/system/user/components/UserSelectV2.vue'
|
||||||
import FeedbackForm from './FeedbackForm.vue'
|
import FeedbackForm from './FeedbackForm.vue'
|
||||||
import { MesProFeedbackStatusEnum } from '@/views/mes/utils/constants'
|
import { MesProFeedbackStatusEnum } from '@/views/mes/utils/constants'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
defineOptions({ name: 'MesProFeedback' })
|
defineOptions({ name: 'MesProFeedback' })
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const currentUserId = useUserStore().getUser.id // 当前登录用户 ID
|
const currentUserId = getCurrentUserId() // 当前登录用户 ID
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const list = ref<ProFeedbackVO[]>([]) // 列表的数据
|
const list = ref<ProFeedbackVO[]>([]) // 列表的数据
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ import {
|
||||||
MesWmStockTakingTypeEnum,
|
MesWmStockTakingTypeEnum,
|
||||||
MesWmStockTakingTaskStatusEnum
|
MesWmStockTakingTaskStatusEnum
|
||||||
} from '@/views/mes/utils/constants'
|
} from '@/views/mes/utils/constants'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
import { getCurrentUserId } from '@/utils/auth'
|
||||||
|
|
||||||
defineOptions({ name: 'StockTakingForm' })
|
defineOptions({ name: 'StockTakingForm' })
|
||||||
|
|
||||||
|
|
@ -258,7 +258,7 @@ const open = async (type: string, id?: number) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 新建时,默认设置当前登录用户为盘点人
|
// 新建时,默认设置当前登录用户为盘点人
|
||||||
formData.value.userId = useUserStore().getUser.id
|
formData.value.userId = getCurrentUserId()
|
||||||
}
|
}
|
||||||
// 保存原始数据快照
|
// 保存原始数据快照
|
||||||
originalFormData.value = JSON.stringify(formData.value)
|
originalFormData.value = JSON.stringify(formData.value)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue