searchFloor.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="content">
  3. <view class="df-fl">
  4. <view class="df-all">
  5. <checkbox-group @change="allCheckChange">
  6. <checkbox value="all" color="#42b983" :checked="allCheck"/>
  7. <text class="text">全选</text>
  8. </checkbox-group>
  9. </view>
  10. <view class="title">{{name}}</view>
  11. <view class="top-right">{{num}}/{{allNum}}</view>
  12. </view>
  13. <view class="search-keyword">
  14. <scroll-view class="keyword-list-box" scroll-y>
  15. <checkbox-group @change="checkboxChange">
  16. <view v-for="(row, index) in dataList" :key="index" class="view-box">
  17. <checkbox @click="paClick(row)" class="top-check1" color="#42b983" :value="row.floor.id" :checked="row.checked" />
  18. <view class="right-ab">{{row.num}}/{{row.children.length}}</view>
  19. <uni-collapse ref="collapse" v-model="row.floor.collapseValue">
  20. <uni-collapse-item :title="row.floor.floorName + '楼'">
  21. <view v-for="(item, index) in row.children" :key="item.id">
  22. <view class="keyword-entry">
  23. <view class="keyword-text">
  24. <checkbox @click="chClick(item)" class="top-check2" color="#42b983" :value="item.id" :checked="item.checked" />
  25. <view class="title-2">{{item.dept}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. </uni-collapse-item>
  30. </uni-collapse>
  31. </view>
  32. </checkbox-group>
  33. </scroll-view>
  34. </view>
  35. <view class="toolbar">
  36. <view class="back" @click="back()">返回</view>
  37. <view class="confirm" @click="confirm()">确定</view>
  38. </view>
  39. <!-- 弹窗 -->
  40. <showModel :title="models.title" :icon="models.icon" :disjunctor="models.disjunctor" :content="models.content" @know="know" :operate="models.operate"></showModel>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. post,
  46. webHandle
  47. } from "../../http/http.js";
  48. export default {
  49. data() {
  50. return {
  51. type: "", //进入该页面的类型
  52. configName: "", //快速组合名称
  53. id: "", //快速组合id
  54. name:"",
  55. changedept: 0, //是否从列表过来的切换负责科室
  56. hosId: "",
  57. dataList: [],
  58. //系统设置的科室类型
  59. sysDeptType: 0,
  60. quickCombinationDeptType: 0,
  61. // 弹窗model
  62. models: {
  63. disjunctor: false,
  64. },
  65. valueColl:false,
  66. allCheck:false,
  67. buildIds:[],
  68. pid:[],
  69. cid:[],
  70. allNum:0,
  71. num:0
  72. };
  73. },
  74. onLoad(options) {
  75. this.hosId = uni.getStorageSync("userData").user.currentHospital.id;
  76. console.log(options, 'options');
  77. this.name = options.name
  78. this.id = options.id;
  79. this.configName = options.configName;
  80. this.changedept = options.changedept;
  81. this.getBuildings();
  82. // #ifdef APP-PLUS
  83. webHandle("no", "app");
  84. // #endif
  85. // #ifdef H5
  86. webHandle("no", "wx");
  87. // #endif
  88. },
  89. onShow(){
  90. // this.getBuildings();
  91. },
  92. methods: {
  93. // 全选
  94. allCheckChange(e){
  95. this.num = 0
  96. if(e.detail.value.length>0){
  97. this.dataList.forEach((item, index)=>{
  98. item.checked = true
  99. if(item.children && item.children.length>0){
  100. for(let i of item.children){
  101. i.checked = true
  102. this.buildIds.push(i)
  103. }
  104. }
  105. item.num = item.children.filter(x=>x.checked).length
  106. this.num += item.num
  107. })
  108. }else{
  109. this.dataList.forEach((item, index)=>{
  110. item.checked = false
  111. if(item.children && item.children.length>0){
  112. for(let i of item.children){
  113. i.checked = false
  114. this.buildIds = []
  115. }
  116. }
  117. item.num = item.children.filter(x=>x.checked).length
  118. this.num += item.num
  119. })
  120. }
  121. // this.buildIds = this.buildIds.filter(v => v.indexOf('parent')==-1);
  122. console.log(888,this.buildIds)
  123. },
  124. //知道了
  125. know() {
  126. this.models.disjunctor = false;
  127. },
  128. back(){
  129. uni.navigateBack({
  130. delta: 1,
  131. })
  132. },
  133. paClick(row){
  134. if(row.checked){
  135. row.checked = false
  136. }else{
  137. row.checked = true
  138. }
  139. for(let item of row.children){
  140. if (row.checked) {
  141. this.$set(item, 'checked', true)
  142. } else {
  143. this.$set(item, 'checked', false)
  144. }
  145. }
  146. this.num = 0
  147. for (let i of this.dataList) {
  148. i.num = i.children.filter(x=>x.checked).length
  149. this.num += i.num
  150. }
  151. console.log(44545454,this.dataList)
  152. },
  153. chClick(row){
  154. this.num = 0
  155. if(row.checked){
  156. row.checked = false
  157. }else{
  158. row.checked = true
  159. }
  160. for (let i of this.dataList) {
  161. i.num = i.children.filter(x=>x.checked).length
  162. this.num += i.num
  163. }
  164. },
  165. // 确认
  166. confirm() {
  167. let data = uni.getStorageSync("setDepts")
  168. let dataList = []
  169. this.dataList.forEach(i=>{
  170. for(let i of i.children){
  171. if(i.checked){
  172. dataList.push(i)
  173. }
  174. }
  175. })
  176. console.log(3333,dataList);
  177. if (dataList.length === 0) {
  178. this.models = {
  179. disjunctor: true,
  180. title: "提示",
  181. content: "请选择至少一个楼层",
  182. icon: "warn",
  183. operate: {
  184. know: "知道了",
  185. },
  186. };
  187. } else {
  188. let allData = null
  189. let data = uni.getStorageSync("setDepts")
  190. if(data){
  191. data.forEach(i=>{
  192. dataList.push(i)
  193. })
  194. allData = dataList
  195. }else{
  196. allData = dataList
  197. }
  198. let newList2 = []
  199. let newList3 = []
  200. allData.forEach((item) => {
  201. if (!newList2.includes(item.id)) {
  202. newList2.push(item.id)
  203. }
  204. })
  205. newList2.forEach(i=>{
  206. newList3.push(allData.find(x=> x.id == i))
  207. })
  208. // console.log(555,newList3)
  209. uni.setStorageSync("setDepts", newList3)
  210. uni.navigateTo({
  211. url: `../setDept/setDept?configName=${this.configName}&id=${this.id}&changedept=${this.changedept}`,
  212. });
  213. }
  214. },
  215. // 选择楼栋
  216. itemClick(item){
  217. },
  218. changeColl(){
  219. },
  220. // 选择楼栋
  221. checkboxChange: function(e) {
  222. },
  223. //获取楼栋列表
  224. getBuildings() {
  225. this.allNum = 0
  226. let data = uni.getStorageSync("floorList")
  227. data.forEach((item, index)=>{
  228. item.num = 0
  229. item.floor.collapseValue = []
  230. item.floor.id = item.floor.id.toString() + 'parent'
  231. item.checked = false
  232. this.allNum += item.children.length
  233. if(item.children && item.children.length>0){
  234. for(let i of item.children){
  235. i.checked = false
  236. i.id = i.id.toString()
  237. i.floor.id = i.floor.id.toString() + 'parent'
  238. }
  239. }
  240. })
  241. console.log(3232131,this.allNum)
  242. this.dataList = data || [];
  243. }
  244. },
  245. };
  246. </script>
  247. <style>
  248. uni-checkbox-group{
  249. /* display: flex;
  250. align-items: center;
  251. position: relative; */
  252. }
  253. /deep/ .uni-collapse-item__title-box{
  254. margin-left: 50rpx
  255. }
  256. </style>
  257. <style scoped lang="less">
  258. view {
  259. display: block;
  260. }
  261. .df-fl{
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. position: relative;
  266. .top-right{
  267. position: absolute;
  268. right: 40rpx;
  269. }
  270. }
  271. .df-all{
  272. position: absolute;
  273. left: 16rpx;
  274. .text{
  275. margin-left: 8rpx;
  276. }
  277. }
  278. .view-box{
  279. position: relative;
  280. }
  281. .top-check1{
  282. position: absolute;
  283. left: 0;
  284. top: 20rpx;
  285. z-index: 999;
  286. }
  287. .top-check2{
  288. position: absolute;
  289. left: 0;
  290. top: 20rpx;
  291. z-index: 999;
  292. }
  293. .right-ab{
  294. position: absolute;
  295. right: 64rpx;
  296. top: 28rpx;
  297. z-index: 999;
  298. color: #303133;
  299. }
  300. .title{
  301. padding: 30rpx;
  302. font-size: 32rpx;
  303. text-align: center;
  304. font-weight: bold;
  305. }
  306. // 底部
  307. .toolbar {
  308. position: fixed;
  309. left: 0;
  310. right: 0;
  311. bottom: 30rpx;
  312. width: 96%;
  313. margin-left: 2%;
  314. z-index: 9999;
  315. height: 88rpx;
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. box-sizing: border-box;
  320. color: #fff;
  321. .back{
  322. width: 48%;
  323. height: 88rpx;
  324. display: flex;
  325. justify-content: center;
  326. align-items: center;
  327. box-sizing: border-box;
  328. border-radius: 10rpx;
  329. background-color: #8F939C;
  330. }
  331. .confirm{
  332. width: 46%;
  333. height: 88rpx;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. box-sizing: border-box;
  338. border-radius: 10rpx;
  339. background-color: #49B856;
  340. }
  341. }
  342. .search-box {
  343. width: 95%;
  344. background-color: rgb(242, 242, 242);
  345. padding: 15upx 2.5%;
  346. display: flex;
  347. justify-content: space-between;
  348. position: sticky;
  349. top: 0;
  350. }
  351. .search-box .mSearch-input-box {
  352. width: 100%;
  353. }
  354. .search-box .input-box {
  355. width: 85%;
  356. flex-shrink: 1;
  357. display: flex;
  358. justify-content: center;
  359. align-items: center;
  360. }
  361. .search-box .search-btn {
  362. width: 15%;
  363. margin: 0 0 0 2%;
  364. display: flex;
  365. justify-content: flex-start;
  366. align-items: center;
  367. flex-shrink: 0;
  368. font-size: 28upx;
  369. color: #fff;
  370. background: linear-gradient(to right, #ff9801, #ff570a);
  371. border-radius: 60upx;
  372. }
  373. .search-box .input-box>input {
  374. width: 100%;
  375. height: 60upx;
  376. font-size: 32upx;
  377. border: 0;
  378. border-radius: 60upx;
  379. -webkit-appearance: none;
  380. -moz-appearance: none;
  381. appearance: none;
  382. padding: 0 3%;
  383. margin: 0;
  384. background-color: #ffffff;
  385. }
  386. .placeholder-class {
  387. color: #9e9e9e;
  388. }
  389. .search-keyword {
  390. width: 100%;
  391. background-color: rgb(242, 242, 242);
  392. }
  393. .keyword-list-box {
  394. height: calc(100vh - 230rpx);
  395. padding-top: 10upx;
  396. // padding: 0 20rpx;
  397. border-radius: 20upx 20upx 0 0;
  398. background-color: #fff;
  399. width: 96%;
  400. padding-left: 2%;
  401. }
  402. .keyword-entry-tap {
  403. background-color: #eee;
  404. }
  405. .keyword-entry {
  406. width: 94%;
  407. height: 80rpx;
  408. margin: 0 3%;
  409. font-size: 30rpx;
  410. color: #333;
  411. display: flex;
  412. justify-content: start;
  413. align-items: center;
  414. border-bottom: solid 1rpx #DEDEDE;
  415. }
  416. .keyword-entry image {
  417. width: 60upx;
  418. height: 60upx;
  419. }
  420. .keyword-entry .keyword-text,
  421. .keyword-entry .keyword-img {
  422. height: 80upx;
  423. display: flex;
  424. align-items: center;
  425. position: relative;
  426. }
  427. .title-2{
  428. padding-left: 76rpx;
  429. }
  430. .keyword-entry .keyword-text {
  431. // width: 90%;
  432. }
  433. .keyword-entry .keyword-img {
  434. width: 10%;
  435. justify-content: center;
  436. }
  437. .keyword-box {
  438. height: calc(100vh - 110upx);
  439. border-radius: 20upx 20upx 0 0;
  440. background-color: #fff;
  441. }
  442. .keyword-box .keyword-block {
  443. padding: 10upx 0;
  444. }
  445. .keyword-box .keyword-block .keyword-list-header {
  446. width: 94%;
  447. padding: 10upx 3%;
  448. font-size: 27upx;
  449. color: #333;
  450. display: flex;
  451. justify-content: space-between;
  452. }
  453. .keyword-box .keyword-block .keyword-list-header image {
  454. width: 40upx;
  455. height: 40upx;
  456. }
  457. .keyword-box .keyword-block .keyword {
  458. width: 94%;
  459. padding: 3px 3%;
  460. display: flex;
  461. flex-flow: wrap;
  462. justify-content: flex-start;
  463. }
  464. .keyword-box .keyword-block .hide-hot-tis {
  465. display: flex;
  466. justify-content: center;
  467. font-size: 28upx;
  468. color: #6b6b6b;
  469. }
  470. .keyword-box .keyword-block .keyword>view {
  471. display: flex;
  472. justify-content: center;
  473. align-items: center;
  474. border-radius: 60upx;
  475. padding: 0 20upx;
  476. margin: 10upx 20upx 10upx 0;
  477. height: 60upx;
  478. font-size: 28upx;
  479. background-color: rgb(242, 242, 242);
  480. color: #6b6b6b;
  481. }
  482. </style>