From f0ae9790ac4ae58faa6fa5eeee7f82eafbbae348 Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Fri, 12 Dec 2025 15:44:39 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/EquipmentUpOrDown/tool/index.vue | 317 +++++++++++++--------
1 file changed, 200 insertions(+), 117 deletions(-)
diff --git a/src/views/EquipmentUpOrDown/tool/index.vue b/src/views/EquipmentUpOrDown/tool/index.vue
index 4d0b88b8..2778ba8f 100644
--- a/src/views/EquipmentUpOrDown/tool/index.vue
+++ b/src/views/EquipmentUpOrDown/tool/index.vue
@@ -110,7 +110,19 @@
-
+
+
+
+
+
@@ -153,7 +165,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 查询
- 重置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 查询
+ 重置
+
+
+ 批量上架
+
+
@@ -231,6 +244,7 @@
+
@@ -260,62 +274,60 @@
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- 查询
- 重置
-
- 批量上架
-
-
-
+
+ 查询
+ 重置
+
+ 批量上架
+
+
@@ -477,7 +489,15 @@ export default {
try {
const res = await listNumberTool(this.numberSearchParams)
if (res.code === 200) {
- this.numberToolList = res.rows || []
+ this.numberToolList =
+ res.rows.map((e) => {
+ return {
+ ...e,
+ isChangePrice: false, // 是否修改租赁价
+ oldLeasePrice: e.leasePrice, // 原始租赁价
+ priceError: false, // 价格校验错误标识
+ }
+ }) || []
this.numberTotal = res.total || 0
} else {
Message.error(res.message || '获取工程列表失败')
@@ -657,6 +677,67 @@ export default {
return
}
+ // 遍历选中的行,校验租赁价格并设置isChangePrice
+ const errorRows = []
+
+ for (let i = 0; i < this.numberToolList.length; i++) {
+ const listRow = this.numberToolList[i]
+
+ // 仅处理已选中的行
+ const isSelected = this.selectedNumberRows.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)
+ this.$set(listRow, 'priceError', true)
+ } else {
+ 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)
+ }
+
+ // 同步更新选中行
+ this.selectedNumberRows.forEach((selectedRow) => {
+ const listRow = this.numberToolList.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.selectedNumberRows.length} 个工具吗?`, '提示', {
type: 'warning',
@@ -664,25 +745,27 @@ export default {
cancelButtonText: '取消',
})
- const ids = this.selectedNumberRows.map((row) => row.id)
+ // 组装参数
+ const launchList = this.selectedNumberRows.map((row) => {
+ return {
+ id: row.id,
+ leasePrice: row.oldLeasePrice,
+ isChangePrice: row.isChangePrice,
+ }
+ })
- const res = await batchUpTool(ids)
+ const res = await batchUpTool(launchList)
if (res.code === 200) {
- Message.success(`成功上架 ${this.selectedNumberRows.length} 个工具`)
- // 刷新数量工具列表
+ this.$modal.msgSuccess(`成功上架 ${this.selectedNumberRows.length} 个工具`)
this.getListNumberTool()
- //工具列表
this.getListTool()
- // 清空选中状态
this.selectedNumberRows = []
} else {
- Message.error(res.message || '批量上架失败')
+ this.$modal.msgError(res.message || '批量上架失败')
}
} catch (error) {
- if (error !== 'cancel') {
- Message.error('网络错误,批量上架失败')
- }
+ console.log('error', error)
}
},
@@ -929,7 +1012,7 @@ export default {
::v-deep .el-form--inline .el-form-item {
margin-right: 6px;
- width: 95%;
+ // width: 95%;
}
.img-list {