index.js 6.0 KB

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