update.js 5.1 KB

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