IncidentListFilter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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.categoryValue" :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. categoryValue:{},
  119. acceptDate: [],
  120. })
  121. // 显示登记时间
  122. function showDatechange(){
  123. isShowDate.value = !isShowDate.value;
  124. }
  125. // 登记时间确定
  126. function bindDateChange(e){
  127. console.log(e);
  128. searchData.acceptDate = e;
  129. }
  130. // 点击tab
  131. function clickTab(tab){
  132. searchData.selected = tab.value;
  133. }
  134. // 点击区域
  135. function clickArea(area){
  136. pageData.pageRouter = 'default';
  137. searchData.area = area;
  138. }
  139. // 点击故障现象
  140. function clickCategory(category){
  141. pageData.pageRouter = 'default';
  142. searchData.category = category;
  143. }
  144. // 清空
  145. function clear(){
  146. setHospital();
  147. searchData.selected = 'todoingAll';
  148. searchData.area = {id: 0, area: '全部'};
  149. searchData.category = {};
  150. searchData.acceptDate = [];
  151. searchData.categoryValue = {};
  152. console.log(searchData.acceptDate)
  153. }
  154. // 取消
  155. function cancel(){
  156. emit('cancelEmit')
  157. }
  158. // 确认
  159. function confirm(){
  160. emit('confirmEmit', searchData);
  161. }
  162. // 设置院区
  163. function setHospital(){
  164. if (loginUserStore.loginUser.user.duty) {
  165. // 当前的所属责任科室
  166. searchData.hospital = {
  167. id: loginUserStore.loginUser.user.duty.branch,
  168. hosName: loginUserStore.loginUser.user.duty.branchName
  169. };
  170. } else if (loginUserStore.loginUser.user.branch) {
  171. // 当前的所属院区
  172. searchData.hospital = {
  173. id: loginUserStore.loginUser.user.branch.id,
  174. hosName: loginUserStore.loginUser.user.branch.hosName
  175. };
  176. }
  177. }
  178. // 选择故障现象
  179. function categoryChange(val){
  180. searchData.category = val.detail.value[val.detail.value.length-1]
  181. }
  182. // 获取楼栋列表
  183. function getAreaList(){
  184. uni.showLoading({
  185. title: "加载中",
  186. mask: true,
  187. });
  188. // let postData = {
  189. // idx: 0,
  190. // sum: 9999,
  191. // area: {
  192. // branch: searchData.hospital.id,
  193. // },
  194. // }
  195. // api_area(postData).then(res => {
  196. // uni.hideLoading();
  197. // if(res.status == 200){
  198. // let list = res.list || [];
  199. // pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  200. // }else{
  201. // uni.showToast({
  202. // icon: 'none',
  203. // title: res.msg || '请求数据失败!'
  204. // });
  205. // }
  206. // })
  207. let postData = {
  208. idx: 0,
  209. sum: 9999,
  210. building:{
  211. hosId: loginUserStore.loginUser.user.currentHospital.id,
  212. }
  213. };
  214. getFetchDataList("simple/data", "building", postData)
  215. .then((res) => {
  216. uni.hideLoading();
  217. let list = res.list || [];
  218. pageData.areaList = [{ id: 0, area: '全部' }, ...list];
  219. });
  220. }
  221. // 获取故障现象列表
  222. function getCategoryList(){
  223. uni.showLoading({
  224. title: "加载中",
  225. mask: true,
  226. });
  227. let postData = {
  228. hasThird:true,
  229. category: {
  230. dutyIds: loginUserStore.loginUser.user.currentHospital.id,
  231. },
  232. }
  233. // if(loginUserStore.loginUser.user.duty){
  234. // postData.incidentcategory.dutyToCategory = loginUserStore.loginUser.user.duty.id;
  235. // }else if(loginUserStore.loginUser.user.branch){
  236. // postData.incidentcategory.selectType = 'one';
  237. // }
  238. // api_incidentcategory(postData).then(res => {
  239. // uni.hideLoading();
  240. // if(res.status == 200){
  241. // let list = res.list || [];
  242. // pageData.categoryList = [{ id:0, category: '全部' }, ...list];
  243. // }else{
  244. // uni.showToast({
  245. // icon: 'none',
  246. // title: res.msg || '请求数据失败!'
  247. // });
  248. // }
  249. // })
  250. api_incidentcategory(postData).then(res => {
  251. uni.hideLoading();
  252. if(res.status == 200){
  253. let list = res.data || [];
  254. list = list.map(i=> ({...i, parentid: i.parent?.id}))
  255. pageData.categoryList = transform(list, 'id', 'parentid')
  256. }else{
  257. uni.showToast({
  258. icon: 'none',
  259. title: res.msg || '请求数据失败!'
  260. });
  261. }
  262. })
  263. }
  264. // 页面路由跳转
  265. function clickPageRouter(type){
  266. pageData.pageRouter = type;
  267. switch(type){
  268. case 'area':
  269. getAreaList();
  270. break;
  271. }
  272. }
  273. // 显示登记时间
  274. function changeIsShowDate(type){
  275. isShowDate.value = true;
  276. }
  277. onLoad((option) => {
  278. getCategoryList()
  279. // searchData.hospital = evt.hospital;
  280. for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
  281. if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_all") {
  282. tabs.splice(0, 0 , { name: '全部事件', value: 'all' });
  283. }
  284. }
  285. setHospital();
  286. searchData.selected = evt.selected;
  287. searchData.area = evt.area;
  288. searchData.category = evt.category;
  289. searchData.categoryValue = evt.categoryValue;
  290. searchData.acceptDate = evt.acceptDate;
  291. })
  292. </script>
  293. <style lang="scss" scoped>
  294. .mask{
  295. position: fixed;
  296. left: 0;
  297. top: 0;
  298. right: 0;
  299. bottom: 0;
  300. background-color: rgba(0, 0, 0, 0.4);
  301. z-index: 999;
  302. }
  303. .line{
  304. content: '';
  305. position: fixed;
  306. top: 0;
  307. left: 0;
  308. z-index: 9999;
  309. height: 8rpx;
  310. width: 100%;
  311. background-color: #EBEBEB;
  312. }
  313. .container{
  314. position: fixed;
  315. left: 125rpx;
  316. top: 0;
  317. right: 0;
  318. bottom: 0;
  319. z-index: 9999;
  320. background-color: #F7F7F7;
  321. display: flex;
  322. flex-direction: column;
  323. justify-content: space-between;
  324. .container_form{
  325. height: 100%;
  326. display: flex;
  327. flex-direction: column;
  328. flex: 1;
  329. min-height: 0;
  330. }
  331. .hospital{
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: center;
  335. padding: 32rpx 24rpx 24rpx;
  336. background-color: #fff;
  337. .name{
  338. font-size: 30rpx;
  339. flex-shrink: 0;
  340. margin-right: 24rpx;
  341. }
  342. .value{
  343. font-size: 26rpx;
  344. color: #5DAAB6;
  345. }
  346. }
  347. .areas{
  348. flex: 1;
  349. min-height: 0;
  350. margin-top: 16rpx;
  351. background-color: #fff;
  352. .areas_item{
  353. padding: 24rpx;
  354. border-bottom: 1rpx solid #DEDEDE;
  355. }
  356. }
  357. .categorys{
  358. flex: 1;
  359. min-height: 0;
  360. margin-top: 16rpx;
  361. background-color: #fff;
  362. .categorys_item{
  363. padding: 24rpx;
  364. border-bottom: 1rpx solid #DEDEDE;
  365. }
  366. }
  367. .tabs{
  368. margin-top: 16rpx;
  369. background-color: #FBFBFB;
  370. display: flex;
  371. flex-wrap: wrap;
  372. justify-content: space-between;
  373. gap: 16rpx 0;
  374. padding: 24rpx 16rpx;
  375. .tab{
  376. width: 180rpx;
  377. height: 60rpx;
  378. display: flex;
  379. justify-content: center;
  380. align-items: center;
  381. background-color: #F7F7F7;
  382. font-size: 28rpx;
  383. position: relative;
  384. .newicon-xuanzejiaobiao{
  385. opacity: 0;
  386. position: absolute;
  387. right: 0;
  388. bottom: 0;
  389. font-size: 38rpx;
  390. color: #53B9BB;
  391. }
  392. &.active{
  393. background-color: rgba(149, 220, 231, 0.30);
  394. .newicon-xuanzejiaobiao{
  395. opacity: 1;
  396. }
  397. }
  398. }
  399. }
  400. .area,
  401. .category,
  402. .acceptDate{
  403. display: flex;
  404. justify-content: space-between;
  405. align-items: center;
  406. padding: 24rpx;
  407. background-color: #fff;
  408. margin-top: 24rpx;
  409. .name{
  410. font-size: 28rpx;
  411. flex-shrink: 0;
  412. margin-right: 24rpx;
  413. }
  414. .flex-1{
  415. flex: 3;
  416. }
  417. }
  418. .container_foot{
  419. .clear{
  420. padding: 24rpx;
  421. font-size: 28rpx;
  422. background-color: #fff;
  423. margin: 0 16rpx;
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. }
  428. .foot_btns{
  429. margin-top: 24rpx;
  430. display: flex;
  431. border-top: 1rpx solid #BFBFBF;
  432. .cancel{
  433. flex: 1;
  434. background-color: #fff;
  435. font-size: 32rpx;
  436. padding: 24rpx;
  437. display: flex;
  438. justify-content: center;
  439. }
  440. .confirm{
  441. flex: 1;
  442. font-size: 32rpx;
  443. padding: 24rpx;
  444. background-color: $uni-primary;
  445. display: flex;
  446. justify-content: center;
  447. color: #fff;
  448. }
  449. }
  450. }
  451. }
  452. </style>