index.js 5.9 KB

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