ResetData.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="container-no-container">
  3. <van-dialog v-model:show="resetDataTrueFalseBy"
  4. :beforeClose="beforeClose"
  5. :title="'若确定重新清点,请输入'+props.modeTypeName+'!'"
  6. show-cancel-button
  7. >
  8. <van-field :class="['code-input',bin>0?'success-border':'']"
  9. v-model="bin"
  10. ref="binRef"
  11. type="digit"
  12. clearable :max="1000"
  13. :placeholder="'请输入'+props.modeTypeName" />
  14. <van-row>
  15. <van-col span="16"></van-col>
  16. <van-col span="8"><div class="completion" @click="onConfirm" >清除全部</div></van-col>
  17. </van-row>
  18. </van-dialog>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { ref } from 'vue'
  23. import { showToast } from 'vant'
  24. const resetDataTrueFalseBy=ref(false)
  25. const binRef=ref(null)
  26. const bin=ref('');
  27. const props = defineProps({
  28. binData: Array,
  29. modeTypeName:String
  30. });
  31. const show = async () => {
  32. resetDataTrueFalseBy.value = true
  33. bin.value=''
  34. setTimeout(()=>{
  35. binRef.value?.focus()
  36. },200)
  37. }
  38. //输入数量
  39. const emit = defineEmits()
  40. const beforeClose= (action) =>
  41. new Promise(async (resolve) => {
  42. if (action === 'confirm') {
  43. if (bin.value == '') {
  44. showToast(`请输入${props.value.modeTypeName}!!!`)
  45. return resolve(false)
  46. }
  47. emit('resetData', bin.value,'bin')
  48. }
  49. resolve(true)
  50. });
  51. const onConfirm=()=>{
  52. resetDataTrueFalseBy.value = false
  53. emit('resetData',undefined,'all')
  54. }
  55. defineExpose({show})
  56. </script>
  57. <style scoped lang="sass">
  58. .container-no-container
  59. .code-input
  60. font-size: 22px
  61. font-weight: bold
  62. border-bottom: 2px solid #0077ff
  63. margin-top: 10px
  64. .completion
  65. text-align: right
  66. font-size: 14px
  67. padding: 10px 20px 10px 0
  68. cursor: pointer
  69. text-decoration: underline
  70. color: #ff0d00
  71. .success-border
  72. border-bottom: 2px solid #1ca600
  73. </style>