checkRent.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="check-rent">
  3. <view class="title">请指定负责查核的查核组</view>
  4. <view class="searchBar">
  5. <image class="serachIcon" src="../../../static/searchIcon.png" mode=""></image>
  6. <tm-input class="searchVal" @onChange="searchInputHandle" placeholder="搜索查核组名称" ></tm-input>
  7. <view class="searchBtn" @click="searchHandle">搜索</view>
  8. </view>
  9. <view class="list">
  10. <view class="item"
  11. v-if="checkRent.list.length>0"
  12. v-for="(item, index) in checkRent.list"
  13. :key="index"
  14. @click="openItemHandle(item.id)">
  15. <view class="img-wrap">
  16. <image :src="`../../static/list-${openItems.includes(item.id)
  17. ?'close':'open'}.png`"></image>
  18. </view>
  19. <view class="content">
  20. <view class="info">
  21. <view class="text">
  22. <view>{{item.name}}</view>
  23. <view>组长:{{item.groupManagerName}}</view>
  24. </view>
  25. <view class="icon" @click="checkedHandle($event, item)">
  26. <image :src="`../../static/check-${checkRent.checkedItem.id === item.id ? 'radio' : 'no'}.png`"></image>
  27. </view>
  28. </view>
  29. <view class="chidren" v-if="openItems.includes(item.id)">
  30. <view class="chid-item">
  31. <view>小组成员</view>
  32. <view>{{item.members.join('、')}}</view>
  33. </view>
  34. <view class="chid-item">
  35. <view>负责要点</view>
  36. <view>
  37. <text>{{item.allPoints}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="empty" v-if="checkRent.list.length==0">
  44. <image src="../../../static/no-data.png" mode=""></image>
  45. <text>暂无内容</text>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { mapState } from "vuex";
  52. import {_stopPropagation} from "../../../utils/compatible.js";
  53. import {arrFilter} from "../../../utils/arrFilter.js";
  54. import {arrayEquality} from "./utils.js";
  55. export default {
  56. data() {
  57. return {
  58. openItems: [],
  59. keyword:''
  60. }
  61. },
  62. computed: {
  63. ...mapState({
  64. checkRent: state => state.creatingSituations.checkRent,
  65. condition: state => state.creatingSituations.condition,
  66. needReload: state => state.creatingSituations.needReload,
  67. editConfig: state => state.creatingSituations.editConfig
  68. })
  69. },
  70. watch:{
  71. keyword(val,oldVal){
  72. if(val.length == 0){
  73. this.getData();
  74. }
  75. }
  76. },
  77. created:function(){
  78. // 编辑的时候不用获取数据
  79. if(this.editConfig && arrayEquality(this.condition.conditionIds, this.editConfig.condition.conditionIds) && this.editConfig.checkRent) {
  80. this.$store.commit({
  81. type: 'creatingSituations/comChangeState',
  82. key: 'checkRent',
  83. data: this.editConfig.checkRent
  84. });
  85. } else if(this.needReload) { // 点击上一步不用获取数据
  86. this.getData();
  87. }
  88. },
  89. methods: {
  90. /**
  91. * @param {string} val
  92. */
  93. searchInputHandle(val){
  94. this.keyword = val;
  95. },
  96. searchHandle(){
  97. const {list,checkedItem} = this.checkRent;
  98. const filtedList = list.filter(t=>t.name.indexOf(this.keyword) != -1);
  99. this.myCommit('list', filtedList);
  100. if(checkedItem.id) { // 如果选中过,要去更新数据
  101. let obj = filtedList.find(({id})=>id === checkedItem.id);
  102. this.myCommit('checkedItem', obj?obj:{id:null});
  103. }
  104. },
  105. /**
  106. * @param {string} searchKey
  107. */
  108. getData(){
  109. this.$store.dispatch({
  110. type: 'creatingSituations/commActions',
  111. key: 'checkGroupList',
  112. data:this.condition.conditionIds
  113. }).then((data)=> {
  114. if(data) {
  115. this.myCommit('list', data);
  116. const {checkedItem} = this.checkRent;
  117. if(checkedItem.id) { // 如果选中过,要去更新数据
  118. let obj = data.find(({id})=>id === checkedItem.id);
  119. this.myCommit('checkedItem', obj?obj:{id:null});
  120. }
  121. }
  122. });
  123. },
  124. openItemHandle: function(key) {
  125. this.openItems = arrFilter(key, this.openItems);
  126. },
  127. checkedHandle: function(e, item) {
  128. _stopPropagation(e);
  129. this.myCommit('checkedItem', item);
  130. },
  131. /**
  132. * 更新condition数据
  133. * @param {Object} key 要更新的属性
  134. * @param {Object} value 值
  135. */
  136. myCommit: function(key, value) {
  137. let data = {...this.checkRent};
  138. data[key] = value;
  139. this.$store.commit({
  140. type: 'creatingSituations/comChangeState',
  141. key: 'checkRent',
  142. data
  143. });
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="less">
  149. .check-rent {
  150. .searchBar {
  151. display: flex;
  152. flex-direction: row;
  153. align-items: center;
  154. height: 87.5rpx;
  155. padding: 0 25rpx;
  156. margin-bottom: 15rpx;
  157. background: #FFFFFF;
  158. .serachIcon {
  159. width: 30rpx;
  160. height:30rpx;
  161. }
  162. .searchVal {
  163. width:85%;
  164. padding-left: 25rpx;
  165. font-size: 25rpx;
  166. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  167. font-weight: 400;
  168. color: #292C33;
  169. }
  170. .searchBtn {
  171. padding-left: 25rpx;
  172. font-size: 25rpx;
  173. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  174. font-weight: 400;
  175. color: #3377FF;
  176. border-left: 1rpx solid #DADEE6;
  177. }
  178. }
  179. .list {
  180. .empty {
  181. display: flex;
  182. height: 500rpx;
  183. flex-direction: column;
  184. justify-content: center;
  185. align-items: center;
  186. &>image {
  187. width: 175rpx;
  188. height: 190rpx;
  189. margin-bottom: 40rpx;
  190. }
  191. &>text {
  192. font-size: 22.5rpx;
  193. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  194. font-weight: 400;
  195. color: #828899;
  196. }
  197. }
  198. .item {
  199. display: flex;
  200. flex-direction: row;
  201. justify-content: space-between;
  202. margin-bottom: 15rpx;
  203. padding: 25rpx;
  204. padding-right: 0;
  205. width: 100%;
  206. background-color: #fff;
  207. .img-wrap {
  208. width: 36.25rpx;
  209. image {
  210. width: 21.25rpx;
  211. height: 12.5rpx;
  212. }
  213. }
  214. .content {
  215. width: calc(100% - 36.25rpx);
  216. font-size: 20rpx;
  217. line-height: 30rpx;
  218. color: #666E80;
  219. .info {
  220. display: flex;
  221. flex-direction: row;
  222. justify-content: space-between;
  223. margin-top: -25rpx;
  224. .text {
  225. padding-top: 25rpx;
  226. view:first-child {
  227. margin-bottom: 25rpx;
  228. font-size: 25rpx;
  229. line-height: 37.5rpx;
  230. color: #292C33;
  231. }
  232. }
  233. .icon { // 图标样式,用view包裹img防止挤压变形
  234. padding-top: 25rpx;
  235. padding-left: 25rpx;
  236. width: 75rpx;
  237. height: inherit;
  238. image {
  239. width: 25rpx;
  240. height: 25rpx;
  241. }
  242. }
  243. }
  244. .chidren {
  245. margin-top: 25rpx;
  246. border-top: 1px solid #DADEE6;
  247. width: 100%;
  248. .chid-item {
  249. padding-top: 25rpx;
  250. padding-right: 25rpx;
  251. view {
  252. overflow: hidden;
  253. white-space: nowrap;
  254. text-overflow: ellipsis;
  255. &:first-child {
  256. padding-bottom: 15rpx;
  257. font-weight: bold;
  258. color: #292C33;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>