detail.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. sa_orderid: null,
  6. tabsActive: 0,
  7. tabsList: [{
  8. label: "产品明细",
  9. icon: "icon-tabchanpin",
  10. model: "#Product"
  11. }, {
  12. label: "附件",
  13. icon: "icon-tabfujian1",
  14. model: "#Yl_Attachment"
  15. }, {
  16. label: "订单进度",
  17. icon: "icon-tabcaozuojilu1",
  18. model: "#Progress"
  19. }, {
  20. label: "发票",
  21. icon: "icon-tabkaipiaoxinxi"
  22. }],
  23. },
  24. onLoad(options) {
  25. this.setData({
  26. sa_orderid: options.id
  27. });
  28. this.getDetail();
  29. },
  30. /* 获取详情 */
  31. getDetail() {
  32. _Http.basic({
  33. "id": 20221108151302,
  34. "content": {
  35. "sa_orderid": this.data.sa_orderid
  36. }
  37. }).then(res => {
  38. console.log("订单详情", res)
  39. if (res.msg != '成功') return wx.showToast({
  40. title: res.msg,
  41. icon: "none"
  42. });
  43. this.setData({
  44. detail: res.data,
  45. loading: false
  46. });
  47. this.partialRenewal(true)
  48. })
  49. },
  50. //tabs 切换
  51. tabsChange({
  52. detail
  53. }) {
  54. this.setData({
  55. tabsActive: detail
  56. });
  57. this.partialRenewal();
  58. },
  59. //局部数据更新 tabs
  60. partialRenewal(init = false) {
  61. let model = this.data.tabsList[this.data.tabsActive].model;
  62. if (model) {
  63. let Component = this.selectComponent(model),
  64. {
  65. total,
  66. pageNumber,
  67. pageTotal
  68. } = Component.data.content,
  69. id = this.data.detail.sa_orderid;
  70. if (total == null || init) {
  71. Component.getList(id, init);
  72. } else if (pageNumber < pageTotal) {
  73. Component.getList(id, false);
  74. }
  75. }
  76. },
  77. onReachBottom() {
  78. this.partialRenewal();
  79. },
  80. /* 更新数据 */
  81. changeDetail() {
  82. let data = this.data.detail,
  83. content = {
  84. "sa_orderid": data.sa_orderid,
  85. "sys_enterpriseid": data.sys_enterpriseid, //订货企业id
  86. "sa_accountclassid": data.accountclass.sa_accountclassid || 0, //营销账户类型ID
  87. "sa_brandid": data.sa_brandid, //品牌ID
  88. "sys_enterprise_financeid": data.finance.sys_enterprise_financeid, //合作企业财务信息ID(开票信息)
  89. "sa_logiscompid": data.logiscomp.sa_logiscompid, //物流公司档案ID
  90. "rec_contactsid": data.contacts.contactsid || 0, //合作企业联系人表ID(收货信息)
  91. "type": data.type, //订单类型
  92. "typemx": data.typemx, // 明细分类,可选
  93. "remarks": data.remarks,
  94. "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
  95. "tradefield": data.tradefield, //必选
  96. "pay_enterpriseid": data.pay_enterpriseid, //结算单位
  97. "rebate_userate": data.accountclass.rebate_userate, //返利金使用比例
  98. "rebate_used": data.rebate_used, //默认0,是否使用返利金
  99. "billdate": data.billdate, //单据日期,默认创建日期
  100. };
  101. if (content.type != '标准订单') {
  102. //"sa_contractid": 1, 合同ID,标准订单不传
  103. //"sa_projectid": 1, 工程项目表ID,标准订单不传
  104. }
  105. return new Promise((resolve, reject) => {
  106. _Http.basic({
  107. "id": 20221108111402,
  108. content
  109. }).then(res => {
  110. console.log("修改订单数据", res);
  111. if (res.msg != '成功') wx.showToast({
  112. title: res.msg,
  113. icon: "none"
  114. });
  115. resolve(res)
  116. })
  117. })
  118. },
  119. /* 修改订单备注 */
  120. changeRemarks(e) {
  121. let value = e.detail.value,
  122. remarks = this.data.detail.remarks,
  123. that = this;
  124. if (value == this.data.detail.remarks) return;
  125. wx.showModal({
  126. title: '提示',
  127. content: '是否确定修改订单备注?',
  128. complete: async (res) => {
  129. if (res.cancel) that.setData({
  130. "detail.remarks": remarks
  131. })
  132. if (res.confirm) {
  133. let res = await that.changeDetail();
  134. that.setData({
  135. "detail.remarks": res.msg == '成功' ? value : remarks
  136. })
  137. }
  138. }
  139. })
  140. },
  141. /* 设置是否使用返利金 */
  142. async changeRebateUsed() {
  143. if (this.data.detail.status != '新建') return wx.showToast({
  144. title: '当前订单状态不可设置!',
  145. icon: "none"
  146. })
  147. this.setData({
  148. "detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
  149. })
  150. let res = await this.changeDetail();
  151. if (res.msg != '成功') this.setData({
  152. "detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
  153. });
  154. },
  155. /* 删除订单 */
  156. deleteItem() {
  157. let that = this;
  158. wx.showModal({
  159. title: '提示',
  160. content: '是否确认删除订单?',
  161. complete: (res) => {
  162. if (res.confirm) _Http.basic({
  163. "id": 20221108152102,
  164. "content": {
  165. "sa_orderids": [
  166. that.data.sa_orderid
  167. ]
  168. }
  169. }).then(s => {
  170. console.log("删除订单", s)
  171. if (s.msg != '成功') return wx.showToast({
  172. title: s.msg,
  173. icon: "none"
  174. });
  175. wx.showToast({
  176. title: `成功删除${that.data.detail.sonum}订单`,
  177. icon: "none"
  178. });
  179. setTimeout(() => {
  180. let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  181. if (page) page.setData({
  182. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  183. "content.total": page.data.content.total - 1,
  184. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  185. });
  186. wx.navigateBack()
  187. }, 500)
  188. })
  189. }
  190. })
  191. },
  192. /* 提交订单 */
  193. submit() {
  194. let that = this,
  195. sys_enterpriseid = that.data.detail.sys_enterpriseid,
  196. sa_accountclassid = that.data.detail.accountclass.sa_accountclassid;
  197. if (!sys_enterpriseid) return wx.showToast({
  198. title: '还未选择开票单位',
  199. icon: "none"
  200. });
  201. if (!sa_accountclassid) return wx.showToast({
  202. title: '还完成支付信息',
  203. icon: "none"
  204. });
  205. wx.showModal({
  206. title: '提示',
  207. content: '是否确认提交订单?',
  208. complete: (res) => {
  209. if (res.confirm) _Http.basic({
  210. "id": 20221108153402,
  211. "content": {
  212. sa_orderid: that.data.sa_orderid,
  213. sys_enterpriseid,
  214. sa_accountclassid
  215. },
  216. }).then(s => {
  217. console.log("提交订单", s)
  218. wx.showToast({
  219. title: s.msg != '成功' ? s.msg : '提交成功',
  220. icon: "none"
  221. });
  222. })
  223. }
  224. })
  225. },
  226. /* 确认订单交期 */
  227. notarize() {
  228. let that = this;
  229. wx.showModal({
  230. title: '提示',
  231. content: '是否确认交期?',
  232. complete: (res) => {
  233. if (res.confirm) _Http.basic({
  234. "id": 20221230094802,
  235. "content": {
  236. sa_orderid: that.data.sa_orderid
  237. },
  238. }).then(s => {
  239. console.log("确认交期", s)
  240. wx.showToast({
  241. title: s.msg != '成功' ? s.msg : '提交成功',
  242. icon: "none"
  243. });
  244. })
  245. }
  246. })
  247. },
  248. /* 判断是否可以编辑 */
  249. isEdit() {
  250. if (this.data.detail.status != '新建') wx.showToast({
  251. title: '当前订单状态不可设置!',
  252. icon: "none"
  253. });
  254. return this.data.detail.status == '新建';
  255. }
  256. })