This commit is contained in:
parent
8ff796775e
commit
0f571eabc8
|
|
@ -315,3 +315,33 @@ export async function downloadPDF(options) {
|
||||||
modal?.closeLoading?.()
|
modal?.closeLoading?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正数输入处理
|
||||||
|
* @param {string | number} value 输入值
|
||||||
|
* @param {number} decimal 最多保留的小数位,默认不限制
|
||||||
|
*/
|
||||||
|
export function handlePositiveNumberInput(value, decimal = Infinity) {
|
||||||
|
let val = String(value ?? '')
|
||||||
|
|
||||||
|
// 1️⃣ 只保留数字和 .
|
||||||
|
val = val.replace(/[^\d.]/g, '')
|
||||||
|
|
||||||
|
// 2️⃣ 只保留第一个小数点
|
||||||
|
const dotIndex = val.indexOf('.')
|
||||||
|
if (dotIndex !== -1) {
|
||||||
|
val = val.slice(0, dotIndex + 1) + val.slice(dotIndex + 1).replace(/\./g, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3️⃣ 限制小数位数(可配置)
|
||||||
|
if (dotIndex !== -1 && Number.isFinite(decimal)) {
|
||||||
|
val = val.slice(0, dotIndex + decimal + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4️⃣ ".5" → "0.5"
|
||||||
|
if (val.startsWith('.')) {
|
||||||
|
val = '0' + val
|
||||||
|
}
|
||||||
|
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -344,6 +344,7 @@ import {
|
||||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
||||||
import ImageUpload from '@/components/ImageUpload'
|
import ImageUpload from '@/components/ImageUpload'
|
||||||
import FileUpload from '@/components/FileImageUpload'
|
import FileUpload from '@/components/FileImageUpload'
|
||||||
|
import { handlePositiveNumberInput } from '@/utils/bonus.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EquipmentEntryEditDialog', // 明确组件名称
|
name: 'EquipmentEntryEditDialog', // 明确组件名称
|
||||||
|
|
@ -536,10 +537,11 @@ export default {
|
||||||
},
|
},
|
||||||
// 价格输入处理
|
// 价格输入处理
|
||||||
handlePriceInput(v) {
|
handlePriceInput(v) {
|
||||||
this.form.originalValue = this.form.originalValue
|
this.form.originalValue = handlePositiveNumberInput(this.form.originalValue)
|
||||||
.replace(/[^\d.]/g, '') // 删除所有非数字和点
|
// this.form.originalValue = this.form.originalValue
|
||||||
.replace(/\.{2,}/g, '.') // 多个点 -> 单点
|
// .replace(/[^\d.]/g, '') // 删除所有非数字和点
|
||||||
.replace(/^(\d+)\.(.*)\./, '$1.$2'); // 只允许一个点
|
// .replace(/\.{2,}/g, '.') // 多个点 -> 单点
|
||||||
|
// .replace(/^(\d+)\.(.*)\./, '$1.$2'); // 只允许一个点
|
||||||
},
|
},
|
||||||
// 处理图片上传变化
|
// 处理图片上传变化
|
||||||
handleImageChange(files) {
|
handleImageChange(files) {
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@
|
||||||
style="width: 105px"
|
style="width: 105px"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
v-model.trim="queryParams.minBuyPrice"
|
v-model.trim="queryParams.minBuyPrice"
|
||||||
|
@input="handleNumber('min')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -125,6 +126,7 @@
|
||||||
style="width: 105px"
|
style="width: 105px"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
v-model.trim="queryParams.maxBuyPrice"
|
v-model.trim="queryParams.maxBuyPrice"
|
||||||
|
@change="handleNumber('max')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
|
@ -304,6 +306,7 @@ import {
|
||||||
equipmentPassAndRejectApiNew
|
equipmentPassAndRejectApiNew
|
||||||
} from '@/api/EquipmentEntryApply/index'
|
} from '@/api/EquipmentEntryApply/index'
|
||||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
import { getManufacturerSelectApi } from '@/api/EquipmentLedger/index.js'
|
||||||
|
import { handlePositiveNumberInput } from '@/utils/bonus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EquipmentDetailList',
|
name: 'EquipmentDetailList',
|
||||||
|
|
@ -384,6 +387,16 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handleNumber(key) {
|
||||||
|
if (key === 'min') {
|
||||||
|
this.queryParams.minBuyPrice = handlePositiveNumberInput(this.queryParams.minBuyPrice)
|
||||||
|
} else if (key === 'max') {
|
||||||
|
this.queryParams.maxBuyPrice = handlePositiveNumberInput(this.queryParams.maxBuyPrice)
|
||||||
|
}
|
||||||
|
if (Number(this.queryParams.minBuyPrice) > Number(this.queryParams.maxBuyPrice) && this.queryParams.maxBuyPrice) {
|
||||||
|
this.queryParams.minBuyPrice = this.queryParams.maxBuyPrice
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 获取装备申请列表
|
* 获取装备申请列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue