| 123456789101112131415161718192021222324252627282930313233 |
- // module/user/components/field-cascader/field-cascader.ts
- Component({
- behaviors: ['wx://form-field'],
- lifetimes: {},
- properties: {
- name: { type: String, value: '' },
- title: { type: String, value: '' },
- closeOnOverlayClick: { type: Boolean, value: true },
- },
- data: {
- visible: false,
- value: [] as { code: string; name: string; }[],
- },
- observers: {
- },
- methods: {
- onShow() {
- this.setData({ visible: true });
- },
- onConfirm(event: { detail: { value: string[]; code: string[] } }) {
- const { value, code } = event.detail;
- const gather = value.map((name, index) => ({ name, code: code[index] }))
- this.setData({ value: gather });
- const name = this.data.name;
- if (name) this.triggerEvent('change', { [name]: gather }, { bubbles: true, composed: true });
- },
- onClose() {
- this.setData({ visible: false })
- }
- }
- })
|