bonus-ui/src/views/EquipmentUpOrDown/tool/index.vue

1337 lines
46 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<!-- 搜索表单 -->
<el-form
:inline="true"
label-width="auto"
label-position="right"
size="small"
ref="searchFormRef"
:model="searchParams"
>
<el-card class="search-box">
<!-- 关键修改使用 flex 布局实现自适应换行 -->
<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"
/>
</el-form-item>
<el-form-item prop="pro_name" label="施工类型" style="margin-bottom: 0; width: 320px">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.greatGrandparentName"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
<el-form-item prop="pro_name" label="工具名称" style="margin-bottom: 0; width: 320px">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.parentTypeName"
style="width: 240px; min-width: 200px"
/>
</el-form-item>
<el-form-item prop="pro_name" label="规格型号" style="margin-bottom: 0; width: 320px">
<el-input
clearable
placeholder="请输入"
v-model="searchParams.typeName"
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"
>
查询
</el-button>
<el-button @click="onReset" icon="el-icon-refresh" size="mini" class="primary-lease"
>重置</el-button
>
</div>
</div>
<el-row> </el-row>
</el-card>
</el-form>
<!-- 数据列表 -->
<el-card class="content-box">
<el-row :gutter="24" class="mb8">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">工具上下架列表</span>
</el-col>
<el-col :span="20">
<el-tooltip
placement="top-start"
content="请选择需要下架的工具后再操作"
:disabled.sync="selectedRows.length !== 0"
>
<el-button
size="mini"
type="danger"
class="primary-lease"
@click="handleBatchDown"
style="float: right;margin-right: 10px"
:disabled="selectedRows.length === 0"
>
批量下架
</el-button>
</el-tooltip>
<el-button size="mini" style="float: right;margin-right: 10px" @click="numberTool" type="primary" class="primary-lease">
上架数量工具
</el-button>
<el-button size="mini" style="float: right;margin-right: 10px" @click="codeTool" type="primary" class="primary-lease"> 上架编码工具 </el-button>
</el-col>
</el-row>
<div>
<el-table
:data="toolList"
show-overflow-tooltip
border
stripe
class="my-table"
@selection-change="handleSelectionChange"
>
<!-- 修复后的表格列代码 -->
<el-table-column type="selection" width="55" align="center" />
<el-table-column align="center" label="序号" type="index" width="80" />
<el-table-column align="center" label="工具专业" prop="fourthParentName" />
<el-table-column align="center" label="施工类型" prop="greatGrandparentName" />
<el-table-column align="center" label="工具类型" prop="grandparentTypeName" />
<el-table-column align="center" label="工具名称" prop="parentTypeName" />
<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="操作" :width="220">
<template slot-scope="scope">
<!-- 下架按钮移除 v-if 条件直接显示 -->
<el-popconfirm
width="220"
icon="el-icon-info"
icon-color="#626AEF"
title="确定下架该工具吗?"
@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>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页组件 -->
<div class="pagination-wrapper">
<el-pagination
background
layout="total,sizes,prev, pager, next"
:total="total"
:page-size="searchParams.pageSize"
:current-page="searchParams.pageNum"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</el-card>
<!-- 上架数量工具 -->
<el-dialog
width="97%"
@close="handleNumberDialogClose"
destroy-on-close
:title="dialogTitleByNumber"
:visible.sync="numberDialogVisible"
custom-class="simple-dialog"
>
<!-- 搜索区域 -->
<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"
placeholder="请输入工具专业"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="施工类型" prop="greatGrandparentName">
<el-input
v-model="numberSearchParams.greatGrandparentName"
placeholder="请输入施工类型"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeName">
<el-input
v-model="numberSearchParams.parentTypeName"
placeholder="请输入工具名称"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeName">
<el-input
v-model="numberSearchParams.typeName"
placeholder="请输入规格型号"
clearable
style="width: 220px"
/>
</el-form-item>
<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>
<el-button
size="mini"
type="danger"
class="primary-lease"
@click="handleBatchUpNum"
:disabled="selectedNumberRows.length === 0"
>
批量上架
</el-button>
</el-form-item>
</el-form>
<!-- 表格区域 -->
<div>
<el-table
:data="numberToolList"
show-overflow-tooltip
border
stripe
@selection-change="handleNumberSelectionChange"
height="546"
>
<!--复选列-->
<el-table-column type="selection" width="55" align="center" />
<el-table-column align="center" label="序号" type="index" width="80" />
<el-table-column align="center" label="工具专业" prop="fourthParentName" />
<el-table-column align="center" label="施工类型" prop="greatGrandparentName" />
<el-table-column align="center" label="工具类型" prop="grandparentTypeName" />
<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" prop="leasePrice" width="180">
<template slot="header">
<span>租赁价</span>
<el-tooltip
class="item"
effect="dark"
content="如果默认为0则表示电话面议"
placement="top"
>
<i class="el-icon-info" style="color: #409eff"></i>
</el-tooltip>
</template>
<template slot-scope="scope">
<el-input
:ref="`leasePriceInputNum${scope.$index}`"
clearable
style="width: 120px"
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>
</div>
<!-- 分页组件 -->
<div class="pagination-wrapper">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:total="numberTotal"
:page-size="numberSearchParams.pageSize"
:current-page="numberSearchParams.pageNum"
:page-sizes="[10, 20, 30, 50]"
@size-change="handleNumberSizeChange"
@current-change="handleNumberCurrentChange"
/>
</div>
</el-dialog>
<!-- 上架编码工具 -->
<el-dialog
width="95%"
@close="handleCodeDialogClose"
destroy-on-close
:title="dialogTitleByCode"
:visible.sync="codeDialogVisible"
custom-class="simple-dialog"
>
<!-- 搜索区域 -->
<el-form inline :model="codeSearchParams" label-width="auto">
<el-form-item label="工具专业" prop="fourthParentName">
<el-input
v-model="codeSearchParams.fourthParentName"
placeholder="请输入工具专业"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="施工类型" prop="greatGrandparentName">
<el-input
v-model="codeSearchParams.greatGrandparentName"
placeholder="请输入施工类型"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具名称" prop="parentTypeName">
<el-input
v-model="codeSearchParams.parentTypeName"
placeholder="请输入工具名称"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeName">
<el-input
v-model="codeSearchParams.typeName"
placeholder="请输入规格型号"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item label="工具编码" prop="toolCode">
<el-input
v-model="codeSearchParams.toolCode"
placeholder="请输入工具编码"
clearable
style="width: 220px"
/>
</el-form-item>
<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
size="mini"
type="danger"
class="primary-lease"
@click="handleBatchUpCode"
:disabled="selectedCodeRows.length === 0"
>
批量上架
</el-button>
</el-form-item>
</el-form>
<!-- 表格区域 -->
<div>
<el-table
:data="codeToolList"
show-overflow-tooltip
border
stripe
height="546"
@selection-change="handleCodeSelectionChange"
>
<!-- 复选列 -->
<el-table-column type="selection" width="55" align="center" />
<el-table-column align="center" label="序号" type="index" width="80" />
<el-table-column align="center" label="工具专业" prop="fourthParentName" />
<el-table-column align="center" label="施工类型" prop="greatGrandparentName" />
<el-table-column align="center" label="工具类型" prop="grandparentTypeName" />
<el-table-column align="center" label="工具名称" prop="parentTypeName" />
<el-table-column align="center" label="规格型号" prop="typeName" />
<el-table-column align="center" label="计量单位" prop="unitName" />
<el-table-column align="center" label="工具编码" prop="toolCode" />
<el-table-column align="center" label="下次检验时间" prop="nextCheckDate" />
<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" width="180">
<template slot="header">
<span>租赁价</span>
<el-tooltip
class="item"
effect="dark"
content="如果默认为0则表示电话面议"
placement="top"
>
<i class="el-icon-info" style="color: #409eff"></i>
</el-tooltip>
</template>
<template slot-scope="scope">
<el-input
:ref="`leasePriceInput${scope.$index}`"
clearable
style="width: 120px"
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>
<!-- 分页组件 -->
<div class="pagination-wrapper">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:total="codeTotal"
:page-size="codeSearchParams.pageSize"
:current-page="codeSearchParams.pageNum"
:page-sizes="[10, 20, 30, 50]"
@size-change="handleCodeSizeChange"
@current-change="handleCodeCurrentChange"
/>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listTool,
listNumberTool,
upToolByNumber,
listCodeTool,
downTool,
batchDownTool,
batchUpTool,
upToolByCode,
} from '@/api/EquipmentUpOrDown/tool'
import { Message } from 'element-ui'
export default {
name: 'ProjectManagement',
data() {
return {
total: 0,
numberTotal: 0,
codeTotal: 0,
toolList: [], //工具列表
codeToolList: [], //编码工具列表
numberToolList: [], //数量工具列表
selectedRows: [], // 存储选中的表格行
selectedNumberRows: [], // 存储数量工具选中行
selectedCodeRows: [], // 存储编码工具选中行
dialogTitleByNumber: '上架数量工具',
dialogTitleByCode: '上架编码工具',
codeDialogVisible: false,
numberDialogVisible: false,
submitLoading: false,
isAdd: true,
isView: false,
//
dialogSearchParams: {
toolCategory: '',
},
// 搜索参数
searchParams: {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1,
},
// 数量工具搜索参数
numberSearchParams: {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1,
},
// 编码工具搜索参数
codeSearchParams: {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1,
},
}
},
mounted() {
this.getListTool()
},
methods: {
// 获取工具列表
async getListTool() {
try {
const res = await listTool(this.searchParams)
if (res.code === 200) {
this.toolList = res.rows || []
this.total = res.total || 0
} else {
Message.error(res.message || '获取工程列表失败')
}
} catch (error) {
Message.error('网络错误,获取工程列表失败')
}
},
// 获取数量工具列表
async getListNumberTool() {
try {
const res = await listNumberTool(this.numberSearchParams)
if (res.code === 200) {
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 || '获取工程列表失败')
}
} catch (error) {
Message.error('网络错误,获取工程列表失败')
}
},
// 获取编码工具列表
async getListCodeTool() {
try {
const res = await listCodeTool(this.codeSearchParams)
if (res.code === 200) {
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 || '获取工程列表失败')
}
} catch (error) {
Message.error('网络错误,获取工程列表失败')
}
},
// 重置搜索
onReset() {
this.searchParams = {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1,
}
this.$refs.searchFormRef?.clearValidate()
this.getListTool()
},
// 数量工具重置搜索
handleNumberReset() {
this.numberSearchParams = {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1,
}
this.getListNumberTool()
},
// 编码工具重置搜索
handleCodeReset() {
this.codeSearchParams = {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1,
}
this.getListCodeTool()
},
// 表格选择变化
handleSelectionChange(selection) {
this.selectedRows = selection
},
// 数量工具表格选择变化
handleNumberSelectionChange(selection) {
this.selectedNumberRows = selection
},
// 编码工具表格选择变化
handleCodeSelectionChange(selection) {
this.selectedCodeRows = selection
},
// 编码工具
codeTool() {
this.isAdd = true
this.isView = false
this.dialogTitle = '上架编码工具'
this.$refs.addOrEditFormRef?.clearValidate()
this.codeDialogVisible = true
this.getListCodeTool()
},
// 数量工具
numberTool() {
this.isAdd = true
this.isView = false
this.dialogTitle = '上架数量工具'
this.$refs.addOrEditFormRef?.clearValidate()
this.numberDialogVisible = true
this.getListNumberTool()
},
// 下架工具
async handleDown(id) {
try {
const res = await downTool(id) // 替换为下架接口
if (res.code === 200) {
Message.success('工具下架成功') // 提示文案适配功能
this.getListTool() // 修正为正确的列表查询方法名
} else {
Message.error(res.message || '工具下架失败')
}
} catch (error) {
Message.error('网络错误,工具下架失败')
}
},
//上架工具
async handleUp(id) {
try {
const res = await upToolByCode(id) // 替换为上架接口
if (res.code === 200) {
Message.success('工具上架成功') // 提示文案适配功能
this.getListTool() // 修正为正确的列表查询方法名
} else {
Message.error(res.message || '工具上架失败')
}
} catch (error) {
Message.error('网络错误,工具上架失败')
}
},
// 批量下架
async handleBatchDown() {
if (this.selectedRows.length === 0) {
Message.warning('请选择要下架的工具')
return
}
try {
await this.$confirm(`确定下架选中的 ${this.selectedRows.length} 个工具吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
})
const ids = this.selectedRows.map((row) => row.id)
// 假设批量下架接口为 downToolBatch
const res = await batchDownTool(ids)
if (res.code === 200) {
Message.success(`成功下架 ${this.selectedRows.length} 个工具`)
// 刷新工具列表
this.getListTool()
// 清空选中状态
this.selectedRows = []
} else {
Message.error(res.message || '批量下架失败')
}
} catch (error) {
if (error !== 'cancel') {
Message.error('网络错误,批量下架失败')
}
}
},
// 数量工具批量上架
async handleBatchUpNum() {
if (this.selectedNumberRows.length === 0) {
Message.warning('请选择要上架的工具')
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',
confirmButtonText: '确定',
cancelButtonText: '取消',
})
// 组装参数
const launchList = this.selectedNumberRows.map((row) => {
return {
id: row.id,
leasePrice: row.oldLeasePrice,
isChangePrice: row.isChangePrice,
}
})
const res = await batchUpTool(launchList)
if (res.code === 200) {
this.$modal.msgSuccess(`成功上架 ${this.selectedNumberRows.length} 个工具`)
this.getListNumberTool()
this.getListTool()
this.selectedNumberRows = []
} else {
this.$modal.msgError(res.message || '批量上架失败')
}
} catch (error) {
console.log('error', error)
}
},
// 校验租赁价格格式
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) {
Message.warning('请选择要上架的工具')
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} 个工具吗?`, '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
})
// 组装参数
const launchList = this.selectedCodeRows.map((row) => {
return {
id: row.id,
leasePrice: row.oldLeasePrice,
isChangePrice: row.isChangePrice,
}
})
const res = await batchUpTool(launchList)
if (res.code === 200) {
this.$modal.msgSuccess(`成功上架 ${this.selectedCodeRows.length} 个工具`)
// 刷新编码工具列表
this.getListCodeTool()
//工具列表
this.getListTool()
// 清空选中状态
this.selectedCodeRows = []
} else {
this.$modal.msgError(res.message || '批量上架失败')
}
} catch (error) {
console.log('error', error)
}
},
// 关闭数量工具对话框
handleNumberDialogClose() {
this.numberDialogVisible = false
this.selectedNumberRows = []
this.numberSearchParams = {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
pageSize: 10,
pageNum: 1,
}
},
// 关闭编码工具对话框
handleCodeDialogClose() {
this.codeDialogVisible = false
this.selectedCodeRows = []
this.codeSearchParams = {
fourthParentName: '',
greatGrandparentName: '',
parentTypeName: '',
typeName: '',
toolCode: '',
pageSize: 10,
pageNum: 1,
}
},
// 分页大小改变
handleSizeChange(val) {
this.searchParams.pageSize = val
this.getListTool()
},
// 当前页码改变
handleCurrentChange(val) {
this.searchParams.pageNum = val
this.getListTool()
},
// 数量工具分页大小改变
handleNumberSizeChange(val) {
this.numberSearchParams.pageSize = val
this.getListNumberTool()
},
// 数量工具当前页码改变
handleNumberCurrentChange(val) {
this.numberSearchParams.pageNum = val
this.getListNumberTool()
},
// 编码工具分页大小改变
handleCodeSizeChange(val) {
this.codeSearchParams.pageSize = val
this.getListCodeTool()
},
// 编码工具当前页码改变
handleCodeCurrentChange(val) {
this.codeSearchParams.pageNum = val
this.getListCodeTool()
},
},
}
</script>
<style lang="scss" scoped>
/* 样式部分保持不变 */
::v-deep .upload-tip .el-form-item__label {
color: transparent;
}
.el-pagination {
justify-content: flex-end;
padding: 5px 0;
}
::v-deep .el-pagination.is-background .el-pager li.is-active {
background-color: #3cb4a6;
}
::v-deep .el-form--inline .el-form-item {
margin-right: 6px;
// width: 95%;
}
.img-list {
display: flex;
align-items: center;
.img-items {
width: 100px;
height: 100px;
margin-right: 8px;
position: relative;
img {
width: 100%;
height: 100%;
}
.mask-img {
visibility: hidden;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #000;
opacity: 0.5;
display: flex;
align-items: center;
justify-content: center;
.delete-icon {
font-size: 20px;
cursor: pointer;
z-index: 9;
color: #fff;
}
}
}
.img-items:hover .mask-img {
visibility: visible;
}
}
.app-container-content {
::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;
max-height: 100vh !important;
.el-dialog__body {
flex: 1;
overflow-y: scroll !important;
padding: 20px 40px;
}
.dialog-content {
padding: 20px;
}
}
}
.search-box {
margin-bottom: 20px;
border-radius: 8px;
padding: 0;
::v-deep .el-card__body {
padding: 20px !important;
}
}
.el-form-item--small.el-form-item {
margin-bottom: 0px;
}
.content-box {
//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;
}
.table-container {
overflow: hidden;
margin-bottom: 0;
min-height: 0;
display: flex;
flex-direction: column;
}
.pagination-wrapper {
flex-shrink: 0;
padding-top: 6px;
margin-top: auto;
text-align: right;
::v-deep .pagination-container {
padding: 0px 20px !important;
/* margin-bottom: 30px; */
}
}
::v-deep .el-table {
&.el-table--striped .el-table__body {
tr.el-table__row--striped td {
background-color: #f6fbfa !important;
}
}
.el-table__header {
background: #e9f0ee;
th {
background: #e9f0ee !important;
color: #606266;
font-weight: 600;
height: 50px;
}
}
&.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #ccf1e9 !important;
}
}
}
.dialog-table {
border-radius: 6px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
::v-deep .el-table {
border-radius: 6px;
overflow: hidden;
&.el-table--striped .el-table__body {
tr.el-table__row--striped td {
background-color: #f6fbfa !important;
}
}
.el-table__header {
background: #e9f0ee;
th {
background: #e9f0ee !important;
color: #606266;
font-weight: 600;
height: 45px;
font-size: 14px;
border-bottom: 2px solid #e4e7ed;
}
}
.el-table__body {
tr {
transition: all 0.2s ease;
&:hover {
background-color: #f8f9fa;
}
td {
padding: 12px 8px;
font-size: 13px;
border-bottom: 1px solid #f0f2f5;
}
}
}
&.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #ccf1e9 !important;
}
&::before {
display: none;
}
&::after {
display: none;
}
}
}
.simple-dialog {
.el-dialog__header {
padding: 15px 20px;
border-bottom: 1px solid #eee;
.el-dialog__title {
font-size: 16px;
font-weight: 600;
}
}
// .el-dialog__body {
// padding: 20px;
// }
.el-dialog__footer {
padding: 10px 20px;
border-top: 1px solid #eee;
text-align: right;
}
}
.simple-form {
.el-form-item {
margin-bottom: 15px;
.el-form-item__label {
color: #333;
padding-right: 10px;
&::before {
content: '*';
color: #ff4d4f;
margin-right: 4px;
}
&.no-required::before {
content: '';
margin-right: 0;
}
}
}
.el-input,
.el-select,
.el-date-picker {
width: 100%;
}
.el-textarea {
width: 100%;
&:focus {
border-color: #1890ff;
}
}
}
.dialog-footer {
.cancel-btn {
margin-right: 10px;
}
.confirm-btn {
background-color: #1890ff;
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>