watch.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. export default function useWatch() {
  2. const watchPuOrgName = () => ({
  3. handler: function (newProp, oldProp) {
  4. if (oldProp) {
  5. this.params.priceApplyOrgs = this.params.priceApplyOrgs.filter(
  6. (item) => item.orgName !== oldProp
  7. );
  8. }
  9. if (newProp) {
  10. const { puOrgCode: orgCode, puOrgName: orgName } = this.params;
  11. this.params.priceApplyOrgs.push({
  12. orgCode,
  13. orgName,
  14. createByName: undefined,
  15. updateByName: undefined,
  16. });
  17. }
  18. },
  19. deep: true,
  20. });
  21. const watchPriceApplyOrgs = () => ({
  22. handler: function (newValue) {
  23. this.newParams.priceApplyOrgs = newValue.filter(
  24. (item) => item.delFlag === "0"
  25. );
  26. },
  27. deep: true,
  28. });
  29. const watchPriceApplyItems = () => ({
  30. handler: function (newValue) {
  31. this.newParams.priceApplyItems = newValue.filter(
  32. (item) => item.delFlag === "0"
  33. );
  34. },
  35. deep: true,
  36. });
  37. return { watchPuOrgName, watchPriceApplyOrgs, watchPriceApplyItems };
  38. }