装备上下架 和 工具上下架增加租赁价格修改

This commit is contained in:
BianLzhaoMin 2025-12-12 15:01:34 +08:00
parent f912dc8016
commit 71bbf49885
2 changed files with 1855 additions and 1616 deletions

View File

@ -13,12 +13,7 @@
<!-- 用Flex实现自动换行+均匀分布 -->
<div>
<el-form-item prop="major" label="专业">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.major"
style="width: 230px;"
/>
<el-input clearable placeholder="请输入" v-model="searchParams.major" style="width: 230px" />
</el-form-item>
<el-form-item prop="subProcess" label="工序" label-width="60px">
@ -26,17 +21,12 @@
clearable
placeholder="请输入"
v-model="searchParams.subProcess"
style="width: 230px;"
style="width: 230px"
/>
</el-form-item>
<el-form-item prop="name" label="装备名称">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.name"
style="width: 230px;"
/>
<el-input clearable placeholder="请输入" v-model="searchParams.name" style="width: 230px" />
</el-form-item>
<el-form-item prop="specificationModel" label="规格型号">
@ -44,17 +34,12 @@
clearable
placeholder="请输入"
v-model="searchParams.specificationModel"
style="width: 230px;"
style="width: 230px"
/>
</el-form-item>
<el-form-item prop="status" label="装备状态">
<el-select
clearable
placeholder="请选择"
v-model="searchParams.status"
style="width: 230px;"
>
<el-select clearable placeholder="请选择" v-model="searchParams.status" style="width: 230px">
<el-option label="在库" value="1"></el-option>
<el-option label="自用" value="2"></el-option>
<el-option label="共享" value="3"></el-option>
@ -64,21 +49,23 @@
</el-form-item>
<el-form-item prop="code" label="装备编码">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.code"
style="width: 230px;"
/>
<el-input clearable placeholder="请输入" v-model="searchParams.code" style="width: 230px" />
</el-form-item>
<!-- 按钮区域固定在右侧 -->
<el-form-item style="float: right">
<el-button @click="getEquipmentList" size="mini" icon="el-icon-search" type="primary" class="primary-lease">
<el-button
@click="getEquipmentList"
size="mini"
icon="el-icon-search"
type="primary"
class="primary-lease"
>
查询
</el-button>
<el-button @click="onReset" icon="el-icon-refresh" size="mini" class="primary-lease">重置</el-button>
<el-button @click="onReset" icon="el-icon-refresh" size="mini" class="primary-lease"
>重置</el-button
>
</el-form-item>
</div>
</el-card>
@ -97,21 +84,16 @@
批量下架
</el-button>
<el-button
size="mini"
@click="equipment"
type="primary"
class="primary-lease"
>
<el-button size="mini" @click="equipment" type="primary" class="primary-lease">
添加上架装备
</el-button>
</el-row>
<el-table
:data="equipmentList"
show-overflow-tooltip
border stripe
border
stripe
@selection-change="handleSelectionChange"
class="custom-table"
height="546"
@ -153,6 +135,7 @@
<el-table-column align="center" prop="purchaseInvoices" label="采购发票" />
<el-table-column align="center" prop="feature1" label="特征项1" />
<el-table-column align="center" prop="featureValue1" label="特征值1" />
<el-table-column align="center" prop="leasePrice" label="租赁价" />
<el-table-column align="center" label="操作" :width="199" fixed="right">
<template slot-scope="scope">
@ -164,7 +147,12 @@
@confirm="handleDown(scope.row.maId)"
>
<template slot="reference">
<el-button size="mini" type="text" icon="el-icon-delete" style="margin-left: 8px; color: red">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
style="margin-left: 8px; color: red"
>
下架
</el-button>
</template>
@ -173,7 +161,6 @@
</el-table-column>
</el-table>
<div class="pagination-wrapper">
<el-pagination
background
@ -190,40 +177,30 @@
<!-- 添加上架装备弹窗保持原有内容优化样式 -->
<el-dialog
width="1600px"
@close="handleDialogClose"
width="95%"
destroy-on-close
:title="dialogTitle"
:visible.sync="equipmentDialogVisible"
@close="handleDialogClose"
custom-class="simple-dialog"
:visible.sync="equipmentDialogVisible"
>
<el-form :inline="true" :model="searchParams" class="dialog-search-form">
<el-row style="height: 36px">
<el-form-item label="装备名称" prop="name">
<el-input
v-model="searchParams.name"
placeholder="请输入"
clearable
style="width: 100%;"
/>
<el-input v-model="searchParams.name" placeholder="请输入" clearable style="width: 100%" />
</el-form-item>
<el-form-item label="规格型号" prop="specificationModel">
<el-input
v-model="searchParams.specificationModel"
placeholder="输入内容"
clearable
style="width: 100%;"
style="width: 100%"
placeholder="输入内容"
v-model="searchParams.specificationModel"
/>
</el-form-item>
<el-form-item label="装备编码" prop="code">
<el-input
v-model="searchParams.code"
placeholder="输入内容"
clearable
style="width: 100%;"
/>
<el-input v-model="searchParams.code" placeholder="输入内容" clearable style="width: 100%" />
</el-form-item>
<el-form-item style="margin-left: 543px">
<el-form-item>
<el-button size="small" type="primary" @click="getListDownEquipment">查询</el-button>
<el-button size="small" @click="handleReset">重置</el-button>
</el-form-item>
@ -244,12 +221,12 @@
</div>
<el-table
:data="downEquipmentList"
show-overflow-tooltip
border stripe
@selection-change="handleSelectionChange"
border
stripe
class="custom-table"
height="546"
show-overflow-tooltip
:data="downEquipmentList"
@selection-change="handleSelectionChange"
>
<!-- 弹窗表格列保持原有内容 -->
<el-table-column type="selection" width="55" align="center" />
@ -261,6 +238,19 @@
<el-table-column align="center" label="生产厂家" prop="manufacturer" />
<el-table-column align="center" label="出厂日期" prop="productionDate" />
<el-table-column align="center" label="资产原值(万元)" prop="originalValue" />
<el-table-column align="center" label="租赁价" width="180">
<template slot-scope="scope">
<el-input
:ref="`leasePriceInput${scope.$index}`"
clearable
style="width: 100%"
placeholder="请输入租赁价"
v-model.trim="scope.row.oldLeasePrice"
:class="{ 'lease-price-error': scope.row.priceError }"
@blur="handleLeasePriceBlur(scope.row, scope.$index)"
/>
</template>
</el-table-column>
<el-table-column align="center" prop="status" label="装备状态">
<template slot-scope="scope">
<el-tag v-if="scope.row.status == 1" type="success" size="mini">在库</el-tag>
@ -296,7 +286,7 @@ import {
listDownEquipment,
listEquipment,
downEquipment,
batchUpEquipment
batchUpEquipment,
} from '@/api/EquipmentUpOrDown/equipment'
import { Message } from 'element-ui'
@ -315,7 +305,7 @@ export default {
isAdd: true,
isView: false,
dialogSearchParams: {
toolCategory: ''
toolCategory: '',
},
searchParams: {
major: '',
@ -326,9 +316,9 @@ export default {
status: '',
code: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
},
projectTypeList: []
projectTypeList: [],
}
},
@ -355,7 +345,15 @@ export default {
try {
const res = await listDownEquipment(this.searchParams)
if (res.code === 200) {
this.downEquipmentList = res.rows || []
this.downEquipmentList =
res.rows.map((e) => {
return {
...e,
isChangePrice: false, //
oldLeasePrice: e.leasePrice, //
priceError: false, //
}
}) || []
this.downTotal = res.total || 0
} else {
Message.error(res.message || '获取待上架装备列表失败')
@ -374,7 +372,7 @@ export default {
status: '',
code: '',
pageSize: this.searchParams.pageSize,
pageNum: 1
pageNum: 1,
}
this.$refs.searchFormRef?.clearValidate()
this.getEquipmentList()
@ -389,7 +387,7 @@ export default {
status: '',
code: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
this.$refs.searchFormRef?.clearValidate()
this.getListDownEquipment()
@ -429,17 +427,13 @@ export default {
}
try {
await this.$confirm(
`确定下架选中的 ${this.selectedRows.length} 个装备吗?`,
'提示',
{
await this.$confirm(`确定下架选中的 ${this.selectedRows.length} 个装备吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消'
}
)
cancelButtonText: '取消',
})
const ids = this.selectedRows.map(row => row.maId)
const ids = this.selectedRows.map((row) => row.maId)
const res = await batchDownEquipment(ids)
if (res.code === 200) {
@ -456,38 +450,157 @@ export default {
}
},
//
validateLeasePrice(value) {
// 0
if (value === '' || value === null || value === undefined) {
return { valid: true, value: 0 }
}
//
const strValue = String(value).trim()
if (strValue === '') {
return { valid: true, value: 0 }
}
//
const regex = /^\d+(\.\d{1,2})?$/
if (!regex.test(strValue)) {
return { valid: false, value: strValue }
}
//
const numValue = parseFloat(strValue)
if (isNaN(numValue) || numValue < 0 || numValue >= 99999999.99) {
return { valid: false, value: strValue }
}
return { valid: true, value: numValue }
},
//
handleLeasePriceBlur(row, index) {
const validation = this.validateLeasePrice(row.oldLeasePrice)
// 0
if (row.oldLeasePrice === '' || row.oldLeasePrice === null || row.oldLeasePrice === undefined) {
this.$set(row, 'oldLeasePrice', 0)
this.$set(row, 'priceError', false)
return
}
//
if (!validation.valid) {
this.$set(row, 'priceError', true)
this.$modal.msgError(
`${index + 1} 行的租赁价格格式不正确请输入大于等于0且小于99999999.99的数字(最多两位小数)`,
)
} else {
this.$set(row, 'oldLeasePrice', validation.value)
this.$set(row, 'priceError', false)
}
},
async handleBatchUp() {
if (this.selectedRows.length === 0) {
Message.warning('请选择要上架的装备')
return
}
// isChangePrice
const errorRows = []
// ref
for (let i = 0; i < this.downEquipmentList.length; i++) {
const listRow = this.downEquipmentList[i]
//
const isSelected = this.selectedRows.some((selectedRow) => selectedRow.maId === listRow.maId)
if (!isSelected) {
continue
}
//
const validation = this.validateLeasePrice(listRow.oldLeasePrice)
if (!validation.valid) {
const displayIndex = i + 1
errorRows.push(displayIndex)
// priceError
this.$set(listRow, 'priceError', true)
} else {
// 0
if (
listRow.oldLeasePrice === '' ||
listRow.oldLeasePrice === null ||
listRow.oldLeasePrice === undefined
) {
this.$set(listRow, 'oldLeasePrice', 0)
} else {
this.$set(listRow, 'oldLeasePrice', validation.value)
}
this.$set(listRow, 'priceError', false)
}
//
const originalPrice = listRow.leasePrice || 0
const newPrice =
listRow.oldLeasePrice === '' ||
listRow.oldLeasePrice === null ||
listRow.oldLeasePrice === undefined
? 0
: parseFloat(listRow.oldLeasePrice) || 0
this.$set(listRow, 'isChangePrice', originalPrice !== newPrice)
}
// selectedRows
this.selectedRows.forEach((selectedRow) => {
const listRow = this.downEquipmentList.find((item) => item.maId === selectedRow.maId)
if (listRow) {
selectedRow.oldLeasePrice = listRow.oldLeasePrice
selectedRow.isChangePrice = listRow.isChangePrice
selectedRow.priceError = listRow.priceError
}
})
//
if (errorRows.length > 0) {
this.$modal.msgError(
`${errorRows.join(
'、',
)} 行的租赁价格格式不正确请输入大于等于0且小于99999999.99的数字最多两位小数`,
)
return
}
try {
await this.$confirm(
`确定上架选中的 ${this.selectedRows.length} 个装备吗?`,
'提示',
{
await this.$confirm(`确定上架选中的 ${this.selectedRows.length} 个装备吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消'
}
)
cancelButtonText: '取消',
})
const ids = this.selectedRows.map(row => row.maId)
const res = await batchUpEquipment(ids)
//
const launchList = this.selectedRows.map((row) => {
return {
maId: row.maId,
leasePrice: row.oldLeasePrice,
isChangePrice: row.isChangePrice,
}
})
const res = await batchUpEquipment(launchList)
if (res.code === 200) {
Message.success(`成功上架 ${this.selectedRows.length} 个装备`)
this.$modal.msgSuccess(`成功上架 ${this.selectedRows.length} 个装备`)
this.getListDownEquipment()
this.getEquipmentList()
this.selectedRows = []
} else {
Message.error(res.message || '批量上架失败')
this.$modal.msgError(res.message || '批量上架失败')
}
} catch (error) {
if (error !== 'cancel') {
Message.error('网络错误,批量上架失败')
}
console.log('error', error)
}
},
@ -515,8 +628,8 @@ export default {
handleDownCurrentChange(val) {
this.searchParams.pageNum = val
this.getListDownEquipment()
}
}
},
},
}
</script>
@ -549,7 +662,6 @@ export default {
}
.search-item {
min-width: 220px;
margin-bottom: 0 !important;
}
@ -596,9 +708,9 @@ export default {
width: 100%;
::v-deep .el-table__header {
background: #E9F0EE;
background: #e9f0ee;
th {
background: #E9F0EE !important;
background: #e9f0ee !important;
color: #606266;
font-weight: 600;
height: 48px;
@ -606,11 +718,11 @@ export default {
}
::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td {
background-color: #F6FBFA !important;
background-color: #f6fbfa !important;
}
::v-deep .el-table__body tr:hover > td.el-table__cell {
background-color: #CCF1E9 !important;
background-color: #ccf1e9 !important;
}
}
@ -669,15 +781,32 @@ export default {
}
}
::v-deep .el-dialog__body {
padding: 20px;
max-height: 70vh;
overflow: auto;
}
::v-deep .el-dialog__footer {
padding: 10px 20px;
border-top: 1px solid #eee;
}
}
::v-deep .el-dialog {
display: flex !important;
flex-direction: column !important;
margin: 0 !important;
position: absolute !important;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
min-height: 95vh !important;
max-height: 95vh !important;
.el-dialog__body {
flex: 1 !important;
overflow-y: scroll !important;
padding: 20px 20px !important;
box-sizing: border-box !important;
}
}
/* 租赁价格输入框错误样式 */
::v-deep .lease-price-error .el-input__inner {
border-color: #f56c6c !important;
}
</style>

View File

@ -11,13 +11,13 @@
>
<el-card class="search-box">
<!-- 关键修改使用 flex 布局实现自适应换行 -->
<div style="display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">
<div style="display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px">
<el-form-item prop="pro_name" label="工具专业" style="margin-bottom: 0; width: 320px">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.fourthParentName"
style="width: 240px; min-width: 200px;"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
@ -26,7 +26,7 @@
clearable
placeholder="请输入"
v-model="searchParams.greatGrandparentName"
style="width: 240px; min-width: 200px;"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
@ -35,7 +35,7 @@
clearable
placeholder="请输入"
v-model="searchParams.parentTypeName"
style="width: 240px; min-width: 200px;"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
@ -44,32 +44,36 @@
clearable
placeholder="请输入"
v-model="searchParams.typeName"
style="width:240px; min-width: 200px;"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
<!-- 按钮区域 -->
<div style="display: flex; gap: 10px; margin-left: auto;">
<el-button @click="getListTool" size="mini" icon="el-icon-search" type="primary"
class="primary-lease">
<div style="display: flex; gap: 10px; margin-left: auto">
<el-button
@click="getListTool"
size="mini"
icon="el-icon-search"
type="primary"
class="primary-lease"
>
查询
</el-button>
<el-button @click="onReset" icon="el-icon-refresh" size="mini" class="primary-lease">重置</el-button>
<el-button @click="onReset" icon="el-icon-refresh" size="mini" class="primary-lease"
>重置</el-button
>
</div>
</div>
<el-row>
</el-row>
<el-row> </el-row>
</el-card>
</el-form>
<!-- 数据列表 -->
<el-card class="content-box">
<el-row style="margin-bottom: 16px; display: flex; justify-content: flex-end; align-items: center; gap: 10px;">
<el-row
style="margin-bottom: 16px; display: flex; justify-content: flex-end; align-items: center; gap: 10px"
>
<el-button
size="mini"
type="danger"
@ -80,35 +84,14 @@
批量下架
</el-button>
<el-button
size="mini"
@click="numberTool"
type="primary"
class="primary-lease"
>
<el-button size="mini" @click="numberTool" type="primary" class="primary-lease">
上架数量工具
</el-button>
<el-button
size="mini"
@click="codeTool"
type="primary"
class="primary-lease"
>
上架编码工具
</el-button>
<el-button size="mini" @click="codeTool" type="primary" class="primary-lease"> 上架编码工具 </el-button>
</el-row>
<div >
<el-table
:data="toolList"
show-overflow-tooltip
border stripe
height="546"
@selection-change="handleSelectionChange"
>
<el-table :data="toolList" show-overflow-tooltip border @selection-change="handleSelectionChange">
<!-- 修复后的表格列代码 -->
<el-table-column type="selection" width="55" align="center" />
<el-table-column align="center" label="序号" type="index" width="80" />
@ -119,12 +102,10 @@
<el-table-column align="center" label="规格型号" prop="typeName" />
<el-table-column align="center" label="工具编码" prop="toolCode" />
<el-table-column align="center" label="数量" prop="totalNum" />
<el-table-column align="center" label="租赁价" prop="leasePrice" />
<el-table-column align="center" label="操作" :width="220">
<template slot-scope="scope">
<!-- 下架按钮移除 v-if 条件直接显示 -->
<el-popconfirm
width="220"
@ -134,18 +115,20 @@
@confirm="handleDown(scope.row.id)"
>
<template slot="reference">
<el-button size="mini" type="text" icon="el-icon-delete" style="margin-left: 8px;color: red">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
style="margin-left: 8px; color: red"
>
下架
</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页组件 -->
<div class="pagination-wrapper">
<el-pagination
background
layout="total,sizes,prev, pager, next"
@ -155,7 +138,6 @@
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</el-card>
<!-- 上架数量工具 -->
@ -166,17 +148,16 @@
:title="dialogTitleByNumber"
:visible.sync="numberDialogVisible"
custom-class="simple-dialog"
>
<!-- 搜索区域 -->
<el-form :inline="true" :model="numberSearchParams" style="width: 100%; margin-bottom: 10px;">
<el-row style="display: flex; justify-content: center; gap: 10px;">
<el-form :inline="true" :model="numberSearchParams" style="width: 100%; margin-bottom: 10px">
<el-row style="display: flex; justify-content: center; gap: 10px">
<el-form-item label="工具专业" prop="fourthParentName">
<el-input
v-model="numberSearchParams.fourthParentName"
placeholder="请输入工具专业"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="施工类型" prop="greatGrandparentName">
@ -184,7 +165,7 @@
v-model="numberSearchParams.greatGrandparentName"
placeholder="请输入施工类型"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeName">
@ -192,7 +173,7 @@
v-model="numberSearchParams.parentTypeName"
placeholder="请输入工具名称"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeName">
@ -200,10 +181,10 @@
v-model="numberSearchParams.typeName"
placeholder="请输入规格型号"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item style="text-align: right;">
<el-form-item style="text-align: right">
<el-button size="small" type="primary" @click="getListNumberTool">查询</el-button>
<el-button size="small" @click="handleNumberReset">重置</el-button>
@ -225,7 +206,8 @@
<el-table
:data="numberToolList"
show-overflow-tooltip
border stripe
border
stripe
@selection-change="handleNumberSelectionChange"
height="546"
>
@ -258,7 +240,7 @@
<!-- 上架编码工具 -->
<el-dialog
width="1600px"
width="95%"
@close="handleCodeDialogClose"
destroy-on-close
:title="dialogTitleByCode"
@ -268,48 +250,48 @@
<!-- 搜索区域 -->
<el-form inline :model="codeSearchParams" label-width="auto">
<el-row>
<el-form-item label="工具专业" prop="fourthParentName" style="width: 300px;">
<el-form-item label="工具专业" prop="fourthParentName" style="width: 300px">
<el-input
v-model="codeSearchParams.fourthParentName"
placeholder="请输入工具专业"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="施工类型" prop="greatGrandparentName" style="width: 300px;">
<el-form-item label="施工类型" prop="greatGrandparentName" style="width: 300px">
<el-input
v-model="codeSearchParams.greatGrandparentName"
placeholder="请输入施工类型"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeName" style="width: 300px;">
<el-form-item label="工具名称" prop="parentTypeName" style="width: 300px">
<el-input
v-model="codeSearchParams.parentTypeName"
placeholder="请输入工具名称"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeName" style="width: 300px;">
<el-form-item label="规格型号" prop="typeName" style="width: 300px">
<el-input
v-model="codeSearchParams.typeName"
placeholder="请输入规格型号"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具编码" prop="toolCode" style="width: 300px;">
<el-form-item label="工具编码" prop="toolCode" style="width: 300px">
<el-input
v-model="codeSearchParams.toolCode"
placeholder="请输入工具编码"
clearable
style="width: 220px;"
style="width: 220px"
/>
</el-form-item>
<el-form-item style="float: right; width: 220px;">
<el-form-item style="float: right; width: 220px">
<el-button size="small" type="primary" @click="getListCodeTool">查询</el-button>
<el-button size="small" @click="handleCodeReset">重置</el-button>
<el-button
@ -321,7 +303,6 @@
>
批量上架
</el-button>
</el-form-item>
</el-row>
</el-form>
@ -331,7 +312,8 @@
<el-table
:data="codeToolList"
show-overflow-tooltip
border stripe
border
stripe
height="546"
@selection-change="handleCodeSelectionChange"
>
@ -349,6 +331,19 @@
<el-table-column align="center" label="生产厂家" prop="supplierName" />
<el-table-column align="center" label="生产日期" prop="productionDate" />
<el-table-column align="center" label="资产原值(万元)" prop="originCost" />
<el-table-column align="center" label="租赁价" width="180">
<template slot-scope="scope">
<el-input
:ref="`leasePriceInput${scope.$index}`"
clearable
style="width: 100%"
placeholder="请输入租赁价"
v-model.trim="scope.row.oldLeasePrice"
:class="{ 'lease-price-error': scope.row.priceError }"
@blur="handleLeasePriceBlur(scope.row, scope.$index)"
/>
</template>
</el-table-column>
<el-table-column align="center" label="原始编码" prop="originalCode" />
</el-table>
</div>
@ -367,13 +362,9 @@
/>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listTool,
@ -382,12 +373,11 @@ import {
listCodeTool,
downTool,
batchDownTool,
batchUpTool, upToolByCode
batchUpTool,
upToolByCode,
} from '@/api/EquipmentUpOrDown/tool'
import { Message } from 'element-ui'
export default {
name: 'ProjectManagement',
data() {
@ -413,10 +403,9 @@ export default {
isAdd: true,
isView: false,
//
dialogSearchParams: {
toolCategory: ''
toolCategory: '',
},
//
@ -426,7 +415,7 @@ export default {
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
},
//
@ -436,7 +425,7 @@ export default {
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
},
//
@ -447,9 +436,8 @@ export default {
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1
}
pageNum: 1,
},
}
},
@ -458,9 +446,6 @@ export default {
},
methods: {
//
async getListTool() {
try {
@ -476,7 +461,6 @@ export default {
}
},
//
async getListNumberTool() {
try {
@ -492,13 +476,20 @@ export default {
}
},
//
async getListCodeTool() {
try {
const res = await listCodeTool(this.codeSearchParams)
if (res.code === 200) {
this.codeToolList = res.rows || []
this.codeToolList =
res.rows.map((e) => {
return {
...e,
isChangePrice: false, //
oldLeasePrice: e.leasePrice, //
priceError: false, //
}
}) || []
this.codeTotal = res.total || 0
} else {
Message.error(res.message || '获取工程列表失败')
@ -508,8 +499,6 @@ export default {
}
},
//
onReset() {
this.searchParams = {
@ -518,7 +507,7 @@ export default {
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
this.$refs.searchFormRef?.clearValidate()
this.getListTool()
@ -532,12 +521,11 @@ export default {
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
this.getListNumberTool()
},
//
handleCodeReset() {
this.codeSearchParams = {
@ -547,12 +535,11 @@ export default {
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
this.getListCodeTool()
},
//
handleSelectionChange(selection) {
this.selectedRows = selection
@ -568,8 +555,6 @@ export default {
this.selectedCodeRows = selection
},
//
codeTool() {
this.isAdd = true
@ -580,7 +565,6 @@ export default {
this.getListCodeTool()
},
//
numberTool() {
this.isAdd = true
@ -591,8 +575,6 @@ export default {
this.getListNumberTool()
},
//
async handleDown(id) {
try {
@ -623,7 +605,6 @@ export default {
}
},
//
async handleBatchDown() {
if (this.selectedRows.length === 0) {
@ -632,17 +613,13 @@ export default {
}
try {
await this.$confirm(
`确定下架选中的 ${this.selectedRows.length} 个工具吗?`,
'提示',
{
await this.$confirm(`确定下架选中的 ${this.selectedRows.length} 个工具吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消'
}
)
cancelButtonText: '取消',
})
const ids = this.selectedRows.map(row => row.id)
const ids = this.selectedRows.map((row) => row.id)
// downToolBatch
const res = await batchDownTool(ids)
@ -670,17 +647,13 @@ export default {
}
try {
await this.$confirm(
`确定上架选中的 ${this.selectedNumberRows.length} 个工具吗?`,
'提示',
{
await this.$confirm(`确定上架选中的 ${this.selectedNumberRows.length} 个工具吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消'
}
)
cancelButtonText: '取消',
})
const ids = this.selectedNumberRows.map(row => row.id)
const ids = this.selectedNumberRows.map((row) => row.id)
const res = await batchUpTool(ids)
@ -702,6 +675,57 @@ export default {
}
},
//
validateLeasePrice(value) {
// 0
if (value === '' || value === null || value === undefined) {
return { valid: true, value: 0 }
}
//
const strValue = String(value).trim()
if (strValue === '') {
return { valid: true, value: 0 }
}
//
const regex = /^\d+(\.\d{1,2})?$/
if (!regex.test(strValue)) {
return { valid: false, value: strValue }
}
//
const numValue = parseFloat(strValue)
if (isNaN(numValue) || numValue < 0 || numValue >= 99999999.99) {
return { valid: false, value: strValue }
}
return { valid: true, value: numValue }
},
//
handleLeasePriceBlur(row, index) {
const validation = this.validateLeasePrice(row.oldLeasePrice)
// 0
if (row.oldLeasePrice === '' || row.oldLeasePrice === null || row.oldLeasePrice === undefined) {
this.$set(row, 'oldLeasePrice', 0)
this.$set(row, 'priceError', false)
return
}
//
if (!validation.valid) {
this.$set(row, 'priceError', true)
this.$modal.msgError(
`${index + 1} 行的租赁价格格式不正确请输入大于等于0且小于99999999.99的数字(最多两位小数)`,
)
} else {
this.$set(row, 'oldLeasePrice', validation.value)
this.$set(row, 'priceError', false)
}
},
//
async handleBatchUpCode() {
if (this.selectedCodeRows.length === 0) {
@ -709,23 +733,92 @@ export default {
return
}
// isChangePrice
const errorRows = []
// ref
for (let i = 0; i < this.codeToolList.length; i++) {
const listRow = this.codeToolList[i]
//
const isSelected = this.selectedCodeRows.some((selectedRow) => selectedRow.id === listRow.id)
if (!isSelected) {
continue
}
//
const validation = this.validateLeasePrice(listRow.oldLeasePrice)
if (!validation.valid) {
const displayIndex = i + 1
errorRows.push(displayIndex)
// priceError
this.$set(listRow, 'priceError', true)
} else {
// 0
if (
listRow.oldLeasePrice === '' ||
listRow.oldLeasePrice === null ||
listRow.oldLeasePrice === undefined
) {
this.$set(listRow, 'oldLeasePrice', 0)
} else {
this.$set(listRow, 'oldLeasePrice', validation.value)
}
this.$set(listRow, 'priceError', false)
}
//
const originalPrice = listRow.leasePrice || 0
const newPrice =
listRow.oldLeasePrice === '' ||
listRow.oldLeasePrice === null ||
listRow.oldLeasePrice === undefined
? 0
: parseFloat(listRow.oldLeasePrice) || 0
this.$set(listRow, 'isChangePrice', originalPrice !== newPrice)
}
// selectedCodeRows
this.selectedCodeRows.forEach((selectedRow) => {
const listRow = this.codeToolList.find((item) => item.id === selectedRow.id)
if (listRow) {
selectedRow.oldLeasePrice = listRow.oldLeasePrice
selectedRow.isChangePrice = listRow.isChangePrice
selectedRow.priceError = listRow.priceError
}
})
//
if (errorRows.length > 0) {
this.$modal.msgError(
`${errorRows.join(
'、',
)} 行的租赁价格格式不正确请输入大于等于0且小于99999999.99的数字最多两位小数`,
)
return
}
try {
await this.$confirm(
`确定上架选中的 ${this.selectedCodeRows.length} 个工具吗?`,
'提示',
{
await this.$confirm(`确定上架选中的 ${this.selectedCodeRows.length} 个工具吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消'
cancelButtonText: '取消',
})
//
const launchList = this.selectedCodeRows.map((row) => {
return {
id: row.id,
leasePrice: row.oldLeasePrice,
isChangePrice: row.isChangePrice,
}
)
})
const ids = this.selectedCodeRows.map(row => row.id)
const res = await batchUpTool(ids)
const res = await batchUpTool(launchList)
if (res.code === 200) {
Message.success(`成功上架 ${this.selectedCodeRows.length} 个工具`)
this.$modal.msgSuccess(`成功上架 ${this.selectedCodeRows.length} 个工具`)
//
this.getListCodeTool()
//
@ -733,17 +826,13 @@ export default {
//
this.selectedCodeRows = []
} else {
Message.error(res.message || '批量上架失败')
this.$modal.msgError(res.message || '批量上架失败')
}
} catch (error) {
if (error !== 'cancel') {
Message.error('网络错误,批量上架失败')
}
console.log('error', error)
}
},
//
handleNumberDialogClose() {
this.numberDialogVisible = false
@ -754,7 +843,7 @@ export default {
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
},
@ -769,7 +858,7 @@ export default {
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1
pageNum: 1,
}
},
@ -807,8 +896,8 @@ export default {
handleCodeCurrentChange(val) {
this.codeSearchParams.pageNum = val
this.getListCodeTool()
}
}
},
},
}
</script>
@ -912,33 +1001,32 @@ export default {
}
.content-box {
height: calc(100vh - 220px);
border-radius: 8px;
display: flex;
flex-direction: column;
overflow: hidden;
// height: calc(100vh - 220px);
// border-radius: 8px;
// display: flex;
// flex-direction: column;
// overflow: hidden;
::v-deep .el-card__body {
display: flex !important;
flex-direction: column !important;
height: 100% !important;
padding: 20px;
}
// ::v-deep .el-card__body {
// display: flex !important;
// flex-direction: column !important;
// height: 100% !important;
// padding: 20px;
// }
.el-row:first-child {
margin-bottom: 16px;
flex-shrink: 0;
// .el-row:first-child {
// margin-bottom: 16px;
// flex-shrink: 0;
.el-col {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 12px;
}
}
// .el-col {
// display: flex;
// justify-content: flex-end;
// align-items: center;
// gap: 12px;
// }
// }
.table-container {
overflow: hidden;
margin-bottom: 0;
min-height: 0;
@ -961,15 +1049,15 @@ export default {
::v-deep .el-table {
&.el-table--striped .el-table__body {
tr.el-table__row--striped td {
background-color: #F6FBFA !important;
background-color: #f6fbfa !important;
}
}
.el-table__header {
background: #E9F0EE;
background: #e9f0ee;
th {
background: #E9F0EE !important;
background: #e9f0ee !important;
color: #606266;
font-weight: 600;
height: 50px;
@ -977,7 +1065,7 @@ export default {
}
&.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #CCF1E9 !important;
background-color: #ccf1e9 !important;
}
}
}
@ -993,15 +1081,15 @@ export default {
&.el-table--striped .el-table__body {
tr.el-table__row--striped td {
background-color: #F6FBFA !important;
background-color: #f6fbfa !important;
}
}
.el-table__header {
background: #E9F0EE;
background: #e9f0ee;
th {
background: #E9F0EE !important;
background: #e9f0ee !important;
color: #606266;
font-weight: 600;
height: 45px;
@ -1027,7 +1115,7 @@ export default {
}
&.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #CCF1E9 !important;
background-color: #ccf1e9 !important;
}
&::before {
@ -1051,9 +1139,9 @@ export default {
}
}
.el-dialog__body {
padding: 20px;
}
// .el-dialog__body {
// padding: 20px;
// }
.el-dialog__footer {
padding: 10px 20px;
@ -1083,7 +1171,9 @@ export default {
}
}
.el-input, .el-select, .el-date-picker {
.el-input,
.el-select,
.el-date-picker {
width: 100%;
}
@ -1106,7 +1196,27 @@ export default {
border-color: #1890ff;
}
}
::v-deep .el-dialog {
display: flex !important;
flex-direction: column !important;
margin: 0 !important;
position: absolute !important;
top: 50% !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
min-height: 95vh !important;
max-height: 95vh !important;
.el-dialog__body {
flex: 1 !important;
overflow-y: scroll !important;
padding: 20px 20px !important;
box-sizing: border-box !important;
}
}
/* 租赁价格输入框错误样式 */
::v-deep .lease-price-error .el-input__inner {
border-color: #f56c6c !important;
}
</style>