|
|
@@ -45,23 +45,18 @@
|
|
|
<el-table-column sortable align="center" label="款号" prop="款号" width="150" />
|
|
|
<el-table-column align="center" label="计划生产小组" width="140">
|
|
|
<template #default="{ row }">
|
|
|
- <el-select
|
|
|
+ <el-autocomplete
|
|
|
v-model="row['计划生产小组']"
|
|
|
+ :fetch-suggestions="queryPlanGroupSuggestions"
|
|
|
clearable
|
|
|
- filterable
|
|
|
- allow-create
|
|
|
- default-first-option
|
|
|
+ placeholder="请选择或输入"
|
|
|
size="small"
|
|
|
style="width: 100%"
|
|
|
- @change="(val) => handlePlanGroupSelectChange(row, val)"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="opt in planGroupSelectOptions"
|
|
|
- :key="opt.value"
|
|
|
- :label="opt.label"
|
|
|
- :value="opt.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
+ value-key="value"
|
|
|
+ @select="(item) => savePlanGroupRow(row, item?.value ?? item)"
|
|
|
+ @blur="() => savePlanGroupRowOnBlur(row)"
|
|
|
+ @clear="() => savePlanGroupRow(row, '')"
|
|
|
+ />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column align="center" label="实际生产小组" prop="实际生产小组" width="110" show-overflow-tooltip />
|
|
|
@@ -354,11 +349,29 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const handlePlanGroupSelectChange = async (row, val) => {
|
|
|
- const team = val == null ? '' : String(val).trim()
|
|
|
- row['计划生产小组'] = team
|
|
|
- syncPlanGroupMetaFromTeam(row, team)
|
|
|
- await submitPlanProductionGroup(row, team)
|
|
|
+ const planGroupSavedMap = new WeakMap()
|
|
|
+
|
|
|
+ const queryPlanGroupSuggestions = (queryString, cb) => {
|
|
|
+ const q = String(queryString ?? '').trim().toLowerCase()
|
|
|
+ const base = planGroupSelectOptions.value
|
|
|
+ const filtered = q
|
|
|
+ ? base.filter((o) => String(o.value).toLowerCase().includes(q))
|
|
|
+ : base
|
|
|
+ cb(filtered.map((o) => ({ value: o.value })))
|
|
|
+ }
|
|
|
+
|
|
|
+ const savePlanGroupRow = async (row, team) => {
|
|
|
+ const name = team == null ? '' : String(team).trim()
|
|
|
+ if (planGroupSavedMap.get(row) === name) return
|
|
|
+ row['计划生产小组'] = name
|
|
|
+ syncPlanGroupMetaFromTeam(row, name)
|
|
|
+ const ok = await submitPlanProductionGroup(row, name)
|
|
|
+ if (ok) planGroupSavedMap.set(row, name)
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 自定义输入后未点选下拉项,失焦时也会保存 */
|
|
|
+ const savePlanGroupRowOnBlur = async (row) => {
|
|
|
+ await savePlanGroupRow(row, row['计划生产小组'])
|
|
|
}
|
|
|
|
|
|
const loadPlanGroupOptions = async () => {
|