IncidentListFilter.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. }
  195. // 取消
  196. function cancel(){
  197. emit('cancelEmit')
  198. }
  199. // 确认
  200. function confirm(){
  201. emit('confirmEmit', searchData);
  202. }
  203. // 设置院区
  204. function setHospital(){
  205. if (loginUserStore.loginUser.user.duty) {
  206. // 当前的所属责任科室
  207. searchData.hospital = {
  208. id: loginUserStore.loginUser.user.duty.branch,
  209. hosName: loginUserStore.loginUser.user.duty.branchName
  210. };
  211. } else if (loginUserStore.loginUser.user.branch) {
  212. // 当前的所属院区
  213. searchData.hospital = {
  214. id: loginUserStore.loginUser.user.branch.id,
  215. hosName: loginUserStore.loginUser.user.branch.hosName
  216. };
  217. }
  218. }
  219. // 选择维修科室
  220. function deptChange(val){
  221. searchData.dept = val.detail.value[val.detail.value.length-1]
  222. }
  223. // 选择故障现象
  224. function categoryChange(val){
  225. searchData.category = val.detail.value[val.detail.value.length-1]
  226. }
  227. // 获取楼栋列表
  228. function getAreaList(){
  229. uni.showLoading({
  230. title: "加载中",
  231. mask: true,
  232. });
  233. // let postData = {
  234. // idx: 0,
  235. // sum: 9999,
  236. // area: {
  237. // branch: searchData.hospital.id,
  238. // },
  239. // }
  240. // api_area(postData).then(res => {
  241. // uni.hideLoading();
  242. // if(res.status == 200){
  243. // let list = res.list || [];
  244. // pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  245. // }else{
  246. // uni.showToast({
  247. // icon: 'none',
  248. // title: res.msg || '请求数据失败!'
  249. // });
  250. // }
  251. // })
  252. let postData = {
  253. idx: 0,
  254. sum: 9999,
  255. building:{
  256. hosId: null
  257. }
  258. };
  259. if(loginUserStore.loginUser.user.currentHospital.parent){
  260. postData.building.hosId = loginUserStore.loginUser.user.currentHospital.parent.id
  261. }else{
  262. postData.building.hosId = loginUserStore.loginUser.user.currentHospital.id
  263. }
  264. getFetchDataList("simple/data", "building", postData)
  265. .then((res) => {
  266. uni.hideLoading();
  267. let list = res.list || [];
  268. pageData.areaList = list;
  269. // pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  270. });
  271. }
  272. // 获取故障现象列表
  273. function getCategoryList(){
  274. uni.showLoading({
  275. title: "加载中",
  276. mask: true,
  277. });
  278. let postData = {
  279. hasThird:true,
  280. category: {
  281. dutyIds: loginUserStore.loginUser.user.currentHospital.id,
  282. },
  283. }
  284. // if(loginUserStore.loginUser.user.duty){
  285. // postData.incidentcategory.dutyToCategory = loginUserStore.loginUser.user.duty.id;
  286. // }else if(loginUserStore.loginUser.user.branch){
  287. // postData.incidentcategory.selectType = 'one';
  288. // }
  289. // api_incidentcategory(postData).then(res => {
  290. // uni.hideLoading();
  291. // if(res.status == 200){
  292. // let list = res.list || [];
  293. // pageData.categoryList = [{ id:0, category: '全部' }, ...list];
  294. // }else{
  295. // uni.showToast({
  296. // icon: 'none',
  297. // title: res.msg || '请求数据失败!'
  298. // });
  299. // }
  300. // })
  301. api_incidentcategory(postData).then(res => {
  302. uni.hideLoading();
  303. if(res.status == 200){
  304. let list = res.data || [];
  305. list = list.map(i=> ({...i, parentid: i.parent?.id}))
  306. pageData.categoryList = transform(list, 'id', 'parentid')
  307. }else{
  308. uni.showToast({
  309. icon: 'none',
  310. title: res.msg || '请求数据失败!'
  311. });
  312. }
  313. })
  314. }
  315. // 页面路由跳转
  316. function clickPageRouter(type){
  317. pageData.pageRouter = type;
  318. switch(type){
  319. case 'area':
  320. getAreaList();
  321. break;
  322. }
  323. }
  324. // 显示登记时间
  325. function changeIsShowDate(type){
  326. isShowDate.value = true;
  327. }
  328. onLoad((option) => {
  329. getCategoryList()
  330. // searchData.hospital = evt.hospital;
  331. let menu = JSON.parse(uni.getStorageSync("menuList")) || []; //菜单
  332. console.log(9555,menu)
  333. showDept.value = false
  334. menu.forEach((e) => {
  335. if (e.title=='故障管理') {
  336. e.childrens.forEach((el) => {
  337. if(el.link=='incidentManagement'){
  338. el.childrens.forEach(item =>{
  339. if(item.link=='strideLook'){
  340. showDept.value = true
  341. }else if(item.link=='all'){
  342. tabs.splice(0, 0 , { name: '全部事件', value: 'all' });
  343. }
  344. })
  345. }
  346. });
  347. }
  348. });
  349. let data = loginUserStore.loginUser.infoPermission
  350. pageData.deptList = data.dutyList
  351. setHospital();
  352. // console.log(999,evt)
  353. searchData.selected = evt.selected;
  354. searchData.area = evt.area;
  355. if(evt.area && evt.area.length>0){
  356. pageData.selectBuildingList = evt.area
  357. searchData.selectBuildingId = []
  358. searchData.areaName = []
  359. evt.area.forEach(i=>{
  360. searchData.selectBuildingId.push(i.id)
  361. searchData.areaName.push(i.buildingName)
  362. })
  363. }
  364. searchData.category = evt.category;
  365. searchData.categoryValue = evt.categoryValue;
  366. searchData.acceptDate = evt.acceptDate;
  367. if(showDept.value){
  368. searchData.deptValue = evt.deptValue;
  369. searchData.dept = evt.dept;
  370. }else{
  371. searchData.deptValue = {};
  372. searchData.dept = {};
  373. }
  374. })
  375. </script>
  376. <style lang="scss" scoped>
  377. .mask{
  378. position: fixed;
  379. left: 0;
  380. top: 0;
  381. right: 0;
  382. bottom: 0;
  383. background-color: rgba(0, 0, 0, 0.4);
  384. z-index: 999;
  385. }
  386. .line{
  387. content: '';
  388. position: fixed;
  389. top: 0;
  390. left: 0;
  391. z-index: 9999;
  392. height: 8rpx;
  393. width: 100%;
  394. background-color: #EBEBEB;
  395. }
  396. .container{
  397. position: fixed;
  398. left: 125rpx;
  399. top: 0;
  400. right: 0;
  401. bottom: 0;
  402. z-index: 9999;
  403. background-color: #F7F7F7;
  404. display: flex;
  405. flex-direction: column;
  406. justify-content: space-between;
  407. .container_form{
  408. height: 100%;
  409. display: flex;
  410. flex-direction: column;
  411. flex: 1;
  412. min-height: 0;
  413. }
  414. .hospital{
  415. display: flex;
  416. justify-content: space-between;
  417. align-items: center;
  418. padding: 32rpx 24rpx 24rpx;
  419. background-color: #fff;
  420. .name{
  421. font-size: 30rpx;
  422. flex-shrink: 0;
  423. margin-right: 24rpx;
  424. }
  425. .value{
  426. font-size: 26rpx;
  427. color: #5DAAB6;
  428. }
  429. }
  430. .areas{
  431. flex: 1;
  432. min-height: 0;
  433. margin-top: 20rpx;
  434. padding-top: 20rpx;
  435. background-color: #fff;
  436. .view-box{
  437. display: flex;
  438. flex-wrap: wrap;
  439. .areas_item{
  440. width: 30%;
  441. height: 80rpx;
  442. background: #F6F6F6;
  443. display: flex;
  444. align-items: center;
  445. justify-content: center;
  446. border-radius: 10rpx;
  447. margin: 0 10rpx 20rpx 10rpx;
  448. }
  449. .ActiveClass{
  450. background: #FFEAE7;
  451. color: #D95D4D;
  452. border: 1px solid #A13728;
  453. box-sizing: border-box;
  454. }
  455. }
  456. }
  457. .categorys{
  458. flex: 1;
  459. min-height: 0;
  460. margin-top: 16rpx;
  461. background-color: #fff;
  462. .categorys_item{
  463. padding: 24rpx;
  464. border-bottom: 1rpx solid #DEDEDE;
  465. }
  466. }
  467. .tabs{
  468. margin-top: 16rpx;
  469. background-color: #FBFBFB;
  470. display: flex;
  471. flex-wrap: wrap;
  472. justify-content: space-between;
  473. gap: 16rpx 0;
  474. padding: 24rpx 16rpx;
  475. .tab{
  476. width: 180rpx;
  477. height: 60rpx;
  478. display: flex;
  479. justify-content: center;
  480. align-items: center;
  481. background-color: #F7F7F7;
  482. font-size: 28rpx;
  483. position: relative;
  484. .newicon-xuanzejiaobiao{
  485. opacity: 0;
  486. position: absolute;
  487. right: 0;
  488. bottom: 0;
  489. font-size: 38rpx;
  490. color: #53B9BB;
  491. }
  492. &.active{
  493. background-color: rgba(149, 220, 231, 0.30);
  494. .newicon-xuanzejiaobiao{
  495. opacity: 1;
  496. }
  497. }
  498. }
  499. }
  500. .area,
  501. .category,
  502. .acceptDate{
  503. display: flex;
  504. justify-content: space-between;
  505. align-items: center;
  506. padding: 24rpx;
  507. background-color: #fff;
  508. margin-top: 24rpx;
  509. .name{
  510. font-size: 28rpx;
  511. flex-shrink: 0;
  512. margin-right: 24rpx;
  513. }
  514. .flex-1{
  515. flex: 3;
  516. }
  517. }
  518. .container_foot{
  519. .clear{
  520. padding: 24rpx;
  521. font-size: 28rpx;
  522. background-color: #fff;
  523. margin: 0 16rpx;
  524. display: flex;
  525. align-items: center;
  526. justify-content: center;
  527. }
  528. .foot_btns{
  529. margin-top: 24rpx;
  530. display: flex;
  531. border-top: 1rpx solid #BFBFBF;
  532. .cancel{
  533. flex: 1;
  534. background-color: #fff;
  535. font-size: 32rpx;
  536. padding: 24rpx;
  537. display: flex;
  538. justify-content: center;
  539. }
  540. .submit{
  541. color: #49b856;
  542. border-left: 1px solid #BFBFBF;
  543. }
  544. .confirm{
  545. flex: 1;
  546. font-size: 32rpx;
  547. padding: 24rpx;
  548. background-color: $uni-primary;
  549. display: flex;
  550. justify-content: center;
  551. color: #fff;
  552. }
  553. }
  554. }
  555. }
  556. </style>