| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- const _Http = getApp().globalData.http,
- currency = require("../../utils/currency"),
- CNY = sum => currency(sum, {
- symbol: "¥",
- precision: 2
- }).format();
- Page({
- data: {
- sa_tpartreimbursementid: null,
- detail: {},
- tabsActive: 0,
- tabsList: [{
- label: "产品明细",
- icon: "icon-tabchanpin",
- model: "#Product"
- }, {
- label: "操作记录",
- icon: "icon-tabcaozuojilu1",
- model: "#record"
- }],
- productTotal: 0
- },
- onLoad(options) {
- this.setData({
- sa_tpartreimbursementid: options.id
- })
- this.getDetail()
- try {
- let privacyFieldC = wx.getStorageSync('auth').writeOff.forms.list.formcols.map(v => v.title);
- this.setData({
- privacyFieldC
- })
- console.log("privacyFieldC", privacyFieldC)
- } catch (error) {
- console.error(error)
- }
- },
- getDetail() {
- _Http.basic({
- "id": 2025081811144603,
- "content": {
- "sa_tpartreimbursementid": this.data.sa_tpartreimbursementid
- }
- }).then(res => {
- console.log("配件核销详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- res.data.totalamount = CNY(res.data.totalamount)
- res.data.offamount = CNY(res.data.offamount)
- this.setData({
- detail: res.data,
- remarks: res.data.remarks
- })
- this.partialRenewal()
- })
- }, //局部数据更新 tabs
- partialRenewal(init = false) {
- let model = this.data.tabsList[this.data.tabsActive].model;
- if (model) {
- let Component = this.selectComponent(model),
- {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content,
- id = this.data.sa_tpartreimbursementid;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- }
- }
- }, //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- onReachBottom() {
- this.partialRenewal();
- },
- // 修改单据日期
- onEdit(e) {
- _Http.basic({
- "id": 2025081811143103,
- "content": {
- "sa_tpartreimbursementid": this.data.detail.sa_tpartreimbursementid,
- "remarks": this.data.detail.remarks,
- "billdate": e.detail.value,
- "id": this.data.detail.sa_tpartreimbursementid
- },
- }).then(res => {
- console.log("修改单据日期", res)
- wx.showToast({
- title: res.code == 1 ? '修改成功' : res.msg,
- icon: "none"
- })
- if (res.code == 1) this.getDetail()
- })
- },
- onSubmit() {
- let that = this;
- wx.showModal({
- title: '提示',
- content: '确定要提交此配件核销申请吗?提交后将无法修改。',
- confirmText: "确认提交",
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 2025081811223203,
- "content": {
- "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
- "issubmit": true
- }
- }).then(res => {
- console.log("提交", res)
- wx.showToast({
- title: res.code == 1 ? '提交成功' : res.msg,
- icon: "none"
- })
- if (res.code == 1) this.getDetail()
- })
- }
- })
- },
- onDetele() {
- let that = this;
- wx.showModal({
- title: '提示',
- content: '确定要删除此配件核销申请吗?删除后将无法恢复',
- confirmText: "确认删除",
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 2025081811150603,
- "content": {
- "sa_tpartreimbursementids": [that.data.detail.sa_tpartreimbursementid]
- }
- }).then(res => {
- console.log("删除", res)
- wx.showToast({
- title: res.code == 1 ? '删除成功' : res.msg,
- icon: "none",
- mask: res.code == 1
- })
- if (res.code == 1) setTimeout(() => {
- wx.navigateBack()
- }, 300)
- })
- }
- })
- },
- onUnload() {
- let page = getCurrentPages().find(v => ["packageA/writeOff/index"].includes(v.__route__))
- if (page) page.updateList && page.updateList()
- },
- onBlur(e) {
- let remarks = e.detail.value,
- that = this;
- wx.showModal({
- title: '提示',
- content: `是否确定修改备注?`,
- complete: (res) => {
- if (res.cancel) {
- that.setData({
- remarks: that.data.detail.remarks
- })
- }
- if (res.confirm) _Http.basic({
- "id": 2025081811143103,
- "content": {
- "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
- "remarks": remarks,
- "billdate": that.data.detail.billdate,
- },
- }).then(res => {
- console.log("修改单据日期", res)
- wx.showToast({
- title: res.code == 1 ? '修改成功' : res.msg,
- icon: "none"
- })
- if (res.code == 1) that.getDetail()
- })
- }
- })
- console.log(remarks)
- }
- })
|