From 5b9a1d6cb3a7d59c8f2de83c495bba1a069b2723 Mon Sep 17 00:00:00 2001 From: gaosp <gaosp> Date: 星期五, 19 一月 2024 00:23:15 +0800 Subject: [PATCH] update --- src/container/ledger/Manage-add-update.vue | 134 ++++++++++++++++++++++---------------------- 1 files changed, 66 insertions(+), 68 deletions(-) diff --git a/src/container/ledger/Manage-add-update.vue b/src/container/ledger/Manage-add-update.vue index f30e000..1f4031f 100644 --- a/src/container/ledger/Manage-add-update.vue +++ b/src/container/ledger/Manage-add-update.vue @@ -1,6 +1,7 @@ <template> <div> - <el-dialog :title="!dataForm.id ? '鏂板缓' : '缂栬緫'" @close="cancel" :close-on-click-modal="false" width="80%" :visible.sync="addVisible"> + <el-dialog :title="!dataForm.id ? '鏂板缓' : '缂栬緫'" @close="cancel" :close-on-click-modal="false" width="80%" + :visible.sync="addVisible"> <!-- 娣诲姞鍐呭--> <el-form :model="dataForm" label-width="100px" ref="dataForm"> <el-row :gutter="20"> @@ -196,13 +197,15 @@ </el-col> <el-col :xs="24" :sm="6" :md="6" :lg="6" :xl="6"> <el-form-item label="璁惧鍘熷��(鍏�)" prop="originalValue"> - <el-input v-model="dataForm.originalValue" :change="checkAmount('originalValue')" placeholder="璁惧鍘熷��" clearable></el-input> + <el-input v-model="dataForm.originalValue" :change="checkAmount('originalValue')" + placeholder="璁惧鍘熷��" clearable></el-input> </el-form-item> </el-col> <el-col :xs="24" :sm="6" :md="6" :lg="6" :xl="6"> <el-form-item label="璁惧鍑�鐜板��(鍏�)" prop="presentValue"> - <el-input v-model="dataForm.presentValue" :change="checkAmount('presentValue')" placeholder="璁惧鍑�鐜板��" clearable></el-input> + <el-input v-model="dataForm.presentValue" :change="checkAmount('presentValue')" + placeholder="璁惧鍑�鐜板��" clearable></el-input> </el-form-item> </el-col> <el-col :xs="24" :sm="6" :md="6" :lg="6" :xl="6"> @@ -307,42 +310,41 @@ // this.init(this.row) }, methods: { - checkAmount (key) { + checkAmount(key) { let checkPlan = '' + this.dataForm[key] - - checkPlan = checkPlan - + + checkPlan = checkPlan + .replace(/[^\d.]/g, '') // 娓呴櫎鈥滄暟瀛椻�濆拰鈥�.鈥濅互澶栫殑瀛楃 - + .replace(/\.{2,}/g, '.') // 鍙繚鐣欑涓�涓�. 娓呴櫎澶氫綑鐨� - + .replace(/^\./g, '') // 淇濊瘉绗竴涓负鏁板瓧鑰屼笉鏄�. - + .replace('.', '$#$') - + .replace(/\./g, '') - + .replace('$#$', '.') - - if (checkPlan.indexOf('.') < 0 && checkPlan !== '') { - + + if (checkPlan.indexOf('.') < 0 && checkPlan !== '') { + // 浠ヤ笂宸茬粡杩囨护锛屾澶勬帶鍒剁殑鏄鏋滄病鏈夊皬鏁扮偣锛岄浣嶄笉鑳戒负绫讳技浜� 01銆�02鐨勯噾棰� - + checkPlan = parseFloat(checkPlan) + '' - - } else if (checkPlan.indexOf('.') >= 0) { - + + } else if (checkPlan.indexOf('.') >= 0) { + checkPlan = checkPlan - - .replace(/^()*(\d+)\.(\d\d).*$/, '$1$2.$3') // 鍙兘杈撳叆涓や釜灏忔暟 - - } - - this.dataForm[key] = checkPlan - + + .replace(/^()*(\d+)\.(\d\d).*$/, '$1$2.$3') // 鍙兘杈撳叆涓や釜灏忔暟 + + } + + this.dataForm[key] = checkPlan + }, init(row) { - debugger if (this.$refs['dataForm']) { this.$refs['dataForm'].resetFields() } @@ -350,11 +352,11 @@ Object.keys(row).forEach(key => { this.dataForm[key] = row[key] }) - } else { + } else { Object.keys(row).forEach(key => { this.dataForm[key] = '' }) - } + } }, /* 鏌ヨ浣跨敤閮ㄩ棬*/ cancel() { @@ -374,47 +376,43 @@ } }, /* 鎻愪氦*/ - async dataFormSubmit() { - let valid = await new Promise(resolve => { - this.$refs.dataForm.validate((valid) => { - if (valid) { - resolve(true) + dataFormSubmit() { + debugger + this.$refs.dataForm.validate((valid) => { + console.log(valid) + if (valid) { + if (!this.dataForm.id) { // 鏂板 + accountCreate(this.dataForm).then(res => { + this.$message({ + message: '鏂板鎴愬姛', + type: 'success', + duration: 1500, + onClose: () => { + this.$emit('confirm') + this.visible = false + } + }) + }) } else { - resolve(false) - this.$message({ - type: 'error', - message: '楠岃瘉澶辫触' + accountUpdate(this.dataForm).then(res => { + this.$message({ + message: '淇敼鎴愬姛', + type: 'success', + duration: 1500, + onClose: () => { + this.$emit('confirm') + this.visible = false + } + }) }) } - }) + } else { + this.$message({ + type: 'error', + message: '楠岃瘉澶辫触' + }) + } }) - if (!valid) return - // return - if (!this.dataForm.id) { // 鏂板 - accountCreate(this.dataForm).then(res => { - this.$message({ - message: '鏂板鎴愬姛', - type: 'success', - duration: 1500, - onClose: () => { - this.$emit('confirm') - this.visible = false - } - }) - }) - } else { - accountUpdate(this.dataForm).then(res => { - this.$message({ - message: '淇敼鎴愬姛', - type: 'success', - duration: 1500, - onClose: () => { - this.$emit('confirm') - this.visible = false - } - }) - }) - } } } } @@ -428,6 +426,7 @@ width: 100%; } + .el-input__inner { color: #000; } @@ -462,5 +461,4 @@ width: 178px; height: 178px; display: block; -} -</style> +}</style> -- Gitblit v1.9.3