IncidentListFilter.vue 12 KB

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