<template> <dm-pop-view ref='popView' title="更多筛选" :isShowConfirm='false'> <view class="screen_container" > <text class="screen_item_title">{{title}}</text> <view class="level_tag_view"> <text class="level_tag" v-for="(item, i) in curOptions" :key="i" :style="{ color: item.isSelected ? '#fff' : '#666', 'background-color': item.isSelected ? themeColor : '#fff' }" @click="chooseTags(item, i)"> {{item.name}} </text> </view> <view class="bottom_btn"> <text class="reset_btn" :style="{'background-color':themeColor25}" @click="resetAction">重置</text> <text class="pop_btn" :style="{'background-color':themeColor}" @click="popConfirm">确定</text> </view> </view> </dm-pop-view> </template> <script> import dmPopView from './dmPopView.vue' export default { props: { options: Array, curItem: Array, items:Array, value: [String, Number], title:{ type:String, default:'请选择' }, }, data() { return { oldSelectItem: [], selectItem: [], curOptions: [], selIdx: 0, themeColor:'', themeColor25:'' } }, watch:{ items(newVal,oldVal){ if(this.curOptions.length==0){ this.curOptions = newVal; } }, selectItem(newVal,oldVal){ var tempOptions = []; for(let index in this.curOptions){ var option = this.curOptions[index]; const temp = newVal.findIndex(item=> option.id==item.dicDataId); option.isSelected = (temp != -1 ? true : false); tempOptions.push(option); } this.curOptions = tempOptions; } }, mounted() { let globalData = getApp().globalData this.themeColor = globalData.themeColor this.themeColor25 = globalData.themeColor25 }, methods: { show() { this.$refs.popView.show() var oldItemTemp = JSON.stringify(this.curItem); var oldItem = JSON.parse(oldItemTemp); // console.log("XXXXXXXX", oldItemTemp, oldItem) this.selectItem = oldItem; this.oldSelectItem = oldItem; }, popConfirm() { // 确定 // console.log("确定",this.selectItem) this.$emit('confirm', { 'selItems': this.selectItem, }) this.$refs.popView.hide() }, resetAction(e) { // 重置 var oldItemTemp = JSON.stringify(this.curItem); var oldItem = JSON.parse(oldItemTemp); this.selectItem = []; }, chooseTags(subitem, idx){ // 选择 this.seltag = idx; const temp = this.selectItem.findIndex(item=> subitem.id==item.dicDataId); if(temp!=-1){ this.selectItem.splice(temp, 1) }else{ this.selectItem.push({"dicDataId":subitem.id, "dicDataName":subitem.name}); } } }, components: { dmPopView } } </script> <style scoped lang="scss"> .pop-pickerView { margin: 40rpx 0; width: 750rpx; height: 300rpx; .column-item { height: 80rpx; display: flex; box-sizing: border-box; white-space: nowrap; overflow: hidden; flex-direction: row; align-items: center; justify-content: center; } } .screen_container { display: flex; flex-direction: column; width: 750rpx; .screen_item_title { margin-left: 30rpx; margin-top: 54rpx; line-height: 44rpx; font-size: 32rpx; font-family: Verdana, Verdana-Bold; font-weight: 700; text-align: left; color: #454545; } .level_tag_view { margin-left: 30rpx; margin-top: 20rpx; margin-bottom: 100rpx; display: flex; flex-wrap: wrap; .level_tag { margin-bottom: 20rpx; padding: 0rpx 20rpx; margin-right: 30rpx; min-width: 116rpx; height: 56rpx; border-radius: 8rpx; font-size: 28rpx; font-family: Verdana, Verdana-Regular; font-weight: 400; text-align: center; line-height: 56rpx; } } .screen_item_sub { margin-top: 8rpx; margin-bottom: 40rpx; margin-left: 30rpx; line-height: 34rpx; font-size: 24rpx; font-family: Verdana, Verdana-Regular; font-weight: 400; text-align: left; color: #999999; } .score_view { margin-top: 30rpx; margin-bottom: 120rpx; display: flex; justify-content: center; align-items: center; height: 82rpx; .score_text { font-size: 70rpx; font-family: 'DIN Alternate', 'DIN Alternate-Bold'; font-weight: 700; } .score_unit { padding-top: 25rpx; font-size: 28rpx; font-family: Verdana, Verdana-Regular; font-weight: 400; } } .bottom_btn { display: flex; justify-content: center; margin-bottom: 60rpx; .reset_btn { width: 156rpx; height: 80rpx; border-radius: 40rpx; font-size: 28rpx; font-family: Verdana, Verdana-Bold; font-weight: 700; text-align: center; line-height: 80rpx; color: #666666; } .pop_btn { margin-left: 30rpx; width: 444rpx; height: 80rpx; border-radius: 40rpx; font-size: 28rpx; font-family: Verdana, Verdana-Bold; font-weight: 700; text-align: center; line-height: 80rpx; color: #ffffff; } } } </style>