feat(equipment): 添加供应商选择功能并优化工艺流程
This commit is contained in:
parent
af0d5e0c4f
commit
0f7cf4f068
@ -21,4 +21,7 @@ public interface SupplierService extends IService<SupplierEntity> {
|
|||||||
String checkForm(SupplierForm form, int i);
|
String checkForm(SupplierForm form, int i);
|
||||||
|
|
||||||
void saveOrUpdate(SupplierForm supplierForm, String id, boolean isSave) throws Exception;
|
void saveOrUpdate(SupplierForm supplierForm, String id, boolean isSave) throws Exception;
|
||||||
|
|
||||||
|
List<SupplierEntity> getSelectList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,4 +120,15 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, SupplierEnt
|
|||||||
BeanUtils.copyProperties(supplierForm, entity);
|
BeanUtils.copyProperties(supplierForm, entity);
|
||||||
this.saveOrUpdate(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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,4 +102,20 @@ public class SupplierController {
|
|||||||
}
|
}
|
||||||
return ActionResult.fail("删除失败,数据不存在");
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,6 +67,14 @@ export function getLineList() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取供应商列表
|
||||||
|
export function getSupplierList() {
|
||||||
|
return request({
|
||||||
|
url: '/api/scm/supplier/getSelectList',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 客户管理字典映射配置(id -> 名称)
|
// 客户管理字典映射配置(id -> 名称)
|
||||||
export const equipmentMaps = {
|
export const equipmentMaps = {
|
||||||
|
|||||||
@ -53,8 +53,9 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="供应商" prop="supplier">
|
<el-form-item label="供应商" prop="supplier">
|
||||||
<JnpfInput v-model="dataForm.supplier" placeholder="请输入供应商" clearable>
|
<el-select v-model="dataForm.supplier" placeholder="请选择供应商" filterable clearable :style="{ width: '100%' }">
|
||||||
</JnpfInput>
|
<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-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
@ -138,6 +139,10 @@ export default {
|
|||||||
lineList: {
|
lineList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
supplierList: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -248,6 +253,9 @@ export default {
|
|||||||
if (this.dataForm.buyDate && typeof this.dataForm.buyDate === 'string') {
|
if (this.dataForm.buyDate && typeof this.dataForm.buyDate === 'string') {
|
||||||
this.dataForm.buyDate = new Date(this.dataForm.buyDate).getTime();
|
this.dataForm.buyDate = new Date(this.dataForm.buyDate).getTime();
|
||||||
}
|
}
|
||||||
|
if (this.dataForm.supplier) {
|
||||||
|
this.dataForm.supplier = String(this.dataForm.supplier);
|
||||||
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@ -288,6 +296,7 @@ export default {
|
|||||||
const line = this.lineList.find(item => item.id === lineId);
|
const line = this.lineList.find(item => item.id === lineId);
|
||||||
this.dataForm.lineName = line ? (line.name || line.lineName) : undefined;
|
this.dataForm.lineName = line ? (line.name || line.lineName) : undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
dataFormSubmit() {
|
dataFormSubmit() {
|
||||||
this.$refs.formRef.validate((valid) => {
|
this.$refs.formRef.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|||||||
@ -87,7 +87,11 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="mode" label="型号" align="center" min-width="100"/>
|
<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="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="userName" label="责任人" align="center" min-width="80"/>
|
||||||
<el-table-column prop="lineName" label="所属产线" align="center" min-width="100"/>
|
<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"/>
|
<el-table-column prop="buyDate" label="购买日期" align="center" min-width="100" :formatter="jnpf.tableDateFormat1"/>
|
||||||
@ -116,12 +120,12 @@
|
|||||||
@pagination="initData"/>
|
@pagination="initData"/>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<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 {getDataInterfaceRes} from "@/api/systemData/dataInterface";
|
||||||
import {mapGetters} from "vuex";
|
import {mapGetters} from "vuex";
|
||||||
import JNPFForm from "./form";
|
import JNPFForm from "./form";
|
||||||
@ -156,6 +160,7 @@ export default {
|
|||||||
formVisible: false,
|
formVisible: false,
|
||||||
deptList: [],
|
deptList: [],
|
||||||
lineList: [],
|
lineList: [],
|
||||||
|
supplierList: [],
|
||||||
enabledStatusOptions: [
|
enabledStatusOptions: [
|
||||||
{fullName: "启用", id: 1},
|
{fullName: "启用", id: 1},
|
||||||
{fullName: "未启用", id: 2},
|
{fullName: "未启用", id: 2},
|
||||||
@ -180,6 +185,7 @@ export default {
|
|||||||
this.initData();
|
this.initData();
|
||||||
this.getDeptList();
|
this.getDeptList();
|
||||||
this.getLineList();
|
this.getLineList();
|
||||||
|
this.getSupplierList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initData() {
|
initData() {
|
||||||
@ -219,6 +225,13 @@ export default {
|
|||||||
this.lineList = res.data || [];
|
this.lineList = res.data || [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getSupplierList() {
|
||||||
|
getSupplierList().then(res => {
|
||||||
|
this.supplierList = res.data || [];
|
||||||
|
}).catch(() => {
|
||||||
|
this.supplierList = [];
|
||||||
|
});
|
||||||
|
},
|
||||||
addOrUpdateHandle(row) {
|
addOrUpdateHandle(row) {
|
||||||
let id = row ? row.id : "";
|
let id = row ? row.id : "";
|
||||||
this.formVisible = true;
|
this.formVisible = true;
|
||||||
@ -288,6 +301,11 @@ export default {
|
|||||||
getEqStatusLabel(value) {
|
getEqStatusLabel(value) {
|
||||||
return getLabel('eqStatus', 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>
|
</script>
|
||||||
|
|||||||
@ -235,4 +235,4 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -60,6 +60,8 @@ export default {
|
|||||||
props: [],
|
props: [],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// 统一分割符号定义
|
||||||
|
PROC_SEPARATOR: '-',
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
btnLoading: false,
|
btnLoading: false,
|
||||||
@ -137,9 +139,12 @@ export default {
|
|||||||
this.dataForm = res.data
|
this.dataForm = res.data
|
||||||
// 将存储的编码拼接转换为名称拼接显示
|
// 将存储的编码拼接转换为名称拼接显示
|
||||||
this.techProcDisplay = this.convertCodeToName(res.data.techProc)
|
this.techProcDisplay = this.convertCodeToName(res.data.techProc)
|
||||||
// 自动选中表格中的工序
|
// 先设置 loading = false 让表格渲染
|
||||||
this.setSelectedRows(res.data.procList || res.data.techProc)
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
// 等待表格渲染完成后再设置选中行
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.setSelectedRows(res.data.procList || res.data.techProc)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
@ -164,37 +169,49 @@ export default {
|
|||||||
if (!codeStr) {
|
if (!codeStr) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
const codes = codeStr.split('_')
|
const codes = codeStr.split(this.PROC_SEPARATOR)
|
||||||
const names = codes.map(code => {
|
const names = codes.map(code => {
|
||||||
const proc = this.procList.find(item => item.procCd === code)
|
const proc = this.procList.find(item => item.procCd === code)
|
||||||
return proc ? proc.procName : code
|
return proc ? proc.procName : code
|
||||||
})
|
})
|
||||||
return names.join('_')
|
return names.join(this.PROC_SEPARATOR)
|
||||||
},
|
},
|
||||||
// 设置表格选中行
|
// 设置表格选中行
|
||||||
setSelectedRows(procCodes) {
|
setSelectedRows(procCodes) {
|
||||||
if (!procCodes || !this.$refs.procTable) {
|
if (!procCodes || !this.$refs.procTable || this.procList.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let codes = []
|
let codes = []
|
||||||
if (Array.isArray(procCodes)) {
|
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') {
|
} else if (typeof procCodes === 'string') {
|
||||||
// 如果是编码拼接字符串
|
// 如果是编码拼接字符串
|
||||||
codes = procCodes.split('_')
|
codes = procCodes.split(this.PROC_SEPARATOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 先清除所有选中状态
|
||||||
|
this.$refs.procTable.clearSelection()
|
||||||
|
|
||||||
if (codes.length > 0) {
|
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
|
this.selectedProcs = selectedRows
|
||||||
// 延迟执行以确保表格已渲染
|
|
||||||
setTimeout(() => {
|
// 使用 nextTick 确保表格已渲染
|
||||||
|
this.$nextTick(() => {
|
||||||
selectedRows.forEach(row => {
|
selectedRows.forEach(row => {
|
||||||
this.$refs.procTable.toggleRowSelection(row, true)
|
this.$refs.procTable.toggleRowSelection(row, true)
|
||||||
})
|
})
|
||||||
}, 100)
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 工序选择变化处理 - 按列表顺序排列
|
// 工序选择变化处理 - 按列表顺序排列
|
||||||
@ -205,9 +222,9 @@ export default {
|
|||||||
// 按列表顺序过滤选中的工序
|
// 按列表顺序过滤选中的工序
|
||||||
const sortedSelected = this.procList.filter(item => selectedCodes.has(item.procCd));
|
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);
|
this.dataForm.procList = sortedSelected.map(item => item.procCd);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -73,6 +73,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// 统一分割符号定义
|
||||||
|
PROC_SEPARATOR: '-',
|
||||||
keyword: "",
|
keyword: "",
|
||||||
query: {
|
query: {
|
||||||
techProc: undefined,
|
techProc: undefined,
|
||||||
@ -127,12 +129,12 @@ export default {
|
|||||||
// 将编码拼接转换为名称拼接
|
// 将编码拼接转换为名称拼接
|
||||||
convertCodeToName(codeStr) {
|
convertCodeToName(codeStr) {
|
||||||
if (!codeStr) return '';
|
if (!codeStr) return '';
|
||||||
const codes = codeStr.split('_');
|
const codes = codeStr.split(this.PROC_SEPARATOR);
|
||||||
const names = codes.map(code => {
|
const names = codes.map(code => {
|
||||||
const proc = this.procList.find(item => item.procCd === code);
|
const proc = this.procList.find(item => item.procCd === code);
|
||||||
return proc ? proc.procName : code;
|
return proc ? proc.procName : code;
|
||||||
});
|
});
|
||||||
return names.join('_');
|
return names.join(this.PROC_SEPARATOR);
|
||||||
},
|
},
|
||||||
initData() {
|
initData() {
|
||||||
this.listLoading = true;
|
this.listLoading = true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user