feat(equipment): 添加供应商选择功能并优化工艺流程

This commit is contained in:
zxy 2026-04-15 11:01:46 +08:00
parent af0d5e0c4f
commit 0f7cf4f068
9 changed files with 106 additions and 22 deletions

View File

@ -21,4 +21,7 @@ public interface SupplierService extends IService<SupplierEntity> {
String checkForm(SupplierForm form, int i);
void saveOrUpdate(SupplierForm supplierForm, String id, boolean isSave) throws Exception;
List<SupplierEntity> getSelectList();
}

View File

@ -120,4 +120,15 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, SupplierEnt
BeanUtils.copyProperties(supplierForm, entity);
this.saveOrUpdate(entity);
}
@Override
public List<SupplierEntity> getSelectList() {
LambdaQueryWrapper<SupplierEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SupplierEntity::getDeleteMark, 0);
wrapper.eq(SupplierEntity::getEnabledStatus, 1);
wrapper.orderByDesc(SupplierEntity::getId);
return this.list(wrapper);
}
}

View File

@ -102,4 +102,20 @@ public class SupplierController {
}
return ActionResult.fail("删除失败,数据不存在");
}
@Operation(summary = "获取产线下拉列表")
@GetMapping("/getSelectList")
public ActionResult getSelectList() {
List<SupplierEntity> list = supplierService.getSelectList();
List<Map<String, Object>> result = list.stream()
.map(entity -> {
Map<String, Object> map = JsonUtil.entityToMap(entity);
map.put("id", entity.getId());
map.put("name", entity.getSupplierName());
return map;
})
.collect(Collectors.toList());
return ActionResult.success(result);
}
}

View File

@ -67,6 +67,14 @@ export function getLineList() {
})
}
// 获取供应商列表
export function getSupplierList() {
return request({
url: '/api/scm/supplier/getSelectList',
method: 'get'
})
}
// 客户管理字典映射配置id -> 名称)
export const equipmentMaps = {

View File

@ -53,8 +53,9 @@
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="供应商" prop="supplier">
<JnpfInput v-model="dataForm.supplier" placeholder="请输入供应商" clearable>
</JnpfInput>
<el-select v-model="dataForm.supplier" placeholder="请选择供应商" filterable clearable :style="{ width: '100%' }">
<el-option v-for="item in supplierList" :key="item.id" :label="item.supplierName" :value="String(item.id)"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@ -138,6 +139,10 @@ export default {
lineList: {
type: Array,
default: () => []
},
supplierList: {
type: Array,
default: () => []
}
},
data() {
@ -248,6 +253,9 @@ export default {
if (this.dataForm.buyDate && typeof this.dataForm.buyDate === 'string') {
this.dataForm.buyDate = new Date(this.dataForm.buyDate).getTime();
}
if (this.dataForm.supplier) {
this.dataForm.supplier = String(this.dataForm.supplier);
}
this.loading = false;
}).catch(() => {
this.loading = false;
@ -288,6 +296,7 @@ export default {
const line = this.lineList.find(item => item.id === lineId);
this.dataForm.lineName = line ? (line.name || line.lineName) : undefined;
},
dataFormSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {

View File

@ -87,7 +87,11 @@
</el-table-column>
<el-table-column prop="mode" label="型号" align="center" min-width="100"/>
<el-table-column prop="manufacturer" label="生产厂家" align="center" min-width="120"/>
<el-table-column prop="supplier" label="供应商" align="center" min-width="120"/>
<el-table-column prop="supplier" label="供应商" align="center" min-width="120">
<template slot-scope="scope">
{{ getSupplierName(scope.row.supplier) }}
</template>
</el-table-column>
<el-table-column prop="userName" label="责任人" align="center" min-width="80"/>
<el-table-column prop="lineName" label="所属产线" align="center" min-width="100"/>
<el-table-column prop="buyDate" label="购买日期" align="center" min-width="100" :formatter="jnpf.tableDateFormat1"/>
@ -116,12 +120,12 @@
@pagination="initData"/>
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" :deptList="deptList" :lineList="lineList"/>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" :deptList="deptList" :lineList="lineList" :supplierList="supplierList"/>
</div>
</template>
<script>
import {customerOptions, deleteEquipment, getEquipmentList, getLabel, getLineList} from "./equipment";
import {customerOptions, deleteEquipment, getEquipmentList, getLabel, getLineList, getSupplierList} from "./equipment";
import {getDataInterfaceRes} from "@/api/systemData/dataInterface";
import {mapGetters} from "vuex";
import JNPFForm from "./form";
@ -156,6 +160,7 @@ export default {
formVisible: false,
deptList: [],
lineList: [],
supplierList: [],
enabledStatusOptions: [
{fullName: "启用", id: 1},
{fullName: "未启用", id: 2},
@ -180,6 +185,7 @@ export default {
this.initData();
this.getDeptList();
this.getLineList();
this.getSupplierList();
},
methods: {
initData() {
@ -219,6 +225,13 @@ export default {
this.lineList = res.data || [];
});
},
getSupplierList() {
getSupplierList().then(res => {
this.supplierList = res.data || [];
}).catch(() => {
this.supplierList = [];
});
},
addOrUpdateHandle(row) {
let id = row ? row.id : "";
this.formVisible = true;
@ -288,6 +301,11 @@ export default {
getEqStatusLabel(value) {
return getLabel('eqStatus', value);
},
getSupplierName(supplierId) {
if (!supplierId) return '-';
const supplier = this.supplierList.find(item => String(item.id) === String(supplierId));
return supplier ? supplier.supplierName : supplierId;
},
},
};
</script>

View File

@ -235,4 +235,4 @@ export default {
},
},
};
</script>
</script>

View File

@ -60,6 +60,8 @@ export default {
props: [],
data() {
return {
//
PROC_SEPARATOR: '-',
dialogVisible: false,
loading: false,
btnLoading: false,
@ -137,9 +139,12 @@ export default {
this.dataForm = res.data
//
this.techProcDisplay = this.convertCodeToName(res.data.techProc)
//
this.setSelectedRows(res.data.procList || res.data.techProc)
// loading = false
this.loading = false
//
this.$nextTick(() => {
this.setSelectedRows(res.data.procList || res.data.techProc)
})
})
} else {
this.loading = false
@ -164,37 +169,49 @@ export default {
if (!codeStr) {
return ''
}
const codes = codeStr.split('_')
const codes = codeStr.split(this.PROC_SEPARATOR)
const names = codes.map(code => {
const proc = this.procList.find(item => item.procCd === code)
return proc ? proc.procName : code
})
return names.join('_')
return names.join(this.PROC_SEPARATOR)
},
//
setSelectedRows(procCodes) {
if (!procCodes || !this.$refs.procTable) {
if (!procCodes || !this.$refs.procTable || this.procList.length === 0) {
return
}
let codes = []
if (Array.isArray(procCodes)) {
//
codes = procCodes
//
if (procCodes.length > 0 && typeof procCodes[0] === 'object') {
// procCd
codes = procCodes.map(item => item.procCd || item.id || item)
} else {
//
codes = procCodes
}
} else if (typeof procCodes === 'string') {
//
codes = procCodes.split('_')
codes = procCodes.split(this.PROC_SEPARATOR)
}
//
this.$refs.procTable.clearSelection()
if (codes.length > 0) {
const selectedRows = this.procList.filter(item => codes.includes(item.procCd))
// 使
const codeSet = new Set(codes.map(c => String(c)))
const selectedRows = this.procList.filter(item => codeSet.has(String(item.procCd)))
this.selectedProcs = selectedRows
//
setTimeout(() => {
// 使 nextTick
this.$nextTick(() => {
selectedRows.forEach(row => {
this.$refs.procTable.toggleRowSelection(row, true)
})
}, 100)
})
}
},
// -
@ -205,9 +222,9 @@ export default {
//
const sortedSelected = this.procList.filter(item => selectedCodes.has(item.procCd));
//
this.techProcDisplay = sortedSelected.map(item => item.procName).join('_');
this.techProcDisplay = sortedSelected.map(item => item.procName).join(this.PROC_SEPARATOR);
//
this.dataForm.techProc = sortedSelected.map(item => item.procCd).join('_');
this.dataForm.techProc = sortedSelected.map(item => item.procCd).join(this.PROC_SEPARATOR);
//
this.dataForm.procList = sortedSelected.map(item => item.procCd);
},

View File

@ -73,6 +73,8 @@ export default {
},
data() {
return {
//
PROC_SEPARATOR: '-',
keyword: "",
query: {
techProc: undefined,
@ -127,12 +129,12 @@ export default {
//
convertCodeToName(codeStr) {
if (!codeStr) return '';
const codes = codeStr.split('_');
const codes = codeStr.split(this.PROC_SEPARATOR);
const names = codes.map(code => {
const proc = this.procList.find(item => item.procCd === code);
return proc ? proc.procName : code;
});
return names.join('_');
return names.join(this.PROC_SEPARATOR);
},
initData() {
this.listLoading = true;