detail.js 6.9 KB

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