index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // components/autoAdd/index.js
  2. import international from "../../international/appointment_scence/index";
  3. Component({
  4. options: {
  5. observers: true
  6. },
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. // 显示标题
  12. label: {
  13. type: String,
  14. value: "受邀人员"
  15. },
  16. //placeholder
  17. placeholder: {
  18. type: String,
  19. value: "请输入手机号"
  20. },
  21. language: {
  22. type: String,
  23. value: "ch"
  24. },
  25. showAddBut: {
  26. type: Boolean
  27. },
  28. closeNum: {
  29. type: false
  30. }
  31. },
  32. /**
  33. * 组件的初始数据
  34. */
  35. data: {
  36. international: international,
  37. //国际化语言包
  38. list: [""]
  39. },
  40. /**
  41. * 组件的方法列表
  42. */
  43. methods: {
  44. // 增加一行
  45. add(e) {
  46. let { list } = this.data;
  47. list.push("")
  48. this.setData({
  49. list
  50. });
  51. },
  52. //删除一行
  53. delete(e) {
  54. let { list } = this.data;
  55. list.splice(e.currentTarget.dataset.index, 1);
  56. this.setData({
  57. list
  58. });
  59. },
  60. //获得用户输入
  61. getValue(e) {
  62. var { list } = this.data;
  63. const index = "list[" + e.currentTarget.dataset.index + "]";
  64. this.setData({
  65. [index]: e.detail.value
  66. });
  67. list = this.data.list.filter(value => {
  68. if (value != "") {
  69. return value;
  70. }
  71. });
  72. this.triggerEvent("change", Array.from(new Set(list)));
  73. }
  74. },
  75. observers: {
  76. showAddBut: function(showAddBut) {
  77. if (!showAddBut) {
  78. this.setData({
  79. list: [""]
  80. });
  81. }
  82. },
  83. closeNum: function(closeNum) {
  84. if (closeNum) {
  85. this.setData({
  86. list: [""]
  87. });
  88. }
  89. }
  90. }
  91. });