projectList.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. condition: ""
  10. },
  11. onLoad(options) {
  12. getApp().globalData.Language.getLanguagePackage(this, '选择项目')
  13. this.setData({
  14. content: _Http.data.content,
  15. })
  16. const filtratelist = [{
  17. label: "项目类型",
  18. index: _Http.data.projecttypes.findIndex(v => v.value == _Http.data.content.where.projecttype) || 0,
  19. showName: "remarks", //显示字段
  20. valueKey: "projecttype", //返回Key
  21. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  22. value: _Http.data.content.where.projecttype, //选中值
  23. list: _Http.data.projecttypes
  24. }, {
  25. label: "项目等级",
  26. index: _Http.data.grades.findIndex(v => v.value == _Http.data.content.where.grade) || 0,
  27. showName: "remarks", //显示字段
  28. valueKey: "grade", //返回Key
  29. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  30. value: _Http.data.content.where.grade, //选中值
  31. list: _Http.data.grades.map(v => {
  32. v.remarks = v.remarks.split("-")[0]
  33. return v
  34. })
  35. }, {
  36. label: "领域",
  37. index: _Http.data.tradefields.findIndex(v => v.value == _Http.data.content.where.tradefield) || 0,
  38. showName: "remarks", //显示字段
  39. valueKey: "tradefield", //返回Key
  40. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  41. value: _Http.data.content.where.tradefield, //选中值
  42. list: _Http.data.tradefields
  43. }, ];
  44. this.setData({
  45. filtratelist
  46. })
  47. this.getList()
  48. },
  49. getList(init = false) {
  50. _Http.init(this.data.content, init).then(content => {
  51. _Http.basic({
  52. "id": 20230715111604,
  53. content
  54. }).then(res => {
  55. console.log("res", res)
  56. this.selectComponent('#ListBox').RefreshToComplete();
  57. if (res.code != '1') return wx.showToast({
  58. title: res.data,
  59. icon: "none"
  60. })
  61. res.data = res.data.map(v => {
  62. v.signamount_due = CNY(v.signamount_due)
  63. v.dealamount = CNY(v.dealamount)
  64. return v
  65. })
  66. this.setData({
  67. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  68. "content.pageNumber": res.pageNumber + 1,
  69. "content.pageSize": res.pageSize,
  70. "content.pageTotal": res.pageTotal,
  71. "total": res.total,
  72. })
  73. })
  74. })
  75. },
  76. handleFilter({
  77. detail
  78. }) {
  79. if (detail.name == "close") return;
  80. this.setData({
  81. "content.where.grade": detail.grade || "",
  82. "content.where.projecttype": detail.projecttype || "",
  83. "content.where.tradefield": detail.tradefield || "",
  84. })
  85. this.getList(true);
  86. },
  87. openFiltrate() {
  88. this.setData({
  89. showFiltrate: true
  90. })
  91. },
  92. selectItem(e) {
  93. const {
  94. item
  95. } = e.currentTarget.dataset;
  96. _Http.selectItem(item)
  97. },
  98. onUnload() {
  99. delete _Http.data
  100. },
  101. onChange(e) {
  102. this.setData({
  103. condition: e.detail,
  104. });
  105. },
  106. onSearch() {
  107. this.setData({
  108. "content.where.condition": this.data.condition
  109. })
  110. this.getList(true);
  111. },
  112. onClear() {
  113. this.setData({
  114. "content.where.condition": "",
  115. condition: "",
  116. })
  117. this.getList(true);
  118. }
  119. })