index.js 6.6 KB

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