代码提交

This commit is contained in:
jiang 2025-12-17 19:29:10 +08:00
parent b7ea784983
commit c1a9c1ba7d
3 changed files with 440 additions and 197 deletions

View File

@ -82,11 +82,11 @@
/> />
</el-form-item>--> </el-form-item>-->
<el-form-item prop="minBuyPrice" label="资产原值(万元)"> <el-form-item prop="minOriginalValue" label="资产原值(万元)">
<el-input clearable style="width: 95px" placeholder="请输入" v-model.trim="queryParams.minBuyPrice" /> <el-input clearable style="width: 95px" placeholder="请输入" @input="handleNumberInput('minOriginalValue')" v-model.trim="queryParams.minOriginalValue" />
</el-form-item> </el-form-item>
<el-form-item prop="maxBuyPrice" label="-" style="margin-left: -6%"> <el-form-item prop="maxOriginalValue" label="-" style="margin-left: -6%">
<el-input clearable style="width: 95px" placeholder="请输入" v-model.trim="queryParams.maxBuyPrice" /> <el-input clearable style="width: 95px" placeholder="请输入" @input="handleNumberInput('maxOriginalValue')" v-model.trim="queryParams.maxOriginalValue" />
</el-form-item> </el-form-item>
<el-form-item style="float: right"> <el-form-item style="float: right">
@ -726,12 +726,17 @@ export default {
originalCode: '', originalCode: '',
manufacturerId: '', manufacturerId: '',
productionDate: '', productionDate: '',
minBuyPrice: '', minOriginalValue: '',
maxBuyPrice: '', maxOriginalValue: '',
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
}, },
//
lastValidValues: {
minOriginalValue: '',
maxOriginalValue: ''
},
currentRow: null, currentRow: null,
uploadType: 1, // 1:234 uploadType: 1, // 1:234
uploadVisible: false, uploadVisible: false,
@ -788,6 +793,117 @@ export default {
this.getManufacturerSelectList() this.getManufacturerSelectList()
}, },
methods: { methods: {
handleNumberInput(key) {
let value = this.queryParams[key] || ''
// 1.
const cleanedValue = this.cleanNumberInput(value)
// 2.
this.lastValidValues[key] = cleanedValue
// 3.
if (key === 'minOriginalValue') {
this.queryParams[key] = this.validateMinValue(cleanedValue)
} else if (key === 'maxOriginalValue') {
this.queryParams[key] = this.validateMaxValue(cleanedValue)
} else {
this.queryParams[key] = cleanedValue
}
// 4.
this.$forceUpdate()
},
//
cleanNumberInput(input) {
if (!input) return ''
//
let cleaned = input.replace(/[^\d.]/g, '')
//
const dotIndex = cleaned.indexOf('.')
if (dotIndex !== -1) {
const before = cleaned.substring(0, dotIndex + 1)
const after = cleaned.substring(dotIndex + 1).replace(/\./g, '')
cleaned = before + after
}
//
const parts = cleaned.split('.')
if (parts.length > 1) {
cleaned = parts[0] + '.' + parts[1].slice(0, 2)
}
return cleaned
},
//
validateMinValue(value) {
//
if (!value || value === '.') return value
const maxValue = this.queryParams.maxOriginalValue
const minNum = this.safeParseNumber(value)
const maxNum = this.safeParseNumber(maxValue)
//
if (maxNum === null) return value
// 使
if (minNum !== null && minNum > maxNum) {
return maxValue
}
return value
},
//
validateMaxValue(value) {
//
if (!value || value === '.') return value
const minValue = this.queryParams.minOriginalValue
const maxNum = this.safeParseNumber(value)
const minNum = this.safeParseNumber(minValue)
//
if (minNum === null) return value
// 使
if (maxNum !== null && maxNum < minNum) {
return minValue
}
return value
},
//
safeParseNumber(str) {
if (!str || str === '.' || isNaN(Number(str))) {
return null
}
return Number(str)
},
//
validateNumberRange() {
const minNum = this.safeParseNumber(this.queryParams.minOriginalValue)
const maxNum = this.safeParseNumber(this.queryParams.maxOriginalValue)
if (minNum !== null && maxNum !== null && minNum > maxNum) {
// 使 <=
const temp = this.queryParams.minOriginalValue
this.queryParams.minOriginalValue = this.queryParams.maxOriginalValue
this.queryParams.maxOriginalValue = temp
//
this.$message.warning('已自动调整数值范围,确保最小值 ≤ 最大值')
return false
}
return true
},
// //
handleFileUploadProgress(event, file, fileList) { handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true this.upload.isUploading = true
@ -895,6 +1011,7 @@ export default {
// //
queryTableList() { queryTableList() {
this.validateNumberRange()
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
}, },

View File

@ -110,12 +110,13 @@
</el-form-item>--> </el-form-item>-->
<!-- <el-col :span="6"> --> <!-- <el-col :span="6"> -->
<el-form-item prop="originalValue" label="资产原值(万元)"> <el-form-item prop="minOriginalValue" label="资产原值(万元)">
<el-input <el-input
clearable clearable
style="width: 103px" style="width: 103px"
placeholder="请输入" placeholder="请输入"
v-model.trim="queryParams.minOriginalValue" v-model.trim="queryParams.minOriginalValue"
@input="handleNumberInput('minOriginalValue')"
/> />
</el-form-item> </el-form-item>
<span style="line-height: 30px;margin: 0 10px 0 0px;"> - </span> <span style="line-height: 30px;margin: 0 10px 0 0px;"> - </span>
@ -125,6 +126,7 @@
style="width: 103px" style="width: 103px"
placeholder="请输入" placeholder="请输入"
v-model.trim="queryParams.maxOriginalValue" v-model.trim="queryParams.maxOriginalValue"
@input="handleNumberInput('maxOriginalValue')"
/> />
</el-form-item> </el-form-item>
<!-- </el-col> --> <!-- </el-col> -->
@ -132,7 +134,9 @@
<!-- <el-col :span="18" style="text-align: right;"> --> <!-- <el-col :span="18" style="text-align: right;"> -->
<el-form-item style="display: flex; justify-content: flex-end"> <el-form-item style="display: flex; justify-content: flex-end">
<el-button class="primary-lease" size="mini" type="primary" icon="el-icon-search" @click="getEquipmentApplyList"> <el-button class="primary-lease" size="mini" type="primary" icon="el-icon-search"
@click="getEquipmentApplyList"
>
查询 查询
</el-button> </el-button>
<el-button class="primary-lease" size="mini" icon="el-icon-refresh" @click="resetForm"> <el-button class="primary-lease" size="mini" icon="el-icon-refresh" @click="resetForm">
@ -178,13 +182,17 @@
</el-table-column> </el-table-column>
<el-table-column prop="name" label="装备名称" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="name" label="装备名称" show-overflow-tooltip align="center" min-width="100"/>
<el-table-column prop="specificationModel" label="规格型号" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="specificationModel" label="规格型号" show-overflow-tooltip align="center"
min-width="100"
/>
<el-table-column prop="originalCode" label="装备原始编码" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="originalCode" label="装备原始编码" show-overflow-tooltip align="center" min-width="100"/>
<el-table-column prop="unit" label="计量单位" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="unit" label="计量单位" show-overflow-tooltip align="center" min-width="100"/>
<el-table-column prop="manufacturer" label="生产厂家" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="manufacturer" label="生产厂家" show-overflow-tooltip align="center" min-width="100"/>
<el-table-column prop="productionDate" label="出厂日期" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="productionDate" label="出厂日期" show-overflow-tooltip align="center" min-width="100"/>
<!-- <el-table-column prop="orderNumber" label="采购日期" align="center"/>--> <!-- <el-table-column prop="orderNumber" label="采购日期" align="center"/>-->
<el-table-column prop="originalValue" label="资产原值(万元)" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="originalValue" label="资产原值(万元)" show-overflow-tooltip align="center"
min-width="100"
/>
<!-- <el-table-column prop="orderNumber" label="最大使用年限(年)" align="center"/>--> <!-- <el-table-column prop="orderNumber" label="最大使用年限(年)" align="center"/>-->
<!-- <el-table-column prop="orderNumber" label="下次维保日期" align="center"/>--> <!-- <el-table-column prop="orderNumber" label="下次维保日期" align="center"/>-->
<el-table-column prop="province" label="所属省份" show-overflow-tooltip align="center" min-width="100"/> <el-table-column prop="province" label="所属省份" show-overflow-tooltip align="center" min-width="100"/>
@ -198,7 +206,9 @@
<span style="color: #00a288; cursor: pointer" @click="handleView(row, 2)">查看</span> <span style="color: #00a288; cursor: pointer" @click="handleView(row, 2)">查看</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="inspectionReports" label="定期检验报告" show-overflow-tooltip align="center" min-width="100"> <el-table-column prop="inspectionReports" label="定期检验报告" show-overflow-tooltip align="center"
min-width="100"
>
<template v-slot="{ row }"> <template v-slot="{ row }">
<span style="color: #00a288; cursor: pointer" @click="handleView(row, 3)">查看</span> <span style="color: #00a288; cursor: pointer" @click="handleView(row, 3)">查看</span>
</template> </template>
@ -319,11 +329,17 @@ export default {
manufacturerId: '', manufacturerId: '',
productionDate: '', productionDate: '',
originalValue: '', originalValue: '',
maxBuyPrice: '', minOriginalValue: '',
maxOriginalValue: '',
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}, },
//
lastValidValues: {
minOriginalValue: '',
maxOriginalValue: ''
},
manufacturerList: [], manufacturerList: [],
tableData: [], tableData: [],
columns2: [], columns2: [],
@ -345,11 +361,11 @@ export default {
{ key: 40, label: `特征项8`, prop: 'featureItem8', visible: true }, { key: 40, label: `特征项8`, prop: 'featureItem8', visible: true },
{ key: 41, label: `特征值8`, prop: 'featureValue8', visible: true }, { key: 41, label: `特征值8`, prop: 'featureValue8', visible: true },
{ key: 42, label: `特征项9`, prop: 'featureItem9', visible: true }, { key: 42, label: `特征项9`, prop: 'featureItem9', visible: true },
{ key: 43, label: `特征值9`, prop: 'featureValue9', visible: true }, { key: 43, label: `特征值9`, prop: 'featureValue9', visible: true }
], ],
dialogVisible: false, dialogVisible: false,
dialogTitle: '', dialogTitle: '',
dialogList: [], dialogList: []
} }
}, },
mounted() { mounted() {
@ -357,6 +373,117 @@ export default {
this.getManufacturerSelectList() this.getManufacturerSelectList()
}, },
methods: { methods: {
handleNumberInput(key) {
let value = this.queryParams[key] || ''
// 1.
const cleanedValue = this.cleanNumberInput(value)
// 2.
this.lastValidValues[key] = cleanedValue
// 3.
if (key === 'minOriginalValue') {
this.queryParams[key] = this.validateMinValue(cleanedValue)
} else if (key === 'maxOriginalValue') {
this.queryParams[key] = this.validateMaxValue(cleanedValue)
} else {
this.queryParams[key] = cleanedValue
}
// 4.
this.$forceUpdate()
},
//
cleanNumberInput(input) {
if (!input) return ''
//
let cleaned = input.replace(/[^\d.]/g, '')
//
const dotIndex = cleaned.indexOf('.')
if (dotIndex !== -1) {
const before = cleaned.substring(0, dotIndex + 1)
const after = cleaned.substring(dotIndex + 1).replace(/\./g, '')
cleaned = before + after
}
//
const parts = cleaned.split('.')
if (parts.length > 1) {
cleaned = parts[0] + '.' + parts[1].slice(0, 2)
}
return cleaned
},
//
validateMinValue(value) {
//
if (!value || value === '.') return value
const maxValue = this.queryParams.maxOriginalValue
const minNum = this.safeParseNumber(value)
const maxNum = this.safeParseNumber(maxValue)
//
if (maxNum === null) return value
// 使
if (minNum !== null && minNum > maxNum) {
return maxValue
}
return value
},
//
validateMaxValue(value) {
//
if (!value || value === '.') return value
const minValue = this.queryParams.minOriginalValue
const maxNum = this.safeParseNumber(value)
const minNum = this.safeParseNumber(minValue)
//
if (minNum === null) return value
// 使
if (maxNum !== null && maxNum < minNum) {
return minValue
}
return value
},
//
safeParseNumber(str) {
if (!str || str === '.' || isNaN(Number(str))) {
return null
}
return Number(str)
},
//
validateNumberRange() {
const minNum = this.safeParseNumber(this.queryParams.minOriginalValue)
const maxNum = this.safeParseNumber(this.queryParams.maxOriginalValue)
if (minNum !== null && maxNum !== null && minNum > maxNum) {
// 使 <=
const temp = this.queryParams.minOriginalValue
this.queryParams.minOriginalValue = this.queryParams.maxOriginalValue
this.queryParams.maxOriginalValue = temp
//
this.$message.warning('已自动调整数值范围,确保最小值 ≤ 最大值')
return false
}
return true
},
// //
getManufacturerSelectList() { getManufacturerSelectList() {
getManufacturerSelectApi().then((res) => { getManufacturerSelectApi().then((res) => {
@ -370,6 +497,7 @@ export default {
* 获取装备申请列表 * 获取装备申请列表
*/ */
getEquipmentApplyList() { getEquipmentApplyList() {
this.validateNumberRange()
this.queryParams.startOrderCreateTime = this.queryParams.orderCreateTime ? this.queryParams.orderCreateTime[0] : '' this.queryParams.startOrderCreateTime = this.queryParams.orderCreateTime ? this.queryParams.orderCreateTime[0] : ''
this.queryParams.endOrderCreateTime = this.queryParams.orderCreateTime ? this.queryParams.orderCreateTime[1] : '' this.queryParams.endOrderCreateTime = this.queryParams.orderCreateTime ? this.queryParams.orderCreateTime[1] : ''
this.queryParams.startProductionDate = this.queryParams.productionDate ? this.queryParams.productionDate[0] : '' this.queryParams.startProductionDate = this.queryParams.productionDate ? this.queryParams.productionDate[0] : ''
@ -551,7 +679,7 @@ export default {
this.dialogList = row.purchaseInvoices || [] this.dialogList = row.purchaseInvoices || []
} }
this.dialogVisible = true this.dialogVisible = true
}, }
} }
} }
</script> </script>
@ -656,6 +784,7 @@ export default {
&.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell { &.el-table--striped .el-table__body tr.el-table__row:hover > td.el-table__cell {
background-color: #CCF1E9 !important; background-color: #CCF1E9 !important;
} }
.el-table__body tr.hover-row > td.el-table__cell { .el-table__body tr.hover-row > td.el-table__cell {
background-color: #ccf1e9 !important; background-color: #ccf1e9 !important;
} }

View File

@ -440,33 +440,30 @@ export default {
{ label: '规格型号', prop: 'typeName' }, { label: '规格型号', prop: 'typeName' },
{ label: '计量单位', prop: 'unitName' }, { label: '计量单位', prop: 'unitName' },
{ label: '工具编码', prop: 'toolCode' }, { label: '工具编码', prop: 'toolCode' },
// { {
// label: "", label: "工具状态",
// prop: "status", prop: "status",
// width: 120, width: 120,
// render: (h, { row }) => { render: (h, { row }) => {
// const statusOptions = { const statusOptions = {
// 0: { text: "", type: "success" }, 0: { text: "在库", type: "success" },
// 1: { text: "", type: "info" }, 1: { text: "在用", type: "info" },
// 2: { text: "", type: "warning" }, 2: { text: "在修", type: "warning" },
// 3: { text: "", type: "danger" }, 3: { text: "已报废", type: "danger" },
// }; };
// const option = statusOptions[row.status] || { const option = statusOptions[row.status]
// text: "", return h(
// type: "", "el-tag",
// }; {
// return h( props: {
// "el-tag", type: option.type,
// { size: "mini",
// props: { },
// type: option.type, },
// size: "mini", option.text
// }, );
// }, },
// option.text },
// );
// },
// },
{ label: '下次检验时间', prop: 'nextCheckDate' }, { label: '下次检验时间', prop: 'nextCheckDate' },
{ label: '生产厂家', prop: 'supplierName', width: 200 }, { label: '生产厂家', prop: 'supplierName', width: 200 },
{ label: '出厂日期', prop: 'productionDate' }, { label: '出厂日期', prop: 'productionDate' },