update.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. const _Http = getApp().globalData.http,
  2. getTime = require("../../utils/getTime");
  3. Page({
  4. data: {
  5. loading: false,
  6. showAll: false,
  7. disabled: true,
  8. content: {
  9. "sa_aftersalesmagid": 0,
  10. "sa_orderid": "",
  11. "reason": "",
  12. "billdate": "",
  13. "type": "退货单"
  14. },
  15. },
  16. onLoad(options) {
  17. let form = [{
  18. label: "返退原因",
  19. error: false,
  20. errMsg: "",
  21. type: "texteara",
  22. value: "",
  23. placeholder: "请输入返退原因",
  24. valueName: "reason",
  25. required: false,
  26. }, {
  27. label: "是否实物退回",
  28. error: false,
  29. errMsg: "",
  30. type: "radio",
  31. radioList: [{
  32. name: '是',
  33. id: 1
  34. },
  35. {
  36. name: '否',
  37. id: 0
  38. },
  39. ],
  40. value: 1,
  41. valueName: "isitemreturn",
  42. required: true,
  43. }];
  44. form.unshift(wx.getStorageSync('userrole') == '业务员' ? {
  45. label: "所属企业",
  46. error: false,
  47. errMsg: "",
  48. type: "route",
  49. url: "/select/agent/index",
  50. params: {
  51. "id": 20220920083901,
  52. "content": {
  53. nocache: true,
  54. "where": {
  55. "condition": "",
  56. "type": 9,
  57. }
  58. }
  59. },
  60. query: '&radio=true&idname=sys_enterpriseid',
  61. value: "",
  62. placeholder: "选择企业",
  63. valueName: "sys_enterpriseid",
  64. checking: "base",
  65. required: true,
  66. interrupt: true
  67. } : {
  68. label: "订单号",
  69. error: false,
  70. errMsg: "",
  71. type: "route",
  72. url: "/packageA/toolBill/modules/selectOrder/index",
  73. params: {
  74. "id": 20230105110003,
  75. "content": {
  76. nocache: true,
  77. "pageNumber": 1,
  78. "pageSize": 20,
  79. "where": {
  80. "condition": ""
  81. }
  82. }
  83. },
  84. query: '&radio=true',
  85. value: "",
  86. placeholder: "选择订单号",
  87. valueName: "sa_orderid",
  88. checking: "base",
  89. required: true
  90. })
  91. this.setData({
  92. form
  93. })
  94. if (options.rowData) {
  95. let data = JSON.parse(options.rowData);
  96. console.log(data);
  97. this.setData({
  98. form: form.map(v => {
  99. if (v.valueName != 'region') {
  100. if (v.valueName == 'enterprisename') {
  101. v.value = [data[v.valueName]]
  102. } else {
  103. v.value = data[v.valueName];
  104. }
  105. } else {
  106. v.value = data.province ? [data.province, data.city, data.county] : []
  107. }
  108. return v
  109. }),
  110. 'form[0].value': [data.sonum, [data.sa_orderid]],
  111. 'content.sa_aftersalesmagid': data.sa_aftersalesmagid
  112. })
  113. this.selectComponent('#Form').confirm()
  114. }
  115. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  116. },
  117. /* 打断处理form */
  118. interrupt({
  119. detail
  120. }) {
  121. detail.form[detail.temporary.index].value = detail.data.value;
  122. detail.form.splice(1, detail.form.some(v => v.label == '订单号') ? 1 : 0, {
  123. label: "订单号",
  124. error: false,
  125. errMsg: "",
  126. type: "route",
  127. url: "/packageA/toolBill/modules/selectOrder/index",
  128. params: {
  129. "id": 20230105110003,
  130. "content": {
  131. nocache: true,
  132. "pageNumber": 1,
  133. "pageSize": 20,
  134. "where": {
  135. "condition": ""
  136. },
  137. sys_enterpriseid: detail.data.id[0]
  138. }
  139. },
  140. query: '&radio=true',
  141. value: "",
  142. placeholder: "选择订单号",
  143. valueName: "sa_orderid",
  144. checking: "base",
  145. required: true
  146. })
  147. this.setData({
  148. form: detail.form
  149. })
  150. wx.navigateBack()
  151. },
  152. async submit() {
  153. let content = {
  154. ...this.data.content,
  155. ...this.selectComponent("#Form").submit()
  156. }
  157. content.sa_orderid = content.sa_orderid[1][0] || '';
  158. content.sys_enterpriseid = content.sys_enterpriseid[1][0] || '';
  159. this.setData({
  160. loading: true
  161. })
  162. let res = await _Http.basic({
  163. "id": "20230104160503",
  164. content
  165. })
  166. this.setData({
  167. loading: false
  168. })
  169. console.log(res)
  170. wx.showToast({
  171. title: res.msg == '成功' ? getApp().globalData.Language.getMapText('创建成功') : res.msg,
  172. icon: "none",
  173. mask: true
  174. })
  175. setTimeout(() => {
  176. wx.redirectTo({
  177. url: '/packageA/returnOne/detail?id=' + res.data.sa_aftersalesmagid,
  178. })
  179. }, 500)
  180. },
  181. // 是否显示全部
  182. onChange({
  183. detail
  184. }) {
  185. this.setData({
  186. showAll: detail
  187. })
  188. },
  189. /* 表单必填项是否完成 */
  190. onConfirm({
  191. detail
  192. }) {
  193. this.setData({
  194. disabled: detail
  195. })
  196. }
  197. })