index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. let content = null,
  4. downCount = null;
  5. Page({
  6. data: {
  7. isInsert: false,
  8. hidePrice: wx.getStorageSync('hidePrice'),
  9. CustomBar: getApp().globalData.CustomBar,
  10. filtratelist: [{
  11. label: "订单类型",
  12. index: null,
  13. showName: "value", //显示字段
  14. valueKey: "type", //返回Key
  15. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  16. value: "", //选中值
  17. list: [{
  18. value: "标准订单"
  19. }, {
  20. value: "促销订单"
  21. }, {
  22. value: "特殊订单"
  23. }]
  24. }]
  25. },
  26. onLoad(options) {
  27. if (wx.getStorageSync('auth').worderform.options.some(v => v == 'insert')) this.setData({
  28. isInsert: true
  29. })
  30. content = {
  31. nocache: true,
  32. "isExport": 0,
  33. "pageNumber": 1,
  34. "pageTotal": 1,
  35. pageSize: 20,
  36. "where": {
  37. "condition": "",
  38. "status": "",
  39. "brandname": "",
  40. "tradefield": ""
  41. }
  42. };
  43. this.getList()
  44. this.getBrand()
  45. this.getDomain()
  46. },
  47. /* 获取产品 */
  48. getList(init = false) {
  49. if (init.detail != undefined) init = init.detail;
  50. if (init) content.pageNumber = 1;
  51. if (content.pageNumber > content.pageTotal) return;
  52. this.setListHeight();
  53. _Http.basic({
  54. "id": 20221224180302,
  55. content
  56. }).then(res => {
  57. console.log("订单列表", res)
  58. this.selectComponent('#ListBox').RefreshToComplete();
  59. /* 格式化价格 */
  60. if (res.data.length != 0) res.data = res.data.map(v => {
  61. v.defaultamount = currency(v.defaultamount, {
  62. symbol: "¥",
  63. precision: 2
  64. }).format();
  65. return v
  66. })
  67. content.pageNumber = res.pageNumber + 1
  68. content.pageTotal = res.pageTotal
  69. this.setData({
  70. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  71. total: res.total,
  72. amount: currency(res.tips.amount, {
  73. symbol: "¥",
  74. precision: 2
  75. }).format()
  76. })
  77. })
  78. },
  79. /* 更新列表 */
  80. updateList() {
  81. let params = JSON.parse(JSON.stringify(content));
  82. params.pageSize = (params.pageNumber - 1) * params.pageSize;
  83. params.pageNumber = 1;
  84. _Http.basic({
  85. "id": 20221224180302,
  86. content: params
  87. }).then(res => {
  88. console.log("订单列表", res)
  89. if (res.msg != '成功') return;
  90. /* 格式化价格 */
  91. if (res.data.length != 0) res.data = res.data.map(v => {
  92. v.defaultamount = currency(v.defaultamount, {
  93. symbol: "¥",
  94. precision: 2
  95. }).format();
  96. return v
  97. })
  98. this.setData({
  99. list: res.data,
  100. total: res.total,
  101. amount: currency(res.tips.amount, {
  102. symbol: "¥",
  103. precision: 2
  104. }).format()
  105. })
  106. })
  107. },
  108. /* 切换tabs */
  109. tabsChange(e) {
  110. let status = "";
  111. switch (e.detail.title) {
  112. case '全部':
  113. status = "";
  114. break;
  115. case '待确认':
  116. status = "交期待确认";
  117. break;
  118. default:
  119. status = e.detail.title
  120. break;
  121. }
  122. content.where.status = status;
  123. this.getList(true);
  124. },
  125. /* 搜索 */
  126. onSearch({
  127. detail
  128. }) {
  129. content.where.condition = detail;
  130. this.getList(true)
  131. },
  132. /* 获取品牌 */
  133. getBrand() {
  134. _Http.basic({
  135. "id": 20220924163702,
  136. "content": {
  137. "pageSize": 9999,
  138. }
  139. }, false).then(res => {
  140. console.log("查询品牌", res)
  141. if (res.msg == '成功') this.data.brandList = res.data
  142. })
  143. },
  144. /* 获取领域 */
  145. getDomain() {
  146. _Http.basic({
  147. "id": 20221223141802,
  148. "content": {
  149. "pageNumber": 1,
  150. "pageSize": 9999,
  151. "where": {
  152. "condition": ""
  153. }
  154. }
  155. }, false).then(res => {
  156. console.log("获取领域", res)
  157. if (res.msg == '成功' && res.data.length > 1) {
  158. this.data.filtratelist.push({
  159. label: "领域",
  160. index: null,
  161. showName: "tradefield", //显示字段
  162. valueKey: "tradefield", //返回Key
  163. selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
  164. value: "", //选中值
  165. list: res.data
  166. })
  167. this.setData({
  168. filtratelist: this.data.filtratelist
  169. });
  170. }
  171. })
  172. },
  173. /* 设置页面高度 */
  174. setListHeight() {
  175. this.selectComponent("#ListBox").setHeight(".tips", this);
  176. },
  177. showModal(e) {
  178. this.setData({
  179. modalName: e.currentTarget.dataset.target
  180. })
  181. },
  182. hideModal(e) {
  183. this.setData({
  184. modalName: null
  185. })
  186. },
  187. handleFiltrate({
  188. detail
  189. }) {
  190. content.where.type = detail.type;
  191. content.where.tradefield = detail.tradefield;
  192. downCount = setTimeout(() => {
  193. this.getList(true);
  194. }, 300);
  195. },
  196. createOrder() {
  197. if (this.data.brandList.length == 1 && this.data.filtratelist[1].list.length == 1) {
  198. wx.showModal({
  199. title: '提示',
  200. content: '是否确定创建标准订单',
  201. complete: ({
  202. confirm
  203. }) => {
  204. if (confirm) _Http.basic({
  205. "id": 20221108111402,
  206. content: {
  207. sa_orderid: 0,
  208. rec_contactsid: 0,
  209. pay_enterpriseid: 0,
  210. sa_contractid: 0,
  211. sa_projectid: 0,
  212. "sa_brandid": this.data.brandList[0].sa_brandid, //品牌ID
  213. "type": "标准订单", //订单类型
  214. "tradefield": this.data.filtratelist[1].list[0].tradefield, //必选
  215. sys_enterpriseid: 0
  216. }
  217. }).then(res => {
  218. console.log("创建标准订单", res);
  219. wx.showToast({
  220. title: res.msg != '成功' ? res.msg : '创建成功',
  221. icon: "none",
  222. mask: true
  223. });
  224. if (res.msg == '成功') setTimeout(() => {
  225. wx.navigateTo({
  226. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  227. });
  228. }, 500)
  229. })
  230. }
  231. })
  232. } else {
  233. wx.navigateTo({
  234. url: '/packageA/orderForm/add/add?type=标准订单',
  235. })
  236. }
  237. }
  238. })