|
|
@@ -481,14 +481,16 @@ const submitForm = (formEl) => {
|
|
|
if (!formEl) return;
|
|
|
formEl.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- const mainSpecies = Array.isArray(ruleForm.speciesItem)
|
|
|
- ? ruleForm.speciesItem[0]
|
|
|
- : ruleForm.speciesItem;
|
|
|
+ const speciesList = Array.isArray(ruleForm.speciesItem) ? ruleForm.speciesItem : (ruleForm.speciesItem ? [ruleForm.speciesItem] : []);
|
|
|
+ const mainSpecies = speciesList[0];
|
|
|
+ const speciesContainer = speciesList.map((item) => ({
|
|
|
+ speciesId: item?.id ?? null,
|
|
|
+ containerId: item?.defaultContainerId ?? null,
|
|
|
+ }));
|
|
|
const params = {
|
|
|
...ruleForm,
|
|
|
wkt: centerPoint.value,
|
|
|
- speciesId: mainSpecies?.id,
|
|
|
- containerId: mainSpecies?.defaultContainerId,
|
|
|
+ speciesContainer,
|
|
|
agriculturalCreate: route.query.type === "client" ? 1 : 0,
|
|
|
// 编辑时geom不是数组,新增时是数组
|
|
|
geom:
|
|
|
@@ -520,6 +522,10 @@ const submitForm = (formEl) => {
|
|
|
if (Array.isArray(queryParams.geom)) {
|
|
|
queryParams.geom = JSON.stringify(queryParams.geom);
|
|
|
}
|
|
|
+ // speciesContainer 为对象时需序列化,否则 query 传递后无法正确解析
|
|
|
+ if (queryParams.speciesContainer && typeof queryParams.speciesContainer === 'object') {
|
|
|
+ queryParams.speciesContainer = JSON.stringify(queryParams.speciesContainer);
|
|
|
+ }
|
|
|
delete queryParams.speciesItem;
|
|
|
queryParams.speciesName = mainSpecies?.name;
|
|
|
|
|
|
@@ -681,18 +687,17 @@ function getSpecieList() {
|
|
|
return VE_API.farm.fetchSpecieList({ point: centerPoint.value }).then(({ data }) => {
|
|
|
const list = Array.isArray(data) ? data : [];
|
|
|
// 只保留名称包含“荔枝”的品类
|
|
|
- const litchiList = list.filter((item) => item?.name && item.name.includes("荔枝"));
|
|
|
- specieList.value = litchiList;
|
|
|
+ specieList.value = list;
|
|
|
// 非编辑模式且当前未选择品类时,默认选中第一项
|
|
|
const noSpeciesSelected =
|
|
|
!Array.isArray(ruleForm.speciesItem) || ruleForm.speciesItem.length === 0;
|
|
|
- if (route.query.type !== "edit" && noSpeciesSelected && litchiList.length > 0) {
|
|
|
- const first = { value: litchiList[0].id, ...litchiList[0] };
|
|
|
+ if (route.query.type !== "edit" && noSpeciesSelected && list.length > 0) {
|
|
|
+ const first = { value: list[0].id, ...list[0] };
|
|
|
ruleForm.speciesItem = [first];
|
|
|
// 同步触发品类变更逻辑(加载品种、自动生成农场名等)
|
|
|
changeSpecie(first);
|
|
|
}
|
|
|
- return litchiList;
|
|
|
+ return list;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1149,7 +1154,7 @@ function handleMianjiInput(value) {
|
|
|
}
|
|
|
|
|
|
.select-item {
|
|
|
- min-width: 76px;
|
|
|
+ min-width: 100px;
|
|
|
}
|
|
|
}
|
|
|
|