Merge pull request 'feat : 对接人用户替换' (#664) from dd into master

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/664
This commit is contained in:
2024-08-04 17:02:10 +00:00
2 changed files with 82 additions and 25 deletions

View File

@@ -21,6 +21,12 @@ export const getUserAccount = () => {
method: 'get'
})
}
export const judgeIsSameRole = () => {
return request({
url: '/admin/mosr/user/company/same',
method: 'get'
})
}
// 查询角色信息
export const getRolesOpt = () => {

View File

@@ -10,22 +10,27 @@
</template>
<script setup lang="jsx">
import { operate } from '@/api/user/user.js'
import { ElLoading, ElNotification } from 'element-plus';
import {ElLoading, ElMessageBox, ElNotification} from 'element-plus';
import {useTagsView} from '@/stores/tagsview.js'
import {useAuthStore} from '@/stores/userstore.js'
import {useCacheStore} from "@/stores/cache.js";
import { getDeptOpt, getSubCompOpt, getRolesOpt, getJobOpt, getUserDetail } from '@/api/user/user.js'
import { onBeforeMount } from 'vue';
import {
getDeptOpt,
getSubCompOpt,
getRolesOpt,
getJobOpt,
getUserDetail,
operate,
judgeIsSameRole
} from '@/api/user/user.js'
const tagsViewStore = useTagsView()
const authStore = useAuthStore()
const cacheStore = useCacheStore();
const route = useRoute()
const form = ref(null)
const currentRoleArray = ref([])
const loading = ref(false)
const localData = reactive({
subCompanyIdOpt: [],
departmentIdOpt: [],
@@ -114,6 +119,49 @@ const schame = computed(()=>{
placeholder: '请选择',
multiple: true,
data: localData.roleOpt
},
on: {
change: async (val) => {
const {code, data} = await judgeIsSameRole()
if (code === 1000) {
console.log('currentRoleArray.value', currentRoleArray.value)
if (currentRoleArray.value.length !== 0) {
val.forEach(selectItem => {
currentRoleArray.value.forEach(currentItem => {
if (data[selectItem]?.length > 0 && selectItem != currentItem) {
ElMessageBox.confirm(`此角色存在对应人员:${data[selectItem][0].nickName},您确定要替换该人员?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(async () => {
}).catch((action) => {
if (action == 'cancel') {
form.value.getValues().roleIds = form.value.getValues().roleIds.filter(roleItem => roleItem != selectItem);
}
})
}
})
})
} else {
val.forEach(selectItem => {
if (data[selectItem]?.length > 0) {
ElMessageBox.confirm(`此角色存在对应人员:${data[selectItem][0].nickName},您确定要替换该人员?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(async () => {
}).catch((action) => {
if (action == 'cancel') {
form.value.getValues().roleIds = form.value.getValues().roleIds.filter(roleItem => roleItem != selectItem);
}
})
}
})
}
}
}
}
},
{
@@ -207,6 +255,7 @@ const getInfo = async () => {
}
nextTick(() => {
form.value.setValues(data)
currentRoleArray.value = form.value.getValues().roleIds
})
}
@@ -224,6 +273,8 @@ const handleSubmit = async () => {
})
loading.close()
res.code === 1000 ? tagsViewStore.delViewAndGoView('/system/user') : null
}).catch(() => {
loading.close()
}).finally(() => {
loading.close()
})