const _Http = getApp().globalData.http;

Page({
    data: {
        loading: false,
        disabled: false,
        form: [{
            label: "费用类型",
            error: false,
            errMsg: "",
            type: "option",
            optionNmae: "feestype",
            optionType: "radio", //复选   radio 单选
            value: "",
            placeholder: "选择类型",
            valueName: "feestype",
            checking: "base",
            required: true
        }, {
            label: "营销费用",
            error: false,
            errMsg: "",
            type: "digit",
            value: "",
            placeholder: "请填写金额",
            valueName: "amount",
            checking: "base",
            required: true
        }]
    },
    onLoad(options) {
        let item = JSON.parse(options.item)
        this.setData({
            content: {
                sa_salesfeesid: item.sa_salesfeesid,
                "salesfeesdetail": [item]
            },
            'form[0].value': item.feestype,
            'form[1].value': item.amount,
        })
    },
    onConfirm({
        detail
    }) {
        this.setData({
            disabled: detail
        })
    },
    submit() {
        const content = this.data.content;
        content.salesfeesdetail[0] = Object.assign(content.salesfeesdetail[0], this.selectComponent("#Form").submit());
        this.setData({
            loading: true
        })
        _Http.basic({
            "id": 20240611093004,
            content
        }).then(res => {
            this.setData({
                loading: false
            })
            console.log("编辑费用明细", res)
            wx.showToast({
                title: res.code == '1' ? getApp().globalData.Language.getMapText('编辑成功') : res.msg,
                icon: "none",
                mask: res.code == '1'
            })
            if (res.code != '1') return;
            _Http.updateExpenseBreakdownList && _Http.updateExpenseBreakdownList();
            setTimeout(() => {
                wx.navigateBack()
            }, 800)
        })
    }
})