Allow negative toman input for SMS auto-block threshold.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import {
|
||||
fromGroupedInput,
|
||||
rialToToman,
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
* Money field bound to **rial** storage values (API/DB).
|
||||
* User types and sees **toman** (÷10 / ×10 at the edges).
|
||||
* With `nullable`, empty input emits `null` (for optional thresholds).
|
||||
* With `allowNegative`, values like `-50,000` are accepted.
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -34,7 +35,18 @@ const emit = defineEmits<{
|
||||
(e: 'update:value', value: number | null): void
|
||||
}>()
|
||||
|
||||
/** Keeps intermediate input like "-" while typing a negative amount. */
|
||||
const draft = ref<string | null>(null)
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
() => {
|
||||
draft.value = null
|
||||
},
|
||||
)
|
||||
|
||||
const display = computed(() => {
|
||||
if (draft.value !== null) return draft.value
|
||||
if (props.nullable && (props.value == null || props.value === undefined)) return ''
|
||||
return toGroupedDisplay(rialToToman(props.value ?? 0))
|
||||
})
|
||||
@@ -42,9 +54,16 @@ const display = computed(() => {
|
||||
function onInput(raw: string | number) {
|
||||
const text = String(raw ?? '').trim()
|
||||
if (props.nullable && !text) {
|
||||
draft.value = null
|
||||
emit('update:value', null)
|
||||
return
|
||||
}
|
||||
// Allow typing a leading minus before digits arrive.
|
||||
if (props.allowNegative && text === '-') {
|
||||
draft.value = '-'
|
||||
return
|
||||
}
|
||||
draft.value = null
|
||||
const toman = fromGroupedInput(text, props.allowNegative)
|
||||
emit('update:value', tomanToRial(toman))
|
||||
}
|
||||
|
||||
@@ -520,15 +520,19 @@ onMounted(async () => {
|
||||
<h3>مسدودسازی خودکار ارسال</h3>
|
||||
<p class="hint">
|
||||
اگر مبلغی بگذارید و موجودی از آن کمتر شود، ارسال پیامک خودکار قطع میشود (کلید مسدودسازی
|
||||
روشن نمیشود). خالی بگذارید تا فقط با کلید دستی مسدود شود.
|
||||
روشن نمیشود). معمولاً منفی است؛ مثلاً
|
||||
<strong dir="ltr">-۵۰٬۰۰۰</strong>
|
||||
یعنی تا ۵۰ هزار تومان بدهی اجازه ارسال هست و پایینتر مسدود میشود. خالی بگذارید تا فقط با
|
||||
کلید دستی مسدود شود.
|
||||
</p>
|
||||
<div class="threshold-grid">
|
||||
<label>
|
||||
<span class="tone-label">آستانه مسدودسازی خودکار (تومان)</span>
|
||||
<MoneyInput
|
||||
v-model:value="form.autoBlockBelowRials"
|
||||
allow-negative
|
||||
nullable
|
||||
placeholder="خالی = بدون مسدودسازی خودکار"
|
||||
placeholder="مثلاً -50,000 — خالی = غیرفعال"
|
||||
/>
|
||||
</label>
|
||||
<a-button type="primary" size="large" :loading="saving" @click="saveThresholds">
|
||||
|
||||
Reference in New Issue
Block a user