Commit bc74c84c by chenwq

对账单bug修复

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