index.js 7.6 KB

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