123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- let util = require('../../../utils/util.js');
- var that
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- index: 1,
- imageurl: '',
- showpay: false,
- payWayarray: [],
- payWayindex: 0,
- paydate: ''
- },
- savepay() {
- if (!this.data.payAmount) {
- util.showToast('请输入金额')
- return
- }
- util.query('supplierpayback/wxapi/create', {
- supplier: {
- id: this.data.id,
- onlyID: this.data.onlyid
- },
- payAmount: this.data.payAmount,
- payWay: this.data.payWayarray[this.data.payWayindex].key,
- createTime: this.data.paydate + ' 00:00:00'
- }, function(res) {
- if (res.code === 10000) {
- util.showToast('保存成功')
- that.getpayback()
- that.getData()
- that.setData({
- showpay: false
- })
- } else {
- util.showToast('保存失败')
- }
- }, 'POST')
- },
- payback() {
- this.setData({
- showpay: true,
- paydate: util.formatShortTime(new Date()),
- payWayindex: 0,
- payAmount: ''
- })
- },
- paytimechange(e) {
- this.setData({
- paydate: e.detail.value
- })
- },
- setprice(e) {
- this.setData({
- payAmount: util.PointNum(e.detail.value)
- })
- },
- payWayChange(e) {
- this.setData({
- payWayindex: e.detail.value
- })
- },
- setindex(e) {
- this.setData({
- index: e.currentTarget.dataset.index
- })
- },
- del(e) {
- wx.showModal({
- title: '确认',
- content: '是否确定删除供应商',
- success(res) {
- if (res.confirm) {
- util.query("supplier/wxapi/delete", {
- id: that.data.id
- }, function(res) {
- if (res.code == 10000) {
- util.showToast('删除成功')
- setTimeout(function() {
- let pages = getCurrentPages()
- let prevPage = pages[pages.length - 2]
- wx.navigateBack({
- delta: 1
- })
- }, 2000)
- } else {
- util.showToast(res.message)
- }
- }, "POST")
- } else if (res.cancel) {
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- that = this
- if (options.id) {
- this.setData({
- id: options.id,
- onlyid: options.onlyid
- })
- util.getPayWay(function(e) {
- that.setData({
- payWayarray: e
- })
- that.getData()
- that.getpayback()
- that.getbuyrecord()
- })
- }
- },
- hidepay() {
- this.setData({
- showpay: false,
- })
- },
- delpay(e) {
- wx.showModal({
- title: '确认',
- content: '是否确定删除付款记录',
- success(res) {
- if (res.confirm) {
- util.query("supplierpayback/wxapi/delete", {
- id: e.currentTarget.dataset.id
- }, function(res) {
- if (res.code == 10000) {
- util.showToast('删除成功')
- that.getpayback()
- that.getData()
- } else {
- util.showToast(res.message)
- }
- }, "POST")
- } else if (res.cancel) {
- }
- }
- })
- },
- getData() {
- util.query('/supplier/wxapi/findbyid', {
- id: this.data.id
- }, function(res) {
- if (res.code === 10000) {
- res.alreadyPayed = res.alreadyPayed.toFixed(2)
- res.needPay = res.needPay.toFixed(2)
- res.purchaseNum = res.purchaseNum.toFixed(2)
- res.stockNum = res.stockNum.toFixed(2)
- res.sumAmount = res.sumAmount.toFixed(2)
- res.totalAmount = res.totalAmount.toFixed(2)
- res.totalDiscount = res.totalDiscount.toFixed(2)
- that.setData(res)
- }
- })
- },
- getpayback() {
- util.query('supplierpayback/wxapi/listpage', {
- supplierOnlyId: this.data.onlyid,
- pageNo: 1,
- pageSize: 9999
- }, function(res) {
- if (res.code === 10000) {
- res.data.content.forEach(function(e) {
- var pyname = ''
- that.data.payWayarray.forEach(function(fe) {
- if (fe.key === e.payWay) {
- pyname = fe.name
- }
- })
- e.pyname = pyname
- })
- that.setData({
- plist: res.data.content
- })
- }
- })
- },
- getbuyrecord() {
- util.query('supplier/wxapi/findPurchaseRecord', {
- id: this.data.id
- }, function(res) {
- if (res.code === 10000) {
- that.setData({
- bdata: res.data
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|