checkRent.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="check-rent">
  3. <view class="title">请指定负责查核的查核组</view>
  4. <view class="list">
  5. <view class="item"
  6. v-for="(item, index) in checkRent.list"
  7. :key="index"
  8. @click="openItemHandle(item.id)">
  9. <view class="img-wrap">
  10. <image :src="`../../static/list-${openItems.includes(item.id)
  11. ?'close':'open'}.png`"></image>
  12. </view>
  13. <view class="content">
  14. <view class="info">
  15. <view class="text">
  16. <view>{{item.name}}</view>
  17. <view>组长:{{item.groupManagerName}}</view>
  18. </view>
  19. <view class="icon" @click="checkedHandle($event, item)">
  20. <image :src="`../../static/check-${checkRent.checkedItem.id === item.id ? 'radio' : 'no'}.png`"></image>
  21. </view>
  22. </view>
  23. <view class="chidren" v-if="openItems.includes(item.id)">
  24. <view class="chid-item">
  25. <view>小组成员</view>
  26. <view>{{item.members.join('、')}}</view>
  27. </view>
  28. <view class="chid-item">
  29. <view>负责要点</view>
  30. <view>
  31. <text>{{item.allPoints}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { mapState } from "vuex";
  42. import {_stopPropagation} from "../../../utils/compatible.js";
  43. import {arrFilter} from "../../../utils/arrFilter.js";
  44. import {arrayEquality} from "./utils.js";
  45. export default {
  46. data() {
  47. return {
  48. openItems: []
  49. }
  50. },
  51. computed: {
  52. ...mapState({
  53. checkRent: state => state.creatingSituations.checkRent,
  54. condition: state => state.creatingSituations.condition,
  55. needReload: state => state.creatingSituations.needReload,
  56. editConfig: state => state.creatingSituations.editConfig
  57. })
  58. },
  59. created:function(){
  60. // 编辑的时候不用获取数据
  61. if(this.editConfig && arrayEquality(this.condition.conditionIds, this.editConfig.condition.conditionIds) && this.editConfig.checkRent) {
  62. this.$store.commit({
  63. type: 'creatingSituations/comChangeState',
  64. key: 'checkRent',
  65. data: this.editConfig.checkRent
  66. });
  67. } else if(this.needReload) { // 点击上一步不用获取数据
  68. this.$store.dispatch({
  69. type: 'creatingSituations/commActions',
  70. key: 'checkGroupList',
  71. data: { conditionIds: this.condition.conditionIds}
  72. }).then((data)=> {
  73. if(data) {
  74. this.myCommit('list', data);
  75. const {checkedItem} = this.checkRent;
  76. if(checkedItem.id) { // 如果选中过,要去更新数据
  77. let obj = data.find(({id})=>id === checkedItem.id);
  78. this.myCommit('checkedItem', obj?obj:{id:null});
  79. }
  80. }
  81. });
  82. }
  83. },
  84. methods: {
  85. openItemHandle: function(key) {
  86. this.openItems = arrFilter(key, this.openItems);
  87. },
  88. checkedHandle: function(e, item) {
  89. _stopPropagation(e);
  90. this.myCommit('checkedItem', item);
  91. },
  92. /**
  93. * 更新condition数据
  94. * @param {Object} key 要更新的属性
  95. * @param {Object} value 值
  96. */
  97. myCommit: function(key, value) {
  98. let data = {...this.checkRent};
  99. data[key] = value;
  100. this.$store.commit({
  101. type: 'creatingSituations/comChangeState',
  102. key: 'checkRent',
  103. data
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="less">
  110. .check-rent {
  111. .list {
  112. .item {
  113. display: flex;
  114. flex-direction: row;
  115. justify-content: space-between;
  116. margin-bottom: 15rpx;
  117. padding: 25rpx;
  118. padding-right: 0;
  119. width: 100%;
  120. background-color: #fff;
  121. .img-wrap {
  122. width: 36.25rpx;
  123. image {
  124. width: 21.25rpx;
  125. height: 12.5rpx;
  126. }
  127. }
  128. .content {
  129. width: calc(100% - 36.25rpx);
  130. font-size: 20rpx;
  131. line-height: 30rpx;
  132. color: #666E80;
  133. .info {
  134. display: flex;
  135. flex-direction: row;
  136. justify-content: space-between;
  137. margin-top: -25rpx;
  138. .text {
  139. padding-top: 25rpx;
  140. view:first-child {
  141. margin-bottom: 25rpx;
  142. font-size: 25rpx;
  143. line-height: 37.5rpx;
  144. color: #292C33;
  145. }
  146. }
  147. .icon { // 图标样式,用view包裹img防止挤压变形
  148. padding-top: 25rpx;
  149. padding-left: 25rpx;
  150. width: 75rpx;
  151. height: inherit;
  152. image {
  153. width: 25rpx;
  154. height: 25rpx;
  155. }
  156. }
  157. }
  158. .chidren {
  159. margin-top: 25rpx;
  160. border-top: 1px solid #DADEE6;
  161. width: 100%;
  162. .chid-item {
  163. padding-top: 25rpx;
  164. padding-right: 25rpx;
  165. view {
  166. overflow: hidden;
  167. white-space: nowrap;
  168. text-overflow: ellipsis;
  169. &:first-child {
  170. padding-bottom: 15rpx;
  171. font-weight: bold;
  172. color: #292C33;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </style>