index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. const _Http = getApp().globalData.http;
  2. /* {
  3. name: '促销订单'
  4. }, */
  5. Component({
  6. data: {
  7. types: [{
  8. name: '标准订单'
  9. }, {
  10. name: '项目订单'
  11. }, {
  12. name: '工具订单'
  13. }],
  14. actionShow: false,
  15. },
  16. methods: {
  17. /* 挑选新增订单类型 */
  18. onSelect() {
  19. return wx.navigateTo({
  20. url: '/packageA/orderForm/add/add?type=标准订单',
  21. })
  22. this.setData({
  23. actionShow: true
  24. })
  25. },
  26. /* 选择订单类型 */
  27. selectType({
  28. detail
  29. }) {
  30. switch (detail.name) {
  31. case '标准订单':
  32. wx.navigateTo({
  33. url: '/pages/index/orderForm/add/add?type=标准订单',
  34. })
  35. break;
  36. case '项目订单':
  37. /* 前去挑选合同 */
  38. wx.navigateTo({
  39. url: `/select/contract/index?params=${JSON.stringify({
  40. "id": 20230103150802,
  41. "content": {
  42. nocache: true,
  43. "pageNumber": 1,
  44. "pageTotal": 1,
  45. "total": null,
  46. "pageSize": 20,
  47. "where": {
  48. "condition": ""
  49. }
  50. }
  51. })}&radio=false`
  52. })
  53. getApp().globalData.handleSelect = this.addProjectOrder.bind(this);
  54. break;
  55. case '促销订单':
  56. /* 前去挑选合同 */
  57. wx.navigateTo({
  58. url: `/select/activity/index?params=${JSON.stringify({
  59. "id": 20220103140003,
  60. "content": {
  61. "version": 1,
  62. "nocache": true,
  63. "pageNumber": 1,
  64. "pageTotal": 1,
  65. "where": {
  66. "condition": ""
  67. },
  68. "sort": []
  69. }
  70. })}&radio=false`
  71. })
  72. getApp().globalData.handleSelect = this.addActivityOrder.bind(this);
  73. break;
  74. case '工具订单':
  75. wx.navigateTo({
  76. url: '/pages/index/orderForm/add/add?type=工具订单',
  77. })
  78. break;
  79. }
  80. this.onCancel();
  81. },
  82. /* 取消选择订单类型 */
  83. onCancel() {
  84. this.setData({
  85. actionShow: false
  86. })
  87. },
  88. /* 创建项目订单 */
  89. addProjectOrder({
  90. item
  91. }) {
  92. wx.showModal({
  93. title: '提示',
  94. content: `是否确认创建“${item.billno}”相关“${item.projectname}”项目订单?`,
  95. complete: (res) => {
  96. if (res.confirm) _Http.basic({
  97. "id": 20230103141402,
  98. "content": {
  99. "sys_enterpriseid": item.sys_enterpriseid, //订货企业id,可不传,默认取当前账号的
  100. "sa_contractid": item.sa_contractid, //合同ID,
  101. "sa_projectid": item.sa_projectid, //工程项目表ID,
  102. },
  103. }).then(res => {
  104. console.log("新建项目订单", res)
  105. if (res.msg != '成功') return wx.showToast({
  106. title: res.msg,
  107. icon: "none",
  108. mask: true
  109. })
  110. if (res.msg == '成功') setTimeout(() => {
  111. wx.redirectTo({
  112. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  113. });
  114. }, 500)
  115. })
  116. }
  117. })
  118. },
  119. addActivityOrder({
  120. item
  121. }) {
  122. wx.showModal({
  123. title: '提示',
  124. content: `是否确定创建“${item.promname}”促销订单`,
  125. complete: (s) => {
  126. if (s) _Http.basic({
  127. "id": 20221108111402,
  128. content: {
  129. sa_orderid: 0,
  130. sa_accountclassid: item.sa_accountclassid,
  131. rec_contactsid: 0,
  132. pay_enterpriseid: 0,
  133. sa_contractid: 0,
  134. sa_projectid: 0,
  135. sa_promotionid: item.sa_promotionid,
  136. "sa_brandid": item.sa_brandid, //品牌ID
  137. "type": '促销订单', //订单类型
  138. "tradefield": item.tradefield, //必选
  139. }
  140. }).then(res => {
  141. console.log("创建促销订单", res);
  142. wx.showToast({
  143. title: res.msg != '成功' ? res.msg : '创建成功',
  144. icon: "none",
  145. mask: true
  146. });
  147. if (res.msg == '成功') setTimeout(() => {
  148. wx.redirectTo({
  149. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  150. });
  151. }, 500)
  152. })
  153. }
  154. })
  155. },
  156. }
  157. })