TestPage001.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  3. <text style="align-self: center;font-size: 35rpx;color: darkslategray;width: 230rpx;">合格数量:</text>
  4. <input v-if="!keyFlag" class="uni-input" type="number" style="margin-right: 5px;color: blue;font-size: 40rpx;font-weight: bold;" v-model="checkOkQty" placeholder="请输合格数量" />
  5. <input v-if="keyFlag" class="uni-input" disabled="true" type="number" style="margin-right: 5px;color: blue;font-size: 40rpx;font-weight: bold;" v-model="checkOkQty" />
  6. </view>
  7. <view style="flex-direction: row;flex-direction: row;display: flex;padding: 2px;">
  8. <text style="align-self: center;font-size: 35rpx;color: red;width: 230rpx;">不合格数量:</text>
  9. <input class="uni-input" type="number" style="margin-right: 5px;color: red;font-size: 40rpx;font-weight: bold;" v-model="checkNgQty" @input="onKeyInput" placeholder="请输不合格数量" />
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. keyFlag: true,
  17. bnSnCode: '',
  18. checkOkQty: 0,
  19. checkNgQty: 0
  20. }
  21. },
  22. onUnload() {
  23. },
  24. onLoad() {
  25. if(this.keyFlag) {
  26. this.checkOkQty = 1
  27. }
  28. },
  29. methods: {
  30. onKeyInput(event) {
  31. console.log(this.checkNgQty)
  32. console.log(event)
  33. if(this.keyFlag) {
  34. if(Number(this.checkNgQty) > 1) {
  35. uni.showToast({
  36. title: '关键件的不合格数量不能大于1,录入错误!',
  37. icon: 'none',
  38. duration: 1000
  39. })
  40. return;
  41. }
  42. if(Number(this.checkNgQty) == 1) {
  43. this.checkOkQty = 0
  44. }
  45. if(Number(this.checkNgQty) == 0) {
  46. this.checkOkQty = 1
  47. }
  48. }
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. </style>