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:
@@ -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 = () => {
|
||||
|
||||
@@ -4,28 +4,33 @@
|
||||
<fvForm :schema="schame" @getInstance="getInstance" :rules="rules"></fvForm>
|
||||
<div class="oper-page-btn">
|
||||
<el-button color="#DED0B2" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleBack">返回</el-button>
|
||||
<el-button @click="handleBack">返回</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="jsx">
|
||||
import { operate } from '@/api/user/user.js'
|
||||
import { ElLoading, 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 {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,
|
||||
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: [],
|
||||
@@ -33,7 +38,7 @@ const localData = reactive({
|
||||
jobOpt: []
|
||||
})
|
||||
|
||||
const schame = computed(()=>{
|
||||
const schame = computed(() => {
|
||||
let arr = [
|
||||
{
|
||||
label: '公司',
|
||||
@@ -49,7 +54,7 @@ const schame = computed(()=>{
|
||||
},
|
||||
on: {
|
||||
change: async (val) => {
|
||||
const { data } = await getDeptOpt({subCompanyId: val})
|
||||
const {data} = await getDeptOpt({subCompanyId: val})
|
||||
localData.departmentIdOpt = data
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -156,9 +204,9 @@ const schame = computed(()=>{
|
||||
},
|
||||
]
|
||||
let editArr = []
|
||||
if(!route.query.isAdd) {
|
||||
arr.forEach(item=>{
|
||||
if(item.prop != 'password') {
|
||||
if (!route.query.isAdd) {
|
||||
arr.forEach(item => {
|
||||
if (item.prop != 'password') {
|
||||
editArr.push(item)
|
||||
}
|
||||
})
|
||||
@@ -198,25 +246,26 @@ const init = async () => {
|
||||
}
|
||||
|
||||
const getInfo = async () => {
|
||||
if(!route.query.id) return
|
||||
if (!route.query.id) return
|
||||
// 获取详情数据
|
||||
const { data } = await getUserDetail(route.query.id)
|
||||
if(data.subCompanyId) {
|
||||
const {data} = await getUserDetail(route.query.id)
|
||||
if (data.subCompanyId) {
|
||||
const res = await getDeptOpt({subCompanyId: data.subCompanyId})
|
||||
localData.departmentIdOpt = res.data
|
||||
}
|
||||
nextTick(()=>{
|
||||
nextTick(() => {
|
||||
form.value.setValues(data)
|
||||
currentRoleArray.value = form.value.getValues().roleIds
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const loading = ElLoading.service({fullscreen: true})
|
||||
const { isValidate } = await form.value.validate()
|
||||
if(!isValidate) return Promise.reject()
|
||||
const {isValidate} = await form.value.validate()
|
||||
if (!isValidate) return Promise.reject()
|
||||
const values = form.value.getValues()
|
||||
operate(values, route.query.userType).then(res=>{
|
||||
operate(values, route.query.userType).then(res => {
|
||||
ElNotification({
|
||||
title: route.query.isAdd ? '新增' : '编辑',
|
||||
message: res.msg,
|
||||
@@ -224,7 +273,9 @@ const handleSubmit = async () => {
|
||||
})
|
||||
loading.close()
|
||||
res.code === 1000 ? tagsViewStore.delViewAndGoView('/system/user') : null
|
||||
}).finally(()=>{
|
||||
}).catch(() => {
|
||||
loading.close()
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
}
|
||||
@@ -233,10 +284,10 @@ const handleBack = () => {
|
||||
history.back()
|
||||
}
|
||||
|
||||
onMounted(async ()=>{
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
await init()
|
||||
if(!route.query.isAdd) {
|
||||
if (!route.query.isAdd) {
|
||||
await getInfo()
|
||||
}
|
||||
loading.value = false
|
||||
|
||||
Reference in New Issue
Block a user