index.js 6.9 KB

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