checkMapDetail.vue 3.9 KB

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