index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. let content = null;
  4. Page({
  5. data: {
  6. isInsert: false,
  7. CustomBar: getApp().globalData.CustomBar,
  8. privacyFieldC: [],
  9. },
  10. onLoad(options) {
  11. if (wx.getStorageSync('auth').worderform.options.some(v => v == 'insert')) this.setData({
  12. isInsert: true
  13. })
  14. content = {
  15. nocache: true,
  16. "isExport": 0,
  17. "pageNumber": 1,
  18. "pageTotal": 1,
  19. "where": {
  20. "condition": "",
  21. },
  22. tablefilter: {}
  23. };
  24. this.getList()
  25. try {
  26. let privacyFieldC = wx.getStorageSync('auth').worderform.forms.list.formcols.map(v => v.title);
  27. this.setData({
  28. privacyFieldC
  29. })
  30. console.log("privacyFieldC", privacyFieldC)
  31. } catch (error) {
  32. console.error(error)
  33. }
  34. },
  35. /* 获取产品 */
  36. getList(init = false) {
  37. if (init.detail != undefined) init = init.detail;
  38. if (init) content.pageNumber = 1;
  39. if (content.pageNumber > content.pageTotal) return;
  40. this.setListHeight();
  41. _Http.basic({
  42. "id": 20221224180302,
  43. content
  44. }).then(res => {
  45. console.log("订单列表", res)
  46. this.selectComponent('#ListBox').RefreshToComplete();
  47. /* 格式化价格 */
  48. if (res.data.length != 0) res.data = res.data.map(v => {
  49. v.defaultamount = currency(v.defaultamount, {
  50. symbol: "¥",
  51. precision: 2
  52. }).format();
  53. return v
  54. })
  55. content.pageNumber = res.pageNumber + 1
  56. content.pageTotal = res.pageTotal
  57. this.setData({
  58. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  59. total: res.total,
  60. amount: currency(res.tips.amount, {
  61. symbol: "¥",
  62. precision: 2
  63. }).format()
  64. })
  65. })
  66. },
  67. /* 更新列表 */
  68. updateList() {
  69. let params = JSON.parse(JSON.stringify(content));
  70. params.pageSize = (params.pageNumber - 1) * params.pageSize;
  71. params.pageNumber = 1;
  72. _Http.basic({
  73. "id": 20221224180302,
  74. content: params
  75. }).then(res => {
  76. console.log("订单列表", res)
  77. if (res.msg != '成功') return;
  78. /* 格式化价格 */
  79. if (res.data.length != 0) res.data = res.data.map(v => {
  80. v.defaultamount = currency(v.defaultamount, {
  81. symbol: "¥",
  82. precision: 2
  83. }).format();
  84. return v
  85. })
  86. this.setData({
  87. list: res.data,
  88. total: res.total,
  89. amount: currency(res.tips.amount, {
  90. symbol: "¥",
  91. precision: 2
  92. }).format()
  93. })
  94. })
  95. },
  96. /* 切换tabs */
  97. tabsChange(e) {
  98. let status = "";
  99. switch (e.detail.title) {
  100. case '全部':
  101. status = "";
  102. break;
  103. case '待确认':
  104. status = "交期待确认";
  105. break;
  106. default:
  107. status = e.detail.title
  108. break;
  109. }
  110. content.tablefilter.status = status;
  111. this.getList(true);
  112. },
  113. /* 搜索 */
  114. onSearch({
  115. detail
  116. }) {
  117. content.where.condition = detail;
  118. this.getList(true)
  119. },
  120. /* 设置页面高度 */
  121. setListHeight() {
  122. this.selectComponent("#ListBox").setHeight(".tips", this);
  123. },
  124. showModal(e) {
  125. this.setData({
  126. modalName: e.currentTarget.dataset.target
  127. })
  128. },
  129. hideModal(e) {
  130. this.setData({
  131. modalName: null
  132. })
  133. },
  134. createOrder() {
  135. _Http.basic({
  136. "id": 20221008134803,
  137. "version": 1,
  138. "content": {
  139. "pageNumber": 1,
  140. "pageTotal": 1,
  141. "pageSize": 9999,
  142. "where": {
  143. "condition": "",
  144. "isused": 1,
  145. "isnotspecialfund": 0,
  146. },
  147. }
  148. }).then(res => {
  149. console.log(res)
  150. if (res.code != 1) wx.showToast({
  151. title: res.msg,
  152. icon: "none",
  153. });
  154. if (res.data.length == 1) {
  155. this.handleAdd(res.data[0].sa_accountclassid)
  156. } else {
  157. wx.navigateTo({
  158. url: '/packageA/orderForm/add/add',
  159. })
  160. }
  161. })
  162. },
  163. handleAdd(sa_accountclassid) {
  164. wx.showModal({
  165. title: '提示',
  166. content: `是否确定创建订单`,
  167. complete: ({
  168. confirm
  169. }) => {
  170. if (confirm) _Http.basic({
  171. "id": 20221108111402,
  172. content: {
  173. sa_orderid: 0,
  174. rec_contactsid: 0,
  175. pay_enterpriseid: 0,
  176. sa_contractid: 0,
  177. sa_projectid: 0,
  178. sa_accountclassid: sa_accountclassid,
  179. "sa_brandid": 0, //品牌ID
  180. "type": '标准订单', //订单类型
  181. "tradefield": '默认', //必选
  182. sys_enterpriseid: 0
  183. }
  184. }).then(res => {
  185. console.log(`创建标准订单`, res);
  186. wx.showToast({
  187. title: res.msg != '成功' ? res.msg : '创建成功',
  188. icon: "none",
  189. mask: true
  190. });
  191. if (res.msg == '成功') setTimeout(() => {
  192. wx.navigateTo({
  193. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  194. });
  195. }, 500)
  196. })
  197. }
  198. })
  199. }
  200. })