user-data-edit.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import DictionariesBehavior from "../../../../core/behavior/dictionaries.behavior";
  2. // module/user/components/user-data-edit/user-data-edit.ts
  3. Component({
  4. behaviors: ['wx://form-field-group', DictionariesBehavior],
  5. lifetimes: {
  6. attached() {
  7. console.log('渲染');
  8. }
  9. },
  10. properties: {
  11. model: { type: Object, value: {} },
  12. sex: { type: String, value: '' },
  13. retractable: { type: Boolean, value: false },
  14. dirty: { type: Boolean, value: false },
  15. },
  16. data: {
  17. expanded: false,
  18. showSpecialPeriodPicker: true,
  19. },
  20. observers: {
  21. 'model.sex, sex'(value, sex) {
  22. const showSpecialPeriodPicker = value === '1' || sex === '1';
  23. this.setData({ showSpecialPeriodPicker })
  24. }
  25. },
  26. methods: {
  27. onChange(event) {
  28. const name = event.mark.name;
  29. const value = event.detail.value;
  30. if (name) this.triggerEvent('change', { [name]: value }, { bubbles: true, composed: true });
  31. },
  32. onKeyboardheightchange(event) {
  33. const name = event.mark.name;
  34. if (!event.detail.height) {
  35. this
  36. .createSelectorQuery()
  37. .select(`#${name}`)
  38. .fields({ properties: ['value'] }, detail => this.onChange({ mark: { name }, detail }))
  39. .exec();
  40. }
  41. },
  42. onExpand() {
  43. this.setData({ expanded: true });
  44. }
  45. }
  46. })