IncidentListFilter.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <view class="container" @touchmove.stop.prevent v-if="pageData.pageRouter === 'default'">
  3. <view class="container_form">
  4. <view class="hospital" v-if="!showDept">
  5. <text class="name">院区</text>
  6. <text class="value">{{loginUserStore.loginUser.user.currentHospital.hosName}}</text>
  7. </view>
  8. <view class="category" v-if="showDept">
  9. <text class="name">维修科室</text>
  10. <text class="value flex-1">
  11. <uni-data-picker @change="deptChange" v-model="searchData.deptValue" :localdata="pageData.deptList" popup-title="请选择维修科室" :map="{text:'hosName',value:'id'}">
  12. </uni-data-picker>
  13. </text>
  14. </view>
  15. <view class="tabs">
  16. <view class="tab" :class="{active: tab.value === searchData.selected}" v-for="tab in tabs" :key="tab.value" @click="clickTab(tab)">{{tab.name}}<text class="newicon newicon-xuanzejiaobiao"></text></view>
  17. </view>
  18. <view class="area" @click="clickPageRouter('area')">
  19. <text class="name">楼栋</text>
  20. <text class="value ellipsis">{{searchData.areaName.length>0 ? searchData.areaName.join('/') : ''}}</text>
  21. </view>
  22. <view class="category">
  23. <text class="name">故障现象</text>
  24. <text class="value flex-1">
  25. <uni-data-picker @change="categoryChange" v-model="searchData.categoryValue" :localdata="pageData.categoryList" popup-title="请选择故障信息" :map="{text:'category',value:'id'}">
  26. </uni-data-picker>
  27. </text>
  28. </view>
  29. <view class="acceptDate" @click="changeIsShowDate()">
  30. <text class="name">登记时间</text>
  31. <text class="value ellipsis" v-if="searchData.acceptDate.length">{{searchData.acceptDate[0] || ''}}至{{searchData.acceptDate[1] || ''}}</text>
  32. <text class="value ellipsis" v-else>全部</text>
  33. </view>
  34. </view>
  35. <view class="container_foot">
  36. <view class="clear" @click="clear">清除选项</view>
  37. <view class="foot_btns">
  38. <view class="cancel" @click="cancel">取消</view>
  39. <view class="confirm" @click="confirm">确认</view>
  40. </view>
  41. </view>
  42. <PyhRdtpicker
  43. :show="isShowDate"
  44. :start="start"
  45. :end="end"
  46. @showchange="showDatechange"
  47. :value="searchData.acceptDate"
  48. @change="bindDateChange"
  49. :themeColor="primaryColor"
  50. ></PyhRdtpicker>
  51. </view>
  52. <view class="container" @touchmove.stop.prevent v-else-if="pageData.pageRouter === 'area'">
  53. <view class="container_form">
  54. <view class="hospital">
  55. <text class="name">楼栋</text>
  56. </view>
  57. <scroll-view scroll-y class="areas">
  58. <view class="view-box">
  59. <view class="areas_item" v-for="area in pageData.areaList"
  60. :key="area.id" @click="clickAreaItem(area)"
  61. :class="searchData.selectBuildingId.indexOf(area.id)!=-1 ? 'ActiveClass': ''"
  62. >{{area.buildingName}}</view>
  63. </view>
  64. </scroll-view>
  65. </view>
  66. <view class="container_foot">
  67. <view class="foot_btns">
  68. <view class="cancel" @click="clickPageRouter('default')">取消</view>
  69. <view class="cancel submit" @click="clickArea()">确定</view>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- <view class="container" @touchmove.stop.prevent v-else-if="pageData.pageRouter === 'category'">
  74. <view class="container_form">
  75. <view class="hospital">
  76. <text class="name">故障现象</text>
  77. </view>
  78. <scroll-view scroll-y class="categorys">
  79. <view class="categorys_item" v-for="category in pageData.categoryList" :key="category.id" @click="clickCategory(category)">{{category.category}}</view>
  80. </scroll-view>
  81. </view>
  82. <view class="container_foot">
  83. <view class="foot_btns">
  84. <view class="cancel" @click="clickPageRouter('default')">取消</view>
  85. </view>
  86. </view>
  87. </view> -->
  88. <view class="mask" @touchmove.stop.prevent></view>
  89. <view class="line" @touchmove.stop.prevent></view>
  90. </template>
  91. <script setup>
  92. import PyhRdtpicker from '@/components/PyhRdtpicker/PyhRdtpicker.vue';
  93. import { defineEmits, ref, reactive, defineProps } from 'vue'
  94. import { startOfYear, endOfYear, format, add } from 'date-fns'
  95. import { onLoad } from '@dcloudio/uni-app'
  96. import { useLoginUserStore } from '@/stores/loginUser'
  97. import { api_area, getFetchDataList, api_incidentcategory } from "@/http/api.js"
  98. import { defaultColor } from '@/static/js/theme.js'
  99. import { transform } from '@/utils/index.js'
  100. const emit = defineEmits(['cancelEmit', 'confirmEmit']);
  101. const { evt } = defineProps({
  102. evt: {
  103. type: Object,
  104. required: true,
  105. },
  106. });
  107. const loginUserStore = useLoginUserStore();
  108. // 主题颜色
  109. const primaryColor = ref(defaultColor)
  110. // 登记时间
  111. const isShowDate = ref(false)
  112. const start = ref(format(startOfYear(add(new Date(), { years: -5})), 'yyyy-MM-dd'));
  113. const end = ref(format(endOfYear(add(new Date(), { years: 0})), 'yyyy-MM-dd'));
  114. const tabs = reactive([
  115. // { name: '全部事件', value: 'all' },
  116. { name: '待我处理', value: 'todoingAll' },
  117. { name: '与我关联', value: 'owns' },
  118. { name: '由我解决', value: 'resolve' },
  119. ])
  120. // 页面数据
  121. const pageData = reactive({
  122. pageRouter: 'default',
  123. areaList: [],
  124. categoryList: [],
  125. deptList:[],
  126. selectBuildingList:[],
  127. });
  128. // 是否开启跨科查看
  129. const showDept = ref(false);
  130. const searchData = reactive({
  131. hospital: {},
  132. selected: 'todoingAll',
  133. area: [],
  134. category: {},
  135. categoryValue:{},
  136. acceptDate: [],
  137. dept: {},
  138. deptValue: {},
  139. selectBuildingId:[],
  140. areaName:[]
  141. })
  142. // 显示登记时间
  143. function showDatechange(){
  144. isShowDate.value = !isShowDate.value;
  145. }
  146. // 登记时间确定
  147. function bindDateChange(e){
  148. console.log(e);
  149. searchData.acceptDate = e;
  150. }
  151. // 点击tab
  152. function clickTab(tab){
  153. searchData.selected = tab.value;
  154. }
  155. // 点击区域
  156. function clickAreaItem(item){
  157. let index = searchData.selectBuildingId.indexOf(item.id)
  158. if(index==-1){
  159. pageData.selectBuildingList.push(item)
  160. }else{
  161. pageData.selectBuildingList.splice(index, 1)
  162. }
  163. searchData.selectBuildingId = pageData.selectBuildingList.map(i=>{
  164. return i.id
  165. })
  166. // console.log(998998,searchData.selectBuildingId)
  167. }
  168. // 选中楼栋
  169. function clickArea(){
  170. pageData.pageRouter = 'default';
  171. searchData.area = pageData.selectBuildingList
  172. searchData.areaName = []
  173. pageData.selectBuildingList.forEach(i=>{
  174. searchData.areaName.push(i.buildingName)
  175. })
  176. }
  177. // 点击故障现象
  178. function clickCategory(category){
  179. pageData.pageRouter = 'default';
  180. searchData.category = category;
  181. }
  182. // 清空
  183. function clear(){
  184. setHospital();
  185. searchData.selected = 'todoingAll';
  186. searchData.area = [];
  187. searchData.category = {};
  188. searchData.acceptDate = [];
  189. searchData.categoryValue = {};
  190. searchData.dept = {};
  191. searchData.deptValue = {};
  192. searchData.selectBuildingId = [];
  193. searchData.areaName = [];
  194. pageData.selectBuildingList = [];
  195. }
  196. // 取消
  197. function cancel(){
  198. emit('cancelEmit')
  199. }
  200. // 确认
  201. function confirm(){
  202. emit('confirmEmit', searchData);
  203. }
  204. // 设置院区
  205. function setHospital(){
  206. if (loginUserStore.loginUser.user.duty) {
  207. // 当前的所属责任科室
  208. searchData.hospital = {
  209. id: loginUserStore.loginUser.user.duty.branch,
  210. hosName: loginUserStore.loginUser.user.duty.branchName
  211. };
  212. } else if (loginUserStore.loginUser.user.branch) {
  213. // 当前的所属院区
  214. searchData.hospital = {
  215. id: loginUserStore.loginUser.user.branch.id,
  216. hosName: loginUserStore.loginUser.user.branch.hosName
  217. };
  218. }
  219. }
  220. // 选择维修科室
  221. function deptChange(val){
  222. searchData.dept = val.detail.value[val.detail.value.length-1]
  223. }
  224. // 选择故障现象
  225. function categoryChange(val){
  226. searchData.category = val.detail.value[val.detail.value.length-1]
  227. }
  228. // 获取楼栋列表
  229. function getAreaList(){
  230. uni.showLoading({
  231. title: "加载中",
  232. mask: true,
  233. });
  234. // let postData = {
  235. // idx: 0,
  236. // sum: 9999,
  237. // area: {
  238. // branch: searchData.hospital.id,
  239. // },
  240. // }
  241. // api_area(postData).then(res => {
  242. // uni.hideLoading();
  243. // if(res.status == 200){
  244. // let list = res.list || [];
  245. // pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  246. // }else{
  247. // uni.showToast({
  248. // icon: 'none',
  249. // title: res.msg || '请求数据失败!'
  250. // });
  251. // }
  252. // })
  253. let postData = {
  254. idx: 0,
  255. sum: 9999,
  256. building:{
  257. hosId: null
  258. }
  259. };
  260. if(loginUserStore.loginUser.user.currentHospital.parent){
  261. postData.building.hosId = loginUserStore.loginUser.user.currentHospital.parent.id
  262. }else{
  263. postData.building.hosId = loginUserStore.loginUser.user.currentHospital.id
  264. }
  265. getFetchDataList("simple/data", "building", postData)
  266. .then((res) => {
  267. uni.hideLoading();
  268. let list = res.list || [];
  269. pageData.areaList = list;
  270. // pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  271. });
  272. }
  273. // 获取故障现象列表
  274. function getCategoryList(){
  275. uni.showLoading({
  276. title: "加载中",
  277. mask: true,
  278. });
  279. let postData = {
  280. hasThird:true,
  281. category: {
  282. dutyIds: loginUserStore.loginUser.user.currentHospital.id,
  283. },
  284. }
  285. // if(loginUserStore.loginUser.user.duty){
  286. // postData.incidentcategory.dutyToCategory = loginUserStore.loginUser.user.duty.id;
  287. // }else if(loginUserStore.loginUser.user.branch){
  288. // postData.incidentcategory.selectType = 'one';
  289. // }
  290. // api_incidentcategory(postData).then(res => {
  291. // uni.hideLoading();
  292. // if(res.status == 200){
  293. // let list = res.list || [];
  294. // pageData.categoryList = [{ id:0, category: '全部' }, ...list];
  295. // }else{
  296. // uni.showToast({
  297. // icon: 'none',
  298. // title: res.msg || '请求数据失败!'
  299. // });
  300. // }
  301. // })
  302. api_incidentcategory(postData).then(res => {
  303. uni.hideLoading();
  304. if(res.status == 200){
  305. let list = res.data || [];
  306. list = list.map(i=> ({...i, parentid: i.parent?.id}))
  307. pageData.categoryList = transform(list, 'id', 'parentid')
  308. }else{
  309. uni.showToast({
  310. icon: 'none',
  311. title: res.msg || '请求数据失败!'
  312. });
  313. }
  314. })
  315. }
  316. // 页面路由跳转
  317. function clickPageRouter(type){
  318. pageData.pageRouter = type;
  319. switch(type){
  320. case 'area':
  321. getAreaList();
  322. break;
  323. }
  324. }
  325. // 显示登记时间
  326. function changeIsShowDate(type){
  327. isShowDate.value = true;
  328. }
  329. onLoad((option) => {
  330. getCategoryList()
  331. // searchData.hospital = evt.hospital;
  332. let menu = JSON.parse(uni.getStorageSync("menuList")) || []; //菜单
  333. console.log(9555,menu)
  334. showDept.value = false
  335. menu.forEach((e) => {
  336. if (e.title=='故障管理') {
  337. e.childrens.forEach((el) => {
  338. if(el.link=='incidentManagement'){
  339. el.childrens.forEach(item =>{
  340. if(item.link=='strideLook'){
  341. showDept.value = true
  342. }else if(item.link=='all'){
  343. tabs.splice(0, 0 , { name: '全部事件', value: 'all' });
  344. }
  345. })
  346. }
  347. });
  348. }
  349. });
  350. let data = loginUserStore.loginUser.infoPermission
  351. pageData.deptList = data.dutyList
  352. setHospital();
  353. // console.log(999,evt)
  354. searchData.selected = evt.selected;
  355. searchData.area = evt.area;
  356. if(evt.area && evt.area.length>0){
  357. pageData.selectBuildingList = evt.area
  358. searchData.selectBuildingId = []
  359. searchData.areaName = []
  360. evt.area.forEach(i=>{
  361. searchData.selectBuildingId.push(i.id)
  362. searchData.areaName.push(i.buildingName)
  363. })
  364. }
  365. searchData.category = evt.category;
  366. searchData.categoryValue = evt.categoryValue;
  367. searchData.acceptDate = evt.acceptDate;
  368. if(showDept.value){
  369. searchData.deptValue = evt.deptValue;
  370. searchData.dept = evt.dept;
  371. }else{
  372. searchData.deptValue = {};
  373. searchData.dept = {};
  374. }
  375. })
  376. </script>
  377. <style lang="scss" scoped>
  378. .mask{
  379. position: fixed;
  380. left: 0;
  381. top: 0;
  382. right: 0;
  383. bottom: 0;
  384. background-color: rgba(0, 0, 0, 0.4);
  385. z-index: 999;
  386. }
  387. .line{
  388. content: '';
  389. position: fixed;
  390. top: 0;
  391. left: 0;
  392. z-index: 9999;
  393. height: 8rpx;
  394. width: 100%;
  395. background-color: #EBEBEB;
  396. }
  397. .container{
  398. position: fixed;
  399. left: 125rpx;
  400. top: 0;
  401. right: 0;
  402. bottom: 0;
  403. z-index: 9999;
  404. background-color: #F7F7F7;
  405. display: flex;
  406. flex-direction: column;
  407. justify-content: space-between;
  408. .container_form{
  409. height: 100%;
  410. display: flex;
  411. flex-direction: column;
  412. flex: 1;
  413. min-height: 0;
  414. }
  415. .hospital{
  416. display: flex;
  417. justify-content: space-between;
  418. align-items: center;
  419. padding: 32rpx 24rpx 24rpx;
  420. background-color: #fff;
  421. .name{
  422. font-size: 30rpx;
  423. flex-shrink: 0;
  424. margin-right: 24rpx;
  425. }
  426. .value{
  427. font-size: 26rpx;
  428. color: #5DAAB6;
  429. }
  430. }
  431. .areas{
  432. flex: 1;
  433. min-height: 0;
  434. margin-top: 20rpx;
  435. padding-top: 20rpx;
  436. background-color: #fff;
  437. .view-box{
  438. display: flex;
  439. flex-wrap: wrap;
  440. .areas_item{
  441. width: 30%;
  442. height: 80rpx;
  443. background: #F6F6F6;
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. border-radius: 10rpx;
  448. margin: 0 10rpx 20rpx 10rpx;
  449. }
  450. .ActiveClass{
  451. background: #FFEAE7;
  452. color: #D95D4D;
  453. border: 1px solid #A13728;
  454. box-sizing: border-box;
  455. }
  456. }
  457. }
  458. .categorys{
  459. flex: 1;
  460. min-height: 0;
  461. margin-top: 16rpx;
  462. background-color: #fff;
  463. .categorys_item{
  464. padding: 24rpx;
  465. border-bottom: 1rpx solid #DEDEDE;
  466. }
  467. }
  468. .tabs{
  469. margin-top: 16rpx;
  470. background-color: #FBFBFB;
  471. display: flex;
  472. flex-wrap: wrap;
  473. justify-content: space-between;
  474. gap: 16rpx 0;
  475. padding: 24rpx 16rpx;
  476. .tab{
  477. width: 180rpx;
  478. height: 60rpx;
  479. display: flex;
  480. justify-content: center;
  481. align-items: center;
  482. background-color: #F7F7F7;
  483. font-size: 28rpx;
  484. position: relative;
  485. .newicon-xuanzejiaobiao{
  486. opacity: 0;
  487. position: absolute;
  488. right: 0;
  489. bottom: 0;
  490. font-size: 38rpx;
  491. color: #53B9BB;
  492. }
  493. &.active{
  494. background-color: rgba(149, 220, 231, 0.30);
  495. .newicon-xuanzejiaobiao{
  496. opacity: 1;
  497. }
  498. }
  499. }
  500. }
  501. .area,
  502. .category,
  503. .acceptDate{
  504. display: flex;
  505. justify-content: space-between;
  506. align-items: center;
  507. padding: 24rpx;
  508. background-color: #fff;
  509. margin-top: 24rpx;
  510. .name{
  511. font-size: 28rpx;
  512. flex-shrink: 0;
  513. margin-right: 24rpx;
  514. }
  515. .flex-1{
  516. flex: 3;
  517. }
  518. }
  519. .container_foot{
  520. .clear{
  521. padding: 24rpx;
  522. font-size: 28rpx;
  523. background-color: #fff;
  524. margin: 0 16rpx;
  525. display: flex;
  526. align-items: center;
  527. justify-content: center;
  528. }
  529. .foot_btns{
  530. margin-top: 24rpx;
  531. display: flex;
  532. border-top: 1rpx solid #BFBFBF;
  533. .cancel{
  534. flex: 1;
  535. background-color: #fff;
  536. font-size: 32rpx;
  537. padding: 24rpx;
  538. display: flex;
  539. justify-content: center;
  540. }
  541. .submit{
  542. color: #49b856;
  543. border-left: 1px solid #BFBFBF;
  544. }
  545. .confirm{
  546. flex: 1;
  547. font-size: 32rpx;
  548. padding: 24rpx;
  549. background-color: $uni-primary;
  550. display: flex;
  551. justify-content: center;
  552. color: #fff;
  553. }
  554. }
  555. }
  556. }
  557. </style>