123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- const _Http = getApp().globalData.http,
- currency = require("../../utils/currency"),
- CNY = num => currency(num, {
- symbol: "¥",
- precision: 2
- }).format();
- Page({
- data: {
- loading: true,
- 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"
- }],
- },
- onLoad(options) {
- this.setData({
- sa_orderid: options.id
- });
- this.getDetail(true);
- getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
- },
- onCopy() {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确定复制该借用单'),
- complete: (a) => {
- if (a.confirm) _Http.basic({
- "id": "20240315131202",
- "content": {
- "sa_orderid": that.data.sa_orderid
- }
- }).then(res => {
- console.log("借用单复制", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('复制成功,是否立即前往'),
- complete: (s) => {
- if (s.confirm) wx.navigateTo({
- url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
- })
- }
- })
- })
- }
- })
- },
- /* 获取详情 */
- getDetail(init = false, show = true) {
- _Http.basic({
- "id": 20230114140402,
- "content": {
- nocache: true,
- "sa_orderid": this.data.sa_orderid
- }
- }, show).then(res => {
- console.log("订单详情", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- res.data.amount = CNY(res.data.amount);
- this.setData({
- detail: res.data,
- loading: false
- });
- if (init) this.partialRenewal(true)
- })
- },
- /* 选择收货人 */
- selectConsignee() {
- if (this.isEdit()) return;
- wx.navigateTo({
- url: `/select/address/index?params=${JSON.stringify({
- "id":20221009155803,
- "content": {
- nocache:true,
- sys_enterpriseid:this.data.detail.sys_enterpriseid,
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 20,
- "where": {
- "condition": "",
- workaddress:1
- },
- }
- })}&radio=true`,
- });
- getApp().globalData.handleSelect = this.setConsignee.bind(this);
- },
- /* 设置收货人 */
- setConsignee({
- item
- }) {
- let that = this;
- console.log("设置收货人", item)
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- t: 1,
- v: '是否确认设置',
- r: "“"
- }, {
- v: item.name,
- }, {
- t: 1,
- v: '为收货人',
- r: "”?"
- }]),
- complete: (res) => {
- if (res.confirm) {
- let rec_contactsid = that.data.detail.rec_contactsid;
- that.setData({
- "detail.rec_contactsid": item.contactsid
- });
- that.changeDetail().then(s => {
- if (s.code == '1') {
- wx.showToast({
- title: getApp().globalData.Language.getMapText('设置成功'),
- icon: "none"
- });
- setTimeout(() => {
- wx.navigateBack();
- that.getDetail();
- }, 500)
- } else {
- that.setData({
- "detail.rec_contactsid": rec_contactsid
- });
- }
- })
- }
- }
- })
- },
- /* 选择财务信息 */
- selectFinance() {
- if (this.isEdit()) return;
- wx.navigateTo({
- url: `/select/finance/index?params=${JSON.stringify({
- "id":20221013160602,
- "content": {
- nocache:true,
- sys_enterpriseid:this.data.detail.sys_enterpriseid,
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 20,
- "where": {
- "condition": "",
- },
- }
- })}&radio=true`,
- });
- getApp().globalData.handleSelect = this.setFinance.bind(this);
- },
- /* 设置财务信息 */
- setFinance({
- item
- }) {
- let that = this;
- console.log("设置财务信息", item)
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- t: 1,
- v: '是否确认设置',
- r: "“"
- }, {
- v: item.enterprisename,
- }, {
- t: 1,
- v: '为开票单位',
- r: "”?"
- }]),
- complete: (res) => {
- if (res.confirm) {
- let sys_enterprise_financeid = that.data.detail.sys_enterprise_financeid;
- that.setData({
- "detail.sys_enterprise_financeid": item.sys_enterprise_financeid
- });
- that.changeDetail().then(s => {
- if (s.code == '1') {
- wx.showToast({
- title: getApp().globalData.Language.getMapText('设置成功'),
- icon: "none"
- });
- setTimeout(() => {
- wx.navigateBack();
- that.getDetail();
- }, 500)
- } else {
- that.setData({
- "detail.sys_enterprise_financeid": sys_enterprise_financeid
- });
- }
- })
- }
- }
- })
- },
- //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 (model == '#Product') id = {
- id: this.data.detail.sa_orderid,
- toolcount: this.data.detail.toolcount || ""
- };
- 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.sys_enterprise_financeid || 0, //合作企业财务信息ID(开票信息)
- "rec_contactsid": data.rec_contactsid || 0, //合作企业联系人表ID(收货信息)
- "type": data.type, //订单类型
- "typemx": data.typemx, // 明细分类,可选
- "remarks": data.remarks,
- sa_contractid: data.sa_contractid,
- "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
- "tradefield": data.tradefield, //必选
- "pay_enterpriseid": data.pay_enterpriseid, //结算单位
- };
- return new Promise((resolve, reject) => {
- _Http.basic({
- "id": 20230116092702,
- content
- }).then(res => {
- console.log("修改订单数据", res);
- if (res.code != '1') 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({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确定修改订单备注') + '?',
- complete: async (res) => {
- if (res.cancel) that.setData({
- "detail.remarks": remarks
- })
- if (res.confirm) {
- this.data.detail.remarks = value;
- let res = await that.changeDetail();
- that.setData({
- "detail.remarks": res.code == '1' ? value : remarks
- })
- }
- }
- })
- },
- /* 删除订单 */
- deleteItem() {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认删除订单') + '?',
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230116100002,
- "content": {
- "sa_orderids": [
- that.data.sa_orderid
- ]
- }
- }).then(s => {
- console.log("删除订单", s)
- if (s.code != '1') return wx.showToast({
- title: s.msg,
- icon: "none"
- });
- getApp().globalData.Language.showToast('成功删除')
- setTimeout(() => {
- /* let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
- if (page) page.setData({
- list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
- "content.total": page.data.content.total - 1,
- amount: (page.data.amount - that.data.detail.amount).toFixed(2)
- }); */
- wx.navigateBack()
- }, 500)
- })
- }
- })
- },
- /* 提交订单 */
- submit() {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认提交订单') + '?',
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230114160002,
- "content": {
- sa_orderid: that.data.sa_orderid
- },
- }).then(s => {
- console.log("提交订单", s)
- wx.showToast({
- title: s.code != '1' ? s.msg : getApp().globalData.Language.showToast('提交成功'),
- icon: "none"
- });
- if (s.code == '1') that.setData({
- "detail.status": "提交"
- })
- })
- }
- })
- },
- /* 确认订单交期 */
- notarize() {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认交期') + '?',
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20230129154102,
- "content": {
- sa_orderid: that.data.sa_orderid
- },
- }).then(s => {
- console.log("确认交期", s)
- wx.showToast({
- title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('确认成功'),
- icon: "none"
- });
- if (s.code == '1') {
- that.setData({
- "detail.status": "交期确认"
- })
- }
- })
- }
- })
- },
- /* 判断是否可以编辑 */
- isEdit() {
- if (this.data.detail.status != '新建') getApp().globalData.Language.showToast('当前订单状态不可设置!')
- return this.data.detail.status != '新建';
- },
- /* 设置项目订单品牌领域 */
- setBraned() {
- wx.navigateTo({
- url: './modules/setBrand/index?id=' + this.data.sa_orderid,
- })
- },
- onUnload() {
- let page = getCurrentPages().find(v => v.__route__ == 'packageA/borrow/index');
- let content = JSON.parse(JSON.stringify(page.data.content));
- content.pageNumber = 1;
- content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
- _Http.basic({
- "id": 20230114105002,
- content
- }).then(res => {
- console.log("更新借用单", res)
- page.setData({
- list: res.data.map(v => {
- v.amount = CNY(v.amount)
- return v
- }),
- "content.total": res.total,
- })
- /* amount: res.tips.amount || 0 */
- })
- },
- })
|