checkMapDetail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="check-map-detail">
  3. <view class="item" v-for="(item, index) in checkMap.actionItem.pointList" :key="index">
  4. <view class="icon-wrap" @click="openChildren(item.id)">
  5. <image :src="`../../static/list-${openItems.includes(item.id)
  6. ?'close':'open'}.png`"></image>
  7. </view>
  8. <view class="content">
  9. <view class="content-title" @click="openChildren(item.id)">{{item.name}}</view>
  10. <view class="children" v-if="openItems.includes(item.id)">
  11. <view class="child" v-for="(child, n) in item.itemList" :key="n">
  12. <text>{{child.name}}</text>
  13. <view class="check-icon-wrap"
  14. @click="changeChecked(index, n, child.selectFlag)">
  15. <image :src="`../../static/check-${child.selectFlag
  16. ?'checkbox':'no'}.png`"></image>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <tm-simple-btn-group :options="botmBtnGroup"
  23. v-on:callback="btnClick" ></tm-simple-btn-group>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapState } from "vuex";
  28. import {arrFilter} from "../../../utils/arrFilter.js";
  29. export default {
  30. data() {
  31. return {
  32. openItems: [],
  33. }
  34. },
  35. computed: {
  36. botmBtnGroup: function() {
  37. return [
  38. {id: 'cancle', label: '取消'},
  39. {id: 'ok', label: `已选${this.selectedNum}项,确定`}
  40. ];
  41. },
  42. ...mapState({
  43. checkMap: state => state.creatingSituations.checkMap,
  44. }),
  45. selectedNum: function() {
  46. let num = 0;
  47. this.checkMap.actionItem.pointList.map((item)=>{
  48. item.itemList.map((ntem)=>{
  49. if(ntem.selectFlag) num++;
  50. });
  51. });
  52. return num;
  53. },
  54. },
  55. created:function(){
  56. this.checkMap.actionItem.pointList.map((item)=>{
  57. this.openItems.push(item.id);
  58. });
  59. },
  60. methods: {
  61. openChildren: function(key) {
  62. this.openItems = arrFilter(key, this.openItems);
  63. },
  64. changeChecked: function(i, n, selectFlag) {
  65. this.checkMap.actionItem.pointList[i].itemList[n].selectFlag = !selectFlag;
  66. this.myCommit('actionItem', this.checkMap.actionItem);
  67. },
  68. btnClick: function(id) {
  69. if(id === 'ok') {
  70. const {id, pointList} = this.checkMap.actionItem;
  71. let list = [...this.checkMap.list];
  72. let index = list.findIndex((item)=> item.id === id);
  73. list[index].pointList = pointList;
  74. this.myCommit('list', list);
  75. }
  76. this.commit('showCheckMapDetail', false);
  77. },
  78. /**
  79. * 更新condition数据
  80. * @param {Object} key 要更新的属性
  81. * @param {Object} value 值
  82. */
  83. myCommit: function(key, value) {
  84. let data = {...this.checkMap};
  85. data[key] = value;
  86. this.commit('checkMap', data);
  87. },
  88. dispatch: function(key, data) {
  89. return this.$store.dispatch({type: 'creatingSituations/commActions', key, data});
  90. },
  91. commit: function(key,data) {
  92. this.$store.commit({type: 'creatingSituations/comChangeState', key, data});
  93. },
  94. }
  95. }
  96. </script>
  97. <style lang="less">
  98. .check-map-detail {
  99. padding-bottom: 75rpx;
  100. width: 100%;
  101. height: 100%;
  102. .item {
  103. display: flex;
  104. flex-direction: row;
  105. border-top: 1px solid #DADEE6;
  106. padding-left: 25rpx;
  107. width: 100%;
  108. background-color: #fff;
  109. .icon-wrap {
  110. padding-top: 28.12rpx;
  111. padding-right: 23.75rpx;
  112. width: 45rpx;
  113. height: inherit;
  114. image {
  115. width: 100%;
  116. height: 12.5rpx;
  117. }
  118. }
  119. .content {
  120. width: 100%;
  121. color: #292C33;
  122. .content-title {
  123. display: flex;
  124. flex-direction: row;
  125. align-items: center;
  126. min-height: 87.5rpx;
  127. font-size: 22.5rpx;
  128. font-weight: 500;
  129. }
  130. .children {
  131. width: 100%;
  132. .child {
  133. display: flex;
  134. flex-direction: row;
  135. justify-content: space-between;
  136. align-items: center;
  137. border-top: 1px solid #DADEE6;
  138. min-height: 87.5rpx;
  139. .check-icon-wrap {
  140. display: flex;
  141. flex-direction: row;
  142. justify-content: center;
  143. align-items: center;
  144. width: 75rpx;
  145. height: 87.5rpx;
  146. image {
  147. width: 25rpx;
  148. height: 25rpx;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. </style>