From 0235f4fd39131763ba751399ce1c2e2ab14d5dc7 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Wed, 08 Apr 2026 06:27:16 +0000
Subject: [PATCH] 合同部分金额添加自定义中文格式显示

---
 eladmin-web-master/src/views/assembly/moneyInput/index.vue |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/eladmin-web-master/src/views/assembly/moneyInput/index.vue b/eladmin-web-master/src/views/assembly/moneyInput/index.vue
index 65cce1f..00352f2 100644
--- a/eladmin-web-master/src/views/assembly/moneyInput/index.vue
+++ b/eladmin-web-master/src/views/assembly/moneyInput/index.vue
@@ -4,11 +4,14 @@
     <el-input
       ref="value"
       v-model="value"
+      type="number"
       :style="{width: width + 'px'}"
       :class="{'web-display-none': showDisplay, 'web-display-inline': !showDisplay}"
       :disabled="disabled"
       @blur="moneyBlur($event.target.value)"
-    />
+    >
+      <template v-if="showCh" slot="append">{{ customChinese }}</template>
+    </el-input>
     <!-- 金额格式输入框 -->
     <el-input
       v-model="valueStr"
@@ -16,11 +19,15 @@
       :class="{'web-display-none': !showDisplay, 'web-display-inline': showDisplay}"
       :disabled="disabled"
       @focus="moneyFocus($event.target.value)"
-    />
+    >
+      <template v-if="showCh" slot="append">{{ customChinese }}</template>
+    </el-input>
   </div>
 </template>
 
 <script>
+import Nzh from 'nzh'
+
 export default {
   name: 'AssemblyMoneyInput',
   model: {
@@ -47,6 +54,12 @@
       default() {
         return false
       }
+    },
+    showCh: {
+      type: Boolean,
+      default() {
+        return false
+      }
     }
   },
   data() {
@@ -59,10 +72,30 @@
       valueStr: null
     }
   },
+  computed: {
+    customNzh() {
+      return new Nzh({
+        ch: '0123456789', // 数字字符
+        ch_u: '个十百千万亿兆京', // 数位单位
+        ch_f: '负', // 负号
+        ch_d: '点', // 小数点
+        m_u: '元角分厘', // 金额单位
+        m_t: '人民币', // 金额前缀
+        m_z: '整' // 无小数后缀
+      })
+    },
+    customChinese() {
+      // 使用自定义配置进行转换
+      if (this.value === null || this.value === undefined) {
+        return ''
+      }
+      return this.customNzh.toMoney(this.value, { outSymbol: false }).replace(/[个十百千]/g, '')
+    }
+  },
   watch: {
     // 监听金额标准输入框数据变化:赋值给modelVal
     value(val) {
-      this.$emit('change', Number(val))
+      this.$emit('change', val !== null && val !== undefined ? Number(val) : null)
       // 回调钩子
       this.$emit('afterChange')
     }
@@ -100,9 +133,15 @@
     // 金额格式化
     getInputValue(el) {
       // 金额
-      const inputVal = el.toString() || ''
-      // 金额添加千分位(金额去除千分位(金额))
-      this.comdify(this.delcommafy(inputVal))
+      const inputVal = el !== null && el !== undefined ? el.toString() : ''
+      if (inputVal.trim() !== '') {
+        // 金额添加千分位(金额去除千分位(金额))
+        this.comdify(this.delcommafy(inputVal))
+      } else {
+        // 清空金额
+        this.valueStr = null
+        this.value = null
+      }
     },
     // 金额去除千分位
     delcommafy(num) {
@@ -131,6 +170,6 @@
   display: none !important;
 }
 .web-display-inline {
-  display: inline-block !important;
+  display: inline-table !important;
 }
 </style>

--
Gitblit v1.9.3