index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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": 20221224180302,
  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. amount: currency(res.tips.amount, {
  81. symbol: "¥",
  82. precision: 2
  83. }).format()
  84. })
  85. })
  86. },
  87. /* 更新列表 */
  88. updateList() {
  89. let params = JSON.parse(JSON.stringify(content));
  90. params.pageSize = (params.pageNumber - 1) * params.pageSize;
  91. params.pageNumber = 1;
  92. _Http.basic({
  93. "id": 20221224180302,
  94. content: params
  95. }).then(res => {
  96. console.log("订单列表", res)
  97. if (res.msg != '成功') return;
  98. /* 格式化价格 */
  99. if (res.data.length != 0) res.data = res.data.map(v => {
  100. v.defaultamount = currency(v.defaultamount, {
  101. symbol: "¥",
  102. precision: 2
  103. }).format();
  104. return v
  105. })
  106. this.setData({
  107. list: res.data,
  108. total: res.total,
  109. amount: currency(res.tips.amount, {
  110. symbol: "¥",
  111. precision: 2
  112. }).format()
  113. })
  114. })
  115. },
  116. /* 切换tabs */
  117. tabsChange(e) {
  118. let status = "";
  119. switch (e.detail.title) {
  120. case '全部':
  121. status = "";
  122. break;
  123. case '待确认':
  124. status = "交期待确认";
  125. break;
  126. default:
  127. status = e.detail.title
  128. break;
  129. }
  130. content.where.status = status;
  131. this.getList(true);
  132. },
  133. /* 搜索 */
  134. onSearch({
  135. detail
  136. }) {
  137. content.where.condition = detail;
  138. this.getList(true)
  139. },
  140. /* 获取品牌 */
  141. getBrand() {
  142. _Http.basic({
  143. "id": 20220924163702,
  144. "content": {
  145. "pageSize": 9999,
  146. }
  147. }, false).then(res => {
  148. console.log("查询品牌", res)
  149. if (res.msg == '成功') this.data.brandList = res.data
  150. })
  151. },
  152. /* 获取领域 */
  153. getDomain() {
  154. _Http.basic({
  155. "id": 20221223141802,
  156. "content": {
  157. "pageNumber": 1,
  158. "pageSize": 9999,
  159. "where": {
  160. "condition": ""
  161. }
  162. }
  163. }, false).then(res => {
  164. console.log("获取领域", res)
  165. if (res.msg == '成功') this.setData({
  166. "filtratelist[1].list": res.data
  167. });
  168. })
  169. },
  170. /* 设置页面高度 */
  171. setListHeight() {
  172. this.selectComponent("#ListBox").setHeight(".tips", this);
  173. },
  174. showModal(e) {
  175. this.setData({
  176. modalName: e.currentTarget.dataset.target
  177. })
  178. },
  179. hideModal(e) {
  180. this.setData({
  181. modalName: null
  182. })
  183. },
  184. handleFiltrate({
  185. detail
  186. }) {
  187. content.where.type = detail.type;
  188. content.where.tradefield = detail.tradefield;
  189. downCount = setTimeout(() => {
  190. this.getList(true);
  191. }, 300);
  192. },
  193. createOrder() {
  194. if (this.data.brandList.length == 1 && this.data.filtratelist[1].list.length == 1) {
  195. wx.showModal({
  196. title: '提示',
  197. content: '是否确定创建标准订单',
  198. complete: ({
  199. confirm
  200. }) => {
  201. if (confirm) _Http.basic({
  202. "id": 20221108111402,
  203. content: {
  204. sa_orderid: 0,
  205. rec_contactsid: 0,
  206. pay_enterpriseid: 0,
  207. sa_contractid: 0,
  208. sa_projectid: 0,
  209. "sa_brandid": this.data.brandList[0].sa_brandid, //品牌ID
  210. "type": "标准订单", //订单类型
  211. "tradefield": this.data.filtratelist[1].list[0].tradefield, //必选
  212. sys_enterpriseid: 0
  213. }
  214. }).then(res => {
  215. console.log("创建标准订单", res);
  216. wx.showToast({
  217. title: res.msg != '成功' ? res.msg : '创建成功',
  218. icon: "none",
  219. mask: true
  220. });
  221. if (res.msg == '成功') setTimeout(() => {
  222. wx.navigateTo({
  223. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  224. });
  225. }, 500)
  226. })
  227. }
  228. })
  229. } else {
  230. wx.navigateTo({
  231. url: '/packageA/orderForm/add/add?type=标准订单',
  232. })
  233. }
  234. }
  235. })