代码提交

This commit is contained in:
jiang 2025-11-28 17:38:26 +08:00
parent 82b511b50b
commit 8b6c4caa1d
2 changed files with 273 additions and 270 deletions

View File

@ -92,11 +92,12 @@
</el-form>
<el-card class="content-box">
<el-row>
<!-- <el-row>
<el-col :span="24" style="text-align: right;">
<el-button type="primary" icon="el-icon-refresh" size="mini" @click="onHandleBatchRetire">批量退役</el-button>
<el-button type="primary" icon="el-icon-refresh" size="mini" @click="onHandleBatchRetire">批量退役
</el-button>
</el-col>
</el-row>
</el-row>-->
<div class="table-container">
<el-table :data="tableData" style="width: 100%" border stripe height="100%">
<el-table-column align="center" show-overflow-tooltip type="index" label="序号" width="50"/>
@ -134,14 +135,14 @@
</span>
</template>
</el-table-column>
<el-table-column align="center" show-overflow-tooltip prop="address" label="操作">
<!-- <el-table-column align="center" show-overflow-tooltip prop="address" label="操作">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="onHandleRetire(scope.row)">退役</el-button>
<!-- <el-button type="primary" size="mini" @click="onHandleRetireEquipment(scope.row)">
&lt;!&ndash; <el-button type="primary" size="mini" @click="onHandleRetireEquipment(scope.row)">
退役装备
</el-button> -->
</el-button> &ndash;&gt;
</template>
</el-table-column>
</el-table-column>-->
</el-table>
</div>
<div class="pagination-wrapper">
@ -370,6 +371,7 @@ export default {
}
}
}
.dialog-table {
border-radius: 6px;
overflow: hidden;

View File

@ -59,7 +59,6 @@
</el-form-item>
</el-form>
</el-card>
@ -318,6 +317,7 @@ export default {
proLocation: '', //
useUnit: '', //
useTime: null,
leaseType: '0',
pageNum: 1, //
pageSize: 10 //
},
@ -337,7 +337,7 @@ export default {
proCounty: [{ required: true, message: '请选择项目所在区/县', trigger: 'change' }],
proLocation: [{ required: true, message: '请输入详细地址', trigger: 'blur' }],
useUnit: [{ required: true, message: '请输入需求单位', trigger: 'blur' }],
useTimeRange: [{ required: true, message: '请选择使用到期日期', trigger: 'change' }],
useTimeRange: [{ required: true, message: '请选择使用到期日期', trigger: 'change' }]
},
@ -403,8 +403,8 @@ export default {
'queryParams.useTimeRange'(newVal) {
if (newVal && newVal.length === 2 && this.tableList.length > 0) {
this.tableList.forEach(item => {
item.useTimeRange = [...newVal]; //
});
item.useTimeRange = [...newVal] //
})
}
}
},
@ -415,12 +415,12 @@ export default {
const [resProject, resVoltage] = await Promise.all([
getUseProjectListAPI(),
getVoltageListAPI()
]);
])
this.useProjectList = resProject.data || []
this.voltageList = resVoltage.data || []
} catch (error) {
this.$message.error('获取项目或电压等级列表失败');
console.error(error);
this.$message.error('获取项目或电压等级列表失败')
console.error(error)
}
},
@ -461,14 +461,14 @@ export default {
async getList(emit = {}) {
// emitid
if (emit.id) {
this.queryParams.id = emit.id;
this.$route.query.id = this.queryParams.id;
this.queryParams.id = emit.id
this.$route.query.id = this.queryParams.id
}
this.isLoading = true;
this.isLoading = true
try {
const params = { ...this.queryParams };
const res = await getApplyDetailsApi(params); //
const params = { ...this.queryParams }
const res = await getApplyDetailsApi(params) //
//
this.tableList = (res.data.devDetailsList || []).map(item => ({
@ -477,29 +477,29 @@ export default {
useTimeRange: item.useStartTime && item.useEndTime
? [new Date(item.useStartTime), new Date(item.useEndTime)]
: [] //
}));
}))
// /
if (this.queryParams.id && res.data.devInfo) {
Object.assign(this.queryParams, res.data.devInfo);
Object.assign(this.queryParams, res.data.devInfo)
//
if (res.data.devInfo.useStartTime && res.data.devInfo.useEndTime) {
this.queryParams.useTimeRange = [
new Date(res.data.devInfo.useStartTime),
new Date(res.data.devInfo.useEndTime)
];
]
}
}
this.total = res.data.total || 0;
this.total = res.data.total || 0
} catch (error) {
this.tableList = [];
this.total = 0;
this.$message.error('获取申请详情失败');
console.error('getList error:', error);
this.tableList = []
this.total = 0
this.$message.error('获取申请详情失败')
console.error('getList error:', error)
} finally {
this.isLoading = false;
this.isLoading = false
}
},
@ -517,20 +517,20 @@ export default {
})
}).catch(() => {
//
});
})
},
//
handleDialog() {
this.addQuery.pageNum = 1;
this.resetAddQuery(); //
this.addQuery.pageNum = 1
this.resetAddQuery() //
this.openAdd = true
//
this.$nextTick(() => {
if (this.$refs.addTable) {
this.$refs.addTable.clearSelection();
this.$refs.addTable.clearSelection()
}
});
})
},
/**
@ -539,70 +539,70 @@ export default {
*/
getApplyList(pagination = {}) {
// 使
const pageNum = pagination.pageNum || this.addQuery.pageNum;
const pageSize = pagination.pageSize || this.addQuery.pageSize;
const pageNum = pagination.pageNum || this.addQuery.pageNum
const pageSize = pagination.pageSize || this.addQuery.pageSize
//
this.addQuery.pageNum = pageNum;
this.addQuery.pageSize = pageSize;
this.addQuery.pageNum = pageNum
this.addQuery.pageSize = pageSize
// devType
const queryParams = {
...this.filterParams,
pageNum,
pageSize
};
}
this.isLoading = true;
this.isLoading = true
getApplyListApi(queryParams)
.then(response => {
if (response && response.data) {
this.addList = response.data.rows || [];
this.addTotal = response.data.total || 0;
this.addList = response.data.rows || []
this.addTotal = response.data.total || 0
//
this.addList.forEach(item => {
item.num = item.manageType === 0 ? 1 : 0;
});
item.num = item.manageType == '0' ? 1 : 0
})
} else {
this.addList = [];
this.addTotal = 0;
this.$message.warning('获取数据格式异常');
this.addList = []
this.addTotal = 0
this.$message.warning('获取数据格式异常')
}
})
.catch(error => {
this.addList = [];
this.addTotal = 0;
this.$message.error(`获取设备列表失败:${error.message || '未知错误'}`);
console.error('分页查询失败:', error);
this.addList = []
this.addTotal = 0
this.$message.error(`获取设备列表失败:${error.message || '未知错误'}`)
console.error('分页查询失败:', error)
})
.finally(() => {
this.isLoading = false;
});
this.isLoading = false
})
},
/**
* 添加申请查询核心处理devType筛选逻辑
*/
handleAddQuery() {
this.addQuery.pageNum = 1; // 1
this.addQuery.pageNum = 1 // 1
const queryParams = { ...this.addQuery };
const queryParams = { ...this.addQuery }
// 1. devType使1=2=
const devType = queryParams.devType || '';
const devType = queryParams.devType || ''
// 2.
let categoryEquipment = '';
let categoryEquipment = ''
if (devType === '1' && queryParams.categoryPath && Array.isArray(queryParams.categoryPath) && queryParams.categoryPath.length > 0) {
categoryEquipment = String(queryParams.categoryPath[queryParams.categoryPath.length - 1]);
categoryEquipment = String(queryParams.categoryPath[queryParams.categoryPath.length - 1])
}
// 3.
let toolTypeId = '';
let toolTypeId = ''
if (devType === '2' && queryParams.toolCategoryPath && Array.isArray(queryParams.toolCategoryPath) && queryParams.toolCategoryPath.length > 0) {
toolTypeId = String(queryParams.toolCategoryPath[queryParams.toolCategoryPath.length - 1]);
toolTypeId = String(queryParams.toolCategoryPath[queryParams.toolCategoryPath.length - 1])
}
// devType
@ -614,13 +614,13 @@ export default {
toolTypeId,
devType, // devType
manageType: queryParams.manageType // manageType
};
}
//
this.getApplyList({
pageNum: this.addQuery.pageNum,
pageSize: this.addQuery.pageSize
});
})
},
/**
@ -636,7 +636,7 @@ export default {
toolCategoryPath: '',
pageNum: 1,
pageSize: 10
};
}
//
this.filterParams = {
@ -646,10 +646,10 @@ export default {
categoryEquipment: '',
toolTypeId: '',
devType: '' // devType
};
}
//
this.getApplyList({ pageNum: 1, pageSize: this.addQuery.pageSize });
this.getApplyList({ pageNum: 1, pageSize: this.addQuery.pageSize })
},
//
@ -666,6 +666,7 @@ export default {
// devType
handleSelectionChange(selection) {
console.log(selection)
this.addTempList = []
this.ids = selection.map(item => item.id)
selection.forEach(item => {
@ -679,7 +680,7 @@ export default {
manageType: item.manageType,
devCode: item.devCode,
storageNum: item.storageNum,
num: item.manageType == 0 ? 1 : item.storageNum, // 1
num: item.manageType === '0' ? '1' : item.storageNum, // 1
useTime: this.queryParams.useTime ? new Date(this.queryParams.useTime) : null // 使
})
})
@ -711,7 +712,7 @@ export default {
})
row.num = row.storageNum //
} else if (row.num < 0) {
row.num = 0; //
row.num = 0 //
}
},
@ -723,7 +724,7 @@ export default {
}
const itemsToAdd = this.addList.filter(item => this.ids.includes(item.id))
const invalidItem = itemsToAdd.find(item => item.manageType === 1 && (item.num === 0 || !item.num))
const invalidItem = itemsToAdd.find(item => item.manageType === '1' && (item.num == 0 || !item.num))
if (invalidItem) {
this.$message.error('请为数量管理的设备填写申请数量。')
return
@ -752,54 +753,54 @@ export default {
//
async submit() {
this.$refs.queryForm.validate(async(valid) => {
if (!valid) return;
if (!valid) return
this.$confirm('是否确定提交申请?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async() => {
this.isLoading = true;
this.isLoading = true
try {
// --- ---
const safeFormatDate = (dateInput) => {
// 1. null undefined
if (!dateInput) {
console.warn('尝试格式化一个空的日期值');
return ''; // '1970-01-01'
console.warn('尝试格式化一个空的日期值')
return '' // '1970-01-01'
}
// 2. Date
let date;
let date
if (dateInput instanceof Date) {
date = dateInput;
date = dateInput
} else {
// Date
date = new Date(dateInput);
date = new Date(dateInput)
}
// 3. Date
if (isNaN(date.getTime())) {
console.error('无效的日期值:', dateInput);
return ''; //
console.error('无效的日期值:', dateInput)
return '' //
}
// 4.
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
};
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
return `${year}-${month}-${day}`
}
// --- ---
// 1.
const devInfo = { ...this.queryParams };
const devInfo = { ...this.queryParams }
if (devInfo.useTimeRange && devInfo.useTimeRange.length === 2) {
// 使
devInfo.useStartTime = safeFormatDate(devInfo.useTimeRange[0]);
devInfo.useEndTime = safeFormatDate(devInfo.useTimeRange[1]);
devInfo.useStartTime = safeFormatDate(devInfo.useTimeRange[0])
devInfo.useEndTime = safeFormatDate(devInfo.useTimeRange[1])
}
delete devInfo.useTimeRange;
delete devInfo.useTimeRange
// 2.
const tempTableList = this.tableList.map(item => ({
@ -810,35 +811,35 @@ export default {
useEndTime: safeFormatDate(item.useTimeRange[1]),
useTimeRange: undefined,
useTime: undefined
}));
}))
const params = {
devInfo,
devDetailsList: tempTableList
};
}
// ... ...
let res;
let res
if (!this.routerParams.id) {
res = await addApplyApi(params);
res = await addApplyApi(params)
} else {
res = await editApplyApi(params);
res = await editApplyApi(params)
}
if (res.code === 200) {
this.$message.success(res.message || '操作成功!');
this.$router.go(-1);
this.$message.success(res.message || '操作成功!')
this.$router.go(-1)
} else {
this.$message.error(res.message || '操作失败!');
this.$message.error(res.message || '操作失败!')
}
} catch (error) {
this.$message.error('提交申请异常,请稍后重试');
console.error('submit error:', error);
this.$message.error('提交申请异常,请稍后重试')
console.error('submit error:', error)
} finally {
this.isLoading = false;
this.isLoading = false
}
});
});
})
})
},
//