checkMapDetail.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. <view class="child-text">{{child.name}}</view>
  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 => JSON.parse(JSON.stringify(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 _pointList = pointList.map((item)=>{
  72. let obj = item.itemList.find(({selectFlag}) => selectFlag);
  73. return {
  74. ...item,
  75. selectFlag: obj ? true : false
  76. }
  77. });
  78. let list = [...this.checkMap.list];
  79. let index = list.findIndex((item)=> item.id === id);
  80. list[index].pointList = _pointList;
  81. this.myCommit('list', list);
  82. }
  83. this.commit('showCheckMapDetail', false);
  84. },
  85. /**
  86. * 更新condition数据
  87. * @param {Object} key 要更新的属性
  88. * @param {Object} value 值
  89. */
  90. myCommit: function(key, value) {
  91. let data = {...this.checkMap};
  92. data[key] = value;
  93. this.commit('checkMap', data);
  94. },
  95. dispatch: function(key, data) {
  96. return this.$store.dispatch({type: 'creatingSituations/commActions', key, data});
  97. },
  98. commit: function(key,data) {
  99. this.$store.commit({type: 'creatingSituations/comChangeState', key, data});
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="less">
  105. .check-map-detail {
  106. padding-bottom: 75rpx;
  107. width: 100%;
  108. height: 100%;
  109. .item {
  110. display: flex;
  111. flex-direction: row;
  112. border-top: 1px solid #DADEE6;
  113. padding-left: 25rpx;
  114. width: 100%;
  115. background-color: #fff;
  116. .icon-wrap {
  117. padding-top: 28.12rpx;
  118. padding-right: 23.75rpx;
  119. width: 45rpx;
  120. height: inherit;
  121. image {
  122. width: 100%;
  123. height: 12.5rpx;
  124. }
  125. }
  126. .content {
  127. width: 100%;
  128. color: #292C33;
  129. .content-title {
  130. display: flex;
  131. flex-direction: row;
  132. align-items: center;
  133. min-height: 87.5rpx;
  134. font-size: 22.5rpx;
  135. font-weight: 500;
  136. }
  137. .children {
  138. width: 100%;
  139. .child {
  140. display: flex;
  141. flex-direction: row;
  142. justify-content: space-between;
  143. align-items: center;
  144. border-top: 1px solid #DADEE6;
  145. min-height: 87.5rpx;
  146. .child-text {
  147. width: calc(100% - 75rpx);
  148. }
  149. .check-icon-wrap {
  150. display: flex;
  151. flex-direction: row;
  152. justify-content: center;
  153. align-items: center;
  154. width: 75rpx;
  155. height: 87.5rpx;
  156. image {
  157. width: 25rpx;
  158. height: 25rpx;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. </style>