123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <view class="check-map-detail">
- <view class="item" v-for="(item, index) in checkMap.actionItem.pointList" :key="index">
- <view class="icon-wrap" @click="openChildren(item.id)">
- <image :src="`../../static/list-${openItems.includes(item.id)
- ?'close':'open'}.png`"></image>
- </view>
- <view class="content">
- <view class="content-title" @click="openChildren(item.id)">{{item.name}}</view>
- <view class="children" v-if="openItems.includes(item.id)">
- <view class="child" v-for="(child, n) in item.itemList" :key="n">
- <text>{{child.name}}</text>
- <view class="check-icon-wrap"
- @click="changeChecked(index, n, child.selectFlag)">
- <image :src="`../../static/check-${child.selectFlag
- ?'checkbox':'no'}.png`"></image>
- </view>
- </view>
- </view>
- </view>
- </view>
- <tm-simple-btn-group :options="botmBtnGroup"
- v-on:callback="btnClick" ></tm-simple-btn-group>
- </view>
- </template>
- <script>
- import { mapState } from "vuex";
- import {arrFilter} from "../../../utils/arrFilter.js";
-
- export default {
- data() {
- return {
- openItems: [],
- }
- },
- computed: {
- botmBtnGroup: function() {
- return [
- {id: 'cancle', label: '取消'},
- {id: 'ok', label: `已选${this.selectedNum}项,确定`}
- ];
- },
- ...mapState({
- 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(){
- this.checkMap.actionItem.pointList.map((item)=>{
- this.openItems.push(item.id);
- });
- },
- methods: {
- openChildren: function(key) {
- this.openItems = arrFilter(key, this.openItems);
- },
- changeChecked: function(i, n, selectFlag) {
- this.checkMap.actionItem.pointList[i].itemList[n].selectFlag = !selectFlag;
- this.myCommit('actionItem', this.checkMap.actionItem);
- },
- btnClick: function(id) {
- if(id === 'ok') {
- const {id, pointList} = this.checkMap.actionItem;
- let list = [...this.checkMap.list];
- let index = list.findIndex((item)=> item.id === id);
- list[index].pointList = pointList;
- this.myCommit('list', list);
- }
- this.commit('showCheckMapDetail', false);
- },
- /**
- * 更新condition数据
- * @param {Object} key 要更新的属性
- * @param {Object} value 值
- */
- myCommit: function(key, value) {
- let data = {...this.checkMap};
- data[key] = value;
- this.commit('checkMap', data);
- },
- dispatch: function(key, data) {
- return this.$store.dispatch({type: 'creatingSituations/commActions', key, data});
- },
- commit: function(key,data) {
- this.$store.commit({type: 'creatingSituations/comChangeState', key, data});
- },
- }
- }
- </script>
- <style lang="less">
- .check-map-detail {
- padding-bottom: 75rpx;
- width: 100%;
- height: 100%;
- .item {
- display: flex;
- flex-direction: row;
- border-top: 1px solid #DADEE6;
- padding-left: 25rpx;
- width: 100%;
- background-color: #fff;
- .icon-wrap {
- padding-top: 28.12rpx;
- padding-right: 23.75rpx;
- width: 45rpx;
- height: inherit;
- image {
- width: 100%;
- height: 12.5rpx;
- }
- }
- .content {
- width: 100%;
- color: #292C33;
- .content-title {
- display: flex;
- flex-direction: row;
- align-items: center;
- min-height: 87.5rpx;
- font-size: 22.5rpx;
- font-weight: 500;
- }
- .children {
- width: 100%;
- .child {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- border-top: 1px solid #DADEE6;
- min-height: 87.5rpx;
- .check-icon-wrap {
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- width: 75rpx;
- height: 87.5rpx;
- image {
- width: 25rpx;
- height: 25rpx;
- }
- }
- }
- }
- }
- }
- }
- </style>
|