| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 | 
							- // pages/agent/serviceBillDetail/index.js
 
- import api from '../../api/api'
 
- import Dialog from 'tdesign-miniprogram/dialog/index';
 
- Page({
 
-   /**
 
-    * 页面的初始数据
 
-    */
 
-   data: {
 
-     showWithInput: false,
 
-     showProgress: false,
 
-     showToWoker: false,
 
-     orderMainData: {},
 
-     list: [],
 
-     templist: [],
 
-     actTemp: null,
 
-     actLeader: null
 
-   },
 
-   async mainData() {
 
-     const res = await api._post({
 
-       "id": "20230206091603",
 
-       "version": 1,
 
-       "content": {
 
-         nocache: true,
 
-         "sa_serviceorderid": this.data.id
 
-       }
 
-     })
 
-     console.log(res)
 
-     let tabbarsList = [];
 
-     if (res.data.status == '新建') {
 
-       tabbarsList = [{
 
-         label: "编辑",
 
-         icon: "icon-dibu-bianji"
 
-       }, {
 
-         label: "提交",
 
-         icon: "icon-tijiao",
 
-       }, {
 
-         label: "删除",
 
-         icon: "icon-guanlian-shanchu"
 
-       }];
 
-     } else if (res.data.status == '待指派') {
 
-       tabbarsList = [{
 
-         label: "转工单",
 
-         icon: "icon-shenhe"
 
-       }, {
 
-         label: "退回",
 
-         icon: "icon-a-fanshenhetuihui",
 
-       }];
 
-     }
 
-     this.setData({
 
-       orderMainData: res.data,
 
-       tabbarsList
 
-     })
 
-     this.productmx()
 
-     this.fileData()
 
-     this.workOrderTemp()
 
-     this.workerData()
 
-   },
 
-   async fileData() {
 
-     const res = await api._post({
 
-       "method": "queryFileLink",
 
-       "classname": "system.attachment.Attachment",
 
-       "content": {
 
-         "ownertable": "sa_serviceorder",
 
-         "ownerid": this.data.id,
 
-         "usetype": "" //传空返回有所
 
-       }
 
-     })
 
-     this.setData({
 
-       filelist: res.data,
 
-       refresh: true
 
-     })
 
-   },
 
-   addProduct() {
 
-     wx.navigateTo({
 
-       url: '/Eservice/workerLeader/billCanUseProduct/index',
 
-     })
 
-   },
 
-   async getAdd(selection) {
 
-     const res = await api._post({
 
-       "id": "20230206161803",
 
-       "version": 1,
 
-       "content": {
 
-         "sa_serviceorderid": this.data.id,
 
-         "iteminfos": selection.map(e => {
 
-           return {
 
-             "sa_serviceorderitemsid": 0,
 
-             "itemid": e,
 
-             "reason": "",
 
-             traceabilitytype: e.traceabilitytype || '',
 
-             "qty": 1
 
-           }
 
-         })
 
-       }
 
-     })
 
-     this.productmx()
 
-   },
 
-   async productmx() {
 
-     const res = await api._post({
 
-       "id": "20230206161903",
 
-       "version": 1,
 
-       "content": {
 
-         "sa_serviceorderid": this.data.id
 
-       }
 
-     })
 
-     this.setData({
 
-       list: res.data
 
-     })
 
-   },
 
-   async onMXDelete(data) {
 
-     let itemid = data.detail.sa_serviceorderitemsid
 
-     const res = await api._post({
 
-       "id": "20230206162003",
 
-       "content": {
 
-         "sa_serviceorderitemsids": [itemid]
 
-       }
 
-     })
 
-     this.productmx()
 
-   },
 
-   /* 底部按钮回调 */
 
-   tabbarOnClick(e) {
 
-     let that = this,
 
-       dialogConfig = null,
 
-       res = null;
 
-     switch (e.detail.label) {
 
-       case "编辑":
 
-         getApp().globalData.handelSelect = this
 
-         wx.navigateTo({
 
-           url: '/Eservice/workerLeader/editServiceBill/index',
 
-         })
 
-         break;
 
-       case "提交":
 
-         dialogConfig = {
 
-           context: this,
 
-           title: getApp().globalData.Language.getMapText('提示'),
 
-           content: getApp().globalData.Language.getMapText('确认提交当前申请单吗'),
 
-           confirmBtn: getApp().globalData.Language.getMapText('确定'),
 
-           cancelBtn: getApp().globalData.Language.getMapText('取消'),
 
-         };
 
-         Dialog.confirm(dialogConfig)
 
-           .then(async () => {
 
-             res = await api._post({
 
-               "id": "20230206101403",
 
-               "version": 1,
 
-               "content": {
 
-                 "sa_serviceorderid": that.data.id,
 
-                 "issumbit": 1,
 
-               }
 
-             });
 
-             wx.showToast({
 
-               title: res.code == '1' ? getApp().globalData.Language.getMapText('提交成功') : res.msg,
 
-               icon: "none",
 
-               mask: true
 
-             })
 
-             if (res.code == '1') that.mainData();
 
-           })
 
-           .catch((err) => console.log(err))
 
-           .finally(() => Dialog.close());
 
-         break;
 
-       case "删除":
 
-         dialogConfig = {
 
-           context: this,
 
-           title: getApp().globalData.Language.getMapText('提示'),
 
-           content: getApp().globalData.Language.getMapText('确认删除当前申请单吗'),
 
-           confirmBtn: getApp().globalData.Language.getMapText('确定'),
 
-           cancelBtn: getApp().globalData.Language.getMapText('取消'),
 
-         };
 
-         Dialog.confirm(dialogConfig)
 
-           .then(async () => {
 
-             res = await api._post({
 
-               "id": "20230206091803",
 
-               "version": 1,
 
-               "content": {
 
-                 "sa_serviceorderids": [that.data.id],
 
-               }
 
-             })
 
-             wx.showToast({
 
-               title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
 
-               icon: "none",
 
-               mask: true
 
-             })
 
-             if (res.code == '1') setTimeout(() => {
 
-               wx.navigateBack()
 
-             }, 500);
 
-           })
 
-           .catch((err) => console.log(err))
 
-           .finally(() => Dialog.close());
 
-         break;
 
-       case "转工单":
 
-         this.setData({
 
-           showToWoker: true
 
-         })
 
-         break;
 
-       case "退回":
 
-         this.setData({
 
-           showWithInput: true
 
-         })
 
-         break;
 
-     }
 
-   },
 
-   /* 专工单/退回 取消 */
 
-   showBackReason() {
 
-     this.setData({
 
-       showWithInput: false,
 
-       showToWoker: false,
 
-       backreason: ""
 
-     })
 
-   },
 
-   inputReason(data) {
 
-     this.data.backreason = data.detail.value;
 
-   },
 
-   async onBack() {
 
-     let that = this
 
-     if (!that.data.backreason) return getApp().globalData.Language.modeBoxPrompts('请说明退回原因!')
 
-     const res = await api._post({
 
-       "id": "20230206101403",
 
-       "version": 1,
 
-       "content": {
 
-         "sa_serviceorderid": that.data.id,
 
-         "issumbit": 0,
 
-         "backreason": that.data.backreason
 
-       }
 
-     })
 
-     wx.showToast({
 
-       title: res.code == '1' ? getApp().globalData.Language.getMapText('已退回工单') : res.msg,
 
-       icon: "none",
 
-       mask: true
 
-     })
 
-     if (res.code == '1') {
 
-       that.mainData()
 
-       that.showBackReason()
 
-     }
 
-   },
 
-   async workOrderTemp() {
 
-     const res = await api._post({
 
-       "id": "20230206155803",
 
-       "version": 1,
 
-       "content": {}
 
-     })
 
-     this.setData({
 
-       templist: res.data
 
-     })
 
-   },
 
-   selectTemp(data) {
 
-     this.setData({
 
-       actTemp: data.currentTarget.dataset.item
 
-     })
 
-   },
 
-   async workerData() {
 
-     const res = await api._post({
 
-       "id": "20230213143003",
 
-       "version": 1,
 
-       "content": {
 
-         "where": {
 
-           "condition": ""
 
-         }
 
-       }
 
-     })
 
-     this.setData({
 
-       workers: res.data
 
-     })
 
-   },
 
-   selectLeader(data) {
 
-     this.setData({
 
-       actLeader: data.currentTarget.dataset.item
 
-     })
 
-   },
 
-   async toWorker() {
 
-     if (!this.data.actTemp && !this.data.actLeader) {
 
-       getApp().globalData.Language.modeBoxPrompts('未选择工单模板或负责人')
 
-     } else {
 
-       const res = await api._post({
 
-         "id": "20230207091003",
 
-         "content": {
 
-           "type": this.data.actTemp.type,
 
-           "sa_serviceorderid": this.data.id,
 
-           "sa_workorder_templateid": this.data.actTemp.sa_workorder_templateid,
 
-           "projectlearders": [this.data.actLeader.userid]
 
-         }
 
-       })
 
-       wx.showToast({
 
-         title: res.code == '1' ? getApp().globalData.Language.getMapText('操作成功') : res.msg,
 
-         icon: "none",
 
-         mask: true
 
-       });
 
-       if (res.code == '1') {
 
-         this.mainData();
 
-         this.linkWorkOrder();
 
-         this.showBackReason()
 
-       }
 
-     }
 
-   },
 
-   async linkWorkOrder() {
 
-     const res = await api._post({
 
-       "id": "20230207154203",
 
-       "version": 1,
 
-       "content": {
 
-         nocache: true,
 
-         "sa_serviceorderid": this.data.id
 
-       }
 
-     })
 
-     console.log("关联工单", res)
 
-     this.setData({
 
-       linkWorkOrders: res.data
 
-     })
 
-   },
 
-   tolinkWorkOrder(e) {
 
-     let id = e.currentTarget.dataset.item.sa_workorderid
 
-     let app = getApp()
 
-     app.globalData.action = ['editLeader']
 
-     wx.navigateTo({
 
-       url: '/Eservice/workerLeader/editworkOrderDetail/index?id=' + id
 
-     })
 
-   },
 
-   async showProgressDialog() {
 
-     const res = await api._post({
 
-       id: "20230208140203",
 
-       content: {}
 
-     })
 
-     this.setData({
 
-       showProgress: !this.data.showProgress,
 
-       progress: res.data
 
-     })
 
-   },
 
-   onLoad(options) {
 
-     this.setData({
 
-       id: options.id
 
-     })
 
-     getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
 
-   },
 
-   onShow() {
 
-     this.mainData();
 
-     this.linkWorkOrder();
 
-   },
 
- })
 
 
  |