person.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="person">
  3. <view class="title">请指定查核人</view>
  4. <view class="searchBar" >
  5. <view class="filter">
  6. <view class="selecter" @click="selecterHandle">
  7. <text>{{selectedStr}}</text>
  8. <image src="../../../static/fillBlackArrow.png" mode=""></image>
  9. </view>
  10. <view class="searchBar">
  11. <image class="serachIcon" src="../../../static/searchIcon.png" mode=""></image>
  12. <tm-input class="searchVal" :clear="ifclearSearch" @onChange="searchInputHandle"
  13. placeholder="请输入人员名称"></tm-input>
  14. <view class="searchBtn" @click="searchHandle">搜索</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="list">
  19. <view class="item" v-for="(item,index) in copiedDepList">
  20. <view class="itemInner">
  21. <text>{{item.empName}}</text>
  22. <text>{{item.empId}}</text>
  23. <text>{{item.departmentName}}</text>
  24. </view>
  25. <view class="icon" @click="checkedHandle($event, item)">
  26. <image
  27. :src="`../../static/check-${ checkPerson.checkedItems&&(checkPerson.checkedItems.findIndex(val=>val.empId == item.empId)) != -1 ? 'checkbox' : 'no'}.png`">
  28. </image>
  29. </view>
  30. </view>
  31. </view>
  32. <uni-popup ref="popup" type="bottom" :maskClick="true">
  33. <view class="selectableList">
  34. <scroll-view scroll-y="true" class="listWrap">
  35. <view :class="getClass(v.id)" v-for="(v,i) in selectables" @click="listClickHandle(v)">
  36. {{`${v.name}`}}
  37. </view>
  38. </scroll-view>
  39. <view class="btnGroup">
  40. <view class="cancelBtn btn" @click="btnGroupClickHandle(false)">取消</view>
  41. <view class="confirmBtn btn" @click="btnGroupClickHandle(true)">确定</view>
  42. </view>
  43. </view>
  44. </uni-popup>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. mapState
  50. } from "vuex";
  51. import {
  52. _stopPropagation
  53. } from "../../../utils/compatible.js";
  54. import {
  55. arrFilter
  56. } from "../../../utils/arrFilter.js";
  57. import {
  58. arrayEquality
  59. } from "./utils.js";
  60. export default {
  61. data() {
  62. return {
  63. openItems: [],
  64. keyword: '',
  65. depList:[],
  66. selectables:[
  67. {
  68. name: '全部单位',
  69. id: 0
  70. }
  71. ],
  72. ifclearSearch:false,
  73. copiedDepList: [], //筛选后结果
  74. //筛选条件
  75. filter: {
  76. keyword: '',
  77. status: [{
  78. name: '全部单位',
  79. id: 0
  80. }]
  81. },
  82. }
  83. },
  84. computed: {
  85. ...mapState({
  86. checkPerson: state => state.creatingSituations.checkPerson,
  87. checkRent: state => state.creatingSituations.checkRent,
  88. condition: state => state.creatingSituations.condition,
  89. needReload: state => state.creatingSituations.needReload,
  90. editConfig: state => state.creatingSituations.editConfig
  91. }),
  92. selectedStr() {
  93. const {
  94. status
  95. } = this.filter;
  96. return (status.map(t => t.name)).join(',')
  97. },
  98. },
  99. watch: {
  100. // filter(val, oldVal) {
  101. // if (val.keyword.length == 0) {
  102. // this.searchHandle();
  103. // }
  104. // }
  105. },
  106. created: function() {
  107. // 编辑的时候不用获取数据
  108. if (this.editConfig && arrayEquality(this.checkPerson, this.editConfig.checkPerson) && this.editConfig
  109. .checkPerson) {
  110. this.$store.commit({
  111. type: 'creatingSituations/comChangeState',
  112. key: 'checkPerson',
  113. data: this.editConfig.checkPerson
  114. });
  115. } else if (this.needReload) { // 点击上一步不用获取数据
  116. this.getData();
  117. }
  118. },
  119. methods: {
  120. /**
  121. * @param {string} val
  122. */
  123. searchInputHandle(val) {
  124. this.filter = {
  125. ...this.filter,
  126. keyword: val
  127. };
  128. },
  129. searchHandle() {
  130. const {keyword,status} = this.filter;
  131. if(keyword.length == 0){
  132. let results = this.checkPerson.list.filter(item=>item.departmentName.indexOf(status[0].name) != -1 );
  133. this.copiedDepList = results;
  134. }
  135. const filtedList = this.copiedDepList.filter(t => t.empName.indexOf(keyword) != -1);
  136. this.copiedDepList = filtedList;
  137. // if (checkedItem.id) { // 如果选中过,要去更新数据
  138. // let obj = filtedList.find(({
  139. // id
  140. // }) => id === checkedItem.id);
  141. // this.myCommit('checkedItem', obj ? obj : {
  142. // id: null
  143. // });
  144. // }
  145. },
  146. /**
  147. * @param {boolean} flag true确定按钮点击,false取消按钮
  148. */
  149. btnGroupClickHandle(flag) {
  150. this.$refs.popup.close();
  151. const {status} = this.filter;
  152. if(flag){
  153. if(status[0].id == 0){
  154. this.copiedDepList = this.checkPerson.list;
  155. }else{
  156. let results = this.checkPerson.list.filter(item=>item.departmentName.indexOf(status[0].name) != -1 );
  157. this.copiedDepList = results;
  158. }
  159. }else{
  160. //清空搜索
  161. this.filter = {
  162. ...this.filter,
  163. keyword: ''
  164. }
  165. }
  166. },
  167. selecterHandle() {
  168. this.$refs.popup.open();
  169. },
  170. getClass(id) {
  171. const ids = this.filter.status.map(item => item.id);
  172. if (ids.indexOf(id) != -1) {
  173. return "list on"
  174. }
  175. return "list"
  176. },
  177. /**
  178. * @param {string} searchKey
  179. */
  180. getData() {
  181. this.$store.dispatch({
  182. type: 'creatingSituations/commActions',
  183. key: 'getCheckPersonLists',
  184. data: {
  185. 'filterList': this.condition.conditionIds,
  186. 'situationId':Number(this.checkPerson.situationId)
  187. }
  188. }).then((data) => {
  189. console.log({data})
  190. if (data) {
  191. this.myCommit('list', data);
  192. this.copiedDepList = data;
  193. let nodedup_depList = data.map((item,index)=>item.departmentName);
  194. let depList = Array.from(new Set(nodedup_depList));
  195. let _depList = depList.map((item,index)=>({name:item,id:index+1}));
  196. this.depList = [...this.depList,..._depList];
  197. this.selectables = [...this.selectables,..._depList];
  198. // const {checkedItem} = this.checkPerson;
  199. // if(checkedItem.id) { // 如果选中过,要去更新数据
  200. // let obj = data.find(({id})=>id === checkedItem.id);
  201. // this.myCommit('checkPerson', obj?obj:{id:null});
  202. // }
  203. }
  204. });
  205. },
  206. listClickHandle(item) {
  207. this.filter = {
  208. ...this.filter,
  209. status: [
  210. item
  211. ]
  212. };
  213. },
  214. openItemHandle: function(key) {
  215. this.openItems = arrFilter(key, this.openItems);
  216. },
  217. checkedHandle: function(e, item) {
  218. _stopPropagation(e);
  219. let _checkedPersons = this.checkPerson.checkedItems;
  220. console.log('this.checkPerson',this.checkPerson)
  221. const index = this.checkPerson.checkedItems.findIndex(val => val.empId == item.empId);
  222. if (index != -1) {
  223. //取消选中
  224. _checkedPersons.splice(index, 1);
  225. } else {
  226. //选中
  227. _checkedPersons.push(item);
  228. }
  229. this.myCommit('checkedItems', _checkedPersons);
  230. },
  231. /**
  232. * 更新condition数据
  233. * @param {Object} key 要更新的属性
  234. * @param {Object} value 值
  235. */
  236. myCommit: function(key, value) {
  237. let data = {
  238. ...this.checkPerson
  239. };
  240. data[key] = value;
  241. this.$store.commit({
  242. type: 'creatingSituations/comChangeState',
  243. key: 'checkPerson',
  244. data
  245. });
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="less" scoped>
  251. .person {
  252. // padding: 15rpx;
  253. .selectableList {
  254. display: flex;
  255. width: 100%;
  256. flex-direction: column;
  257. height: 50vh;
  258. padding-top: 50rpx;
  259. box-sizing: border-box;
  260. border-radius: 25rpx 25rpx 0px 0px;
  261. background-color: #FFFFFF;
  262. .listWrap {
  263. height: calc(50vh - 75rpx);
  264. overflow-y: scroll;
  265. .list {
  266. height: 87.5rpx;
  267. line-height: 87.5rpx;
  268. text-align: center;
  269. font-size: 30rpx;
  270. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  271. font-weight: 400;
  272. color: #8A8F99;
  273. &.on {
  274. font-weight: 500;
  275. color: #3377FF;
  276. }
  277. }
  278. }
  279. .btnGroup {
  280. display: flex;
  281. width: 100%;
  282. flex-direction: row;
  283. justify-content: center;
  284. align-items: center;
  285. .btn {
  286. width: 50%;
  287. height: 75rpx;
  288. line-height: 75rpx;
  289. text-align: center;
  290. font-size: 22.5rpx;
  291. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  292. font-weight: 400;
  293. color: #3377FF;
  294. }
  295. .cancelBtn {
  296. border-top: 0.62rpx solid #DADEE6;
  297. }
  298. .confirmBtn {
  299. color: #FFFFFF;
  300. background: #3377FF;
  301. }
  302. }
  303. }
  304. .searchBar {
  305. width: 100%%;
  306. margin: 0 auto;
  307. .filter {
  308. display: flex;
  309. flex-direction: row;
  310. justify-content: space-between;
  311. align-items: center;
  312. margin-bottom: 15rpx;
  313. padding: 0 25rpx;
  314. background: #FFFFFF;
  315. .selecter {
  316. display: flex;
  317. width: 25%;
  318. height: 70rpx;
  319. flex-direction: row;
  320. justify-content: space-between;
  321. align-items: center;
  322. padding-right: 25rpx;
  323. border-right: 0.62rpx solid #DADEE6;
  324. &>text {
  325. width: 112.5rpx;
  326. font-size: 25rpx;
  327. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  328. font-weight: 500;
  329. color: #292C33;
  330. text-overflow: ellipsis;
  331. overflow: hidden;
  332. white-space: nowrap;
  333. }
  334. &>image {
  335. width: 11.25rpx;
  336. height: 7.5rpx;
  337. }
  338. }
  339. .searchBar {
  340. display: flex;
  341. width: 75%;
  342. flex-direction: row;
  343. align-items: center;
  344. height: 70rpx;
  345. padding-left: 25rpx;
  346. .serachIcon {
  347. width: 25rpx;
  348. height: 25rpx;
  349. }
  350. .searchVal {
  351. width: 79%;
  352. padding-left: 25rpx;
  353. font-size: 25rpx;
  354. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  355. font-weight: 400;
  356. color: #292C33;
  357. }
  358. .searchBtn {
  359. padding-left: 25rpx;
  360. font-size: 25rpx;
  361. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  362. font-weight: 400;
  363. color: #3377FF;
  364. white-space: nowrap;
  365. border-left: 1rpx solid #DADEE6;
  366. }
  367. }
  368. }
  369. }
  370. .list {
  371. .empty {
  372. display: flex;
  373. height: 500rpx;
  374. flex-direction: column;
  375. justify-content: center;
  376. align-items: center;
  377. &>image {
  378. width: 175rpx;
  379. height: 190rpx;
  380. margin-bottom: 40rpx;
  381. }
  382. &>text {
  383. font-size: 22.5rpx;
  384. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  385. font-weight: 400;
  386. color: #828899;
  387. }
  388. }
  389. .item {
  390. display: flex;
  391. flex-direction: row;
  392. justify-content: space-between;
  393. align-items: center;
  394. height: 87.5rpx;
  395. padding: 0 25rpx;
  396. background: #FFFFFF;
  397. .itemInner {
  398. &>text {
  399. font-size: 22.5rpx;
  400. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  401. font-weight: 400;
  402. color: #292C33;
  403. padding-right: 20rpx;
  404. }
  405. }
  406. .icon {
  407. // 图标样式,用view包裹img防止挤压变形
  408. display: flex;
  409. justify-content: center;
  410. align-items: center;
  411. height: inherit;
  412. image {
  413. width: 25rpx;
  414. height: 25rpx;
  415. }
  416. }
  417. }
  418. }
  419. }
  420. </style>