123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- sa_orderid: null,
- tabsActive: 0,
- tabsList: [{
- label: "产品明细",
- icon: "icon-tabchanpin",
- model: "#Product"
- }, {
- label: "附件",
- icon: "icon-tabfujian1",
- model: "#Yl_Attachment"
- }, {
- label: "订单进度",
- icon: "icon-tabcaozuojilu1",
- model: "#Progress"
- }, {
- label: "发票",
- icon: "icon-tabkaipiaoxinxi"
- }],
- },
- onLoad(options) {
- this.setData({
- sa_orderid: options.id
- });
- this.getDetail();
- },
- /* 获取详情 */
- getDetail() {
- _Http.basic({
- "id": 20221108151302,
- "content": {
- "sa_orderid": this.data.sa_orderid
- }
- }).then(res => {
- console.log("订单详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setData({
- detail: res.data
- });
- this.partialRenewal(true)
- })
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- 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.detail.sa_orderid;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber < pageTotal) {
- Component.getList(id, false);
- }
- }
- },
- onReachBottom() {
- this.partialRenewal();
- },
- /* 更新数据 */
- changeDetail() {
- let data = this.data.detail,
- content = {
- "sa_orderid": data.sa_orderid,
- "sys_enterpriseid": data.sys_enterpriseid, //订货企业id
- "sa_accountclassid": data.accountclass.sa_accountclassid || 0, //营销账户类型ID
- "sa_brandid": data.sa_brandid, //品牌ID
- "sys_enterprise_financeid": data.finance.sys_enterprise_financeid, //合作企业财务信息ID(开票信息)
- "sa_logiscompid": data.logiscomp.sa_logiscompid, //物流公司档案ID
- "rec_contactsid": data.contacts.contactsid || 0, //合作企业联系人表ID(收货信息)
- "type": data.type, //订单类型
- "typemx": data.typemx, // 明细分类,可选
- "remarks": data.remarks,
- "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
- "tradefield": data.tradefield, //必选
- "pay_enterpriseid": data.pay_enterpriseid, //结算单位
- "rebate_userate": data.accountclass.rebate_userate, //返利金使用比例
- "rebate_used": data.accountclass.rebate_used, //默认0,是否使用返利金
- "billdate": data.billdate, //单据日期,默认创建日期
- };
- if (content.type != '标准订单') {
- //"sa_contractid": 1, 合同ID,标准订单不传
- //"sa_projectid": 1, 工程项目表ID,标准订单不传
- }
- return new Promise((resolve, reject) => {
- _Http.basic({
- "id": 20221108111402,
- content
- }).then(res => {
- console.log("修改订单数据", res);
- if (res.msg != '成功') wx.showToast({
- title: res.msg,
- icon: "none"
- });
- resolve(res)
- })
- })
- },
- /* 修改订单备注 */
- changeRemarks(e) {
- let value = e.detail.value,
- remarks = this.data.detail.remarks,
- that = this;
- if (value == this.data.detail.remarks) return;
- wx.showModal({
- title: '提示',
- content: '是否确定修改订单备注?',
- complete: async (res) => {
- if (res.cancel) that.setData({
- "detail.remarks": remarks
- })
- if (res.confirm) {
- let res = await that.changeDetail();
- that.setData({
- "detail.remarks": res.msg == '成功' ? value : remarks
- })
- }
- }
- })
- },
- /* 设置是否使用返利金 */
- async changeRebateUsed() {
- this.setData({
- "detail.accountclass.rebate_used": this.data.detail.accountclass.rebate_used == 0 ? 1 : 0
- })
- let res = await this.changeDetail();
- if (res.msg != '成功') this.setData({
- "detail.accountclass.rebate_used": this.data.detail.accountclass.rebate_used == 0 ? 1 : 0
- });
- },
- })
|