index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. Component({
  2. properties: {
  3. list: {
  4. type: Array
  5. },
  6. showList: {
  7. type: Array
  8. },
  9. getResult: {
  10. type: Function
  11. }
  12. },
  13. options: {
  14. addGlobalClass: true
  15. },
  16. data: {
  17. show: false,
  18. result: []
  19. },
  20. lifetimes: {
  21. attached: function () {
  22. getApp().globalData.Language.getLanguagePackage(this)
  23. }
  24. },
  25. methods: {
  26. onChange({
  27. detail
  28. }) {
  29. this.setData({
  30. result: detail
  31. })
  32. },
  33. onClose() {
  34. this.setData({
  35. show: false
  36. })
  37. },
  38. startSearch({
  39. detail
  40. }) {
  41. if (!detail.trim()) return this.setData({
  42. showList: this.data.list
  43. })
  44. let showList = this.data.list.filter(v => `${v.projectname},${v.projectnum},${v.address}`.includes(detail.trim()));
  45. this.setData({
  46. showList
  47. })
  48. },
  49. onClear() {
  50. this.setData({
  51. showList: this.data.list
  52. })
  53. },
  54. handleReturn() {
  55. if (!this.data.result.length) return;
  56. this.triggerEvent("getResult", this.data.result)
  57. this.setData({
  58. show: false,
  59. result: []
  60. })
  61. }
  62. }
  63. })