responsibleList.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <view class="searchBar">
  5. <input class="inputArea" @input="keywordsHandle" type="text" v-model="keywords" placeholder="搜索当事人" placeholder-class="placeholder" />
  6. <view class="searchActiver" @click="searchHandle">
  7. <image class="searchIcon" src="../../static/search.png" mode=""></image>
  8. </view>
  9. </view>
  10. <view class="tabWrap">
  11. <view @click="tabClick(0)" :class="[currentTabIndex==0?'tab on':'tab']">全院</view>
  12. <view @click="tabClick(1)" :class="[currentTabIndex==1?'tab on':'tab']">当前病区</view>
  13. </view>
  14. </view>
  15. <view class="content">
  16. <index-list :padding='padding' v-on:listClick="listClickHandle" :checkedResponsibleList='checkedResponsibleList' :options="list"></index-list>
  17. </view>
  18. <view class="bottom">
  19. <view class="selectAll" @click="selectAllHandle">
  20. <image v-if="selectAll" class="icon" src="../../static/selectAll.png" mode=""></image>
  21. <image v-if="!selectAll" class="icon" src="../../static/selectAllnoclor.png" mode=""></image>
  22. <text :class="[selectAll?'text on':'text']">{{selectAll?'取消':'全选'}}</text>
  23. </view>
  24. <view class="cancelBtn" @click="cancelCheck">取消</view>
  25. <view class="comfirm" @click="sureCheck">确定</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import indexList from '../../components/index-list/index-list.vue';
  31. export default {
  32. data() {
  33. return {
  34. currentTabIndex:0,
  35. checkedResponsibleListTemp:[],
  36. checkedResponsibleListTemp_all:[],
  37. checkedResponsibleListTemp_dept:[],
  38. checkedResponsibleList:[],//已选择的当事人列表
  39. list:[],
  40. checkId:'',
  41. padding:0,
  42. deptId:'',
  43. keywords:'',
  44. deptIdTemp:'',
  45. selectAll:false,
  46. isFromCheckMainPoints:false,
  47. };
  48. },
  49. onLoad({deptId,isFromCheckMainPoints,checkId}) {
  50. this.deptIdTemp = deptId;
  51. this.isFromCheckMainPoints = isFromCheckMainPoints;
  52. if(checkId)this.checkId = checkId
  53. },
  54. onShow() {
  55. const {responsibleList} = this.$store.state;
  56. // console.log({responsibleList});
  57. this.checkedResponsibleList = responsibleList.checkedResponsibleList;
  58. },
  59. computed:{
  60. },
  61. mounted(){
  62. this.getResponsibleList();
  63. //设置当事人页面滚动距离顶部距离
  64. uni
  65. .createSelectorQuery()
  66. .in(this)
  67. .select('.top')
  68. .boundingClientRect()
  69. .exec(res => {
  70. if (res[0]) {
  71. this.padding = res[0].height;
  72. // resolve(res[0].top);
  73. } else {
  74. that.$nextTick(() => {
  75. ++count <= 8 ? getHeight() : this.padding = 0;
  76. });
  77. }
  78. });
  79. },
  80. onUnload(){
  81. this.checkedResponsibleList=[];
  82. },
  83. methods:{
  84. bindClick(){
  85. },
  86. selectAllHandle(){
  87. if(!this.selectAll){
  88. this.selectAll = true;
  89. const getResponsibleListIds = (arr,index)=>{
  90. if(index == arr.length-1){
  91. return arr[index].data
  92. }
  93. return arr[index].data.concat(getResponsibleListIds(arr,index+1))
  94. }
  95. this.checkedResponsibleList = getResponsibleListIds(this.list,0);
  96. }else {
  97. this.selectAll = false;
  98. this.checkedResponsibleList = [];
  99. }
  100. // console.log('selectAllHandle',this.checkedResponsibleList);
  101. },
  102. keywordsHandle(e){
  103. if(e.target.value.length==0){
  104. this.getResponsibleList();
  105. }
  106. this.keywords = e.target.value;
  107. },
  108. searchHandle(){
  109. this.getResponsibleList();
  110. },
  111. //获取当时人列表
  112. getResponsibleList(){
  113. this.$store.dispatch({
  114. type: "responsibleList/commActions",
  115. payload: {
  116. key: "getResponsibleList",
  117. data: {
  118. deptId:this.deptId,
  119. keywords:this.keywords
  120. },
  121. }
  122. }).then((data)=>{
  123. this.list = data;
  124. })
  125. },
  126. //当事人列表点击handle
  127. listClickHandle(checkedList){
  128. if(this.currentTabIndex == 0){
  129. //全院
  130. this.checkedResponsibleListTemp_all = checkedList;
  131. }
  132. if(this.currentTabIndex == 1){
  133. //当前病区
  134. this.checkedResponsibleListTemp_dept = checkedList;
  135. }
  136. // console.log(this.currentTabIndex,this.checkedResponsibleListTemp_all,this.checkedResponsibleListTemp_dept)
  137. },
  138. sureCheck(){
  139. const responsibleUserIds = this.currentTabIndex == 0?this.checkedResponsibleListTemp_all.map(item=>item.id):this.checkedResponsibleListTemp_dept.map(item=>item.id);
  140. const responsibleUserNames = this.currentTabIndex == 0?this.checkedResponsibleListTemp_all.map(item=>item.main):this.checkedResponsibleListTemp_dept.map(item=>item.main);
  141. // console.log(this.currentTabIndex,this.checkedResponsibleListTemp_all,this.checkedResponsibleListTemp_dept)
  142. // console.log({responsibleUserIds,responsibleUserNames});
  143. // return;
  144. if(this.isFromCheckMainPoints){
  145. //批量保存当事人
  146. const {checkMainPoints:{detailList}} = this.$store.state;
  147. const detailListFlat = (arr,index)=>{
  148. if(index == arr.length-1){
  149. return arr[index].responseList
  150. }
  151. return arr[index].responseList.concat(detailListFlat(arr,index+1))
  152. }
  153. const tempCheckIds = detailListFlat(detailList,0);
  154. const checkIds = tempCheckIds.map(item=>item.id);
  155. this.$store.dispatch({
  156. type: "responsibleList/commActions",
  157. payload: {
  158. key: "bindCheckDetailResponsibleUser",
  159. data: {
  160. responsibleUserId:responsibleUserIds.join(','),
  161. responsibleUserName:responsibleUserNames.join(','),
  162. checkIds:checkIds,
  163. },
  164. }
  165. }).then((data)=>{
  166. uni.showModal({
  167. title: '提示',
  168. content: '批量分配当事人成功!',
  169. showCancel:false,
  170. success:(res)=>{
  171. if (res.confirm) {
  172. uni.navigateBack({
  173. delta: 1
  174. });
  175. }
  176. }
  177. });
  178. })
  179. }else {
  180. this.$store.dispatch({
  181. type: "responsibleList/commActions",
  182. payload: {
  183. key: "bindCheckDetailResponsibleUser",
  184. data: {
  185. responsibleUserId:responsibleUserIds.join(','),
  186. responsibleUserName:responsibleUserNames.join(','),
  187. checkIds:[parseInt(this.checkId)],
  188. },
  189. }
  190. });
  191. this.$store.commit('responsibleList/updateCheckedResponsibleList',this.currentTabIndex == 0?this.checkedResponsibleListTemp_all:this.checkedResponsibleListTemp_dept);
  192. uni.navigateBack({
  193. delta: 1
  194. });
  195. }
  196. },
  197. cancelCheck(){
  198. uni.navigateBack({
  199. delta: 1
  200. });
  201. },
  202. tabClick(index){
  203. if(index==1){
  204. this.deptId = this.deptIdTemp;
  205. }else {
  206. this.deptId ='';
  207. }
  208. // this.checkedResponsibleListTemp = [],
  209. // this.checkedResponsibleList = [],
  210. this.getResponsibleList();
  211. this.currentTabIndex = index;
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="less">
  217. .container {
  218. display: flex;
  219. height: 100%;
  220. flex-direction: column;
  221. .top { position: relative;
  222. z-index: 10;
  223. height:170rpx;
  224. padding: 0 25rpx;
  225. padding-top: 18.75rpx;
  226. background-color: #FFFFFF;
  227. box-sizing: border-box;
  228. box-shadow: 0px 3.75rpx 12.5rpx 0px rgba(0, 13, 51, 0.1);
  229. .searchBar {
  230. display: flex;
  231. flex-direction: row;
  232. justify-content: space-evenly;
  233. align-items: center;
  234. height: 55rpx;
  235. background: #F0F2F7;
  236. border-radius: 5rpx;
  237. padding-left: 25rpx;
  238. .inputArea {
  239. flex-grow:0.9;
  240. font-size: 22.5rpx;
  241. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  242. font-weight: 400;
  243. }
  244. .placeholder {
  245. font-size: 22.5rpx;
  246. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  247. font-weight: 400;
  248. color: #A1A7B3;
  249. }
  250. .searchActiver {
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. flex-grow: 0.1;
  255. height:100%;
  256. .searchIcon {
  257. width: 21.25rpx;
  258. height: 21.25rpx;
  259. }
  260. }
  261. }
  262. .tabWrap {
  263. display: flex;
  264. flex-direction: row;
  265. justify-content: space-around;
  266. align-items: center;
  267. margin-top: 25rpx;
  268. .tab {
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. width: 325rpx;
  273. height: 50rpx;
  274. font-size: 22.5rpx;
  275. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  276. font-weight: 400;
  277. color: #292C33;
  278. background: #EBEFF7;
  279. border-radius: 25rpx;
  280. &.on {
  281. color: #FFFFFF;
  282. background: #3377FF;
  283. }
  284. }
  285. }
  286. }
  287. .content {
  288. flex: 1;
  289. overflow: hidden;
  290. }
  291. .bottom {
  292. display: flex;
  293. flex-direction: row;
  294. height:75rpx;
  295. border-top: 0.62rpx solid #DADEE6;
  296. background-color: #FFFFFF;
  297. .selectAll {
  298. display: flex;
  299. width: 20%;
  300. flex-direction: row;
  301. justify-content: center;
  302. align-items: center;
  303. .icon {
  304. width: 25rpx;
  305. height: 24.37rpx;
  306. margin-right: 15rpx;
  307. }
  308. .text {
  309. font-size: 22.5rpx;
  310. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  311. font-weight: 400;
  312. color: #8F9BB3;
  313. &.on {
  314. color:#3377FF;
  315. }
  316. }
  317. }
  318. .cancelBtn {
  319. display: flex;
  320. width: 40%;
  321. height: 100%;
  322. justify-content: center;
  323. align-items: center;
  324. font-size: 22.5rpx;
  325. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  326. font-weight: 400;
  327. color: #3377FF;
  328. border-left: 0.62rpx solid #DADEE6;
  329. }
  330. .comfirm {
  331. display: flex;
  332. width: 40%;
  333. height: 100%;
  334. font-size: 22.5rpx;
  335. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  336. font-weight: 400;
  337. color: #FFFFFF;
  338. justify-content: center;
  339. align-items: center;
  340. background: #3377FF;
  341. }
  342. }
  343. }
  344. </style>