const _Http = getApp().globalData.http Component({ properties: { detail: { type: Object }, disabled: { type: Boolean } }, options: { addGlobalClass: true, }, data: { content: { nocache: true, pageNumber: 1, pageTotal: 1, total: null } }, lifetimes: { attached: function () { getApp().globalData.Language.getLanguagePackage(this) } }, methods: { isEdit() { if (this.data.disabled) getApp().globalData.Language.showToast('当前状态不可编辑!') }, getList(id, init) { let content = this.data.content; content.sa_paybillid = id; if (init) content.pageNumber = 1; _Http.basic({ "id": "20221227092804", content }).then(res => { console.log("打款明细", res) if (res.code != '1') return wx.showToast({ title: res.msg, icon: "none" }) this.setData({ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), "content.pageNumber": res.pageNumber + 1, "content.pageSize": res.pageSize, "content.pageTotal": res.pageTotal, "content.total": res.total, sa_paybillid: id }) }) }, /* 添加明细 */ addProduct() { wx.navigateTo({ url: `/packageA/remitVoucher/modules/selectAccount/index?params=${ JSON.stringify({ "id": 20221228085004, "content": { "pageNumber": 1, "pageSize": 20, "sa_paybillid":getCurrentPages()[getCurrentPages().length - 1].data.sa_paybillid, "where": { "condition": "" } } }) }`, }) getApp().globalData.handleSelect = this.handleSelect.bind(this) }, /* 操作选中的账户信息 */ async handleSelect(data) { wx.navigateBack() let paybilldetails = data.list.map(item => { return { "sa_paybilldetailid": 0, "sa_accountclassid": item.sa_accountclassid, "amount": item.amount } }), page = getCurrentPages()[getCurrentPages().length - 2] let res = await _Http.basic({ "id": 20221227092904, "content": { sa_paybillid: page.data.sa_paybillid, paybilldetails } }) if (res.code == '1') { this.getList(page.data.sa_paybillid, true) } }, /* 金额改变 */ async priceChange(e) { console.log(e); let data = e.currentTarget.dataset.data if (e.detail.value == data.amount) return let res = await _Http.basic({ "id": 20221227092904, "content": { sa_paybillid: data.sa_paybillid, paybilldetails: [{ "sa_paybilldetailid": data.sa_paybilldetailid, "sa_accountclassid": data.sa_accountclassid, "amount": e.detail.value, }] } }) if (res.code == '1') { this.triggerEvent('onSuccess') } else { wx.showToast({ title: res.msg, icon: 'none' }) } }, /* 删除明细 */ deleteProduct(e) { if (this.properties.detail.status != '新建') return getApp().globalData.Language.showToast('非新建状态无法删除') wx.showModal({ cancelText: getApp().globalData.Language.getMapText('取消'), confirmText: getApp().globalData.Language.getMapText('确定'), title: getApp().globalData.Language.getMapText('提示'), content: getApp().globalData.Language.getMapText('是否删除当前打款明细') + '?', complete: async (res) => { console.log(res); if (res.confirm) { let res = await _Http.basic({ "id": 20221227093004, "content": { "sa_paybillid": e.currentTarget.dataset.data.sa_paybillid, "sa_paybilldetailids": [e.currentTarget.dataset.data.sa_paybilldetailid] } }) if (res.code == '1') { this.getList(getCurrentPages()[getCurrentPages().length - 1].data.sa_paybillid, true) } else { wx.showToast({ title: res.msg, icon: 'none' }) } } } }) } } })