|
@@ -10,8 +10,9 @@
|
|
<view class="children" v-if="openItems.includes(item.id)">
|
|
<view class="children" v-if="openItems.includes(item.id)">
|
|
<view class="child" v-for="(child, n) in item.itemList" :key="n">
|
|
<view class="child" v-for="(child, n) in item.itemList" :key="n">
|
|
<text>{{child.name}}</text>
|
|
<text>{{child.name}}</text>
|
|
- <view class="check-icon-wrap" @click="changeChecked(child.id)">
|
|
|
|
- <image :src="`../../static/check-${checkedIds.includes(child.id)
|
|
|
|
|
|
+ <view class="check-icon-wrap"
|
|
|
|
+ @click="changeChecked(index, n, child.selectFlag)">
|
|
|
|
+ <image :src="`../../static/check-${child.selectFlag
|
|
?'checkbox':'no'}.png`"></image>
|
|
?'checkbox':'no'}.png`"></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -31,48 +32,46 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
openItems: [],
|
|
openItems: [],
|
|
- checkedIds: [],
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
botmBtnGroup: function() {
|
|
botmBtnGroup: function() {
|
|
return [
|
|
return [
|
|
{id: 'cancle', label: '取消'},
|
|
{id: 'cancle', label: '取消'},
|
|
- {id: 'ok', label: `已选${this.checkedIds.length}项,确定`}
|
|
|
|
|
|
+ {id: 'ok', label: `已选${this.selectedNum}项,确定`}
|
|
];
|
|
];
|
|
},
|
|
},
|
|
...mapState({
|
|
...mapState({
|
|
checkMap: state => state.creatingSituations.checkMap,
|
|
checkMap: state => state.creatingSituations.checkMap,
|
|
- })
|
|
|
|
|
|
+ }),
|
|
|
|
+ selectedNum: function() {
|
|
|
|
+ let num = 0;
|
|
|
|
+ this.checkMap.actionItem.pointList.map((item)=>{
|
|
|
|
+ item.itemList.map((ntem)=>{
|
|
|
|
+ if(ntem.selectFlag) num++;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ return num;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
created:function(){
|
|
created:function(){
|
|
- // 默认全选中
|
|
|
|
this.checkMap.actionItem.pointList.map((item)=>{
|
|
this.checkMap.actionItem.pointList.map((item)=>{
|
|
this.openItems.push(item.id);
|
|
this.openItems.push(item.id);
|
|
- item.itemList.map((ntem)=>{
|
|
|
|
- if(ntem.selectFlag === undefined || ntem.selectFlag) {
|
|
|
|
- this.checkedIds.push(ntem.id);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
});
|
|
});
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
openChildren: function(key) {
|
|
openChildren: function(key) {
|
|
this.openItems = arrFilter(key, this.openItems);
|
|
this.openItems = arrFilter(key, this.openItems);
|
|
},
|
|
},
|
|
- changeChecked: function(id) {
|
|
|
|
- this.checkedIds = arrFilter(id, this.checkedIds);
|
|
|
|
|
|
+ changeChecked: function(i, n, selectFlag) {
|
|
|
|
+ this.checkMap.actionItem.pointList[i].itemList[n].selectFlag = !selectFlag;
|
|
|
|
+ this.myCommit('actionItem', this.checkMap.actionItem);
|
|
},
|
|
},
|
|
btnClick: function(id) {
|
|
btnClick: function(id) {
|
|
if(id === 'ok') {
|
|
if(id === 'ok') {
|
|
- let pointList = [...this.checkMap.actionItem.pointList];
|
|
|
|
- pointList.map((item)=>{
|
|
|
|
- item.itemList.map((ntem)=>{
|
|
|
|
- ntem.selectFlag = this.checkedIds.includes(ntem.id) ? true : false;
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ const {id, pointList} = this.checkMap.actionItem;
|
|
let list = [...this.checkMap.list];
|
|
let list = [...this.checkMap.list];
|
|
- let index = list.findIndex(({id})=> id === this.checkMap.actionItem.id);
|
|
|
|
|
|
+ let index = list.findIndex((item)=> item.id === id);
|
|
list[index].pointList = pointList;
|
|
list[index].pointList = pointList;
|
|
this.myCommit('list', list);
|
|
this.myCommit('list', list);
|
|
}
|
|
}
|