checkRent.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. theme: state => state.creatingSituations.theme,
  69. conditionCard: state => state.creatingSituations.conditionCard,
  70. })
  71. },
  72. watch:{
  73. keyword(val,oldVal){
  74. if(val.length == 0){
  75. this.getData();
  76. }
  77. }
  78. },
  79. created:function(){
  80. // 编辑的时候不用获取数据
  81. if(this.editConfig && arrayEquality(this.condition.conditionIds, this.editConfig.condition.conditionIds) && this.editConfig.checkRent) {
  82. this.$store.commit({
  83. type: 'creatingSituations/comChangeState',
  84. key: 'checkRent',
  85. data: this.editConfig.checkRent
  86. });
  87. } else if(this.needReload) { // 点击上一步不用获取数据
  88. this.getData();
  89. }
  90. },
  91. methods: {
  92. /**
  93. * @param {string} val
  94. */
  95. searchInputHandle(val){
  96. this.keyword = val;
  97. },
  98. searchHandle(){
  99. const {list,checkedItem} = this.checkRent;
  100. const filtedList = list.filter(t=>t.name.indexOf(this.keyword) != -1);
  101. this.myCommit('list', filtedList);
  102. if(checkedItem.id) { // 如果选中过,要去更新数据
  103. let obj = filtedList.find(({id})=>id === checkedItem.id);
  104. this.myCommit('checkedItem', obj?obj:{id:null});
  105. }
  106. },
  107. /**
  108. * @param {string} searchKey
  109. */
  110. getData(){
  111. this.$store.dispatch({
  112. type: 'creatingSituations/commActions',
  113. key: 'checkGroupList',
  114. data:this.condition.conditionIds
  115. }).then((data)=> {
  116. if(data) {
  117. this.myCommit('list', data);
  118. const {checkedItem} = this.checkRent;
  119. if(checkedItem.id) { // 如果选中过,要去更新数据
  120. let obj = data.find(({id})=>id === checkedItem.id);
  121. this.myCommit('checkedItem', obj?obj:{id:null});
  122. }
  123. }
  124. });
  125. },
  126. openItemHandle: function(key) {
  127. this.openItems = arrFilter(key, this.openItems);
  128. },
  129. checkedHandle: function(e, item) {
  130. _stopPropagation(e);
  131. this.myCommit('checkedItem', item);
  132. },
  133. /**
  134. * 更新condition数据
  135. * @param {Object} key 要更新的属性
  136. * @param {Object} value 值
  137. */
  138. myCommit: function(key, value) {
  139. let data = {...this.checkRent};
  140. data[key] = value;
  141. this.$store.commit({
  142. type: 'creatingSituations/comChangeState',
  143. key: 'checkRent',
  144. data
  145. });
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="less">
  151. .check-rent {
  152. .searchBar {
  153. display: flex;
  154. flex-direction: row;
  155. align-items: center;
  156. height: 87.5rpx;
  157. padding: 0 25rpx;
  158. margin-bottom: 15rpx;
  159. background: #FFFFFF;
  160. .serachIcon {
  161. width: 30rpx;
  162. height:30rpx;
  163. }
  164. .searchVal {
  165. width:85%;
  166. padding-left: 25rpx;
  167. font-size: 25rpx;
  168. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  169. font-weight: 400;
  170. color: #292C33;
  171. }
  172. .searchBtn {
  173. padding-left: 25rpx;
  174. font-size: 25rpx;
  175. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  176. font-weight: 400;
  177. color: #3377FF;
  178. border-left: 1rpx solid #DADEE6;
  179. }
  180. }
  181. .list {
  182. .empty {
  183. display: flex;
  184. height: 500rpx;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. &>image {
  189. width: 175rpx;
  190. height: 190rpx;
  191. margin-bottom: 40rpx;
  192. }
  193. &>text {
  194. font-size: 22.5rpx;
  195. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  196. font-weight: 400;
  197. color: #828899;
  198. }
  199. }
  200. .item {
  201. display: flex;
  202. flex-direction: row;
  203. justify-content: space-between;
  204. margin-bottom: 15rpx;
  205. padding: 25rpx;
  206. padding-right: 0;
  207. width: 100%;
  208. background-color: #fff;
  209. .img-wrap {
  210. width: 36.25rpx;
  211. image {
  212. width: 21.25rpx;
  213. height: 12.5rpx;
  214. }
  215. }
  216. .content {
  217. width: calc(100% - 36.25rpx);
  218. font-size: 20rpx;
  219. line-height: 30rpx;
  220. color: #666E80;
  221. .info {
  222. display: flex;
  223. flex-direction: row;
  224. justify-content: space-between;
  225. margin-top: -25rpx;
  226. .text {
  227. padding-top: 25rpx;
  228. view:first-child {
  229. margin-bottom: 25rpx;
  230. font-size: 25rpx;
  231. line-height: 37.5rpx;
  232. color: #292C33;
  233. }
  234. }
  235. .icon { // 图标样式,用view包裹img防止挤压变形
  236. padding-top: 25rpx;
  237. padding-left: 25rpx;
  238. width: 75rpx;
  239. height: inherit;
  240. image {
  241. width: 25rpx;
  242. height: 25rpx;
  243. }
  244. }
  245. }
  246. .chidren {
  247. margin-top: 25rpx;
  248. border-top: 1px solid #DADEE6;
  249. width: 100%;
  250. .chid-item {
  251. padding-top: 25rpx;
  252. padding-right: 25rpx;
  253. view {
  254. overflow: hidden;
  255. white-space: nowrap;
  256. text-overflow: ellipsis;
  257. &:first-child {
  258. padding-bottom: 15rpx;
  259. font-weight: bold;
  260. color: #292C33;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. </style>