|
@@ -881,8 +881,15 @@ export default {
|
|
|
return this.$message.warning("请选择医共体");
|
|
return this.$message.warning("请选择医共体");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 校验医共体是否重复
|
|
|
|
|
|
|
+ // 校验唯一性:医共体+医疗机构+科室组合不可重复
|
|
|
{
|
|
{
|
|
|
|
|
+ const editInstId = this.editData.stitutionsId || "";
|
|
|
|
|
+ const editDeptIds = Array.isArray(this.editData.departmentidSelsource)
|
|
|
|
|
+ ? this.editData.departmentidSelsource
|
|
|
|
|
+ : (this.editData.departmentidSelsource || "")
|
|
|
|
|
+ .split(",")
|
|
|
|
|
+ .filter(Boolean);
|
|
|
|
|
+
|
|
|
const checkRes = await getNondrugList({
|
|
const checkRes = await getNondrugList({
|
|
|
page: 1,
|
|
page: 1,
|
|
|
limit: 9999,
|
|
limit: 9999,
|
|
@@ -892,42 +899,48 @@ export default {
|
|
|
const items = (checkRes.Data.Items || []).filter(
|
|
const items = (checkRes.Data.Items || []).filter(
|
|
|
(item) => item.pid !== this.editData.pid,
|
|
(item) => item.pid !== this.editData.pid,
|
|
|
);
|
|
);
|
|
|
- if (items.length > 0) {
|
|
|
|
|
- const ygtName =
|
|
|
|
|
- this.doctorBodyList.find(
|
|
|
|
|
- (i) => i.pid === this.editData.ygtid,
|
|
|
|
|
- )?.name || "";
|
|
|
|
|
- return this.$message.warning(
|
|
|
|
|
- `医共体"${ygtName}"的非药物目录已存在,不可重复新增`,
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 校验唯一性:同一医共体/机构下,任一科室不可重复
|
|
|
|
|
- {
|
|
|
|
|
- const editDeptIds = Array.isArray(this.editData.departmentidSelsource)
|
|
|
|
|
- ? this.editData.departmentidSelsource
|
|
|
|
|
- : (this.editData.departmentidSelsource || "")
|
|
|
|
|
- .split(",")
|
|
|
|
|
- .filter(Boolean);
|
|
|
|
|
- if (editDeptIds.length > 0 && this.editData.stitutionsId) {
|
|
|
|
|
- const checkRes = await getNondrugList({
|
|
|
|
|
- page: 1,
|
|
|
|
|
- limit: 9999,
|
|
|
|
|
- ygtid: this.editData.ygtid,
|
|
|
|
|
- });
|
|
|
|
|
- if (checkRes.ResultCode == 0) {
|
|
|
|
|
- const items = (checkRes.Data.Items || []).filter(
|
|
|
|
|
- (item) => item.pid !== this.editData.pid,
|
|
|
|
|
- );
|
|
|
|
|
- // 找出同一机构下的记录,逐个科室检查是否已存在
|
|
|
|
|
|
|
+ const ygtName =
|
|
|
|
|
+ this.doctorBodyList.find(
|
|
|
|
|
+ (i) => i.pid === this.editData.ygtid,
|
|
|
|
|
+ )?.name || "";
|
|
|
|
|
+
|
|
|
|
|
+ if (!editInstId && editDeptIds.length === 0) {
|
|
|
|
|
+ // 只有医共体:检查是否已有同样只有该医共体的记录
|
|
|
|
|
+ const conflict = items.find((item) => {
|
|
|
|
|
+ const inst = item.stitutionsId || "";
|
|
|
|
|
+ const depts = (item.departmentidSelsource || "")
|
|
|
|
|
+ .split(",")
|
|
|
|
|
+ .filter(Boolean);
|
|
|
|
|
+ return !inst && depts.length === 0;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (conflict) {
|
|
|
|
|
+ return this.$message.warning(
|
|
|
|
|
+ `医共体"${ygtName}"的非药物目录已存在,不可重复新增`,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (editInstId && editDeptIds.length === 0) {
|
|
|
|
|
+ // 医共体+医疗机构(无科室):检查是否已有相同组合且无科室的记录
|
|
|
|
|
+ const conflict = items.find((item) => {
|
|
|
|
|
+ const inst = item.stitutionsId || "";
|
|
|
|
|
+ const depts = (item.departmentidSelsource || "")
|
|
|
|
|
+ .split(",")
|
|
|
|
|
+ .filter(Boolean);
|
|
|
|
|
+ return inst === editInstId && depts.length === 0;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (conflict) {
|
|
|
|
|
+ const instName =
|
|
|
|
|
+ this.editInstitutionList.find(
|
|
|
|
|
+ (i) => i.value === editInstId,
|
|
|
|
|
+ )?.label || "";
|
|
|
|
|
+ return this.$message.warning(
|
|
|
|
|
+ `医共体"${ygtName}"-医疗机构"${instName}"的非药物目录已存在,不可重复新增`,
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (editInstId && editDeptIds.length > 0) {
|
|
|
|
|
+ // 医共体+医疗机构+科室:检查任一科室是否在同一医共体+医疗机构下已存在
|
|
|
const matchedItems = items.filter(
|
|
const matchedItems = items.filter(
|
|
|
- (item) =>
|
|
|
|
|
- (item.stitutionsId || "") === this.editData.stitutionsId &&
|
|
|
|
|
- (item.departmentidSelsource || ""),
|
|
|
|
|
|
|
+ (item) => (item.stitutionsId || "") === editInstId,
|
|
|
);
|
|
);
|
|
|
- // 收集已存在的科室ID -> 名称映射
|
|
|
|
|
const existDeptMap = {};
|
|
const existDeptMap = {};
|
|
|
matchedItems.forEach((item) => {
|
|
matchedItems.forEach((item) => {
|
|
|
const ids = (item.departmentidSelsource || "")
|
|
const ids = (item.departmentidSelsource || "")
|
|
@@ -942,7 +955,6 @@ export default {
|
|
|
});
|
|
});
|
|
|
const conflictIds = editDeptIds.filter((id) => existDeptMap[id]);
|
|
const conflictIds = editDeptIds.filter((id) => existDeptMap[id]);
|
|
|
if (conflictIds.length > 0) {
|
|
if (conflictIds.length > 0) {
|
|
|
- // 用 editDepartList 查出冲突科室名称
|
|
|
|
|
const conflictNames = conflictIds
|
|
const conflictNames = conflictIds
|
|
|
.map((id) => {
|
|
.map((id) => {
|
|
|
const dept = this.editDepartList.find(
|
|
const dept = this.editDepartList.find(
|
|
@@ -951,13 +963,9 @@ export default {
|
|
|
return dept ? dept.label : id;
|
|
return dept ? dept.label : id;
|
|
|
})
|
|
})
|
|
|
.join("、");
|
|
.join("、");
|
|
|
- const ygtName =
|
|
|
|
|
- this.doctorBodyList.find(
|
|
|
|
|
- (i) => i.pid === this.editData.ygtid,
|
|
|
|
|
- )?.name || "";
|
|
|
|
|
const instName =
|
|
const instName =
|
|
|
this.editInstitutionList.find(
|
|
this.editInstitutionList.find(
|
|
|
- (i) => i.value === this.editData.stitutionsId,
|
|
|
|
|
|
|
+ (i) => i.value === editInstId,
|
|
|
)?.label || "";
|
|
)?.label || "";
|
|
|
return this.$message.warning(
|
|
return this.$message.warning(
|
|
|
`${ygtName}-${instName}-${conflictNames}的非药物目录已存在`,
|
|
`${ygtName}-${instName}-${conflictNames}的非药物目录已存在`,
|