// packageA/modules/projectList/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        list: Array,
        showList: Array,
        getResult: Function
    },
    options: {
        addGlobalClass: true
    },
    /**
     * 组件的初始数据
     */
    data: {
        show: false,
        result: []
    },
    /**
     * 组件的方法列表
     */
    methods: {
        onChange({
            detail
        }) {
            this.setData({
                result: detail
            })
        },
        onClose() {
            this.setData({
                show: false
            })
        },
        startSearch({
            detail
        }) {
            if (!detail.trim()) return this.setData({
                showList: this.data.list
            })
            let showList = this.data.list.filter(v => `${v.projectname},${v.projectnum},${v.address}`.includes(detail.trim()));
            this.setData({
                showList
            })
        },
        onClear() {
            this.setData({
                showList: this.data.list
            })
        },
        handleReturn() {
            if (!this.data.result.length) return;
            this.triggerEvent("getResult", this.data.result)
            this.setData({
                show: false,
                result: []
            })
        }
    }
})