index.js
3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* @Description:
* @Author: huyue
* @Date: 2023-04-28 16:19:53
* @LastEditors: huyue
* @LastEditTime: 2023-05-05 10:00:50
*/
Component({
externalClasses: ['switch-active-class', 'switch-class', 'switch-item-class', 'lable-class'],
data: {
// 显示省市
provinceShow: false,
// 显示日期时间
dateTimeShow: false,
// 图片地址前缀
prefix: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/glsx-applet-comonents/'
},
properties: {
/**
* formItem:表单某一项的配置数据
* 其中的参数:
* type:标签类型 必填
* lable:标签页面显示名称 必填
* name:标签名称 必填
* rules: 验证规则,Object, 非必填
* textLeft: 输入框文字的位置,非必填,默认靠右,填了靠左
*/
formItem: {
type: Object,
value: {},
observer: function () {
// this.init(n)
},
},
/**
* formObj:表单数据绑定的对象
*/
formObj: {
type: Object,
value: {}
},
/**
* inline:表单配置是否一行展示
*/
inline: {
type: Boolean,
value: true
},
/**
* themeStyle: 主题样式
*/
themeStyle: {
type: String,
value: '#3582EE'
},
textPostion: {
type: String,
value: 'right'
}
},
methods: {
// 输入框输入触发
handleInput(e) {
const {name} = e.currentTarget.dataset
const inputValue = e.detail.value
this.triggerEvent('getFormItemValue', {name, value: inputValue})
},
// 点击触发省市弹框
// showProvince() {
// console.log(333);
// this.setData({
// provinceShow: !this.data.provinceShow
// })
// },
// 获取省市数据
// getProvinceCode(e) {
// let address = e.detail.provinceNameData.toString()
// address = address.replace(/,/g, '-')
// this.setData({
// 'platformObj.code': e.detail.codeData,
// 'platformObj.address': address,
// 'platformObj.name': e.detail.provinceNameData,
// })
// },
// 默认开关切换
switch1Change(e) {
console.log(e);
const {name} = e.currentTarget.dataset
this.triggerEvent('getFormItemValue', {name, value: e.detail.value})
},
// 自定义开关切换
switch2Change(e) {
console.log(e);
const {index, name} = e.currentTarget.dataset
this.triggerEvent('getFormItemValue', {name, value: index})
},
// 点击触发时间日期弹框
// showDatePicker() {
// this.setData({
// dateTimeShow: !this.data.dateTimeShow
// })
// }
// 自定义框点击事件
customClick(e) {
console.log(e);
const {name} = e.currentTarget.dataset
this.triggerEvent('customClick', name)
},
// 单选框点击
radioChange(e) {
console.log(e);
const {name} = e.currentTarget.dataset
const checkValue = e.detail.value
this.triggerEvent('getFormItemValue', {name, value: checkValue})
},
// 获取选择时间
changeTime(e) {
console.log(e);
const {name} = e.currentTarget.dataset
const timeValue = e.detail.value
this.triggerEvent('getFormItemValue', {name, value: timeValue})
},
// 获取选择日期
changeDate(e) {
console.log(e);
const {name} = e.currentTarget.dataset
const dateValue = e.detail.value
this.triggerEvent('getFormItemValue', {name, value: dateValue})
},
// 图片删除(单个)
delSingleImg(e) {
console.log(e);
const {name} = e.currentTarget.dataset
this.triggerEvent('getFormItemValue', {name, value: ''})
},
// 图片删除(多个)
delmultiImg(e) {
console.log(e);
const {name, index} = e.currentTarget.dataset
this.triggerEvent('getFormItemValue', {name, value: index, type: 'muiltiImg'})
}
},
// 组件生命周期
lifetimes: {
}
});