This commit is contained in:
parent
ad01758eea
commit
f0ae9790ac
|
|
@ -110,7 +110,19 @@
|
|||
<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="180">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
:ref="`leasePriceInputNum${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="操作" :width="220">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -153,7 +165,7 @@
|
|||
|
||||
<!-- 上架数量工具 -->
|
||||
<el-dialog
|
||||
width="1600px"
|
||||
width="97%"
|
||||
@close="handleNumberDialogClose"
|
||||
destroy-on-close
|
||||
:title="dialogTitleByNumber"
|
||||
|
|
@ -161,8 +173,10 @@
|
|||
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" label-width="auto">
|
||||
<!-- <el-row style="display: flex; justify-content: center; gap: 10px">
|
||||
|
||||
</el-row> -->
|
||||
<el-form-item label="工具专业" prop="fourthParentName">
|
||||
<el-input
|
||||
v-model="numberSearchParams.fourthParentName"
|
||||
|
|
@ -209,7 +223,6 @@
|
|||
批量上架
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
|
|
@ -231,6 +244,7 @@
|
|||
<el-table-column align="center" label="工具名称" prop="parentTypeName" />
|
||||
<el-table-column align="center" label="规格型号" prop="typeName" />
|
||||
<el-table-column align="center" label="数量" prop="totalNum" />
|
||||
<el-table-column align="center" label="租赁价" prop="leasePrice" />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
|
|
@ -260,8 +274,7 @@
|
|||
>
|
||||
<!-- 搜索区域 -->
|
||||
<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">
|
||||
<el-input
|
||||
v-model="codeSearchParams.fourthParentName"
|
||||
placeholder="请输入工具专业"
|
||||
|
|
@ -269,7 +282,7 @@
|
|||
style="width: 220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="施工类型" prop="greatGrandparentName" style="width: 300px">
|
||||
<el-form-item label="施工类型" prop="greatGrandparentName">
|
||||
<el-input
|
||||
v-model="codeSearchParams.greatGrandparentName"
|
||||
placeholder="请输入施工类型"
|
||||
|
|
@ -277,7 +290,7 @@
|
|||
style="width: 220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="工具名称" prop="parentTypeName" style="width: 300px">
|
||||
<el-form-item label="工具名称" prop="parentTypeName">
|
||||
<el-input
|
||||
v-model="codeSearchParams.parentTypeName"
|
||||
placeholder="请输入工具名称"
|
||||
|
|
@ -285,7 +298,7 @@
|
|||
style="width: 220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="规格型号" prop="typeName" style="width: 300px">
|
||||
<el-form-item label="规格型号" prop="typeName">
|
||||
<el-input
|
||||
v-model="codeSearchParams.typeName"
|
||||
placeholder="请输入规格型号"
|
||||
|
|
@ -293,7 +306,7 @@
|
|||
style="width: 220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="工具编码" prop="toolCode" style="width: 300px">
|
||||
<el-form-item label="工具编码" prop="toolCode">
|
||||
<el-input
|
||||
v-model="codeSearchParams.toolCode"
|
||||
placeholder="请输入工具编码"
|
||||
|
|
@ -315,7 +328,6 @@
|
|||
批量上架
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue