detail.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.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. if (this.data.detail.status != '新建') return wx.showToast({
  142. title: '当前订单状态不可设置!',
  143. icon: "none"
  144. })
  145. this.setData({
  146. "detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
  147. })
  148. let res = await this.changeDetail();
  149. if (res.msg != '成功') this.setData({
  150. "detail.accountclass.rebate_used": this.data.detail.rebate_used == 1 ? 0 : 1
  151. });
  152. },
  153. /* 删除订单 */
  154. deleteItem() {
  155. let that = this;
  156. wx.showModal({
  157. title: '提示',
  158. content: '是否确认删除订单?',
  159. complete: (res) => {
  160. if (res.confirm) _Http.basic({
  161. "id": 20221108152102,
  162. "content": {
  163. "sa_orderids": [
  164. that.data.sa_orderid
  165. ]
  166. }
  167. }).then(s => {
  168. console.log("删除订单", s)
  169. if (s.msg != '成功') return wx.showToast({
  170. title: s.msg,
  171. icon: "none"
  172. });
  173. wx.showToast({
  174. title: `成功删除${that.data.detail.sonum}订单`,
  175. icon: "none"
  176. });
  177. setTimeout(() => {
  178. let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  179. if (page) page.setData({
  180. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  181. "content.total": page.data.content.total - 1,
  182. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  183. });
  184. wx.navigateBack()
  185. }, 500)
  186. })
  187. }
  188. })
  189. },
  190. /* 提交订单 */
  191. submit() {
  192. let that = this,
  193. sys_enterpriseid = that.data.detail.sys_enterpriseid,
  194. sa_accountclassid = that.data.detail.accountclass.sa_accountclassid;
  195. if (!sys_enterpriseid) return wx.showToast({
  196. title: '还未选择开票单位',
  197. icon: "none"
  198. });
  199. if (!sa_accountclassid) return wx.showToast({
  200. title: '还完成支付信息',
  201. icon: "none"
  202. });
  203. wx.showModal({
  204. title: '提示',
  205. content: '是否确认提交订单?',
  206. complete: (res) => {
  207. if (res.confirm) _Http.basic({
  208. "id": 20221108153402,
  209. "content": {
  210. sa_orderid: that.data.sa_orderid,
  211. sys_enterpriseid,
  212. sa_accountclassid
  213. },
  214. }).then(s => {
  215. console.log("提交订单", s)
  216. wx.showToast({
  217. title: s.msg != '成功' ? s.msg : '提交成功',
  218. icon: "none"
  219. });
  220. })
  221. }
  222. })
  223. },
  224. /* 确认订单交期 */
  225. notarize() {
  226. let that = this;
  227. wx.showModal({
  228. title: '提示',
  229. content: '是否确认交期?',
  230. complete: (res) => {
  231. if (res.confirm) _Http.basic({
  232. "id": 20221230094802,
  233. "content": {
  234. sa_orderid: that.data.sa_orderid
  235. },
  236. }).then(s => {
  237. console.log("确认交期", s)
  238. wx.showToast({
  239. title: s.msg != '成功' ? s.msg : '提交成功',
  240. icon: "none"
  241. });
  242. })
  243. }
  244. })
  245. },
  246. /* 判断是否可以编辑 */
  247. isEdit() {
  248. if (this.data.detail.status != '新建') wx.showToast({
  249. title: '当前订单状态不可设置!',
  250. icon: "none"
  251. });
  252. return this.data.detail.status == '新建';
  253. }
  254. })