|
@@ -9,12 +9,12 @@
|
|
v-model="inputVal"
|
|
v-model="inputVal"
|
|
placeholder="0"
|
|
placeholder="0"
|
|
autofocus
|
|
autofocus
|
|
- @input="onAmountInput"
|
|
|
|
- @blur="onAmountBlur">
|
|
|
|
|
|
+ @input="onValueInput"
|
|
|
|
+ @blur="onValueBlur">
|
|
</div>
|
|
</div>
|
|
<div class="btn-wrapper">
|
|
<div class="btn-wrapper">
|
|
<div class="btn cancel">
|
|
<div class="btn cancel">
|
|
-
|
|
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
<div class="btn confirm">
|
|
<div class="btn confirm">
|
|
|
|
|
|
@@ -25,21 +25,56 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { onMounted, ref, defineProps } from "vue";
|
|
|
|
|
|
+import { ref, defineProps, defineEmits } from "vue";
|
|
|
|
|
|
let inputVal = ref('');
|
|
let inputVal = ref('');
|
|
|
|
|
|
-const onAmountInput = () => {
|
|
|
|
|
|
+const props = defineProps({
|
|
|
|
+ title: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: '',
|
|
|
|
+ },
|
|
|
|
+ cancelText: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: 'Cancel',
|
|
|
|
+ },
|
|
|
|
+ confirmText: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: 'Continue',
|
|
|
|
+ },
|
|
|
|
+});
|
|
|
|
|
|
-}
|
|
|
|
|
|
+const emits = defineEmits(["cancel", "confirm"]);
|
|
|
|
|
|
-const onAmountBlur = () => {
|
|
|
|
|
|
+const onValueInput = () => {
|
|
|
|
+ inputValHandler();
|
|
|
|
+}
|
|
|
|
|
|
|
|
+const onValueBlur = () => {
|
|
|
|
+ inputValHandler();
|
|
}
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
|
+// emits("postPublishFinish", { publishRes });
|
|
|
|
+
|
|
|
|
+const inputValHandler = () => {
|
|
|
|
+ let val = inputVal.value;
|
|
|
|
+ val = val.replace(/[^\d^\.]+/g, "");
|
|
|
|
+
|
|
|
|
+ if(val == '00') {
|
|
|
|
+ val = '0'
|
|
|
|
+ }
|
|
|
|
+ if(val.indexOf('.') > -1){ //校验 例:00.12 => 0.12
|
|
|
|
+ let arr = val.split('.');
|
|
|
|
+ if(arr[0].startsWith('0')) {
|
|
|
|
+ let num = +arr[0];
|
|
|
|
+ val = num + '.' + arr[1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ inputVal.value = val;
|
|
|
|
+ return val;
|
|
|
|
+}
|
|
|
|
|
|
-})
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|