|
@@ -16,7 +16,7 @@
|
|
|
:model="form"
|
|
:model="form"
|
|
|
class="el-form-box"
|
|
class="el-form-box"
|
|
|
:rules="rules"
|
|
:rules="rules"
|
|
|
- label-width="82px"
|
|
|
|
|
|
|
+ label-width="110px"
|
|
|
:disabled="disabled"
|
|
:disabled="disabled"
|
|
|
>
|
|
>
|
|
|
<el-row :gutter="15">
|
|
<el-row :gutter="15">
|
|
@@ -46,9 +46,9 @@
|
|
|
></el-option>
|
|
></el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="所属机构:" prop="groupId">
|
|
|
|
|
|
|
+ <el-form-item label="主所属部门:" prop="groupId">
|
|
|
<org-select
|
|
<org-select
|
|
|
- :data="institutionOptions"
|
|
|
|
|
|
|
+ :data="institutionList"
|
|
|
placeholder="请选择所属机构"
|
|
placeholder="请选择所属机构"
|
|
|
v-model="form.groupId"
|
|
v-model="form.groupId"
|
|
|
:disabled="!!form.loginName"
|
|
:disabled="!!form.loginName"
|
|
@@ -59,13 +59,13 @@
|
|
|
<el-form-item label="隶属部门:">
|
|
<el-form-item label="隶属部门:">
|
|
|
<el-cascader
|
|
<el-cascader
|
|
|
class="ele-block"
|
|
class="ele-block"
|
|
|
- :options="deptOptions"
|
|
|
|
|
- :placeholder="form.groupId ? '请选择隶属部门' : '请先选择所属机构'"
|
|
|
|
|
|
|
+ :options="organization"
|
|
|
|
|
+ placeholder="请选择隶属部门"
|
|
|
:props="defaultProps"
|
|
:props="defaultProps"
|
|
|
ref="deptRef"
|
|
ref="deptRef"
|
|
|
:show-all-levels="true"
|
|
:show-all-levels="true"
|
|
|
@change="handleChange"
|
|
@change="handleChange"
|
|
|
- :disabled="!!form.loginName || !form.groupId"
|
|
|
|
|
|
|
+ :disabled="!!form.loginName"
|
|
|
v-model="form.deptIds"
|
|
v-model="form.deptIds"
|
|
|
clearable
|
|
clearable
|
|
|
></el-cascader>
|
|
></el-cascader>
|
|
@@ -1422,8 +1422,6 @@
|
|
|
value: 'id',
|
|
value: 'id',
|
|
|
label: 'name'
|
|
label: 'name'
|
|
|
},
|
|
},
|
|
|
- // 上一次所属机构(用于判断用户是否真的换了机构,避免误清隶属部门)
|
|
|
|
|
- lastGroupId: null,
|
|
|
|
|
|
|
|
|
|
professionList: []
|
|
professionList: []
|
|
|
};
|
|
};
|
|
@@ -1433,53 +1431,8 @@
|
|
|
styleResponsive() {
|
|
styleResponsive() {
|
|
|
return this.$store.state.theme.styleResponsive;
|
|
return this.$store.state.theme.styleResponsive;
|
|
|
},
|
|
},
|
|
|
- // 组织架构平铺数据(含父级,用于判断公司机构与部门归属)
|
|
|
|
|
- orgFlatList() {
|
|
|
|
|
- const result = [];
|
|
|
|
|
- const walk = (nodes) => {
|
|
|
|
|
- (nodes || []).forEach((item) => {
|
|
|
|
|
- result.push(item);
|
|
|
|
|
- walk(item.children);
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
- walk(
|
|
|
|
|
- this.institutionList && this.institutionList.length
|
|
|
|
|
- ? this.institutionList
|
|
|
|
|
- : this.organizationList
|
|
|
|
|
- );
|
|
|
|
|
- return result;
|
|
|
|
|
- },
|
|
|
|
|
- // 组织树全部 id 集合:parentId 不在其中的节点即公司机构
|
|
|
|
|
- orgIdSet() {
|
|
|
|
|
- return new Set(this.orgFlatList.map((item) => String(item.id)));
|
|
|
|
|
- },
|
|
|
|
|
- /*
|
|
|
|
|
- * 所属机构下拉:只允许选择公司机构,非公司节点置灰保留层级;
|
|
|
|
|
- * 已选节点即使不是公司也保留(置灰),避免回显成裸 id
|
|
|
|
|
- */
|
|
|
|
|
- institutionOptions() {
|
|
|
|
|
- return this.buildInstitutionOptions(
|
|
|
|
|
- this.institutionList && this.institutionList.length
|
|
|
|
|
- ? this.institutionList
|
|
|
|
|
- : this.organizationList
|
|
|
|
|
- );
|
|
|
|
|
- },
|
|
|
|
|
- /*
|
|
|
|
|
- * 隶属部门级联:与所属机构联动,只展示所选公司机构下的部门;
|
|
|
|
|
- * 未选机构时为空(提示先选机构),所选机构不在组织树中时兜底展示整棵树
|
|
|
|
|
- */
|
|
|
|
|
- deptOptions() {
|
|
|
|
|
- const groupId = this.form.groupId;
|
|
|
|
|
- if (groupId == null || groupId === '') {
|
|
|
|
|
- return [];
|
|
|
|
|
- }
|
|
|
|
|
- const company = this.orgFlatList.find(
|
|
|
|
|
- (item) => String(item.id) === String(groupId)
|
|
|
|
|
- );
|
|
|
|
|
- if (!company) {
|
|
|
|
|
- return this.copyOrgTree(this.organizationList);
|
|
|
|
|
- }
|
|
|
|
|
- return this.copyOrgTree(company.children || []);
|
|
|
|
|
|
|
+ organization() {
|
|
|
|
|
+ return this.setList(this.organizationList);
|
|
|
},
|
|
},
|
|
|
identityPhotosColumns() {
|
|
identityPhotosColumns() {
|
|
|
return [
|
|
return [
|
|
@@ -2020,74 +1973,15 @@
|
|
|
|
|
|
|
|
this.professionList = res.list || [];
|
|
this.professionList = res.list || [];
|
|
|
},
|
|
},
|
|
|
- /*
|
|
|
|
|
- * 所属机构下拉数据:公司机构可选,其它节点置灰;
|
|
|
|
|
- * 既不是公司又没有下级公司的纯部门节点直接丢弃,避免下拉被部门撑满
|
|
|
|
|
- */
|
|
|
|
|
- buildInstitutionOptions(list) {
|
|
|
|
|
- const result = [];
|
|
|
|
|
- // 编辑回显的机构(不限公司)保留在选项中,避免历史数据回显成裸 id
|
|
|
|
|
- const selectedId = this.data ? this.data.groupId : null;
|
|
|
|
|
- (list || []).forEach((item) => {
|
|
|
|
|
- const children = this.buildInstitutionOptions(item.children);
|
|
|
|
|
- const isCompany = this.isCompanyOrg(item);
|
|
|
|
|
- const isSelected = String(item.id) === String(selectedId);
|
|
|
|
|
- if (!isCompany && !isSelected && !children.length) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- const node = { ...item, disabled: !isCompany };
|
|
|
|
|
- if (children.length) {
|
|
|
|
|
- node.children = children;
|
|
|
|
|
- } else {
|
|
|
|
|
- delete node.children;
|
|
|
|
|
- }
|
|
|
|
|
- result.push(node);
|
|
|
|
|
- });
|
|
|
|
|
- return result;
|
|
|
|
|
- },
|
|
|
|
|
- /* 组织树浅拷贝,避免直接改动父组件传入的数据 */
|
|
|
|
|
- copyOrgTree(list) {
|
|
|
|
|
- return (list || []).map((item) => {
|
|
|
|
|
- const node = { ...item };
|
|
|
|
|
- if (item.children && item.children.length) {
|
|
|
|
|
- node.children = this.copyOrgTree(item.children);
|
|
|
|
|
- } else {
|
|
|
|
|
- delete node.children;
|
|
|
|
|
|
|
+ setList(list) {
|
|
|
|
|
+ return list.map((val) => {
|
|
|
|
|
+ val['disabled'] = val.id == this.form.groupId;
|
|
|
|
|
+ if (val.children) {
|
|
|
|
|
+ val.children = this.setList(val.children);
|
|
|
}
|
|
}
|
|
|
- return node;
|
|
|
|
|
|
|
+ return val;
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- /*
|
|
|
|
|
- * 是否公司机构:上级不在组织树内的节点即顶层机构(公司)。
|
|
|
|
|
- * 组织机构列表已在页面过滤「超级管理员」,故顶层节点就是公司机构
|
|
|
|
|
- */
|
|
|
|
|
- isCompanyOrg(node) {
|
|
|
|
|
- if (!node || node.name === '超级管理员') {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- return !this.orgIdSet.has(String(node.parentId));
|
|
|
|
|
- },
|
|
|
|
|
- /* 沿父级上溯取所属公司机构 id(新增时把树里选中的部门换算成公司) */
|
|
|
|
|
- resolveCompanyId(id) {
|
|
|
|
|
- if (id == null || id === '') {
|
|
|
|
|
- return id;
|
|
|
|
|
- }
|
|
|
|
|
- const byId = new Map(
|
|
|
|
|
- this.orgFlatList.map((item) => [String(item.id), item])
|
|
|
|
|
- );
|
|
|
|
|
- let node = byId.get(String(id));
|
|
|
|
|
- const seen = new Set();
|
|
|
|
|
- while (
|
|
|
|
|
- node &&
|
|
|
|
|
- !this.isCompanyOrg(node) &&
|
|
|
|
|
- byId.has(String(node.parentId)) &&
|
|
|
|
|
- !seen.has(String(node.id))
|
|
|
|
|
- ) {
|
|
|
|
|
- seen.add(String(node.id));
|
|
|
|
|
- node = byId.get(String(node.parentId));
|
|
|
|
|
- }
|
|
|
|
|
- return node && this.isCompanyOrg(node) ? node.id : id;
|
|
|
|
|
- },
|
|
|
|
|
addIdentityPhotos() {
|
|
addIdentityPhotos() {
|
|
|
this.form.identityPhotos.push({
|
|
this.form.identityPhotos.push({
|
|
|
holder: this.form.name,
|
|
holder: this.form.name,
|
|
@@ -2247,24 +2141,15 @@
|
|
|
this.form.deptIds = this.form.deptIds || [];
|
|
this.form.deptIds = this.form.deptIds || [];
|
|
|
},
|
|
},
|
|
|
checkedKeys(value) {
|
|
checkedKeys(value) {
|
|
|
- const groupId = this.form.groupId;
|
|
|
|
|
this.getLabelName(this.institutionList, (i) => {
|
|
this.getLabelName(this.institutionList, (i) => {
|
|
|
- if (String(i.id) === String(groupId)) {
|
|
|
|
|
|
|
+ if (i.id == this.form.groupId) {
|
|
|
return (this.form.groupName = i.name);
|
|
return (this.form.groupName = i.name);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- // 所属机构变化:清空隶属部门(部门选项已按新机构重建)
|
|
|
|
|
- if (
|
|
|
|
|
- this.lastGroupId != null &&
|
|
|
|
|
- String(this.lastGroupId) !== String(groupId)
|
|
|
|
|
- ) {
|
|
|
|
|
- this.form.deptIds = [];
|
|
|
|
|
- this.form.deptName = '';
|
|
|
|
|
- }
|
|
|
|
|
- this.lastGroupId = groupId;
|
|
|
|
|
- this.form.deptIds = (this.form.deptIds || []).filter(
|
|
|
|
|
- (item) => String(item) != String(groupId)
|
|
|
|
|
|
|
+ this.form.deptIds = this.form.deptIds.filter(
|
|
|
|
|
+ (item) => item != this.form.groupId
|
|
|
);
|
|
);
|
|
|
|
|
+ console.log(this.form.groupName);
|
|
|
},
|
|
},
|
|
|
getLabelName(data, callback) {
|
|
getLabelName(data, callback) {
|
|
|
data.some((i) => {
|
|
data.some((i) => {
|
|
@@ -2285,8 +2170,6 @@
|
|
|
res.postId = res.postId.split(',');
|
|
res.postId = res.postId.split(',');
|
|
|
}
|
|
}
|
|
|
this.form = { ...res };
|
|
this.form = { ...res };
|
|
|
- // 记录回显的所属机构,避免后续误判为「换了机构」而清空隶属部门
|
|
|
|
|
- this.lastGroupId = this.form.groupId ?? null;
|
|
|
|
|
if (Array.isArray(this.form.signature)) {
|
|
if (Array.isArray(this.form.signature)) {
|
|
|
this.form.signature = this.form.signature[0];
|
|
this.form.signature = this.form.signature[0];
|
|
|
}
|
|
}
|
|
@@ -2312,14 +2195,11 @@
|
|
|
// console.log('this.form',this.form)
|
|
// console.log('this.form',this.form)
|
|
|
} else {
|
|
} else {
|
|
|
this.city = null;
|
|
this.city = null;
|
|
|
- // 新增时默认带入左侧树选中的机构:若选中的是部门,上溯到所属公司机构
|
|
|
|
|
- this.form.groupId = this.resolveCompanyId(this.organizationId);
|
|
|
|
|
- this.lastGroupId = this.form.groupId ?? null;
|
|
|
|
|
|
|
+ this.form.groupId = this.organizationId;
|
|
|
this.isUpdate = false;
|
|
this.isUpdate = false;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
this.city = null;
|
|
this.city = null;
|
|
|
- this.lastGroupId = null;
|
|
|
|
|
this.$refs.form.clearValidate();
|
|
this.$refs.form.clearValidate();
|
|
|
this.form = { ...this.defaultForm };
|
|
this.form = { ...this.defaultForm };
|
|
|
}
|
|
}
|