gaosp
2024-01-18 fbcbc7aca6e37c685b7a8ca3241169abf308298d
update
已修改2个文件
138 ■■■■ 文件已修改
src/container/ledger/Manage-add-update.vue 134 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/container/ledger/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
src/container/ledger/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-01-06 17:40:19
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-17 23:37:03
 * @LastEditTime: 2024-01-18 23:26:42
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/ledger/index.vue
-->
<template>
@@ -264,7 +264,7 @@
                        message: '删除成功!'
                    })
                    this.submitForm()
                }).catch(() => {
                },() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'