代码提交

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-form>
<el-card class="content-box"> <el-card class="content-box">
<el-row> <!-- <el-row>
<el-col :span="24" style="text-align: right;"> <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-col>
</el-row> </el-row>-->
<div class="table-container"> <div class="table-container">
<el-table :data="tableData" style="width: 100%" border stripe height="100%"> <el-table :data="tableData" style="width: 100%" border stripe height="100%">
<el-table-column align="center" show-overflow-tooltip type="index" label="序号" width="50"/> <el-table-column align="center" show-overflow-tooltip type="index" label="序号" width="50"/>
@ -134,14 +135,14 @@
</span> </span>
</template> </template>
</el-table-column> </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"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="onHandleRetire(scope.row)">退役</el-button> <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> </template>
</el-table-column> </el-table-column>-->
</el-table> </el-table>
</div> </div>
<div class="pagination-wrapper"> <div class="pagination-wrapper">
@ -370,6 +371,7 @@ export default {
} }
} }
} }
.dialog-table { .dialog-table {
border-radius: 6px; border-radius: 6px;
overflow: hidden; overflow: hidden;

View File

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