num-range.ts 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { getDecimalNum } from "../../utils/util";
  2. // components/num-range/num-range.ts
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. /// 单位
  9. unit: {
  10. type: String,
  11. value: 'CT'
  12. },
  13. min: {
  14. type: String,
  15. value: '0.00'
  16. },
  17. max: {
  18. type: String,
  19. value: '0.00'
  20. }
  21. },
  22. /**
  23. * 组件的初始数据
  24. */
  25. data: {},
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. /**
  31. * 输入框变化
  32. */
  33. valueInput(e: any) {
  34. /// 截取2位小数位
  35. let num = getDecimalNum(e.detail.value)
  36. switch (e.target.id) {
  37. case 'min':
  38. this.setData({ min: num })
  39. break;
  40. default:
  41. this.setData({ max: num })
  42. break;
  43. }
  44. this.triggerEvent('sync', { value: [this.properties.min, this.properties.max] })
  45. }
  46. },
  47. observers: {}
  48. })