detail.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Page({
  8. data: {
  9. searchShow: false,
  10. searchValue: "",
  11. typeShow: false,
  12. tradefieldShow: false
  13. },
  14. onLoad(options) {
  15. const content = Object.assign(JSON.parse(options.data), {
  16. "pageNumber": 1,
  17. "pageSize": 20,
  18. "where": {
  19. "condition": "",
  20. "type": "",
  21. "tradefield": ""
  22. }
  23. }),
  24. ids = {
  25. "订单": 2025032613405702,
  26. "出货": 2025032615330102,
  27. "开票": 2025032616343302,
  28. "回款": 2025032616352402,
  29. };
  30. getApp().globalData.Language.getLanguagePackage(this, content.typeName + '明细')
  31. this.setData({
  32. content,
  33. id: ids[content.typeName],
  34. siteid: wx.getStorageSync('userMsg').siteid
  35. })
  36. _Http.basic({
  37. "classname": "sysmanage.develop.optiontype.optiontype",
  38. "method": "optiontypeselect",
  39. "content": {
  40. "pageNumber": 1,
  41. "pageSize": 1000,
  42. "typename": "ordertype",
  43. "parameter": {}
  44. },
  45. }).then(res => {
  46. console.log("订单类型", res)
  47. let types = res.data.map(v => {
  48. return {
  49. name: getApp().globalData.Language.getMapText(v.remarks || v.value),
  50. value: v.value
  51. }
  52. })
  53. types.unshift({
  54. name: getApp().globalData.Language.getMapText('全部'),
  55. value: "",
  56. color: "#3874F6"
  57. })
  58. this.setData({
  59. types
  60. })
  61. })
  62. _Http.basic({
  63. "classname": "sysmanage.develop.optiontype.optiontype",
  64. "method": "optiontypeselect",
  65. "content": {
  66. "pageNumber": 1,
  67. "pageSize": 1000,
  68. "typename": "tradefield",
  69. },
  70. }).then(res => {
  71. console.log("领域", res)
  72. let tradefields = res.data.map(v => {
  73. return {
  74. name: getApp().globalData.Language.getMapText(v.remarks || v.value),
  75. value: v.value
  76. }
  77. })
  78. tradefields.unshift({
  79. name: getApp().globalData.Language.getMapText('全部'),
  80. value: "",
  81. color: "#3874F6"
  82. })
  83. this.setData({
  84. tradefields
  85. })
  86. })
  87. this.getList()
  88. },
  89. changeSearchShow() {
  90. this.setData({
  91. searchShow: !this.data.searchShow
  92. })
  93. this.selectComponent('#ListBox').automaticSetHei();
  94. },
  95. getList(init = false) {
  96. _Http.init(this.data.content, init).then(content => {
  97. _Http.basic({
  98. "id": this.data.id,
  99. content
  100. }).then(res => {
  101. console.log(content.typeName + "明细列表", res)
  102. this.selectComponent('#ListBox').automaticSetHei();
  103. this.selectComponent('#ListBox').RefreshToComplete();
  104. if (res.code != '1') return wx.showToast({
  105. title: res.data,
  106. icon: "none"
  107. })
  108. res.data = res.data.map(v => {
  109. v.marketprice = CNY(v.marketprice)
  110. v.amount = CNY(v.amount)
  111. v.invoiceamount = CNY(v.invoiceamount)
  112. v.uninvoiceamount = CNY(v.uninvoiceamount)
  113. v.writeoffamount = CNY(v.writeoffamount)
  114. v.unwriteoffamount = CNY(v.unwriteoffamount)
  115. v.returnamount = CNY(v.returnamount)
  116. v.price = CNY(v.price)
  117. v.logisticsamount = CNY(v.logisticsamount)
  118. v.expanded = false;
  119. return v
  120. })
  121. this.setData({
  122. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  123. "content.pageNumber": res.pageNumber + 1,
  124. "content.pageSize": res.pageSize,
  125. "content.pageTotal": res.pageTotal,
  126. "total": res.total,
  127. })
  128. this.onCancel()
  129. })
  130. })
  131. },
  132. changeExpanded(e) {
  133. console.log(e)
  134. const {
  135. index
  136. } = e.currentTarget.dataset;
  137. this.setData({
  138. [`list[${index}].expanded`]: !this.data.list[index].expanded
  139. })
  140. },
  141. onSearch() {
  142. this.data.content.where.condition = this.data.searchValue;
  143. this.getList(true);
  144. },
  145. onChange(event) {
  146. this.setData({
  147. searchValue: event.detail
  148. })
  149. },
  150. onClear() {
  151. this.setData({
  152. searchValue: "",
  153. "content.where.condition": ""
  154. })
  155. this.getList(true);
  156. },
  157. openTypeShow() {
  158. this.setData({
  159. typeShow: true
  160. })
  161. },
  162. openTradefieldShow() {
  163. this.setData({
  164. tradefieldShow: true
  165. })
  166. },
  167. onSelect(event) {
  168. const {
  169. value
  170. } = event.detail;
  171. if (this.data.content.where.type == value) return this.onCancel();
  172. this.setData({
  173. types: this.data.types.map(item => {
  174. item.color = item.value == value ? "#3874F6" : "";
  175. item.loading = item.value == value ? true : false;
  176. return item
  177. })
  178. })
  179. this.setData({
  180. "content.where.type": value
  181. })
  182. this.getList(true)
  183. },
  184. onSelect1(event) {
  185. const {
  186. value
  187. } = event.detail;
  188. if (this.data.content.where.tradefield == value) return this.onCancel();
  189. this.setData({
  190. tradefields: this.data.tradefields.map(item => {
  191. item.color = item.value == value ? "#3874F6" : "";
  192. item.loading = item.value == value ? true : false;
  193. return item
  194. })
  195. })
  196. this.setData({
  197. "content.where.tradefield": value
  198. })
  199. this.getList(true)
  200. },
  201. onCancel() {
  202. this.setData({
  203. typeShow: false,
  204. types: this.data.types.map(item => {
  205. item.loading = false;
  206. return item
  207. }),
  208. tradefieldShow: false,
  209. tradefields: this.data.tradefields.map(item => {
  210. item.loading = false;
  211. return item
  212. }),
  213. })
  214. }
  215. })