12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // components/autoAdd/index.js
- import international from "../../international/appointment_scence/index";
- Component({
- options: {
- observers: true
- },
- /**
- * 组件的属性列表
- */
- properties: {
- // 显示标题
- label: {
- type: String,
- value: "受邀人员"
- },
- //placeholder
- placeholder: {
- type: String,
- value: "请输入手机号"
- },
- language: {
- type: String,
- value: "ch"
- },
- showAddBut: {
- type: Boolean
- },
- closeNum: {
- type: false
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- international: international,
- //国际化语言包
- list: [""]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 增加一行
- add(e) {
- let { list } = this.data;
- list.push("")
- this.setData({
- list
- });
- },
- //删除一行
- delete(e) {
- let { list } = this.data;
- list.splice(e.currentTarget.dataset.index, 1);
- this.setData({
- list
- });
- },
- //获得用户输入
- getValue(e) {
- var { list } = this.data;
- const index = "list[" + e.currentTarget.dataset.index + "]";
- this.setData({
- [index]: e.detail.value
- });
- list = this.data.list.filter(value => {
- if (value != "") {
- return value;
- }
- });
- this.triggerEvent("change", Array.from(new Set(list)));
- }
- },
- observers: {
- showAddBut: function(showAddBut) {
- if (!showAddBut) {
- this.setData({
- list: [""]
- });
- }
- },
- closeNum: function(closeNum) {
- if (closeNum) {
- this.setData({
- list: [""]
- });
- }
- }
- }
- });
|