代码提交

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

@ -4,155 +4,156 @@
<el-row> <el-row>
<el-form ref="queryForm" size="small" label-width="auto" :model="queryParams"> <el-form ref="queryForm" size="small" label-width="auto" :model="queryParams">
<el-card class="search-box"> <el-card class="search-box">
<el-row :gutter="20" style="display: flex; justify-content: space-between"> <el-row :gutter="20" style="display: flex; justify-content: space-between">
<el-col :span="5"> <el-col :span="5">
<el-form-item label="装备名称" prop="name" > <el-form-item label="装备名称" prop="name">
<el-input <el-input
style="width: 100%" style="width: 100%"
v-model="queryParams.name" v-model="queryParams.name"
placeholder="输入装备名称" placeholder="输入装备名称"
clearable clearable
/>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="装备厂家" prop="manufacturerId">
<el-select
v-model="queryParams.manufacturerId"
placeholder="请选择生产厂家"
clearable
style="width: 100%"
>
<el-option
v-for="item in manufacturerList"
:key="item.id"
:label="item.label"
:value="item.id"
/> />
</el-select> </el-form-item>
</el-form-item> </el-col>
</el-col> <el-col :span="5">
<el-col :span="5"> <el-form-item label="装备厂家" prop="manufacturerId">
<el-form-item label="实际使用年限" prop="yearsDiff"> <el-select
<el-select v-model="queryParams.manufacturerId"
style="width: 100%" placeholder="请选择生产厂家"
v-model="queryParams.yearsDiff1" clearable
placeholder="选择选项" style="width: 100%"
clearable >
> <el-option
<el-option label="0-5年" value="0-5"/> v-for="item in manufacturerList"
<el-option label="5-10年" value="5-10"/> :key="item.id"
<el-option label="10-15年" value="10-15"/> :label="item.label"
<el-option label="15年以上" value="15-99"/> :value="item.id"
</el-select> />
</el-form-item> </el-select>
</el-col> </el-form-item>
<el-col :span="5"> </el-col>
<el-form-item label="剩余使用年限" prop="remainingYears"> <el-col :span="5">
<el-select <el-form-item label="实际使用年限" prop="yearsDiff">
style="width: 100%" <el-select
v-model="queryParams.yearsDiff2" style="width: 100%"
placeholder="选择选项" v-model="queryParams.yearsDiff1"
clearable placeholder="选择选项"
> clearable
<el-option label="0-5年" value="0-5"/> >
<el-option label="5-10年" value="5-10"/> <el-option label="0-5年" value="0-5"/>
<el-option label="10-15年" value="10-15"/> <el-option label="5-10年" value="5-10"/>
<el-option label="15年以上" value="15-99"/> <el-option label="10-15年" value="10-15"/>
</el-select> <el-option label="15年以上" value="15-99"/>
</el-form-item> </el-select>
</el-col > </el-form-item>
<el-col :span="5"> </el-col>
<el-form-item label="寿命告警状态" prop="isWarn"> <el-col :span="5">
<el-select <el-form-item label="剩余使用年限" prop="remainingYears">
style="width: 100%" <el-select
v-model="queryParams.isWarn" style="width: 100%"
placeholder="选择选项" v-model="queryParams.yearsDiff2"
clearable placeholder="选择选项"
> clearable
<el-option label="告警" value="1"/> >
<el-option label="未告警" value="0"/> <el-option label="0-5年" value="0-5"/>
</el-select> <el-option label="5-10年" value="5-10"/>
</el-form-item> <el-option label="10-15年" value="10-15"/>
</el-col> <el-option label="15年以上" value="15-99"/>
</el-row> </el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="寿命告警状态" prop="isWarn">
<el-select
style="width: 100%"
v-model="queryParams.isWarn"
placeholder="选择选项"
clearable
>
<el-option label="告警" value="1"/>
<el-option label="未告警" value="0"/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col style="text-align: right;"> <el-col style="text-align: right;">
<el-button type="primary" icon="el-icon-search" size="mini" @click="onHandleQuery"> <el-button type="primary" icon="el-icon-search" size="mini" @click="onHandleQuery">
查询 查询
</el-button> </el-button>
<el-button icon="el-icon-refresh" size="mini" @click="onHandleReset">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="onHandleReset">重置</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
</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"/>
<el-table-column align="center" show-overflow-tooltip prop="propertyUnit" label="单位名称"/> <el-table-column align="center" show-overflow-tooltip prop="propertyUnit" label="单位名称"/>
<el-table-column align="center" show-overflow-tooltip prop="name" label="装备名称"/> <el-table-column align="center" show-overflow-tooltip prop="name" label="装备名称"/>
<el-table-column align="center" show-overflow-tooltip prop="specificationModel" label="装备型号"/> <el-table-column align="center" show-overflow-tooltip prop="specificationModel" label="装备型号"/>
<el-table-column align="center" show-overflow-tooltip prop="code" label="装备编码"/> <el-table-column align="center" show-overflow-tooltip prop="code" label="装备编码"/>
<el-table-column align="center" show-overflow-tooltip prop="manufacturer" label="生产厂家"/> <el-table-column align="center" show-overflow-tooltip prop="manufacturer" label="生产厂家"/>
<el-table-column align="center" show-overflow-tooltip prop="productionDate" label="出厂日期"> <el-table-column align="center" show-overflow-tooltip prop="productionDate" label="出厂日期">
<template slot-scope="scope"> <template slot-scope="scope">
{{ formatDate(scope.row.productionDate) }} {{ formatDate(scope.row.productionDate) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
show-overflow-tooltip show-overflow-tooltip
prop="workingHours" prop="workingHours"
label="标准使用到期时间(年限)" label="标准使用到期时间(年限)"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ formatDate(scope.row.expirationTime) }} ({{ scope.row.expirationYears }}) {{ formatDate(scope.row.expirationTime) }} ({{ scope.row.expirationYears }})
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" show-overflow-tooltip prop=" remainingYears" label="实际使用天数(天数)"> <el-table-column align="center" show-overflow-tooltip prop=" remainingYears" label="实际使用天数(天数)">
<template slot-scope="scope"> {{ scope.row.daysDiff }} ({{ scope.row.yearsDiff }})</template> <template slot-scope="scope"> {{ scope.row.daysDiff }} ({{ scope.row.yearsDiff }})</template>
</el-table-column> </el-table-column>
<el-table-column align="center" show-overflow-tooltip prop="remainingDays" label="实际使用天数(年限)"> <el-table-column align="center" show-overflow-tooltip prop="remainingDays" label="实际使用天数(年限)">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.remainingDays }} ({{ scope.row.remainingYears }}) {{ scope.row.remainingDays }} ({{ scope.row.remainingYears }})
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" show-overflow-tooltip prop="deviceStatus" label="预警情况"> <el-table-column align="center" show-overflow-tooltip prop="deviceStatus" label="预警情况">
<template slot-scope="scope"> <template slot-scope="scope">
<span :class="scope.row.status=='临近364天退役'?'red':''">{{ scope.row.status }} <span :class="scope.row.status=='临近364天退役'?'red':''">{{ scope.row.status }}
</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">
<pagination <pagination
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getRetireList" @pagination="getRetireList"
/> />
</div> </div>
</el-card> </el-card>
</el-row> </el-row>
</div> </div>
</template> </template>
@ -340,7 +341,7 @@ export default {
padding-top: 6px; padding-top: 6px;
margin-top: auto; margin-top: auto;
::v-deep .pagination-container { ::v-deep .pagination-container {
padding: 0px 20px !important; padding: 0px 20px !important;
margin-bottom: 30px; margin-bottom: 30px;
} }
@ -365,11 +366,12 @@ export default {
} }
} }
&.el-table--striped .el-table__body tr.el-table__row:hover>td.el-table__cell { &.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #CCF1E9 !important; background-color: #CCF1E9 !important;
} }
} }
} }
.dialog-table { .dialog-table {
border-radius: 6px; border-radius: 6px;
overflow: hidden; overflow: hidden;
@ -415,7 +417,7 @@ export default {
} }
} }
&.el-table--striped .el-table__body tr.el-table__row:hover>td.el-table__cell { &.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #CCF1E9 !important; background-color: #CCF1E9 !important;
} }

View File

@ -59,7 +59,6 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
@ -137,7 +136,7 @@
<!-- 添加申请 --> <!-- 添加申请 -->
<el-dialog title="添加申请" :visible.sync="openAdd" width="1200px" append-to-body> <el-dialog title="添加申请" :visible.sync="openAdd" width="1200px" append-to-body>
<el-form :model="addQuery" ref="addQueryForm" label-width="70px" inline> <el-form :model="addQuery" ref="addQueryForm" label-width="70px" inline>
<el-form-item label="名称" prop="typeName"> <el-form-item label="名称" prop="typeName">
<el-input v-model="addQuery.typeName" maxlength="20" placeholder="请输入名称"/> <el-input v-model="addQuery.typeName" maxlength="20" placeholder="请输入名称"/>
</el-form-item> </el-form-item>
@ -164,47 +163,47 @@
<!-- 新增动态显示的管理模式下拉框 --> <!-- 新增动态显示的管理模式下拉框 -->
<el-form-item <el-form-item
v-if="addQuery.devType === '2'" v-if="addQuery.devType === '2'"
label="管理模式" label="管理模式"
prop="manageType" prop="manageType"
> >
<el-select <el-select
v-model="addQuery.manageType" v-model="addQuery.manageType"
placeholder="请选择管理模式" placeholder="请选择管理模式"
clearable clearable
> >
<el-option label="编码设备" value="0"/> <el-option label="编码设备" value="0"/>
<el-option label="数量设备" value="1"/> <el-option label="数量设备" value="1"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="装备分类" prop="categoryPath">--> <!-- <el-form-item label="装备分类" prop="categoryPath">-->
<!-- <el-cascader--> <!-- <el-cascader-->
<!-- v-model="addQuery.categoryPath"--> <!-- v-model="addQuery.categoryPath"-->
<!-- :options="processedTreeData"--> <!-- :options="processedTreeData"-->
<!-- :props="cascaderProps"--> <!-- :props="cascaderProps"-->
<!-- placeholder="请选择装备分类(最多六级)"--> <!-- placeholder="请选择装备分类(最多六级)"-->
<!-- clearable--> <!-- clearable-->
<!-- style="width: 100%"--> <!-- style="width: 100%"-->
<!-- filterable--> <!-- filterable-->
<!-- popper-class="six-level-cascader"--> <!-- popper-class="six-level-cascader"-->
<!-- @change="handleCategoryChange"--> <!-- @change="handleCategoryChange"-->
<!-- />--> <!-- />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- <el-form-item label="工具分类" prop="toolCategoryPath">--> <!-- <el-form-item label="工具分类" prop="toolCategoryPath">-->
<!-- <el-cascader--> <!-- <el-cascader-->
<!-- v-model="addQuery.toolCategoryPath"--> <!-- v-model="addQuery.toolCategoryPath"-->
<!-- :options="toolTreeData"--> <!-- :options="toolTreeData"-->
<!-- :props="toolCascaderProps"--> <!-- :props="toolCascaderProps"-->
<!-- placeholder="请选择工具分类"--> <!-- placeholder="请选择工具分类"-->
<!-- clearable--> <!-- clearable-->
<!-- style="width: 100%"--> <!-- style="width: 100%"-->
<!-- filterable--> <!-- filterable-->
<!-- popper-class="six-level-cascader"--> <!-- popper-class="six-level-cascader"-->
<!-- @change="handleToolCategoryChange"--> <!-- @change="handleToolCategoryChange"-->
<!-- />--> <!-- />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item style="margin-left: 980px"> <el-form-item style="margin-left: 980px">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleAddQuery">查询</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleAddQuery">查询</el-button>
@ -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' }]
}, },
@ -365,8 +365,8 @@ export default {
devCode: '', devCode: '',
categoryEquipment: '', // ID categoryEquipment: '', // ID
toolTypeId: '', // ID toolTypeId: '', // ID
devType: '' ,// 1=2= devType: '',// 1=2=
manageType:'' manageType: ''
}, },
addTotal: 0, // addTotal: 0, //
addList: [], // addList: [], //
@ -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
@ -751,55 +752,55 @@ export default {
// /devType // /devType
// //
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
} }
}); })
}); })
}, },
// //