async "form.szd"(val, oldVal) {
// 判断是否真正修改了所在地
const oldSzd = Array.isArray(oldVal)
? oldVal.join(",")
: oldVal;
const newSzd = Array.isArray(val)
? val.join(",")
: val;
// 只有用户真正修改所在地,才清空原来的园区
if (oldSzd !== newSzd) {
this.form.szgjyq = "";
}
this.szgjyq_options = [];
if (!val || val.length < 2) return;
const sf = val[0];
const cs = val[1];
try {
const res = await axios.get("/api/FqtgExt/GetGjYq", {
params: {
sf: sf,
cs: cs
}
});
const result = res.data;
if (result.statusCode !== 200) {
throw new Error(result.errors || "获取数据失败");
}
this.szgjyq_options = result.data.map(item => ({
Value: item.mc,
Text: item.mc
}));
// console.log("园区选项加载完成:", this.szgjyq_options.length);
// console.log("当前园区值:", this.form.szgjyq);
// console.log("是否匹配:", this.szgjyq_options.some(
// x => x.Text === this.form.szgjyq
// ));
} catch (err) {
console.error("获取园区失败:", err);
ElMessage.error(
err.response?.data?.errors ||
err.message ||
"获取园区数据失败"
);
}
if (val) {
document.querySelector(".szd-waring")
?.classList.remove("is-error");
}
},