xq feat:"完成了用户和项目关联(前端逻辑)"
This commit is contained in:
@ -67,6 +67,7 @@ export interface UserForm {
|
|||||||
remark?: string;
|
remark?: string;
|
||||||
postIds: string[];
|
postIds: string[];
|
||||||
roleIds: string[];
|
roleIds: string[];
|
||||||
|
wxList: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserInfoVO {
|
export interface UserInfoVO {
|
||||||
|
@ -2,15 +2,21 @@ import { defineStore } from 'pinia';
|
|||||||
|
|
||||||
interface ProgramState {
|
interface ProgramState {
|
||||||
programID: string;
|
programID: string;
|
||||||
|
personProgramTemp: any;
|
||||||
}
|
}
|
||||||
const useProgram = defineStore('program', {
|
const useProgram = defineStore('program', {
|
||||||
state: (): ProgramState => ({
|
state: (): ProgramState => ({
|
||||||
programID: ''
|
programID: '',
|
||||||
|
personProgramTemp: []
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
updateId(id: string) {
|
updateId(id: string) {
|
||||||
this.programID = id;
|
this.programID = id;
|
||||||
|
},
|
||||||
|
updateTemp(arr: any) {
|
||||||
|
console.info(arr);
|
||||||
|
this.personProgramTemp = arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -240,7 +240,7 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="项目选择">
|
<el-form-item label="项目选择">
|
||||||
<el-select placeholder="选择项目" multiple v-model="tempArr">
|
<el-select placeholder="选择项目" multiple v-model="form.wxList" @change="updateTemp">
|
||||||
<el-option v-for="(p, index) in programList" :key="index" :value="p.nbqId" :label="p.projectBrief"></el-option>
|
<el-option v-for="(p, index) in programList" :key="index" :value="p.nbqId" :label="p.projectBrief"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -323,6 +323,7 @@ import { hasPermi } from '@/directive/permission';
|
|||||||
import { checkPermi } from '@/utils/permission';
|
import { checkPermi } from '@/utils/permission';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { getAll } from '@/api/business/inverter';
|
import { getAll } from '@/api/business/inverter';
|
||||||
|
import { useProgram } from '@/store/modules/program';
|
||||||
const props = { multiple: true };
|
const props = { multiple: true };
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
@ -341,6 +342,7 @@ const enabledDeptOptions = ref<DeptTreeVO[]>([]);
|
|||||||
const initPassword = ref<string>('');
|
const initPassword = ref<string>('');
|
||||||
const postOptions = ref<PostVO[]>([]);
|
const postOptions = ref<PostVO[]>([]);
|
||||||
const roleOptions = ref<RoleVO[]>([]);
|
const roleOptions = ref<RoleVO[]>([]);
|
||||||
|
const programStore = useProgram();
|
||||||
|
|
||||||
const options = ref([
|
const options = ref([
|
||||||
{
|
{
|
||||||
@ -459,7 +461,8 @@ const initFormData: UserForm = {
|
|||||||
status: '0',
|
status: '0',
|
||||||
remark: '',
|
remark: '',
|
||||||
postIds: [],
|
postIds: [],
|
||||||
roleIds: []
|
roleIds: [],
|
||||||
|
wxList: []
|
||||||
};
|
};
|
||||||
|
|
||||||
const initData: PageData<UserForm, UserQuery> = {
|
const initData: PageData<UserForm, UserQuery> = {
|
||||||
@ -550,8 +553,24 @@ function getAllList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTemp(a) {
|
||||||
|
const arr = [];
|
||||||
|
programList.value.forEach((item) => {
|
||||||
|
a.forEach((item2) => {
|
||||||
|
if (item.nbqId === item2) {
|
||||||
|
arr.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
tempArr.value = [];
|
||||||
|
arr.forEach((item) => {
|
||||||
|
tempArr.value.push(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
watch(tempArr, (nv) => {
|
watch(tempArr, (nv) => {
|
||||||
programArr.value = programList.value.filter((obj) => nv.includes(obj.nbqId));
|
programArr.value = nv;
|
||||||
|
programStore.updateTemp(programArr.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
@ -719,6 +738,13 @@ const handleUpdate = async (row?: UserForm) => {
|
|||||||
reset();
|
reset();
|
||||||
const userId = row?.userId || ids.value[0];
|
const userId = row?.userId || ids.value[0];
|
||||||
const { data } = await api.getUser(userId);
|
const { data } = await api.getUser(userId);
|
||||||
|
if (data.wxLis && data.wxLis.length > 0) {
|
||||||
|
programStore.updateTemp(data.wxLis);
|
||||||
|
tempArr.value = data.wxLis;
|
||||||
|
} else {
|
||||||
|
programStore.updateTemp([]);
|
||||||
|
tempArr.value = [];
|
||||||
|
}
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
dialog.title = '修改用户';
|
dialog.title = '修改用户';
|
||||||
Object.assign(form.value, data.user);
|
Object.assign(form.value, data.user);
|
||||||
@ -746,6 +772,7 @@ const submitForm = () => {
|
|||||||
*/
|
*/
|
||||||
const closeDialog = () => {
|
const closeDialog = () => {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
|
programStore.updateTemp([]);
|
||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user