Commit bc74c84c by chenwq

对账单bug修复

1 parent 2468876e
......@@ -15,7 +15,6 @@
<script>
import { deepClone } from "@/common/util"
import { limitPrice } from "@/common/format"
import { tmplTypeList, localTmplList } from "../constant/baseData"
import { tmplAddOrEdit, getTmplById } from '@api/accountManage'
import AccountTmpl from "./components/AccountTmpl"
......
......@@ -15,7 +15,7 @@
<el-table-column prop="adjustAmount" label="调整金额" width="180">
<template slot-scope="scope">
<el-form-item :prop="'tableData.' + scope.$index + '.adjustAmount'" :rules="adjustAmountRules">
<el-input v-model="scope.row.adjustAmount" :disabled="!isEdit" placeholder="请输入金额" type="number" @blur="handleInputBlur"></el-input>
<el-input v-model="scope.row.adjustAmount" :disabled="!isEdit" placeholder="请输入金额" type="number" @input="handleInput(scope.$index, 'adjustAmount')" @blur="handleInputBlur"></el-input>
</el-form-item>
</template>
</el-table-column>
......@@ -44,6 +44,8 @@
</template>
<script>
import { deepClone, Util } from '@/common/util'
import { limitPrice } from '@/common/format'
export default {
name: 'DynamicAdjustmentTable',
props: {
......@@ -59,12 +61,14 @@ export default {
data() {
return {
dynamicForm: {
tableData: []
tableData: [],
tableOldData: []
},
adjustAmountRules: [
{ required: true, message: '请输入调整金额', trigger: 'blur' },
{
validator: (rule, value, callback) => {
const decimalPart = String(value).split('.')[1]
if (value && isNaN(Number(value))) {
callback(new Error('请输入有效的数字'));
} else {
......@@ -96,6 +100,7 @@ export default {
},
mounted() {
this.dynamicForm.tableData = this.adjustments
this.tableOldData = deepClone(this.adjustments)
},
methods: {
addRow() {
......@@ -103,35 +108,29 @@ export default {
adjustAmount: '',
adjustReason: ''
});
this.tableOldData = deepClone(this.tableData)
},
deleteRow(index) {
// if (this.tableData.length <= 1) {
// this.$message.warning('至少保留一行数据');
// return;
// }
this.tableData.splice(index, 1);
this.tableOldData = deepClone(this.tableData)
},
handleInput(rowIdx, attr) {
const val = this.tableData[rowIdx][attr]
const oldVal = this.tableOldData[rowIdx][attr]
this.tableData[rowIdx][attr] = limitPrice(val, oldVal, 9, 2)
this.tableOldData[rowIdx][attr] = this.tableData[rowIdx][attr]
},
handleInputBlur() {
this.$emit('handleInputBlur')
},
showTableData() {
const formattedData = this.tableData.map((row, index) => ({
'序号': index + 1,
'调整金额': row.adjustAmount,
'调整事由': row.adjustReason
}));
console.log('当前表格数据:', formattedData);
},
validateForm() {
var flag = true
this.$refs.dynamicForm.validate(valid => {
if (valid) {
this.$message.success('验证通过,表单数据有效');
this.showTableData();
} else {
this.$message.error('请检查表单,确保所有必填项已填写');
return false;
if (!valid) {
flag = false
}
});
return flag
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!