|
|
|
|
@ -17,6 +17,7 @@ |
|
|
|
|
@on-load="onLoad" |
|
|
|
|
@row-save="rowSave" |
|
|
|
|
@row-update="rowUpdate" |
|
|
|
|
:before-open="beforeOpen" |
|
|
|
|
> |
|
|
|
|
<template #menu-left> </template> |
|
|
|
|
|
|
|
|
|
@ -25,7 +26,24 @@ |
|
|
|
|
<el-button type="primary" @click="handleImport">导入</el-button> |
|
|
|
|
</span> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<template #bcId="{ row }"> |
|
|
|
|
{{ row.bcName }} |
|
|
|
|
</template> |
|
|
|
|
<template #bcId-form="{ type }"> |
|
|
|
|
<span v-show="type == 'edit' || type == 'add'"> |
|
|
|
|
<el-select v-model="form.bcId" placeholder="请选择镀种分类" filterable |
|
|
|
|
remote |
|
|
|
|
reserve-keyword |
|
|
|
|
:remote-method="remoteMethod"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in bcIdData" |
|
|
|
|
:key="item.id" |
|
|
|
|
:value="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
/> |
|
|
|
|
</el-select> |
|
|
|
|
</span> |
|
|
|
|
</template> |
|
|
|
|
<template #bsBasicClass.name="scope"> |
|
|
|
|
<span> |
|
|
|
|
{{ scope.row.bsBasicClass ? scope.row.bsBasicClass.name : '-' }} |
|
|
|
|
@ -75,6 +93,7 @@ import { |
|
|
|
|
getQueryAllCaDel, |
|
|
|
|
} from '@/api/processManagement/processCapability'; |
|
|
|
|
import { getDictionary } from '@/api/system/dict'; |
|
|
|
|
import { getList } from '@/api/basicData/platingAssort'; |
|
|
|
|
import basicImport from '@/components/basic-import/main.vue'; |
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
@ -93,6 +112,7 @@ export default { |
|
|
|
|
currentPage: 1, |
|
|
|
|
total: 0, |
|
|
|
|
}, |
|
|
|
|
bcIdData: [], |
|
|
|
|
formOption: { |
|
|
|
|
menuSpan: 12, |
|
|
|
|
enter: true, |
|
|
|
|
@ -173,13 +193,13 @@ export default { |
|
|
|
|
filterable: true, |
|
|
|
|
remote: true, |
|
|
|
|
props: { |
|
|
|
|
label: "name", |
|
|
|
|
value: "id", |
|
|
|
|
desc:"code", |
|
|
|
|
res:"data.records" |
|
|
|
|
label: 'name', |
|
|
|
|
value: 'id', |
|
|
|
|
desc: 'code', |
|
|
|
|
res: 'data.records', |
|
|
|
|
}, |
|
|
|
|
dicUrl: '/api/blade-desk/BA/BasicClazz/list?current=1&size=9999&descs=CODE&name={{key}}', |
|
|
|
|
// dicUrl: "/blade-desk/BA/BasicClazz/listForSelectPlatingAssort", |
|
|
|
|
dicUrl: |
|
|
|
|
'/api/blade-desk/BA/BasicClazz/list?current=1&size=9999&descs=CODE&name={{key}}', |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
@ -483,12 +503,35 @@ export default { |
|
|
|
|
this.$refs.crud.toggleSelection(); |
|
|
|
|
}, |
|
|
|
|
// 打开弹框 前操作 打开表单前会执行beforeOpen方法 |
|
|
|
|
beforeOpen(done, type) { |
|
|
|
|
if (['add'].includes(type)) { |
|
|
|
|
this.form.flagCycleTest = 0; |
|
|
|
|
} |
|
|
|
|
if (['edit', 'view'].includes(type)) { |
|
|
|
|
this.form.bcId = this.form.bcId + ''; |
|
|
|
|
async beforeOpen(done, type, loading) { |
|
|
|
|
try { |
|
|
|
|
// 1. 拉取镀种分类全量数据 |
|
|
|
|
await this.remoteMethod(''); |
|
|
|
|
// 2. 新增默认值 |
|
|
|
|
if (['add'].includes(type)) { |
|
|
|
|
this.form.flagCycleTest = 0; |
|
|
|
|
} |
|
|
|
|
// 3. 编辑 / 查看时:自动补全 bcId 到下拉数组(解决500条以外不显示) |
|
|
|
|
if (['edit', 'view'].includes(type)) { |
|
|
|
|
const currentId = (this.form.bcId || '').toString().trim(); |
|
|
|
|
const currentName = this.form.bcName || '-'; // 你后台返回的名称 |
|
|
|
|
// 判断:如果id不在数组里,就插入到第一个 |
|
|
|
|
if (currentId) { |
|
|
|
|
const hasItem = this.bcIdData.some(item => item.id == currentId); |
|
|
|
|
console.log('hasItem =', hasItem); |
|
|
|
|
if (!hasItem) { |
|
|
|
|
// 插入到数组最前面 |
|
|
|
|
this.bcIdData.unshift({ |
|
|
|
|
id: currentId, |
|
|
|
|
name: currentName, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 转字符串保证选中 |
|
|
|
|
this.form.bcId = currentId; |
|
|
|
|
} |
|
|
|
|
} catch (err) { |
|
|
|
|
console.error('加载镀种分类失败', err); |
|
|
|
|
} |
|
|
|
|
done(); |
|
|
|
|
}, |
|
|
|
|
@ -512,22 +555,48 @@ export default { |
|
|
|
|
refreshChange() { |
|
|
|
|
this.onLoad(this.page, this.query); |
|
|
|
|
}, |
|
|
|
|
async remoteMethod(query) { |
|
|
|
|
const res = await getList({ current: 1, size: 9999, descs: 'CODE',name:query }) |
|
|
|
|
this.bcIdData = res.data.data.records || [] |
|
|
|
|
}, |
|
|
|
|
// 根据ID查询镀种分类名称 —— 异步Promise |
|
|
|
|
getBcName(id) { |
|
|
|
|
if (!id) return Promise.resolve('-'); |
|
|
|
|
return getList({ |
|
|
|
|
current: 1, |
|
|
|
|
size: 1, |
|
|
|
|
id_equal: id, |
|
|
|
|
descs: 'CODE', |
|
|
|
|
}) |
|
|
|
|
.then(res => { |
|
|
|
|
return res.data?.data?.records?.[0]?.name || id; |
|
|
|
|
}) |
|
|
|
|
.catch(() => id); |
|
|
|
|
}, |
|
|
|
|
// 加载页面数据 |
|
|
|
|
// 加载页面数据 |
|
|
|
|
onLoad(page, params = {}) { |
|
|
|
|
async onLoad(page, params = {}) { |
|
|
|
|
this.loading = true; |
|
|
|
|
getPlatingTypeList({ |
|
|
|
|
current: this.page.currentPage, |
|
|
|
|
size: this.page.pageSize, |
|
|
|
|
...this.query, |
|
|
|
|
}).then(res => { |
|
|
|
|
res.data.data.records.map(item => { |
|
|
|
|
item.bcId = item.bcId + ''; |
|
|
|
|
item.subClass = item.subClass + ''; |
|
|
|
|
try { |
|
|
|
|
const res = await getPlatingTypeList({ |
|
|
|
|
current: this.page.currentPage, |
|
|
|
|
size: this.page.pageSize, |
|
|
|
|
...this.query, |
|
|
|
|
}); |
|
|
|
|
this.data = res.data.data.records; |
|
|
|
|
let list = res.data.data.records; |
|
|
|
|
// 批量获取 bcName —— 正确用法! |
|
|
|
|
await Promise.all( |
|
|
|
|
list.map(async item => { |
|
|
|
|
item.bcId = item.bcId + ''; |
|
|
|
|
item.subClass = item.subClass + ''; |
|
|
|
|
item.bcName = await this.getBcName(item.bcId); // ✅ 等待返回 |
|
|
|
|
console.log('item.bcName =', item.bcName); // 现在一定有值 |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
this.data = list; |
|
|
|
|
this.page.total = res.data.data.total; |
|
|
|
|
this.loading = false; |
|
|
|
|
}); |
|
|
|
|
} catch (e) {} |
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
|
|
// // getLazyList(this.parentId, Object.assign(params, this.query)).then(res => { |
|
|
|
|
// // this.data = res.data.data; |
|
|
|
|
@ -1018,4 +1087,4 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
</script> |