This commit is contained in:
parent
ad1b979b7c
commit
71e1fe5c41
|
|
@ -50,6 +50,8 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
},
|
},
|
||||||
selectionList: [],
|
selectionList: [],
|
||||||
|
treeDataList: [],
|
||||||
|
projectList: [], // 新增:存储项目列表数据
|
||||||
option: {
|
option: {
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
calcHeight: 32,
|
calcHeight: 32,
|
||||||
|
|
@ -80,6 +82,10 @@ export default {
|
||||||
dicMethod: 'post',
|
dicMethod: 'post',
|
||||||
props: { label: 'proName', value: 'id' },
|
props: { label: 'proName', value: 'id' },
|
||||||
rules: [{ required: true, message: '请选择项目', trigger: 'change' }],
|
rules: [{ required: true, message: '请选择项目', trigger: 'change' }],
|
||||||
|
change: (form) => {
|
||||||
|
// 项目选择变化时自动填充项目名称和单项工程名称
|
||||||
|
this.handleProjectChange(form);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '单项工程名称',
|
label: '单项工程名称',
|
||||||
|
|
@ -101,6 +107,8 @@ export default {
|
||||||
prop: 'deptId',
|
prop: 'deptId',
|
||||||
type: 'tree',
|
type: 'tree',
|
||||||
search: true,
|
search: true,
|
||||||
|
viewDisplay: false,
|
||||||
|
hide: true,
|
||||||
dicData: [],
|
dicData: [],
|
||||||
props: { label: 'label', value: 'id', children: 'children' },
|
props: { label: 'label', value: 'id', children: 'children' },
|
||||||
rules: [{ required: true, message: '请选择接收单位', trigger: 'change' }],
|
rules: [{ required: true, message: '请选择接收单位', trigger: 'change' }],
|
||||||
|
|
@ -121,7 +129,7 @@ export default {
|
||||||
search: true,
|
search: true,
|
||||||
hide: true,
|
hide: true,
|
||||||
display: false,
|
display: false,
|
||||||
type: 'select', //指定该字段在表单中的输入类型为“下拉选择框”
|
type: 'select', //指定该字段在表单中的输入类型为"下拉选择框"
|
||||||
dicUrl: '/blade-system/system/dict/data/type', // 接口地址
|
dicUrl: '/blade-system/system/dict/data/type', // 接口地址
|
||||||
dicMethod: 'post', // 指定为 POST 请求
|
dicMethod: 'post', // 指定为 POST 请求
|
||||||
dicQuery: {
|
dicQuery: {
|
||||||
|
|
@ -146,7 +154,7 @@ export default {
|
||||||
search: true,
|
search: true,
|
||||||
hide: true,
|
hide: true,
|
||||||
display: false,
|
display: false,
|
||||||
type: 'select', //指定该字段在表单中的输入类型为“下拉选择框”
|
type: 'select', //指定该字段在表单中的输入类型为"下拉选择框"
|
||||||
dicUrl: '/blade-system/system/dict/data/type', // 接口地址
|
dicUrl: '/blade-system/system/dict/data/type', // 接口地址
|
||||||
dicMethod: 'post', // 指定为 POST 请求
|
dicMethod: 'post', // 指定为 POST 请求
|
||||||
dicQuery: {
|
dicQuery: {
|
||||||
|
|
@ -189,7 +197,44 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 处理项目选择变化
|
||||||
|
handleProjectChange(form) {
|
||||||
|
if (!form.proId) return;
|
||||||
|
|
||||||
|
// 从项目列表中查找选中的项目
|
||||||
|
const selectedProject = this.projectList.find(item => item.id === form.proId);
|
||||||
|
if (selectedProject) {
|
||||||
|
form.proName = selectedProject.proName; // 项目名称
|
||||||
|
form.singleProName = selectedProject.name; // 单项工程名称(name字段)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 确保项目数据映射
|
||||||
|
ensureProjectData(row) {
|
||||||
|
if (row.proId && (!row.proName || !row.singleProName)) {
|
||||||
|
const selectedProject = this.projectList.find(item => item.id === row.proId);
|
||||||
|
if (selectedProject) {
|
||||||
|
row.proName = selectedProject.proName;
|
||||||
|
row.singleProName = selectedProject.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载项目列表数据
|
||||||
|
loadProjectList() {
|
||||||
|
this.$axios.post('/blade-system/transferApply/getProSelect', {}).then(res => {
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
this.projectList = res.data.data;
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('加载项目列表失败:', error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
rowSave(row, done, loading) {
|
rowSave(row, done, loading) {
|
||||||
|
// 确保项目数据正确映射
|
||||||
|
this.ensureProjectData(row);
|
||||||
|
|
||||||
const findTreeNode = (nodes, id) => {
|
const findTreeNode = (nodes, id) => {
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
if (node.id === id) {
|
if (node.id === id) {
|
||||||
|
|
@ -208,13 +253,16 @@ export default {
|
||||||
// 只提取需要的字段
|
// 只提取需要的字段
|
||||||
const submitData = {
|
const submitData = {
|
||||||
proId: row.proId, // 项目ID
|
proId: row.proId, // 项目ID
|
||||||
proName: row.proName, // 项目名称
|
proName: row.proName || '', // 项目名称
|
||||||
singleProName: row.singleProName, // 单项工程名称
|
singleProName: row.singleProName || '', // 单项工程名称
|
||||||
transferTime: row.transferTime, // 移交时间(YYYY-MM-DD)
|
transferTime: row.transferTime, // 移交时间(YYYY-MM-DD)
|
||||||
deptId: row.deptId, // 接收单位ID
|
deptId: row.deptId, // 接收单位ID
|
||||||
deptName: deptName , // 接收名称
|
deptName: deptName , // 接收名称
|
||||||
transferIssue: row.transferIssue, // 移交问题
|
transferIssue: row.transferIssue, // 移交问题
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('提交数据:', submitData);
|
||||||
|
|
||||||
addTransferProblemApi(submitData).then(
|
addTransferProblemApi(submitData).then(
|
||||||
() => {
|
() => {
|
||||||
this.onLoad(this.page);
|
this.onLoad(this.page);
|
||||||
|
|
@ -230,6 +278,7 @@ export default {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadDeptOptions() {
|
loadDeptOptions() {
|
||||||
getDeptSelectApi().then(res => {
|
getDeptSelectApi().then(res => {
|
||||||
this.treeDataList = this.convertToVueTree(res.data.data);
|
this.treeDataList = this.convertToVueTree(res.data.data);
|
||||||
|
|
@ -242,6 +291,7 @@ export default {
|
||||||
console.error('加载部门列表失败', err);
|
console.error('加载部门列表失败', err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 树数据过滤 - 支持无限层级转换
|
// 树数据过滤 - 支持无限层级转换
|
||||||
convertToVueTree(data, level = 1) {
|
convertToVueTree(data, level = 1) {
|
||||||
if (!data || !Array.isArray(data)) {
|
if (!data || !Array.isArray(data)) {
|
||||||
|
|
@ -263,6 +313,7 @@ export default {
|
||||||
return node
|
return node
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
rowUpdate(row, index, done, loading) {
|
rowUpdate(row, index, done, loading) {
|
||||||
// 只保留需要的字段
|
// 只保留需要的字段
|
||||||
const submitData = {
|
const submitData = {
|
||||||
|
|
@ -291,6 +342,7 @@ export default {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
rowDel(row) {
|
rowDel(row) {
|
||||||
this.$confirm('确定将选择数据删除?', {
|
this.$confirm('确定将选择数据删除?', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
|
|
@ -308,6 +360,7 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDelete() {
|
handleDelete() {
|
||||||
if (this.selectionList.length === 0) {
|
if (this.selectionList.length === 0) {
|
||||||
this.$message.warning('请选择至少一条数据');
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
|
@ -330,38 +383,53 @@ export default {
|
||||||
this.$refs.crud.toggleSelection();
|
this.$refs.crud.toggleSelection();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeOpen(done, type, row) {
|
beforeOpen(done, type, row) {
|
||||||
done(); // 必须调用 done()
|
// 确保新增时数据已加载
|
||||||
|
if (type === 'add') {
|
||||||
|
this.loadDeptOptions();
|
||||||
|
this.loadProjectList();
|
||||||
|
}
|
||||||
|
done();
|
||||||
},
|
},
|
||||||
|
|
||||||
searchReset() {
|
searchReset() {
|
||||||
this.query = {};
|
this.query = {};
|
||||||
this.onLoad(this.page);
|
this.onLoad(this.page);
|
||||||
},
|
},
|
||||||
|
|
||||||
searchChange(params, done) {
|
searchChange(params, done) {
|
||||||
this.query = params;
|
this.query = params;
|
||||||
this.page.currentPage = 1;
|
this.page.currentPage = 1;
|
||||||
this.onLoad(this.page, params);
|
this.onLoad(this.page, params);
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
|
|
||||||
selectionChange(list) {
|
selectionChange(list) {
|
||||||
this.selectionList = list;
|
this.selectionList = list;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectionClear() {
|
selectionClear() {
|
||||||
this.selectionList = [];
|
this.selectionList = [];
|
||||||
this.$refs.crud.toggleSelection();
|
this.$refs.crud.toggleSelection();
|
||||||
},
|
},
|
||||||
|
|
||||||
currentChange(currentPage) {
|
currentChange(currentPage) {
|
||||||
this.page.currentPage = currentPage;
|
this.page.currentPage = currentPage;
|
||||||
},
|
},
|
||||||
|
|
||||||
sizeChange(pageSize) {
|
sizeChange(pageSize) {
|
||||||
this.page.pageSize = pageSize;
|
this.page.pageSize = pageSize;
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshChange() {
|
refreshChange() {
|
||||||
this.onLoad(this.page, this.query);
|
this.onLoad(this.page, this.query);
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(page, params = {}) {
|
onLoad(page, params = {}) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.loadDeptOptions();
|
this.loadDeptOptions();
|
||||||
|
this.loadProjectList(); // 加载项目列表
|
||||||
let data = {
|
let data = {
|
||||||
...params,
|
...params,
|
||||||
pageNum:page.currentPage,
|
pageNum:page.currentPage,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue