image.png
<picker :disabled="isSelect" mode="multiSelector" @change="bindPickerChange" @columnchange="columnchange" :value="index"
:range="array" range-key="title">
<view class="uni-input picker" :style="{color:multiIndexs>-1?'#555':'#a0a0a0'}">
<!-- {{title}} -->
{{multiIndexs>-1?totalData.fFeedbackusername:title}}
</view>
</picker>
export default {
data() {
return {
// 監(jiān)控問題反饋人
index: [0, 0],
array: [
[],
[]
],
childArr: [], // 二級分類數(shù)據(jù)源
title: '請先選擇要求整改單位',
isSelect: true, //監(jiān)控問題反饋人
multiIndexs: -1
}夕土,
onLoad() {
this.getCate()
},
methods: {
// 任務分類 監(jiān)控問題反饋人 數(shù)據(jù)獲取
getCate() {
// this.Get('請求的接口地址').then((res) => {
// if (!res.err) {
// 返回的數(shù)據(jù)格式
// 一級分類的數(shù)據(jù)源
// this.array[0] = res.result
this.array[0] = [{
id: 4,
title: "懸賞現(xiàn)金懸賞現(xiàn)金懸賞",
desc: "",
child: [{
id: 10,
title: "現(xiàn)金懸賞",
desc: ""
}, {
id: 11,
title: "黃金懸賞",
desc: ""
}]
},
{
id: 8,
title: "懸賞1",
desc: "",
child: [{
id: 5,
title: "現(xiàn)金懸賞1",
desc: ""
}, {
id: 16,
title: "黃金懸賞1",
desc: ""
}]
}, {
id: 3,
title: "懸賞5",
desc: "",
child: [{
id: 14,
title: "現(xiàn)金懸賞5",
desc: ""
}, {
id: 32,
title: "黃金懸賞5",
desc: ""
}]
}
]
// 將數(shù)據(jù)源中的二級分類 push 進 childArr,作為二級分類的數(shù)據(jù)源
this.childArr = this.array[0].map((item) => item.child)
// 第一次打開時稀余,默認給一級分類添加它的二級分類
this.array[1] = this.childArr[0]
// }
// })
},
// 獲取二級分類 監(jiān)控問題反饋人 二級分類
columnchange(e) {
console.log(e)
// 當滾動切換一級分類時推穷,為當前的一級分類添加它的子類
if (e.detail.column == 0) {
// #ifdef H5
// 在小程序中直接賦值無效 H5 可直接賦值
this.array[1] = this.childArr[e.detail.value]
// #endif
// #ifdef MP-WEIXIN
// 在 H5 環(huán)境下 $set 會導致一級分類無法滾動襟沮, 小程序正常運行
this.$set(this.array, 1, this.childArr[e.detail.value])
// #endif
// console.log(this.childArr[e.detail.value])
}
},
// 選擇任務分類 監(jiān)控問題反饋人點擊確認
bindPickerChange: function(e) {
console.log('picker發(fā)送選擇改變诬像,攜帶值為', e.target.value)
let value = e.target.value;
this.multiIndexs = 0
this.index = value;
if (this.array[0].length != 0) {
this.totalData.fFeedbackusername = this.array[0][this.index[0]].title
// this.totalData.fFeedbackusername = this.title
// console.log(this.array[0][this.index[0]].id)
};
if (this.array[1].length != 0) {
this.totalData.fFeedbackusername = this.array[1][this.index[1]].title
// this.totalData.fFeedbackusername = this.title
// console.log(this.array[1][this.index[1]].id)
}
},
}
}