const _Http = getApp().globalData.http;

Page({
    data: {
        loading: false,
        disabled: true,
        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) {
        this.data.salesfeesdetail = JSON.parse(options.salesfeesdetail)
        getApp().globalData.Language.getLanguagePackage(this, '新增费用明细');
    },
    onConfirm({
        detail
    }) {
        this.setData({
            disabled: detail
        })
    },
    submit() {
        const salesfeesdetail = Object.assign(this.data.salesfeesdetail, this.selectComponent("#Form").submit());
        this.setData({
            loading: true
        })
        _Http.basic({
            "id": 20240629090604,
            "content": {
                "userid": wx.getStorageSync('userMsg').userid,
                salesfeesdetail
            }
        }).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)

        })
    }
})