|
|
@@ -73,11 +73,16 @@
|
|
|
<uni-easyinput v-else v-model="baseForm.secondparty_name" disabled></uni-easyinput>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item name="contract_money" label="合同金额">
|
|
|
- <uni-easyinput v-model="baseForm.contract_money"
|
|
|
- :disabled="!isInitiateOrFieldEditable('contract_money')"
|
|
|
- type="digit"
|
|
|
- placeholder="请输入合同金额"
|
|
|
- @blur="onContractMoneyBlur"></uni-easyinput>
|
|
|
+ <view>
|
|
|
+ <uni-easyinput v-model="baseForm.contract_money"
|
|
|
+ :disabled="!isInitiateOrFieldEditable('contract_money')"
|
|
|
+ type="digit"
|
|
|
+ placeholder="请输入合同金额"
|
|
|
+ @blur="onContractMoneyBlur"></uni-easyinput>
|
|
|
+ <view class="contract-money-uppercase">
|
|
|
+ <text>{{ contractMoneyUppercase }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item name="contractContent" label="合同内容">
|
|
|
<uni-easyinput v-if="isInitiateOrFieldEditable('contractContent')"
|
|
|
@@ -839,6 +844,9 @@ watch(() => props.formData, (newVal) => {
|
|
|
universalid: newVal.universalid || ''
|
|
|
}
|
|
|
|
|
|
+ // 初始化合同金额大写
|
|
|
+ updateContractMoneyUppercase()
|
|
|
+
|
|
|
// 初始化 lastContractType
|
|
|
lastContractType = String(newVal.contract_type || '')
|
|
|
|
|
|
@@ -1487,6 +1495,8 @@ function calculateMaterialPrice(item: any) {
|
|
|
|
|
|
// 重新计算总价
|
|
|
calculateTotalPrice()
|
|
|
+ // 更新大写金额
|
|
|
+ updateContractMoneyUppercase()
|
|
|
}
|
|
|
|
|
|
// 计算合同总价
|
|
|
@@ -1530,6 +1540,8 @@ function calculateTotalPrice() {
|
|
|
|
|
|
// 更新付款信息中的金额
|
|
|
calculatePaymentAmount()
|
|
|
+ // 更新大写金额
|
|
|
+ updateContractMoneyUppercase()
|
|
|
}
|
|
|
|
|
|
// 计算物料总价值(仅返回数值,不更新合同金额)
|
|
|
@@ -1543,6 +1555,47 @@ function calculateTotalPriceValue(): number {
|
|
|
return total
|
|
|
}
|
|
|
|
|
|
+// 合同金额大写
|
|
|
+const contractMoneyUppercase = ref('零元整')
|
|
|
+
|
|
|
+// 数字转中文大写函数
|
|
|
+function numberToChineseUppercase(n) {
|
|
|
+ const fraction = ['角', '分']
|
|
|
+ const digit = [
|
|
|
+ '零', '壹', '贰', '叁', '肆',
|
|
|
+ '伍', '陆', '柒', '捌', '玖'
|
|
|
+ ]
|
|
|
+ const unit = [
|
|
|
+ ['元', '万', '亿'],
|
|
|
+ ['', '拾', '佰', '仟']
|
|
|
+ ]
|
|
|
+ const head = n < 0 ? '欠' : ''
|
|
|
+ n = Math.abs(n)
|
|
|
+ let s = ''
|
|
|
+ for (let i = 0; i < fraction.length; i++) {
|
|
|
+ s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '')
|
|
|
+ }
|
|
|
+ s = s || '整'
|
|
|
+ n = Math.floor(n)
|
|
|
+ for (let i = 0; i < unit[0].length && n > 0; i++) {
|
|
|
+ let p = ''
|
|
|
+ for (let j = 0; j < unit[1].length && n > 0; j++) {
|
|
|
+ p = digit[n % 10] + unit[1][j] + p
|
|
|
+ n = Math.floor(n / 10)
|
|
|
+ }
|
|
|
+ s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s
|
|
|
+ }
|
|
|
+ return head + s.replace(/(零.)*零元/, '元')
|
|
|
+ .replace(/(零.)+/g, '零')
|
|
|
+ .replace(/^整$/, '零元整')
|
|
|
+}
|
|
|
+
|
|
|
+// 更新合同金额大写显示
|
|
|
+function updateContractMoneyUppercase() {
|
|
|
+ const contractMoney = parseFloat(baseForm.value.contract_money) || 0
|
|
|
+ contractMoneyUppercase.value = numberToChineseUppercase(contractMoney)
|
|
|
+}
|
|
|
+
|
|
|
// 监听合同金额变化(检测用户手动输入)- 失焦时触发
|
|
|
function onContractMoneyBlur() {
|
|
|
// 当用户手动修改合同金额时,设置手动输入标记
|
|
|
@@ -1553,6 +1606,8 @@ function onContractMoneyBlur() {
|
|
|
manualInput = true
|
|
|
}
|
|
|
|
|
|
+ // 更新大写金额
|
|
|
+ updateContractMoneyUppercase()
|
|
|
calculatePaymentAmount()
|
|
|
}
|
|
|
|
|
|
@@ -2140,6 +2195,14 @@ defineExpose({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 合同金额大写样式
|
|
|
+.contract-money-uppercase {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #666;
|
|
|
+ margin-top: 5px;
|
|
|
+ padding-left: 2px;
|
|
|
+}
|
|
|
+
|
|
|
.picker {
|
|
|
padding: 10px 0;
|
|
|
color: #333;
|