修复业务模块bug

This commit is contained in:
2026-08-14 14:19:12 +08:00
parent 6bc9981ffc
commit 574b1a52f4
8 changed files with 1035 additions and 254 deletions
@@ -137,21 +137,22 @@
label="货物名称"
min-width="130"
><template #default="{ row }"
><el-select
><el-autocomplete
v-model="row.cargoName"
filterable
allow-create
default-first-option
clearable
placeholder="请选择或输入"
placeholder="请输入货物名称"
:debounce="300"
:fetch-suggestions="
(queryString, callback) => fetchCargoSuggestions(queryString, callback, row.cargoTypePath)
"
:loading="isCargoOptionsLoading(row.cargoTypePath)"
@visible-change="visible => visible && loadCargoOptionsByType(row.cargoTypePath)"
@change="selectCargoName(row, $event)"
><el-option
v-for="cargo in getCargoOptionsByType(row.cargoTypePath)"
:key="cargo.id"
:label="cargo.cargoName"
:value="cargo.cargoName" /></el-select
@select="cargo => selectCargoSuggestion(row, cargo)"
><template #default="{ item }">
<div class="master-editor__cargo-autocomplete-item">
<span>{{ item.cargoName || item.name || '' }}</span>
<small v-if="item.cargoCode">{{ item.cargoCode }}</small>
</div>
</template></el-autocomplete
></template></el-table-column
><el-table-column label="货物类型" min-width="130"
><template #default="{ row }"
@@ -1062,6 +1063,45 @@ export default {
this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: false };
}
},
async fetchCargoSuggestions(queryString, callback, path = []) {
const keyword = String(queryString || '').trim();
const cargoType = this.getCargoTypeByPath(path);
const key = this.getCargoOptionsKey(path);
if (!keyword && !cargoType) {
callback([]);
return;
}
if (key) this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: true };
try {
const response = await getCommonCargoList(1, 50, {
allDept: 0,
...(cargoType
? {
secondCargoTypeName: cargoType.label,
secondCargoTypeCode: cargoType.cargoCode || cargoType.code || '',
}
: {}),
...(keyword ? { cargoName: keyword } : {}),
});
const options = this.responseRecords(response);
if (key) this.cargoOptionsMap = { ...this.cargoOptionsMap, [key]: options };
callback(
options.map(item => ({
...item,
value: item.cargoName || item.name || '',
}))
);
} catch (error) {
window.console.log(error);
callback([]);
} finally {
if (key) this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: false };
}
},
selectCargoSuggestion(goods, cargo = {}) {
goods.cargoName = cargo.cargoName || cargo.name || '';
Object.assign(goods, this.normalizeCargoRow(cargo, goods.cargoTypePath));
},
selectCargoName(goods, cargoName) {
if (!cargoName) return;
const cargo = this.getCargoOptionsByType(goods.cargoTypePath).find(