Component({
    properties: {
        list: Array,
        disabled: {
            type: Boolean,
            value: true
        },
        change: Function,
        handleDetele: Function
    },
    options: {
        addGlobalClass: true
    },
    methods: {
        /* 步进器修改 */
        onChange(e) {
            let index = e.currentTarget.dataset.index,
                item = this.data.list[index];
            switch (e.type) {
                case "blur":
                    if (item.qty == e.detail.value - 0) return;
                    item.qty = e.detail.value - 0;
                    break;
                case "plus":
                    item.qty += 1;
                    break;
                case "minus":
                    item.qty -= 1;
                    break;
            };
            this.toChange(item, index)
        },
        onBlur(e) {
            let index = e.currentTarget.dataset.index,
                item = this.data.list[index];
            if (item.price == e.detail.value - 0) return;
            item.price = e.detail.value - 0;
            this.toChange(item, index)
        },
        toChange(item, index) {
            item.amount = ((item.qty - 0) * (item.price - 0)).toFixed();
            this.triggerEvent("change", {
                item,
                index
            })
        },
        deleteProduct(e) {
            let that = this;
            const {
                item
            } = e.currentTarget.dataset;
            wx.showModal({
                title: '提示',
                content: '是否确定删除该费用',
                complete: (res) => {
                    if (res.confirm) that.triggerEvent("handleDetele", item.sa_quotedprice_specialitemsid)
                }
            })
        }
    }
})