IncidentListFilter.vue 11 KB

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