123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import {getEventParam} from "../../utils/utils";
- import {logicStatus} from "../../model/enum";
- Component({
- properties: {
- label: String,
- pickData: {
- type: Array,
- value: [
- {dictLabel: '是', dictValue: logicStatus.YES + ""},
- {dictLabel: '否', dictValue: logicStatus.NO + ""}
- ]
- },
- key: {
- type: String,
- value: 'dictLabel'
- },
- value: {
- type: String,
- value: 'dictValue'
- },
- emitKey: String,
- index: String,
- placeholder: String,
- required: {
- type: Boolean,
- value: true
- }
- },
- observers: {
- index: function (index) {
- this.setData({
- position: this.findIndex(this.data.pickData, index)
- })
- }
- },
- data: {
- position: -1
- },
- methods: {
- findIndex(arr, value) {
- return arr.findIndex(item => item.dictValue === value);
- },
- bindChange(e) {
- this.setData({
- position: getEventParam(e, 'value')
- }, () => {
- this.triggerEvent('change', {
- [this.data.emitKey]: this.data.pickData[this.data.position][this.data.value]
- })
- })
- },
- }
- });
|