1
0

three-phase-power.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const threePhasePowerCalculator = require('../../../tools/three-phase-power/index.js')
  2. const handlers = {
  3. setThreePhasePowerState(changedData) {
  4. this.setData(threePhasePowerCalculator.updateState(this.data, changedData))
  5. },
  6. onThreePhaseConnectionTap(event) {
  7. const connection = event.currentTarget.dataset.connection
  8. const connectionIndex = (this.data.threePhaseConnectionOptions || []).findIndex((item) => item.key === connection)
  9. if (connectionIndex < 0) return
  10. this.setThreePhasePowerState({
  11. threePhaseConnectionIndex: connectionIndex
  12. })
  13. },
  14. onThreePhaseInput(event) {
  15. const field = event.currentTarget.dataset.field
  16. if (!field) return
  17. const changedData = {
  18. [field]: event.detail.value
  19. }
  20. if (threePhasePowerCalculator.ELECTRICAL_INPUT_KEYS.includes(field)) {
  21. changedData.threePhaseElectricalDriver = field
  22. }
  23. if (threePhasePowerCalculator.POWER_DRIVER_KEYS.includes(field)) {
  24. changedData.threePhasePowerDriver = field
  25. }
  26. this.setThreePhasePowerState(changedData)
  27. },
  28. clearThreePhaseInputs() {
  29. this.setData(threePhasePowerCalculator.clearInputs(this.data))
  30. }
  31. }
  32. module.exports = {
  33. handlers
  34. }