|
|
@@ -306,8 +306,28 @@ export default {
|
|
|
positionId: [
|
|
|
{ required: true, message: "请选择应聘岗位", trigger: "change" },
|
|
|
],
|
|
|
+ /* 岗位序列:部门未配置序列时,报错文案直接给出可操作指引(去主数据补部门岗位) */
|
|
|
positionSequenceId: [
|
|
|
- { required: true, message: "请选择岗位序列", trigger: "change" },
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value != null && value !== "") {
|
|
|
+ callback();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const departmentId =
|
|
|
+ this.form.departmentId ?? this.form.hiringDeptId ?? null;
|
|
|
+ let message = "请选择岗位序列";
|
|
|
+ if (departmentId == null || departmentId === "") {
|
|
|
+ message = "请先选择入职部门";
|
|
|
+ } else if (!this.positionSequenceOptions.length) {
|
|
|
+ message =
|
|
|
+ "当前入职部门未配置岗位序列,请到「主数据 → 组织机构」完善该部门的岗位信息";
|
|
|
+ }
|
|
|
+ callback(new Error(message));
|
|
|
+ },
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
],
|
|
|
positionLevelId: [
|
|
|
{ required: true, message: "请选择岗位层级", trigger: "change" },
|
|
|
@@ -535,8 +555,12 @@ export default {
|
|
|
this.form.education = this.resolveEducation(this.form.education);
|
|
|
},
|
|
|
// ========== 部门岗位关联级联加载 ==========
|
|
|
- /** 入职部门 → 岗位序列下拉选项 */
|
|
|
- async loadPositionSequences(deptId) {
|
|
|
+ /**
|
|
|
+ * 入职部门 → 岗位序列下拉选项
|
|
|
+ * notifyEmpty:用户主动切换部门时,该部门没配岗位序列就给出可操作指引
|
|
|
+ * (普通回显路径不弹提示,避免打开弹窗时噪音;提交时由 rules 兜底提示)
|
|
|
+ */
|
|
|
+ async loadPositionSequences(deptId, { notifyEmpty = false } = {}) {
|
|
|
if (deptId == null || deptId === "") {
|
|
|
this.positionSequenceOptions = [];
|
|
|
return;
|
|
|
@@ -547,6 +571,11 @@ export default {
|
|
|
this.positionSequenceOptions = (asList(data) || []).filter(
|
|
|
(item) => item && item.positionSequenceId != null,
|
|
|
);
|
|
|
+ if (notifyEmpty && !this.positionSequenceOptions.length) {
|
|
|
+ this.$message.warning(
|
|
|
+ "该入职部门未配置岗位序列,请到「主数据 → 组织机构」完善该部门的岗位信息",
|
|
|
+ );
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
this.positionSequenceOptions = [];
|
|
|
showRequestError(error, "岗位序列加载失败");
|
|
|
@@ -640,23 +669,26 @@ export default {
|
|
|
}))
|
|
|
.filter((item) => item.id != null && item.name);
|
|
|
const byId = new Map(records.map((item) => [String(item.id), item]));
|
|
|
- this.allDepartments = records.map((item) => {
|
|
|
- let current = item;
|
|
|
- const seen = new Set();
|
|
|
- while (
|
|
|
- current &&
|
|
|
- byId.has(String(current.parentId)) &&
|
|
|
- !seen.has(String(current.id))
|
|
|
- ) {
|
|
|
- seen.add(String(current.id));
|
|
|
- current = byId.get(String(current.parentId));
|
|
|
- }
|
|
|
- return {
|
|
|
- id: item.id,
|
|
|
- name: item.name,
|
|
|
- legalId: current?.id,
|
|
|
- };
|
|
|
- });
|
|
|
+ this.allDepartments = records
|
|
|
+ .map((item) => {
|
|
|
+ let current = item;
|
|
|
+ const seen = new Set();
|
|
|
+ while (
|
|
|
+ current &&
|
|
|
+ byId.has(String(current.parentId)) &&
|
|
|
+ !seen.has(String(current.id))
|
|
|
+ ) {
|
|
|
+ seen.add(String(current.id));
|
|
|
+ current = byId.get(String(current.parentId));
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ name: item.name,
|
|
|
+ legalId: current?.id,
|
|
|
+ };
|
|
|
+ })
|
|
|
+ /* 公司根节点(上级链顶到自己)不是部门,不进入职部门下拉 */
|
|
|
+ .filter((item) => String(item.id) !== String(item.legalId));
|
|
|
} catch (error) {
|
|
|
/* 机构选项来自登录缓存,不因组织列表接口失败而清空 */
|
|
|
this.allDepartments = [];
|
|
|
@@ -788,7 +820,7 @@ export default {
|
|
|
}
|
|
|
this.form.departmentId = departmentId;
|
|
|
this.syncOrgAndDeptFields();
|
|
|
- await this.loadPositionSequences(departmentId);
|
|
|
+ await this.loadPositionSequences(departmentId, { notifyEmpty: true });
|
|
|
},
|
|
|
async fillRelatedInfo() {
|
|
|
if (this.localOnly) return;
|