|
|
@@ -690,10 +690,13 @@ function getSpecieList() {
|
|
|
// 只保留名称包含“荔枝”的品类
|
|
|
const litchiList = list.filter((item) => item?.name && item.name.includes("荔枝"));
|
|
|
specieList.value = litchiList;
|
|
|
- // 非编辑模式且当前未选择品类时,默认选中第一项
|
|
|
- const noSpeciesSelected =
|
|
|
- !Array.isArray(ruleForm.speciesItem) || ruleForm.speciesItem.length === 0;
|
|
|
- if (route.query.type !== "edit" && noSpeciesSelected && litchiList.length > 0) {
|
|
|
+ // 返回空列表时,重置已选品类,避免保留上一次默认项
|
|
|
+ if (litchiList.length === 0) {
|
|
|
+ ruleForm.speciesItem = [];
|
|
|
+ return litchiList;
|
|
|
+ }
|
|
|
+ //列表有值时,默认选中第一项
|
|
|
+ if (litchiList.length > 0) {
|
|
|
const first = { value: litchiList[0].id, ...litchiList[0] };
|
|
|
ruleForm.speciesItem = [first];
|
|
|
// 同步触发品类变更逻辑(加载品种、自动生成农场名等)
|