forked from mfay/IOReportMgt
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1017 B
37 lines
1017 B
|
4 years ago
|
import yfieldsControls from "../yfieldsControls"
|
||
|
|
Component({
|
||
|
|
behaviors: [yfieldsControls],
|
||
|
|
properties: {
|
||
|
|
bindValue: String,
|
||
|
|
defaultValue: String,
|
||
|
|
label: String,
|
||
|
|
},
|
||
|
|
|
||
|
|
relations: {
|
||
|
|
'../yform/yform': {
|
||
|
|
type: 'ancestor', // 关联的目标节点应为祖先节点
|
||
|
|
linked: function (target) {
|
||
|
|
this.updateFormItemValue = (curValue) => {
|
||
|
|
target.data.form[this.data.bindValue] = curValue
|
||
|
|
this.setData({ value: curValue })
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
lifetimes: {
|
||
|
|
attached: function () {
|
||
|
|
const initValue = this.data.defaultValue || ''
|
||
|
|
this.dataset[this.data.bindValue] = initValue
|
||
|
|
this.setData({ value: initValue })
|
||
|
|
}
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
// 这个方法是父组件提供的,这里只是为了不报错
|
||
|
|
updateFormItemValue: (_: string) => { },
|
||
|
|
bindinput: function (event: WechatMiniprogram.Input) {
|
||
|
|
this.dataset[this.data.bindValue] = event.detail.value
|
||
|
|
this.updateFormItemValue(event.detail.value)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|