How to deal with some values when dealing with business logic?

problem description

in business development, it is often encountered that certain values are related.

the environmental background of the problems and what methods you have tried

Environmental background

give the simplest example: a country-province-city 3-level linkage drop-down box (may not be appropriate, or can you expand to imagine a linkage you are familiar with?).
take another example of complexity: A-B-C-D has three values, and X-> Y means that when X changes, Y will change accordingly.
A-> B, A-> C, B-> C, D-> A
when one value changes, other values are triggered to change (you may also need to verify whether it is legal / not empty). It would be disgusting to write a method to deal with the linkage between them or to verify them.

try

so I was wondering if I could use Object.defineProperty to rewrite set () / get () methods in a project (the current project is done in Vue, and item in this.list cannot use computed due to restrictions on the usage of dependent components).
but it always feels like it"s too "corny" to do so. It is not elegant enough, but it is more troublesome to deal with the business relationship between these values by writing methods.

what result do you expect? What is the error message actually seen?

I would like to ask you how to deal with the situation of connectedness in this kind of business logic (a change in one value causes a change in other values).

Jul.20,2021

take the provincial, municipal and district selection drop-down box as an example

declare 4 business logic units ( function or class )

  1. get a list of Chinese provinces: getProvinces
  2. get the list of cities in the specified province: getCitys
  3. get the district list of the specified city: getAreas
  4. emptying area list data: clearAreas

define 2 events:

  1. Select province: select-province
  2. Select a city: select-city

when provinces, cities and autonomous regions select the drop-down box to initialize, execute the logical unit getProvinces get the province list data in advance

select-province event triggers the business logic unit to be executed:

  • getCitys
  • clearAreas

select-city event triggers the business logic unit to be executed:

  • getAreas

will this be troublesome?


watch listens for a change in a value. After probing, the method triggers the method to update the second data, the second data of watch, and the third


.
what do you mean by saying that I am ambiguous to deal with one by one? Value changes trigger other value changes a > A1 > a2.
isn't it a matter of code? Trigger the change of the city according to the three-level linkage provincial change you mentioned.
ex:
input   @change |     input
input   @change |     input
input   ...

watch similarly
is there any complication? How to deal with one by one

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e51284-45120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e51284-45120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?