detail.js 6.2 KB

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